You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 10:02:29 UTC

[01/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Repository: thrift
Updated Branches:
  refs/heads/master ca7e97e04 -> 74260aa90


http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/src/TestServer.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
old mode 100755
new mode 100644
index a343221..6d2a260
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -50,7 +50,7 @@
 
 #include <signal.h>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -68,14 +68,12 @@ using namespace thrift::test;
 #define EXECUTABLE_FILE_NAME_LENGTH 19
 
 class TestHandler : public ThriftTestIf {
- public:
+public:
   TestHandler() {}
 
-  void testVoid() {
-    printf("testVoid()\n");
-  }
+  void testVoid() { printf("testVoid()\n"); }
 
-  void testString(string& out, const string &thing) {
+  void testString(string& out, const string& thing) {
     printf("testString(\"%s\")\n", thing.c_str());
     out = thing;
   }
@@ -100,18 +98,28 @@ class TestHandler : public ThriftTestIf {
     return thing;
   }
 
-  void testStruct(Xtruct& out, const Xtruct &thing) {
-    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
+  void testStruct(Xtruct& out, const Xtruct& thing) {
+    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
+           thing.string_thing.c_str(),
+           (int)thing.byte_thing,
+           thing.i32_thing,
+           thing.i64_thing);
     out = thing;
   }
 
   void testNest(Xtruct2& out, const Xtruct2& nest) {
-    const Xtruct &thing = nest.struct_thing;
-    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
+    const Xtruct& thing = nest.struct_thing;
+    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
+           (int)nest.byte_thing,
+           thing.string_thing.c_str(),
+           (int)thing.byte_thing,
+           thing.i32_thing,
+           thing.i64_thing,
+           nest.i32_thing);
     out = nest;
   }
 
-  void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
+  void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
@@ -127,7 +135,8 @@ class TestHandler : public ThriftTestIf {
     out = thing;
   }
 
-  void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) {
+  void testStringMap(map<std::string, std::string>& out,
+                     const map<std::string, std::string>& thing) {
     printf("testMap({");
     map<std::string, std::string>::const_iterator m_iter;
     bool first = true;
@@ -143,7 +152,7 @@ class TestHandler : public ThriftTestIf {
     out = thing;
   }
 
-  void testSet(set<int32_t> &out, const set<int32_t> &thing) {
+  void testSet(set<int32_t>& out, const set<int32_t>& thing) {
     printf("testSet({");
     set<int32_t>::const_iterator s_iter;
     bool first = true;
@@ -159,7 +168,7 @@ class TestHandler : public ThriftTestIf {
     out = thing;
   }
 
-  void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
+  void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
     printf("testList({");
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
@@ -185,23 +194,22 @@ class TestHandler : public ThriftTestIf {
     return thing;
   }
 
-  void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
+  void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
     printf("testMapMap(%d)\n", hello);
 
-    map<int32_t,int32_t> pos;
-    map<int32_t,int32_t> neg;
+    map<int32_t, int32_t> pos;
+    map<int32_t, int32_t> neg;
     for (int i = 1; i < 5; i++) {
-      pos.insert(make_pair(i,i));
-      neg.insert(make_pair(-i,-i));
+      pos.insert(make_pair(i, i));
+      neg.insert(make_pair(-i, -i));
     }
 
     mapmap.insert(make_pair(4, pos));
     mapmap.insert(make_pair(-4, neg));
-
   }
 
-  void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
-    (void) argument;
+  void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
+    (void)argument;
     printf("testInsanity()\n");
 
     Xtruct hello;
@@ -237,13 +245,11 @@ class TestHandler : public ThriftTestIf {
 
     printf("return");
     printf(" = {");
-    map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
+    map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
     for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
       printf("%" PRId64 " => {", i_iter->first);
-      map<Numberz::type,Insanity>::const_iterator i2_iter;
-      for (i2_iter = i_iter->second.begin();
-           i2_iter != i_iter->second.end();
-           ++i2_iter) {
+      map<Numberz::type, Insanity>::const_iterator i2_iter;
+      for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
         printf("%d => {", i2_iter->first);
         map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
         map<Numberz::type, UserId>::const_iterator um;
@@ -257,7 +263,11 @@ class TestHandler : public ThriftTestIf {
         vector<Xtruct>::const_iterator x;
         printf("{");
         for (x = xtructs.begin(); x != xtructs.end(); ++x) {
-          printf("{\"%s\", %d, %d, %" PRId64 "}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
+          printf("{\"%s\", %d, %d, %" PRId64 "}, ",
+                 x->string_thing.c_str(),
+                 (int)x->byte_thing,
+                 x->i32_thing,
+                 x->i64_thing);
         }
         printf("}");
 
@@ -266,14 +276,18 @@ class TestHandler : public ThriftTestIf {
       printf("}, ");
     }
     printf("}\n");
-
-
   }
 
-  void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string>  &arg3, const Numberz::type arg4, const UserId arg5) {
-    (void) arg3;
-    (void) arg4;
-    (void) arg5;
+  void testMulti(Xtruct& hello,
+                 const int8_t arg0,
+                 const int32_t arg1,
+                 const int64_t arg2,
+                 const std::map<int16_t, std::string>& arg3,
+                 const Numberz::type arg4,
+                 const UserId arg5) {
+    (void)arg3;
+    (void)arg4;
+    (void)arg5;
 
     printf("testMulti()\n");
 
@@ -283,9 +297,7 @@ class TestHandler : public ThriftTestIf {
     hello.i64_thing = (int64_t)arg2;
   }
 
-  void testException(const std::string &arg)
-    throw(Xception, apache::thrift::TException)
-  {
+  void testException(const std::string& arg) throw(Xception, apache::thrift::TException) {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
@@ -302,7 +314,9 @@ class TestHandler : public ThriftTestIf {
     }
   }
 
-  void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
+  void testMultiException(Xtruct& result,
+                          const std::string& arg0,
+                          const std::string& arg1) throw(Xception, Xception2) {
 
     printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
 
@@ -329,28 +343,23 @@ class TestHandler : public ThriftTestIf {
   }
 };
 
-
 class TestProcessorEventHandler : public TProcessorEventHandler {
   virtual void* getContext(const char* fn_name, void* serverContext) {
-    (void) serverContext;
+    (void)serverContext;
     return new std::string(fn_name);
   }
   virtual void freeContext(void* ctx, const char* fn_name) {
-    (void) fn_name;
+    (void)fn_name;
     delete static_cast<std::string*>(ctx);
   }
-  virtual void preRead(void* ctx, const char* fn_name) {
-    communicate("preRead", ctx, fn_name);
-  }
+  virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
   virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) bytes;
+    (void)bytes;
     communicate("postRead", ctx, fn_name);
   }
-  virtual void preWrite(void* ctx, const char* fn_name) {
-    communicate("preWrite", ctx, fn_name);
-  }
+  virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
   virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) bytes;
+    (void)bytes;
     communicate("postWrite", ctx, fn_name);
   }
   virtual void asyncComplete(void* ctx, const char* fn_name) {
@@ -365,7 +374,6 @@ class TestProcessorEventHandler : public TProcessorEventHandler {
   }
 };
 
-
 class TestHandlerAsync : public ThriftTestCobSvIf {
 public:
   TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
@@ -376,7 +384,8 @@ public:
     cob();
   }
 
-  virtual void testString(tcxx::function<void(std::string const& _return)> cob, const std::string& thing) {
+  virtual void testString(tcxx::function<void(std::string const& _return)> cob,
+                          const std::string& thing) {
     std::string res;
     _delegate->testString(res, thing);
     cob(res);
@@ -414,31 +423,37 @@ public:
     cob(res);
   }
 
-  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t>  const& _return)> cob, const std::map<int32_t, int32_t> & thing) {
+  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
+                       const std::map<int32_t, int32_t>& thing) {
     std::map<int32_t, int32_t> res;
     _delegate->testMap(res, thing);
     cob(res);
   }
 
-  virtual void testStringMap(tcxx::function<void(std::map<std::string, std::string>  const& _return)> cob, const std::map<std::string, std::string> & thing) {
+  virtual void testStringMap(
+      tcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
+      const std::map<std::string, std::string>& thing) {
     std::map<std::string, std::string> res;
     _delegate->testStringMap(res, thing);
     cob(res);
   }
 
-  virtual void testSet(tcxx::function<void(std::set<int32_t>  const& _return)> cob, const std::set<int32_t> & thing) {
+  virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob,
+                       const std::set<int32_t>& thing) {
     std::set<int32_t> res;
     _delegate->testSet(res, thing);
     cob(res);
   }
 
-  virtual void testList(tcxx::function<void(std::vector<int32_t>  const& _return)> cob, const std::vector<int32_t> & thing) {
+  virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob,
+                        const std::vector<int32_t>& thing) {
     std::vector<int32_t> res;
     _delegate->testList(res, thing);
     cob(res);
   }
 
-  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob, const Numberz::type thing) {
+  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob,
+                        const Numberz::type thing) {
     Numberz::type res = _delegate->testEnum(thing);
     cob(res);
   }
@@ -448,39 +463,56 @@ public:
     cob(res);
   }
 
-  virtual void testMapMap(tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> >  const& _return)> cob, const int32_t hello) {
+  virtual void testMapMap(
+      tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
+      const int32_t hello) {
     std::map<int32_t, std::map<int32_t, int32_t> > res;
     _delegate->testMapMap(res, hello);
     cob(res);
   }
 
-  virtual void testInsanity(tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> >  const& _return)> cob, const Insanity& argument) {
+  virtual void testInsanity(
+      tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
+      const Insanity& argument) {
     std::map<UserId, std::map<Numberz::type, Insanity> > res;
     _delegate->testInsanity(res, argument);
     cob(res);
- }
+  }
 
-  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> & arg3, const Numberz::type arg4, const UserId arg5) {
+  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob,
+                         const int8_t arg0,
+                         const int32_t arg1,
+                         const int64_t arg2,
+                         const std::map<int16_t, std::string>& arg3,
+                         const Numberz::type arg4,
+                         const UserId arg5) {
     Xtruct res;
     _delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
     cob(res);
   }
 
-  virtual void testException(tcxx::function<void()> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg) {
+  virtual void testException(
+      tcxx::function<void()> cob,
+      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      const std::string& arg) {
     try {
       _delegate->testException(arg);
-    } catch(const apache::thrift::TException& e) {
+    } catch (const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
     cob();
   }
 
-  virtual void testMultiException(tcxx::function<void(Xtruct const& _return)> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg0, const std::string& arg1) {
+  virtual void testMultiException(
+      tcxx::function<void(Xtruct const& _return)> cob,
+      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      const std::string& arg0,
+      const std::string& arg1) {
     Xtruct res;
     try {
       _delegate->testMultiException(res, arg0, arg1);
-    } catch(const apache::thrift::TException& e) {
+    } catch (const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
@@ -496,13 +528,12 @@ protected:
   boost::shared_ptr<TestHandler> _delegate;
 };
 
-
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 
   string file_path = boost::filesystem::system_complete(argv[0]).string();
-  string dir_path = file_path.substr(0, file_path.size()-EXECUTABLE_FILE_NAME_LENGTH);
+  string dir_path = file_path.substr(0, file_path.size() - EXECUTABLE_FILE_NAME_LENGTH);
 
-  #if _WIN32
+#if _WIN32
   transport::TWinsockSingleton::create();
 #endif
   int port = 9090;
@@ -513,32 +544,35 @@ int main(int argc, char **argv) {
   string domain_socket = "";
   size_t workers = 4;
 
-
   boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to listen")
-	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket),
-	    "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
-      ("server-type", boost::program_options::value<string>(&server_type)->default_value(server_type),
-        "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
-      ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type),
-        "transport: buffered, framed, http")
-      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
-        "protocol: binary, compact, json")
-	  ("ssl", "Encrypted Transport using SSL")
-	  ("processor-events", "processor-events")
-      ("workers,n", boost::program_options::value<size_t>(&workers)->default_value(workers),
-        "Number of thread pools workers. Only valid for thread-pool server type")
-  ;
+  desc.add_options()("help,h", "produce help message")(
+      "port",
+      boost::program_options::value<int>(&port)->default_value(port),
+      "Port number to listen")("domain-socket",
+                               boost::program_options::value<string>(&domain_socket)
+                                   ->default_value(domain_socket),
+                               "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")(
+      "server-type",
+      boost::program_options::value<string>(&server_type)->default_value(server_type),
+      "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")(
+      "transport",
+      boost::program_options::value<string>(&transport_type)->default_value(transport_type),
+      "transport: buffered, framed, http")(
+      "protocol",
+      boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
+      "protocol: binary, compact, json")("ssl", "Encrypted Transport using SSL")(
+      "processor-events",
+      "processor-events")("workers,n",
+                          boost::program_options::value<size_t>(&workers)->default_value(workers),
+                          "Number of thread pools workers. Only valid for thread-pool server type");
 
   boost::program_options::variables_map vm;
   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
   boost::program_options::notify(vm);
 
   if (vm.count("help")) {
-      cout << desc << "\n";
-      return 1;
+    cout << desc << "\n";
+    return 1;
   }
 
   try {
@@ -548,7 +582,7 @@ int main(int argc, char **argv) {
       } else if (server_type == "threaded") {
       } else if (server_type == "nonblocking") {
       } else {
-          throw invalid_argument("Unknown server type "+server_type);
+        throw invalid_argument("Unknown server type " + server_type);
       }
     }
 
@@ -557,7 +591,7 @@ int main(int argc, char **argv) {
       } else if (protocol_type == "compact") {
       } else if (protocol_type == "json") {
       } else {
-          throw invalid_argument("Unknown protocol type "+protocol_type);
+        throw invalid_argument("Unknown protocol type " + protocol_type);
       }
     }
 
@@ -566,7 +600,7 @@ int main(int argc, char **argv) {
       } else if (transport_type == "framed") {
       } else if (transport_type == "http") {
       } else {
-          throw invalid_argument("Unknown transport type "+transport_type);
+        throw invalid_argument("Unknown transport type " + transport_type);
       }
     }
 
@@ -589,7 +623,8 @@ int main(int argc, char **argv) {
     boost::shared_ptr<TProtocolFactory> compactProtocolFactory(new TCompactProtocolFactory());
     protocolFactory = compactProtocolFactory;
   } else {
-    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(new TBinaryProtocolFactoryT<TBufferBase>());
+    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(
+        new TBinaryProtocolFactoryT<TBufferBase>());
     protocolFactory = binaryProtocolFactory;
   }
 
@@ -598,8 +633,8 @@ int main(int argc, char **argv) {
   boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
 
   if (vm.count("processor-events")) {
-    testProcessor->setEventHandler(boost::shared_ptr<TProcessorEventHandler>(
-          new TestProcessorEventHandler()));
+    testProcessor->setEventHandler(
+        boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
   }
 
   // Transport
@@ -637,8 +672,8 @@ int main(int argc, char **argv) {
   }
 
   // Server Info
-  cout << "Starting \"" << server_type << "\" server ("
-    << transport_type << "/" << protocol_type << ") listen on: " << domain_socket;
+  cout << "Starting \"" << server_type << "\" server (" << transport_type << "/" << protocol_type
+       << ") listen on: " << domain_socket;
   if (port != 0) {
     cout << port;
   }
@@ -648,17 +683,13 @@ int main(int argc, char **argv) {
   boost::shared_ptr<apache::thrift::server::TServer> server;
 
   if (server_type == "simple") {
-    server.reset(new TSimpleServer(testProcessor,
-                               serverSocket,
-                               transportFactory,
-                               protocolFactory));
+    server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "thread-pool") {
 
-    boost::shared_ptr<ThreadManager> threadManager =
-      ThreadManager::newSimpleThreadManager(workers);
+    boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
 
-    boost::shared_ptr<PlatformThreadFactory> threadFactory =
-      boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    boost::shared_ptr<PlatformThreadFactory> threadFactory
+        = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
     threadManager->threadFactory(threadFactory);
 
@@ -671,15 +702,15 @@ int main(int argc, char **argv) {
                                        threadManager));
   } else if (server_type == "threaded") {
 
-    server.reset(new TThreadedServer(testProcessor,
-                                   serverSocket,
-                                   transportFactory,
-                                   protocolFactory));
+    server.reset(
+        new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "nonblocking") {
-    if(transport_type == "http") {
+    if (transport_type == "http") {
       boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
-      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(new ThriftTestAsyncProcessor(testHandlerAsync));
-      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
+      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(
+          new ThriftTestAsyncProcessor(testHandlerAsync));
+      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
+          new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
 
       // not loading nonblockingServer into "server" because
       // TEvhttpServer doesn't inherit from TServer, and doesn't
@@ -691,17 +722,18 @@ int main(int argc, char **argv) {
     }
   }
 
-  if(server.get() != NULL)
-  {
+  if (server.get() != NULL) {
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
     boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
-    boost::shared_ptr<apache::thrift::concurrency::Thread> thread = factory.newThread(serverThreadRunner);
+    boost::shared_ptr<apache::thrift::concurrency::Thread> thread
+        = factory.newThread(serverThreadRunner);
     thread->start();
 
     // HACK: cross language test suite is unable to handle cin properly
     //       that's why we stay in a endless loop here
-    while(1){}
+    while (1) {
+    }
     // FIXME: find another way to stop the server (e.g. a signal)
     // cout<<"Press enter to stop the server."<<endl;
     // cin.ignore(); //wait until a key is pressed

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/src/ThriftTest_extras.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/ThriftTest_extras.cpp b/test/cpp/src/ThriftTest_extras.cpp
index 33f681f..af5606e 100644
--- a/test/cpp/src/ThriftTest_extras.cpp
+++ b/test/cpp/src/ThriftTest_extras.cpp
@@ -22,12 +22,12 @@
 #include <thrift/protocol/TDebugProtocol.h>
 #include "gen-cpp/ThriftTest_types.h"
 
-
-namespace thrift { namespace test {
+namespace thrift {
+namespace test {
 
 bool Insanity::operator<(thrift::test::Insanity const& other) const {
   using apache::thrift::ThriftDebugString;
   return ThriftDebugString(*this) < ThriftDebugString(other);
 }
-
-}}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/tutorial/cpp/CppClient.cpp
----------------------------------------------------------------------
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp
index 4475338..258cbd6 100644
--- a/tutorial/cpp/CppClient.cpp
+++ b/tutorial/cpp/CppClient.cpp
@@ -76,5 +76,4 @@ int main() {
   } catch (TException& tx) {
     cout << "ERROR: " << tx.what() << endl;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/tutorial/cpp/CppServer.cpp
----------------------------------------------------------------------
diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp
index 133d75d..84b79d4 100644
--- a/tutorial/cpp/CppServer.cpp
+++ b/tutorial/cpp/CppServer.cpp
@@ -44,12 +44,10 @@ using namespace tutorial;
 using namespace shared;
 
 class CalculatorHandler : public CalculatorIf {
- public:
+public:
   CalculatorHandler() {}
 
-  void ping() {
-    cout << "ping()" << endl;
-  }
+  void ping() { cout << "ping()" << endl; }
 
   int32_t add(const int32_t n1, const int32_t n2) {
     cout << "add(" << n1 << ", " << n2 << ")" << endl;
@@ -95,18 +93,15 @@ class CalculatorHandler : public CalculatorIf {
     return val;
   }
 
-  void getStruct(SharedStruct &ret, const int32_t logid) {
+  void getStruct(SharedStruct& ret, const int32_t logid) {
     cout << "getStruct(" << logid << ")" << endl;
     ret = log[logid];
   }
 
-  void zip() {
-    cout << "zip()" << endl;
-  }
+  void zip() { cout << "zip()" << endl; }
 
 protected:
   map<int32_t, SharedStruct> log;
-
 };
 
 int main() {
@@ -116,11 +111,7 @@ int main() {
   boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
   boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
 
-  TSimpleServer server(processor,
-                       serverTransport,
-                       transportFactory,
-                       protocolFactory);
-
+  TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
 
   /**
    * Or you could do one of these

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/tutorial/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/tutorial/cpp/Makefile.am b/tutorial/cpp/Makefile.am
index 9768c51..3b38240 100755
--- a/tutorial/cpp/Makefile.am
+++ b/tutorial/cpp/Makefile.am
@@ -76,6 +76,9 @@ tutorialserver: all
 tutorialclient: all
 	./TutorialClient
 
+style-local:
+	$(CPPSTYLE_CMD)
+
 EXTRA_DIST = \
 	CppClient.cpp \
 	CppServer.cpp


[03/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TransportTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
old mode 100755
new mode 100644
index c1cb976..0305732
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -36,10 +36,9 @@
 
 #include <thrift/concurrency/FunctionRunner.h>
 #if _WIN32
-  #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
-
 using namespace apache::thrift::transport;
 
 static boost::mt19937 rng;
@@ -49,14 +48,14 @@ void initrand(unsigned int seed) {
 }
 
 class SizeGenerator {
- public:
+public:
   virtual ~SizeGenerator() {}
   virtual uint32_t nextSize() = 0;
   virtual std::string describe() const = 0;
 };
 
 class ConstantSizeGenerator : public SizeGenerator {
- public:
+public:
   ConstantSizeGenerator(uint32_t value) : value_(value) {}
   uint32_t nextSize() { return value_; }
   std::string describe() const {
@@ -65,14 +64,14 @@ class ConstantSizeGenerator : public SizeGenerator {
     return desc.str();
   }
 
- private:
+private:
   uint32_t value_;
 };
 
 class RandomSizeGenerator : public SizeGenerator {
- public:
-  RandomSizeGenerator(uint32_t min, uint32_t max) :
-    generator_(rng, boost::uniform_int<int>(min, max)) {}
+public:
+  RandomSizeGenerator(uint32_t min, uint32_t max)
+    : generator_(rng, boost::uniform_int<int>(min, max)) {}
 
   uint32_t nextSize() { return generator_(); }
 
@@ -85,9 +84,8 @@ class RandomSizeGenerator : public SizeGenerator {
   uint32_t getMin() const { return (generator_.distribution().min)(); }
   uint32_t getMax() const { return (generator_.distribution().max)(); }
 
- private:
-  boost::variate_generator< boost::mt19937&, boost::uniform_int<int> >
-    generator_;
+private:
+  boost::variate_generator<boost::mt19937&, boost::uniform_int<int> > generator_;
 };
 
 /**
@@ -98,16 +96,15 @@ class RandomSizeGenerator : public SizeGenerator {
  *   to make a copy of the generator to bind it to the test function.)
  */
 class GenericSizeGenerator : public SizeGenerator {
- public:
-  GenericSizeGenerator(uint32_t value) :
-    generator_(new ConstantSizeGenerator(value)) {}
-  GenericSizeGenerator(uint32_t min, uint32_t max) :
-    generator_(new RandomSizeGenerator(min, max)) {}
+public:
+  GenericSizeGenerator(uint32_t value) : generator_(new ConstantSizeGenerator(value)) {}
+  GenericSizeGenerator(uint32_t min, uint32_t max)
+    : generator_(new RandomSizeGenerator(min, max)) {}
 
   uint32_t nextSize() { return generator_->nextSize(); }
   std::string describe() const { return generator_->describe(); }
 
- private:
+private:
   boost::shared_ptr<SizeGenerator> generator_;
 };
 
@@ -125,7 +122,7 @@ class GenericSizeGenerator : public SizeGenerator {
  */
 template <class Transport_>
 class CoupledTransports {
- public:
+public:
   virtual ~CoupledTransports() {}
   typedef Transport_ TransportType;
 
@@ -134,18 +131,17 @@ class CoupledTransports {
   boost::shared_ptr<Transport_> in;
   boost::shared_ptr<Transport_> out;
 
- private:
+private:
   CoupledTransports(const CoupledTransports&);
-  CoupledTransports &operator=(const CoupledTransports&);
+  CoupledTransports& operator=(const CoupledTransports&);
 };
 
 /**
  * Coupled TMemoryBuffers
  */
 class CoupledMemoryBuffers : public CoupledTransports<TMemoryBuffer> {
- public:
-  CoupledMemoryBuffers() :
-    buf(new TMemoryBuffer) {
+public:
+  CoupledMemoryBuffers() : buf(new TMemoryBuffer) {
     in = buf;
     out = buf;
   }
@@ -159,7 +155,7 @@ class CoupledMemoryBuffers : public CoupledTransports<TMemoryBuffer> {
  */
 template <class WrapperTransport_, class InnerCoupledTransports_>
 class CoupledWrapperTransportsT : public CoupledTransports<WrapperTransport_> {
- public:
+public:
   CoupledWrapperTransportsT() {
     if (inner_.in) {
       this->in.reset(new WrapperTransport_(inner_.in));
@@ -176,34 +172,27 @@ class CoupledWrapperTransportsT : public CoupledTransports<WrapperTransport_> {
  * Coupled TBufferedTransports.
  */
 template <class InnerTransport_>
-class CoupledBufferedTransportsT :
-  public CoupledWrapperTransportsT<TBufferedTransport, InnerTransport_> {
-};
+class CoupledBufferedTransportsT
+    : public CoupledWrapperTransportsT<TBufferedTransport, InnerTransport_> {};
 
-typedef CoupledBufferedTransportsT<CoupledMemoryBuffers>
-  CoupledBufferedTransports;
+typedef CoupledBufferedTransportsT<CoupledMemoryBuffers> CoupledBufferedTransports;
 
 /**
  * Coupled TFramedTransports.
  */
 template <class InnerTransport_>
-class CoupledFramedTransportsT :
-  public CoupledWrapperTransportsT<TFramedTransport, InnerTransport_> {
-};
+class CoupledFramedTransportsT
+    : public CoupledWrapperTransportsT<TFramedTransport, InnerTransport_> {};
 
-typedef CoupledFramedTransportsT<CoupledMemoryBuffers>
-  CoupledFramedTransports;
+typedef CoupledFramedTransportsT<CoupledMemoryBuffers> CoupledFramedTransports;
 
 /**
  * Coupled TZlibTransports.
  */
 template <class InnerTransport_>
-class CoupledZlibTransportsT :
-  public CoupledWrapperTransportsT<TZlibTransport, InnerTransport_> {
-};
+class CoupledZlibTransportsT : public CoupledWrapperTransportsT<TZlibTransport, InnerTransport_> {};
 
-typedef CoupledZlibTransportsT<CoupledMemoryBuffers>
-  CoupledZlibTransports;
+typedef CoupledZlibTransportsT<CoupledMemoryBuffers> CoupledZlibTransports;
 
 #ifndef _WIN32
 // FD transport doesn't make much sense on Windows.
@@ -211,7 +200,7 @@ typedef CoupledZlibTransportsT<CoupledMemoryBuffers>
  * Coupled TFDTransports.
  */
 class CoupledFDTransports : public CoupledTransports<TFDTransport> {
- public:
+public:
   CoupledFDTransports() {
     int pipes[2];
 
@@ -229,7 +218,7 @@ class CoupledFDTransports : public CoupledTransports<TFDTransport> {
  * Coupled TSockets
  */
 class CoupledSocketTransports : public CoupledTransports<TSocket> {
- public:
+public:
   CoupledSocketTransports() {
     THRIFT_SOCKET sockets[2] = {0};
     if (THRIFT_SOCKETPAIR(PF_UNIX, SOCK_STREAM, 0, sockets) != 0) {
@@ -242,39 +231,34 @@ class CoupledSocketTransports : public CoupledTransports<TSocket> {
   }
 };
 
-//These could be made to work on Windows, but I don't care enough to make it happen
+// These could be made to work on Windows, but I don't care enough to make it happen
 #ifndef _WIN32
 /**
  * Coupled TFileTransports
  */
 class CoupledFileTransports : public CoupledTransports<TFileTransport> {
- public:
+public:
   CoupledFileTransports() {
 #ifndef _WIN32
     const char* tmp_dir = "/tmp";
-    #define FILENAME_SUFFIX "/thrift.transport_test"
+#define FILENAME_SUFFIX "/thrift.transport_test"
 #else
     const char* tmp_dir = getenv("TMP");
-    #define FILENAME_SUFFIX "\\thrift.transport_test"
+#define FILENAME_SUFFIX "\\thrift.transport_test"
 #endif
 
     // Create a temporary file to use
     filename.resize(strlen(tmp_dir) + strlen(FILENAME_SUFFIX));
-    THRIFT_SNPRINTF(&filename[0], filename.size(),
-             "%s" FILENAME_SUFFIX, tmp_dir);
-    #undef FILENAME_SUFFIX
+    THRIFT_SNPRINTF(&filename[0], filename.size(), "%s" FILENAME_SUFFIX, tmp_dir);
+#undef FILENAME_SUFFIX
 
-    {
-      std::ofstream dummy_creation(filename.c_str(), std::ofstream::trunc);
-    }
+    { std::ofstream dummy_creation(filename.c_str(), std::ofstream::trunc); }
 
     in.reset(new TFileTransport(filename, true));
     out.reset(new TFileTransport(filename));
   }
 
-  ~CoupledFileTransports() {
-    remove(filename.c_str());
-  }
+  ~CoupledFileTransports() { remove(filename.c_str()); }
 
   std::string filename;
 };
@@ -290,7 +274,7 @@ class CoupledFileTransports : public CoupledTransports<TFileTransport> {
  */
 template <class CoupledTransports_>
 class CoupledTTransports : public CoupledTransports<TTransport> {
- public:
+public:
   CoupledTTransports() : transports() {
     in = transports.in;
     out = transports.out;
@@ -308,7 +292,7 @@ class CoupledTTransports : public CoupledTransports<TTransport> {
  */
 template <class CoupledTransports_>
 class CoupledBufferBases : public CoupledTransports<TBufferBase> {
- public:
+public:
   CoupledBufferBases() : transports() {
     in = transports.in;
     out = transports.out;
@@ -332,12 +316,8 @@ class CoupledBufferBases : public CoupledTransports<TBufferBase> {
  **************************************************************************/
 
 struct TriggerInfo {
-  TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport,
-              uint32_t writeLength) :
-    timeoutSeconds(seconds),
-    transport(transport),
-    writeLength(writeLength),
-    next(NULL) {}
+  TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport, uint32_t writeLength)
+    : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(NULL) {}
 
   int timeoutSeconds;
   boost::shared_ptr<TTransport> transport;
@@ -351,7 +331,7 @@ unsigned int g_numTriggersFired;
 bool g_teardown = false;
 
 void alarm_handler() {
-  TriggerInfo *info = NULL;
+  TriggerInfo* info = NULL;
   {
     apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
     // The alarm timed out, which almost certainly means we're stuck
@@ -383,26 +363,26 @@ void alarm_handler() {
 }
 
 void alarm_handler_wrapper() {
-  int64_t timeout = 0;  //timeout of 0 means wait forever
-  while(true) {
+  int64_t timeout = 0; // timeout of 0 means wait forever
+  while (true) {
     bool fireHandler = false;
     {
       apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
-      if(g_teardown)
-         return;
-      //calculate timeout
+      if (g_teardown)
+        return;
+      // calculate timeout
       if (g_triggerInfo == NULL) {
         timeout = 0;
       } else {
-         timeout = g_triggerInfo->timeoutSeconds * 1000;
+        timeout = g_triggerInfo->timeoutSeconds * 1000;
       }
 
       int waitResult = g_alarm_monitor.waitForTimeRelative(timeout);
-      if(waitResult == THRIFT_ETIMEDOUT)
+      if (waitResult == THRIFT_ETIMEDOUT)
         fireHandler = true;
     }
-    if(fireHandler)
-      alarm_handler(); //calling outside the lock
+    if (fireHandler)
+      alarm_handler(); // calling outside the lock
   }
 }
 
@@ -415,7 +395,7 @@ void alarm_handler_wrapper() {
  * to the end.)
  */
 void add_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport> &transport,
+                 const boost::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   TriggerInfo* info = new TriggerInfo(seconds, transport, write_len);
   {
@@ -437,7 +417,7 @@ void add_trigger(unsigned int seconds,
 }
 
 void clear_triggers() {
-  TriggerInfo *info = NULL;
+  TriggerInfo* info = NULL;
 
   {
     apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
@@ -455,7 +435,7 @@ void clear_triggers() {
 }
 
 void set_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport> &transport,
+                 const boost::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   clear_triggers();
   add_trigger(seconds, transport, write_len);
@@ -499,10 +479,8 @@ void test_rw(uint32_t totalSize,
   BOOST_REQUIRE(transports.in != NULL);
   BOOST_REQUIRE(transports.out != NULL);
 
-  boost::shared_array<uint8_t> wbuf =
-    boost::shared_array<uint8_t>(new uint8_t[totalSize]);
-  boost::shared_array<uint8_t> rbuf =
-    boost::shared_array<uint8_t>(new uint8_t[totalSize]);
+  boost::shared_array<uint8_t> wbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
+  boost::shared_array<uint8_t> rbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
 
   // store some data in wbuf
   for (uint32_t n = 0; n < totalSize; ++n) {
@@ -522,8 +500,7 @@ void test_rw(uint32_t totalSize,
 
     // Make sure (total_written - total_read) + wchunk_size
     // is less than maxOutstanding
-    if (maxOutstanding > 0 &&
-        wchunk_size > maxOutstanding - (total_written - total_read)) {
+    if (maxOutstanding > 0 && wchunk_size > maxOutstanding - (total_written - total_read)) {
       wchunk_size = maxOutstanding - (total_written - total_read);
     }
 
@@ -537,8 +514,7 @@ void test_rw(uint32_t totalSize,
 
       try {
         transports.out->write(wbuf.get() + total_written, write_size);
-      }
-      catch (TTransportException & te) {
+      } catch (TTransportException& te) {
         if (te.getType() == TTransportException::TIMED_OUT)
           break;
         throw te;
@@ -572,17 +548,15 @@ void test_rw(uint32_t totalSize,
       try {
         bytes_read = transports.in->read(rbuf.get() + total_read, read_size);
       } catch (TTransportException& e) {
-        BOOST_FAIL("read(pos=" << total_read << ", size=" << read_size <<
-                   ") threw exception \"" << e.what() <<
-                   "\"; written so far: " << total_written << " / " <<
-                   totalSize << " bytes");
+        BOOST_FAIL("read(pos=" << total_read << ", size=" << read_size << ") threw exception \""
+                               << e.what() << "\"; written so far: " << total_written << " / "
+                               << totalSize << " bytes");
       }
 
       BOOST_REQUIRE_MESSAGE(bytes_read > 0,
-                            "read(pos=" << total_read << ", size=" <<
-                            read_size << ") returned " << bytes_read <<
-                            "; written so far: " << total_written << " / " <<
-                            totalSize << " bytes");
+                            "read(pos=" << total_read << ", size=" << read_size << ") returned "
+                                        << bytes_read << "; written so far: " << total_written
+                                        << " / " << totalSize << " bytes");
       chunk_read += bytes_read;
       total_read += bytes_read;
     }
@@ -592,7 +566,6 @@ void test_rw(uint32_t totalSize,
   BOOST_CHECK_EQUAL(memcmp(rbuf.get(), wbuf.get(), totalSize), 0);
 }
 
-
 template <class CoupledTransports>
 void test_read_part_available() {
   CoupledTransports transports;
@@ -609,8 +582,8 @@ void test_read_part_available() {
   transports.out->flush();
   set_trigger(3, transports.out, 1);
   uint32_t bytes_read = transports.in->read(read_buf, 10);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
-  BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 9);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
+  BOOST_CHECK_EQUAL(bytes_read, (uint32_t)9);
 
   clear_triggers();
 }
@@ -676,7 +649,7 @@ void test_read_partial_midframe() {
 
   // Now read 4 bytes, so that we are partway through the written data.
   uint32_t bytes_read = transports.in->read(read_buf, 4);
-  BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 4);
+  BOOST_CHECK_EQUAL(bytes_read, (uint32_t)4);
 
   // Now attempt to read 10 bytes.  Only 9 more are available.
   //
@@ -689,13 +662,13 @@ void test_read_partial_midframe() {
   while (total_read < 9) {
     set_trigger(3, transports.out, 1);
     bytes_read = transports.in->read(read_buf, 10);
-    BOOST_REQUIRE_EQUAL(g_numTriggersFired, (unsigned int) 0);
-    BOOST_REQUIRE_GT(bytes_read, (uint32_t) 0);
+    BOOST_REQUIRE_EQUAL(g_numTriggersFired, (unsigned int)0);
+    BOOST_REQUIRE_GT(bytes_read, (uint32_t)0);
     total_read += bytes_read;
-    BOOST_REQUIRE_LE(total_read, (uint32_t) 9);
+    BOOST_REQUIRE_LE(total_read, (uint32_t)9);
   }
 
-  BOOST_CHECK_EQUAL(total_read, (uint32_t) 9);
+  BOOST_CHECK_EQUAL(total_read, (uint32_t)9);
 
   clear_triggers();
 }
@@ -717,7 +690,7 @@ void test_borrow_part_available() {
   set_trigger(3, transports.out, 1);
   uint32_t borrow_len = 10;
   const uint8_t* borrowed_buf = transports.in->borrow(read_buf, &borrow_len);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
   BOOST_CHECK(borrowed_buf == NULL);
 
   clear_triggers();
@@ -743,11 +716,11 @@ void test_read_none_available() {
   add_trigger(1, transports.out, 8);
   uint32_t bytes_read = transports.in->read(read_buf, 10);
   if (bytes_read == 0) {
-    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
     clear_triggers();
   } else {
-    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 1);
-    BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 2);
+    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)1);
+    BOOST_CHECK_EQUAL(bytes_read, (uint32_t)2);
   }
 
   clear_triggers();
@@ -767,7 +740,7 @@ void test_borrow_none_available() {
   uint32_t borrow_len = 10;
   const uint8_t* borrowed_buf = transports.in->borrow(NULL, &borrow_len);
   BOOST_CHECK(borrowed_buf == NULL);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
 
   clear_triggers();
 }
@@ -788,47 +761,40 @@ void test_borrow_none_available() {
  *   is compiler-dependent.  gcc returns mangled names.)
  **************************************************************************/
 
-#define ADD_TEST_RW(CoupledTransports, totalSize, ...) \
-    addTestRW< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports), \
-                                   totalSize, ## __VA_ARGS__);
-
-#define TEST_RW(CoupledTransports, totalSize, ...) \
-  do { \
-    /* Add the test as specified, to test the non-virtual function calls */ \
-    ADD_TEST_RW(CoupledTransports, totalSize, ## __VA_ARGS__); \
-    /* \
-     * Also test using the transport as a TTransport*, to test \
-     * the read_virt()/write_virt() calls \
-     */ \
-    ADD_TEST_RW(CoupledTTransports<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TBufferedTransport */ \
-    ADD_TEST_RW(CoupledBufferedTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TFramedTransports */ \
-    ADD_TEST_RW(CoupledFramedTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TZlibTransport */ \
-    ADD_TEST_RW(CoupledZlibTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
+#define ADD_TEST_RW(CoupledTransports, totalSize, ...)                                             \
+  addTestRW<CoupledTransports>(BOOST_STRINGIZE(CoupledTransports), totalSize, ##__VA_ARGS__);
+
+#define TEST_RW(CoupledTransports, totalSize, ...)                                                 \
+  do {                                                                                             \
+    /* Add the test as specified, to test the non-virtual function calls */                        \
+    ADD_TEST_RW(CoupledTransports, totalSize, ##__VA_ARGS__);                                      \
+    /*                                                                                             \
+     * Also test using the transport as a TTransport*, to test                                     \
+     * the read_virt()/write_virt() calls                                                          \
+     */                                                                                            \
+    ADD_TEST_RW(CoupledTTransports<CoupledTransports>, totalSize, ##__VA_ARGS__);                  \
+    /* Test wrapping the transport with TBufferedTransport */                                      \
+    ADD_TEST_RW(CoupledBufferedTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);          \
+    /* Test wrapping the transport with TFramedTransports */                                       \
+    ADD_TEST_RW(CoupledFramedTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);            \
+    /* Test wrapping the transport with TZlibTransport */                                          \
+    ADD_TEST_RW(CoupledZlibTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);              \
   } while (0)
 
-#define ADD_TEST_BLOCKING(CoupledTransports) \
-    addTestBlocking< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports));
+#define ADD_TEST_BLOCKING(CoupledTransports)                                                       \
+  addTestBlocking<CoupledTransports>(BOOST_STRINGIZE(CoupledTransports));
 
-#define TEST_BLOCKING_BEHAVIOR(CoupledTransports) \
-  ADD_TEST_BLOCKING(CoupledTransports); \
-  ADD_TEST_BLOCKING(CoupledTTransports<CoupledTransports>); \
-  ADD_TEST_BLOCKING(CoupledBufferedTransportsT<CoupledTransports>); \
-  ADD_TEST_BLOCKING(CoupledFramedTransportsT<CoupledTransports>); \
+#define TEST_BLOCKING_BEHAVIOR(CoupledTransports)                                                  \
+  ADD_TEST_BLOCKING(CoupledTransports);                                                            \
+  ADD_TEST_BLOCKING(CoupledTTransports<CoupledTransports>);                                        \
+  ADD_TEST_BLOCKING(CoupledBufferedTransportsT<CoupledTransports>);                                \
+  ADD_TEST_BLOCKING(CoupledFramedTransportsT<CoupledTransports>);                                  \
   ADD_TEST_BLOCKING(CoupledZlibTransportsT<CoupledTransports>);
 
 class TransportTestGen {
- public:
-  TransportTestGen(boost::unit_test::test_suite* suite,
-                   float sizeMultiplier) :
-      suite_(suite),
-      sizeMultiplier_(sizeMultiplier) {}
+public:
+  TransportTestGen(boost::unit_test::test_suite* suite, float sizeMultiplier)
+    : suite_(suite), sizeMultiplier_(sizeMultiplier) {}
 
   void generate() {
     GenericSizeGenerator rand4k(1, 4096);
@@ -839,15 +805,15 @@ class TransportTestGen {
      */
 
     // TMemoryBuffer tests
-    TEST_RW(CoupledMemoryBuffers, 1024*1024, 0, 0);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163);
-    TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 1024, 0, 0);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 167, 163);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 16, 1, 1);
 
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 0, 0, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 0, 0, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, rand4k, rand4k, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 167, 163, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 16, 1, 1, rand4k, rand4k);
 
     TEST_BLOCKING_BEHAVIOR(CoupledMemoryBuffers);
 
@@ -856,68 +822,57 @@ class TransportTestGen {
     // Since CoupledFDTransports tests with a pipe, writes will block
     // if there is too much outstanding unread data in the pipe.
     uint32_t fd_max_outstanding = 4096;
-    TEST_RW(CoupledFDTransports, 1024*1024, 0, 0,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
-            0, 0, fd_max_outstanding);
-
-    TEST_RW(CoupledFDTransports, 1024*256, 0, 0,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
-            rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 1024, 0, 0, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, rand4k, rand4k, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, 167, 163, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, 0, 0, fd_max_outstanding);
+
+    TEST_RW(CoupledFDTransports, 1024 * 256, 0, 0, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, rand4k, rand4k, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, 167, 163, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, rand4k, rand4k, fd_max_outstanding);
 
     TEST_BLOCKING_BEHAVIOR(CoupledFDTransports);
 #endif //_WIN32
 
     // TSocket tests
     uint32_t socket_max_outstanding = 4096;
-    TEST_RW(CoupledSocketTransports, 1024*1024, 0, 0,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
-            0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 1024, 0, 0, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, rand4k, rand4k, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 167, 163, 0, 0, socket_max_outstanding);
     // Doh.  Apparently writing to a socket has some additional overhead for
     // each send() call.  If we have more than ~400 outstanding 1-byte write
     // requests, additional send() calls start blocking.
-    TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 0, 0,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
-            rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 16, 1, 1, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 0, 0, rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports,
+            1024 * 256,
+            rand4k,
+            rand4k,
+            rand4k,
+            rand4k,
+            socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 167, 163, rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 16, 1, 1, rand4k, rand4k, socket_max_outstanding);
 
     TEST_BLOCKING_BEHAVIOR(CoupledSocketTransports);
 
-//These could be made to work on Windows, but I don't care enough to make it happen
+// These could be made to work on Windows, but I don't care enough to make it happen
 #ifndef _WIN32
     // TFileTransport tests
     // We use smaller buffer sizes here, since TFileTransport is fairly slow.
     //
     // TFileTransport can't write more than 16MB at once
-    uint32_t max_write_at_once = 1024*1024*16 - 4;
-    TEST_RW(CoupledFileTransports, 1024*1024, max_write_at_once, 0);
-    TEST_RW(CoupledFileTransports, 1024*128, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*128, 167, 163);
-    TEST_RW(CoupledFileTransports, 1024*2, 1, 1);
-
-    TEST_RW(CoupledFileTransports, 1024*64, 0, 0, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*64,
-            rand4k, rand4k, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*64, 167, 163, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*2, 1, 1, rand4k, rand4k);
+    uint32_t max_write_at_once = 1024 * 1024 * 16 - 4;
+    TEST_RW(CoupledFileTransports, 1024 * 1024, max_write_at_once, 0);
+    TEST_RW(CoupledFileTransports, 1024 * 128, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 128, 167, 163);
+    TEST_RW(CoupledFileTransports, 1024 * 2, 1, 1);
+
+    TEST_RW(CoupledFileTransports, 1024 * 64, 0, 0, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 64, rand4k, rand4k, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 64, 167, 163, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 2, 1, 1, rand4k, rand4k);
 
     TEST_BLOCKING_BEHAVIOR(CoupledFileTransports);
 #endif
@@ -925,23 +880,45 @@ class TransportTestGen {
     // Add some tests that access TBufferedTransport and TFramedTransport
     // via TTransport pointers and TBufferBase pointers.
     ADD_TEST_RW(CoupledTTransports<CoupledBufferedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledBufferBases<CoupledBufferedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledTTransports<CoupledFramedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledBufferBases<CoupledFramedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
 
     // Test using TZlibTransport via a TTransport pointer
     ADD_TEST_RW(CoupledTTransports<CoupledZlibTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
   }
 
- private:
+private:
   template <class CoupledTransports>
-  void addTestRW(const char* transport_name, uint32_t totalSize,
-                 GenericSizeGenerator wSizeGen, GenericSizeGenerator rSizeGen,
+  void addTestRW(const char* transport_name,
+                 uint32_t totalSize,
+                 GenericSizeGenerator wSizeGen,
+                 GenericSizeGenerator rSizeGen,
                  GenericSizeGenerator wChunkSizeGen = 0,
                  GenericSizeGenerator rChunkSizeGen = 0,
                  uint32_t maxOutstanding = 0,
@@ -950,60 +927,50 @@ class TransportTestGen {
     totalSize = static_cast<uint32_t>(totalSize * sizeMultiplier_);
 
     std::ostringstream name;
-    name << transport_name << "::test_rw(" << totalSize << ", " <<
-      wSizeGen.describe() << ", " << rSizeGen.describe() << ", " <<
-      wChunkSizeGen.describe() << ", " << rChunkSizeGen.describe() << ", " <<
-      maxOutstanding << ")";
-
-    boost::unit_test::callback0<> test_func =
-      apache::thrift::stdcxx::bind(test_rw<CoupledTransports>, totalSize,
-                     wSizeGen, rSizeGen, wChunkSizeGen, rChunkSizeGen,
-                     maxOutstanding);
-    boost::unit_test::test_case* tc =
-      boost::unit_test::make_test_case(test_func, name.str());
+    name << transport_name << "::test_rw(" << totalSize << ", " << wSizeGen.describe() << ", "
+         << rSizeGen.describe() << ", " << wChunkSizeGen.describe() << ", "
+         << rChunkSizeGen.describe() << ", " << maxOutstanding << ")";
+
+    boost::unit_test::callback0<> test_func
+        = apache::thrift::stdcxx::bind(test_rw<CoupledTransports>,
+                                       totalSize,
+                                       wSizeGen,
+                                       rSizeGen,
+                                       wChunkSizeGen,
+                                       rChunkSizeGen,
+                                       maxOutstanding);
+    boost::unit_test::test_case* tc = boost::unit_test::make_test_case(test_func, name.str());
     suite_->add(tc, expectedFailures);
   }
 
   template <class CoupledTransports>
-  void addTestBlocking(const char* transportName,
-                       uint32_t expectedFailures = 0) {
+  void addTestBlocking(const char* transportName, uint32_t expectedFailures = 0) {
     char name[1024];
     boost::unit_test::test_case* tc;
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_part_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_part_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available_in_chunks()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_part_available_in_chunks<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available_in_chunks()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_part_available_in_chunks<CoupledTransports>,
+                                          name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_partial_midframe()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_partial_midframe<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_partial_midframe()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_partial_midframe<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_none_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_none_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_none_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_none_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_part_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_borrow_part_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_part_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_borrow_part_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_none_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_borrow_none_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_none_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_borrow_none_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
   }
 
@@ -1022,15 +989,15 @@ class TransportTestGen {
 struct global_fixture {
   boost::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_;
   global_fixture() {
-  #if _WIN32
+#if _WIN32
     apache::thrift::transport::TWinsockSingleton::create();
-  #endif
+#endif
 
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
 
     alarmThread_ = factory.newThread(
-      apache::thrift::concurrency::FunctionRunner::create(alarm_handler_wrapper));
+        apache::thrift::concurrency::FunctionRunner::create(alarm_handler_wrapper));
     alarmThread_->start();
   }
   ~global_fixture() {
@@ -1054,8 +1021,7 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
 
   initrand(seed);
 
-  boost::unit_test::test_suite* suite =
-    &boost::unit_test::framework::master_test_suite();
+  boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();
   suite->p_name.value = "TransportTest";
   TransportTestGen transport_test_generator(suite, 1);
   transport_test_generator.generate();

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/ZlibTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index 49c5514..14b1a37 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -48,26 +48,24 @@ boost::mt19937 rng;
  */
 
 class SizeGenerator {
- public:
+public:
   virtual ~SizeGenerator() {}
   virtual unsigned int getSize() = 0;
 };
 
 class ConstantSizeGenerator : public SizeGenerator {
- public:
+public:
   ConstantSizeGenerator(unsigned int value) : value_(value) {}
-  virtual unsigned int getSize() {
-    return value_;
-  }
+  virtual unsigned int getSize() { return value_; }
 
- private:
+private:
   unsigned int value_;
 };
 
 class LogNormalSizeGenerator : public SizeGenerator {
- public:
-  LogNormalSizeGenerator(double mean, double std_dev) :
-      gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
+public:
+  LogNormalSizeGenerator(double mean, double std_dev)
+    : gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
 
   virtual unsigned int getSize() {
     // Loop until we get a size of 1 or more
@@ -79,8 +77,8 @@ class LogNormalSizeGenerator : public SizeGenerator {
     }
   }
 
- private:
-  boost::variate_generator< boost::mt19937, boost::lognormal_distribution<double> > gen_;
+private:
+  boost::variate_generator<boost::mt19937, boost::lognormal_distribution<double> > gen_;
 };
 
 uint8_t* gen_uniform_buffer(uint32_t buf_len, uint8_t c) {
@@ -95,10 +93,10 @@ uint8_t* gen_compressible_buffer(uint32_t buf_len) {
   // Generate small runs of alternately increasing and decreasing bytes
   boost::uniform_smallint<uint32_t> run_length_distribution(1, 64);
   boost::uniform_smallint<uint8_t> byte_distribution(0, UINT8_MAX);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint8_t> >
-    byte_generator(rng, byte_distribution);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint32_t> >
-    run_len_generator(rng, run_length_distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
+      byte_generator(rng, byte_distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint32_t> >
+      run_len_generator(rng, run_length_distribution);
 
   uint32_t idx = 0;
   int8_t step = 1;
@@ -125,8 +123,8 @@ uint8_t* gen_random_buffer(uint32_t buf_len) {
   uint8_t* buf = new uint8_t[buf_len];
 
   boost::uniform_smallint<uint8_t> distribution(0, UINT8_MAX);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint8_t> >
-    generator(rng, distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
+      generator(rng, distribution);
 
   for (uint32_t n = 0; n < buf_len; ++n) {
     buf[n] = generator();
@@ -167,7 +165,7 @@ void test_separate_checksum(const uint8_t* buf, uint32_t buf_len) {
   membuf->appendBufferToString(tmp_buf);
   zlib_trans.reset(new TZlibTransport(membuf,
                                       TZlibTransport::DEFAULT_URBUF_SIZE,
-                                      static_cast<uint32_t>(tmp_buf.length()-1)));
+                                      static_cast<uint32_t>(tmp_buf.length() - 1)));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
   uint32_t got = zlib_trans->readAll(mirror.get(), buf_len);
@@ -186,8 +184,7 @@ void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) {
   string tmp_buf;
   membuf->appendBufferToString(tmp_buf);
   tmp_buf.erase(tmp_buf.length() - 1);
-  membuf->resetBuffer(const_cast<uint8_t*>(
-                        reinterpret_cast<const uint8_t*>(tmp_buf.data())),
+  membuf->resetBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(tmp_buf.data())),
                       static_cast<uint32_t>(tmp_buf.length()));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
@@ -202,7 +199,8 @@ void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) {
   }
 }
 
-void test_read_write_mix(const uint8_t* buf, uint32_t buf_len,
+void test_read_write_mix(const uint8_t* buf,
+                         uint32_t buf_len,
                          const boost::shared_ptr<SizeGenerator>& write_gen,
                          const boost::shared_ptr<SizeGenerator>& read_gen) {
   // Try it with a mix of read/write sizes.
@@ -232,7 +230,7 @@ void test_read_write_mix(const uint8_t* buf, uint32_t buf_len,
     }
     uint32_t got = zlib_trans->read(mirror.get() + tot, read_len);
     BOOST_REQUIRE_LE(got, expected_read_len);
-    BOOST_REQUIRE_NE(got, (uint32_t) 0);
+    BOOST_REQUIRE_NE(got, (uint32_t)0);
     tot += got;
   }
 
@@ -264,8 +262,7 @@ void test_invalid_checksum(const uint8_t* buf, uint32_t buf_len) {
   // error when only modifying checksum bytes.
   int index = static_cast<int>(tmp_buf.size() - 1);
   tmp_buf[index]++;
-  membuf->resetBuffer(const_cast<uint8_t*>(
-                        reinterpret_cast<const uint8_t*>(tmp_buf.data())),
+  membuf->resetBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(tmp_buf.data())),
                       static_cast<uint32_t>(tmp_buf.length()));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
@@ -323,21 +320,22 @@ void test_no_write() {
     TZlibTransport w_zlib_trans(membuf);
   }
 
-  BOOST_CHECK_EQUAL(membuf->available_read(), (uint32_t) 0);
+  BOOST_CHECK_EQUAL(membuf->available_read(), (uint32_t)0);
 }
 
 /*
  * Initialization
  */
 
-#define ADD_TEST_CASE(suite, name, function, ...) \
-  do { \
-    ::std::ostringstream name_ss; \
-    name_ss << name << "-" << BOOST_STRINGIZE(function); \
-    ::boost::unit_test::test_case* tc = ::boost::unit_test::make_test_case( \
-        ::apache::thrift::stdcxx::bind(function, ## __VA_ARGS__), \
-        name_ss.str()); \
-    (suite)->add(tc); \
+#define ADD_TEST_CASE(suite, name, function, ...)                                                  \
+  do {                                                                                             \
+    ::std::ostringstream name_ss;                                                                  \
+    name_ss << name << "-" << BOOST_STRINGIZE(function);                                           \
+    ::boost::unit_test::test_case* tc                                                              \
+        = ::boost::unit_test::make_test_case(::apache::thrift::stdcxx::bind(function,              \
+                                                                            ##__VA_ARGS__),        \
+                                             name_ss.str());                                       \
+    (suite)->add(tc);                                                                              \
   } while (0)
 
 void add_tests(boost::unit_test::test_suite* suite,
@@ -350,20 +348,30 @@ void add_tests(boost::unit_test::test_suite* suite,
   ADD_TEST_CASE(suite, name, test_invalid_checksum, buf, buf_len);
   ADD_TEST_CASE(suite, name, test_write_after_flush, buf, buf_len);
 
-  boost::shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1<<15));
+  boost::shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1 << 15));
   boost::shared_ptr<SizeGenerator> size_lognormal(new LogNormalSizeGenerator(20, 30));
-  ADD_TEST_CASE(suite, name << "-constant",
-                test_read_write_mix, buf, buf_len,
-                size_32k, size_32k);
-  ADD_TEST_CASE(suite, name << "-lognormal-write",
-                test_read_write_mix, buf, buf_len,
-                size_lognormal, size_32k);
-  ADD_TEST_CASE(suite, name << "-lognormal-read",
-                test_read_write_mix, buf, buf_len,
-                size_32k, size_lognormal);
-  ADD_TEST_CASE(suite, name << "-lognormal-both",
-                test_read_write_mix, buf, buf_len,
-                size_lognormal, size_lognormal);
+  ADD_TEST_CASE(suite, name << "-constant", test_read_write_mix, buf, buf_len, size_32k, size_32k);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-write",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_lognormal,
+                size_32k);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-read",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_32k,
+                size_lognormal);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-both",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_lognormal,
+                size_lognormal);
 
   // Test with a random size distribution,
   // but use the exact same distribution for reading as for writing.
@@ -373,9 +381,13 @@ void add_tests(boost::unit_test::test_suite* suite,
   // both start with random number generators in the same state.
   boost::shared_ptr<SizeGenerator> write_size_gen(new LogNormalSizeGenerator(20, 30));
   boost::shared_ptr<SizeGenerator> read_size_gen(new LogNormalSizeGenerator(20, 30));
-  ADD_TEST_CASE(suite, name << "-lognormal-same-distribution",
-                test_read_write_mix, buf, buf_len,
-                write_size_gen, read_size_gen);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-same-distribution",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                write_size_gen,
+                read_size_gen);
 }
 
 void print_usage(FILE* f, const char* argv0) {
@@ -392,11 +404,10 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
   printf("seed: %" PRIu32 "\n", seed);
   rng.seed(seed);
 
-  boost::unit_test::test_suite* suite =
-    &boost::unit_test::framework::master_test_suite();
+  boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();
   suite->p_name.value = "ZlibTest";
 
-  uint32_t buf_len = 1024*32;
+  uint32_t buf_len = 1024 * 32;
   add_tests(suite, gen_uniform_buffer(buf_len, 'a'), buf_len, "uniform");
   add_tests(suite, gen_compressible_buffer(buf_len), buf_len, "compressible");
   add_tests(suite, gen_random_buffer(buf_len), buf_len, "random");

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/Tests.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index c80bb88..0d81d7e 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -29,7 +29,7 @@ int main(int argc, char** argv) {
 
   std::string arg;
 
-  std::vector<std::string>  args(argc - 1 > 1 ? argc - 1 : 1);
+  std::vector<std::string> args(argc - 1 > 1 ? argc - 1 : 1);
 
   args[0] = "all";
 
@@ -45,9 +45,9 @@ int main(int argc, char** argv) {
 
     std::cout << "ThreadFactory tests..." << std::endl;
 
-    size_t count =  1000;
-    size_t floodLoops =  1;
-    size_t floodCount =  100000;
+    size_t count = 1000;
+    size_t floodLoops = 1;
+    size_t floodCount = 100000;
 
     std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl;
 
@@ -89,7 +89,6 @@ int main(int argc, char** argv) {
     std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl;
   }
 
-
   if (runAll || args[0].compare("timer-manager") == 0) {
 
     std::cout << "TimerManager tests..." << std::endl;
@@ -113,16 +112,17 @@ int main(int argc, char** argv) {
 
       int64_t delay = 10LL;
 
-      std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+      std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+                << " task count: " << taskCount << " delay: " << delay << std::endl;
 
       ThreadManagerTests threadManagerTests;
 
       assert(threadManagerTests.loadTest(taskCount, delay, workerCount));
 
-      std::cout << "\t\tThreadManager block test: worker count: " << workerCount << " delay: " << delay << std::endl;
+      std::cout << "\t\tThreadManager block test: worker count: " << workerCount
+                << " delay: " << delay << std::endl;
 
       assert(threadManagerTests.blockTest(delay, workerCount));
-
     }
   }
 
@@ -140,11 +140,12 @@ int main(int argc, char** argv) {
 
       int64_t delay = 10LL;
 
-      for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
+      for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount *= 2) {
 
         size_t taskCount = workerCount * tasksPerWorker;
 
-        std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+        std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+                  << " task count: " << taskCount << " delay: " << delay << std::endl;
 
         ThreadManagerTests threadManagerTests;
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/ThreadFactoryTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
old mode 100755
new mode 100644
index 2d97337..d7431a8
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -27,7 +27,10 @@
 #include <iostream>
 #include <set>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using boost::shared_ptr;
 using namespace apache::thrift::concurrency;
@@ -40,18 +43,14 @@ using namespace apache::thrift::concurrency;
 class ThreadFactoryTests {
 
 public:
-
   static const double TEST_TOLERANCE;
 
-  class Task: public Runnable {
+  class Task : public Runnable {
 
   public:
-
     Task() {}
 
-    void run() {
-      std::cout << "\t\t\tHello World" << std::endl;
-    }
+    void run() { std::cout << "\t\t\tHello World" << std::endl; }
   };
 
   /**
@@ -77,20 +76,17 @@ public:
   /**
    * Reap N threads
    */
-  class ReapNTask: public Runnable {
-
-   public:
+  class ReapNTask : public Runnable {
 
-    ReapNTask(Monitor& monitor, int& activeCount) :
-      _monitor(monitor),
-      _count(activeCount) {}
+  public:
+    ReapNTask(Monitor& monitor, int& activeCount) : _monitor(monitor), _count(activeCount) {}
 
     void run() {
       Synchronized s(_monitor);
 
       _count--;
 
-      //std::cout << "\t\t\tthread count: " << _count << std::endl;
+      // std::cout << "\t\t\tthread count: " << _count << std::endl;
 
       if (_count == 0) {
         _monitor.notify();
@@ -102,15 +98,15 @@ public:
     int& _count;
   };
 
-  bool reapNThreads(int loop=1, int count=10) {
+  bool reapNThreads(int loop = 1, int count = 10) {
 
-    PlatformThreadFactory threadFactory =  PlatformThreadFactory();
+    PlatformThreadFactory threadFactory = PlatformThreadFactory();
 
     Monitor* monitor = new Monitor();
 
-    for(int lix = 0; lix < loop; lix++) {
+    for (int lix = 0; lix < loop; lix++) {
 
-      int* activeCount  = new int(count);
+      int* activeCount = new int(count);
 
       std::set<shared_ptr<Thread> > threads;
 
@@ -118,20 +114,25 @@ public:
 
       for (tix = 0; tix < count; tix++) {
         try {
-          threads.insert(threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
-        } catch(SystemResourceException& e) {
-          std::cout << "\t\t\tfailed to create " << lix * count + tix << " thread " << e.what() << std::endl;
+          threads.insert(
+              threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
+        } catch (SystemResourceException& e) {
+          std::cout << "\t\t\tfailed to create " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
           throw e;
         }
       }
 
       tix = 0;
-      for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin(); thread != threads.end(); tix++, ++thread) {
+      for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin();
+           thread != threads.end();
+           tix++, ++thread) {
 
         try {
           (*thread)->start();
-        } catch(SystemResourceException& e) {
-          std::cout << "\t\t\tfailed to start  " << lix * count + tix << " thread " << e.what() << std::endl;
+        } catch (SystemResourceException& e) {
+          std::cout << "\t\t\tfailed to start  " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
           throw e;
         }
       }
@@ -143,7 +144,7 @@ public:
         }
       }
       delete activeCount;
-      std::cout << "\t\t\treaped " << lix * count << " threads" << std::endl;
+      std::cout << "\t\t\treaped " << lix* count << " threads" << std::endl;
     }
 
     std::cout << "\t\t\tSuccess!" << std::endl;
@@ -151,21 +152,12 @@ public:
     return true;
   }
 
-  class SynchStartTask: public Runnable {
+  class SynchStartTask : public Runnable {
 
-   public:
-
-    enum STATE {
-      UNINITIALIZED,
-      STARTING,
-      STARTED,
-      STOPPING,
-      STOPPED
-    };
+  public:
+    enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED };
 
-    SynchStartTask(Monitor& monitor, volatile  STATE& state) :
-      _monitor(monitor),
-      _state(state) {}
+    SynchStartTask(Monitor& monitor, volatile STATE& state) : _monitor(monitor), _state(state) {}
 
     void run() {
       {
@@ -189,9 +181,9 @@ public:
       }
     }
 
-   private:
+  private:
     Monitor& _monitor;
-    volatile  STATE& _state;
+    volatile STATE& _state;
   };
 
   bool synchStartTest() {
@@ -200,9 +192,10 @@ public:
 
     SynchStartTask::STATE state = SynchStartTask::UNINITIALIZED;
 
-    shared_ptr<SynchStartTask> task = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
+    shared_ptr<SynchStartTask> task
+        = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
 
-    PlatformThreadFactory threadFactory =  PlatformThreadFactory();
+    PlatformThreadFactory threadFactory = PlatformThreadFactory();
 
     shared_ptr<Thread> thread = threadFactory.newThread(task);
 
@@ -226,8 +219,8 @@ public:
       Synchronized s(monitor);
 
       try {
-          monitor.wait(100);
-      } catch(TimedOutException& e) {
+        monitor.wait(100);
+      } catch (TimedOutException& e) {
       }
 
       if (state == SynchStartTask::STARTED) {
@@ -253,7 +246,7 @@ public:
 
   /** See how accurate monitor timeout is. */
 
-  bool monitorTimeoutTest(size_t count=1000, int64_t timeout=10) {
+  bool monitorTimeoutTest(size_t count = 1000, int64_t timeout = 10) {
 
     Monitor monitor;
 
@@ -263,8 +256,8 @@ public:
       {
         Synchronized s(monitor);
         try {
-            monitor.wait(timeout);
-        } catch(TimedOutException& e) {
+          monitor.wait(timeout);
+        } catch (TimedOutException& e) {
         }
       }
     }
@@ -273,31 +266,32 @@ public:
 
     double error = ((endTime - startTime) - (count * timeout)) / (double)(count * timeout);
 
-    if (error < 0.0)  {
+    if (error < 0.0) {
 
       error *= 1.0;
     }
 
     bool success = error < ThreadFactoryTests::TEST_TOLERANCE;
 
-    std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << count * timeout << "ms elapsed time: "<< endTime - startTime << "ms error%: " << error * 100.0 << std::endl;
+    std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+              << "! expected time: " << count * timeout
+              << "ms elapsed time: " << endTime - startTime << "ms error%: " << error * 100.0
+              << std::endl;
 
     return success;
   }
 
-
   class FloodTask : public Runnable {
   public:
-
-    FloodTask(const size_t id) :_id(id) {}
-    ~FloodTask(){
-      if(_id % 1000 == 0) {
+    FloodTask(const size_t id) : _id(id) {}
+    ~FloodTask() {
+      if (_id % 1000 == 0) {
         std::cout << "\t\tthread " << _id << " done" << std::endl;
       }
     }
 
-    void run(){
-      if(_id % 1000 == 0) {
+    void run() {
+      if (_id % 1000 == 0) {
         std::cout << "\t\tthread " << _id << " started" << std::endl;
       }
 
@@ -306,42 +300,41 @@ public:
     const size_t _id;
   };
 
-  void foo(PlatformThreadFactory *tf) {
-    (void) tf;
-  }
+  void foo(PlatformThreadFactory* tf) { (void)tf; }
 
-  bool floodNTest(size_t loop=1, size_t count=100000) {
+  bool floodNTest(size_t loop = 1, size_t count = 100000) {
 
     bool success = false;
 
-    for(size_t lix = 0; lix < loop; lix++) {
+    for (size_t lix = 0; lix < loop; lix++) {
 
       PlatformThreadFactory threadFactory = PlatformThreadFactory();
       threadFactory.setDetached(true);
 
-        for(size_t tix = 0; tix < count; tix++) {
+      for (size_t tix = 0; tix < count; tix++) {
 
-          try {
+        try {
 
-            shared_ptr<FloodTask> task(new FloodTask(lix * count + tix ));
+          shared_ptr<FloodTask> task(new FloodTask(lix * count + tix));
 
-            shared_ptr<Thread> thread = threadFactory.newThread(task);
+          shared_ptr<Thread> thread = threadFactory.newThread(task);
 
-            thread->start();
+          thread->start();
 
-            THRIFT_SLEEP_USEC(1);
+          THRIFT_SLEEP_USEC(1);
 
-          } catch (TException& e) {
+        } catch (TException& e) {
 
-            std::cout << "\t\t\tfailed to start  " << lix * count + tix << " thread " << e.what() << std::endl;
+          std::cout << "\t\t\tfailed to start  " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
 
-            return success;
-          }
+          return success;
         }
+      }
 
-        std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
+      std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
 
-        success = true;
+      success = true;
     }
 
     return success;
@@ -349,5 +342,7 @@ public:
 };
 
 const double ThreadFactoryTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency::test
+}
+}
+}
+} // apache::thrift::concurrency::test

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/ThreadManagerTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
old mode 100755
new mode 100644
index c08448b..27bf6c5
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -29,7 +29,10 @@
 #include <set>
 #include <stdint.h>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using namespace apache::thrift::concurrency;
 
@@ -38,15 +41,11 @@ class ThreadManagerTests {
   static const double TEST_TOLERANCE;
 
 public:
-  class Task: public Runnable {
+  class Task : public Runnable {
 
   public:
-
-    Task(Monitor& monitor, size_t& count, int64_t timeout) :
-      _monitor(monitor),
-      _count(count),
-      _timeout(timeout),
-      _done(false) {}
+    Task(Monitor& monitor, size_t& count, int64_t timeout)
+      : _monitor(monitor), _count(count), _timeout(timeout), _done(false) {}
 
     void run() {
 
@@ -57,9 +56,9 @@ public:
 
         try {
           _sleep.wait(_timeout);
-        } catch(TimedOutException& e) {
+        } catch (TimedOutException& e) {
           ;
-        }catch(...) {
+        } catch (...) {
           assert(0);
         }
       }
@@ -96,7 +95,7 @@ public:
    * completes. Verify that all tasks completed and that thread manager cleans
    * up properly on delete.
    */
-  bool loadTest(size_t count=100, int64_t timeout=100LL, size_t workerCount=4) {
+  bool loadTest(size_t count = 100, int64_t timeout = 100LL, size_t workerCount = 4) {
 
     Monitor monitor;
 
@@ -104,7 +103,8 @@ public:
 
     shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
 
-    shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    shared_ptr<PlatformThreadFactory> threadFactory
+        = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
 #ifndef USE_BOOST_THREAD
     threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -117,20 +117,23 @@ public:
 
     for (size_t ix = 0; ix < count; ix++) {
 
-      tasks.insert(shared_ptr<ThreadManagerTests::Task>(new ThreadManagerTests::Task(monitor, activeCount, timeout)));
+      tasks.insert(shared_ptr<ThreadManagerTests::Task>(
+          new ThreadManagerTests::Task(monitor, activeCount, timeout)));
     }
 
     int64_t time00 = Util::currentTime();
 
-    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+         ix != tasks.end();
+         ix++) {
 
-        threadManager->add(*ix);
+      threadManager->add(*ix);
     }
 
     {
       Synchronized s(monitor);
 
-      while(activeCount > 0) {
+      while (activeCount > 0) {
 
         monitor.wait();
       }
@@ -145,7 +148,9 @@ public:
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+         ix != tasks.end();
+         ix++) {
 
       shared_ptr<ThreadManagerTests::Task> task = *ix;
 
@@ -169,43 +174,43 @@ public:
         maxTime = delta;
       }
 
-      averageTime+= delta;
+      averageTime += delta;
     }
 
     averageTime /= count;
 
-    std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime << "ms" << std::endl;
+    std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime
+              << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime
+              << "ms" << std::endl;
 
     double expectedTime = ((count + (workerCount - 1)) / workerCount) * timeout;
 
     double error = ((time01 - time00) - expectedTime) / expectedTime;
 
     if (error < 0) {
-      error*= -1.0;
+      error *= -1.0;
     }
 
     bool success = error < TEST_TOLERANCE;
 
-    std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << expectedTime << "ms elapsed time: "<< time01 - time00 << "ms error%: " << error * 100.0 << std::endl;
+    std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+              << "! expected time: " << expectedTime << "ms elapsed time: " << time01 - time00
+              << "ms error%: " << error * 100.0 << std::endl;
 
     return success;
   }
 
-  class BlockTask: public Runnable {
+  class BlockTask : public Runnable {
 
   public:
-
-    BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count) :
-      _monitor(monitor),
-      _bmonitor(bmonitor),
-      _count(count) {}
+    BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count)
+      : _monitor(monitor), _bmonitor(bmonitor), _count(count) {}
 
     void run() {
       {
         Synchronized s(_bmonitor);
 
         _bmonitor.wait();
-
       }
 
       {
@@ -229,8 +234,8 @@ public:
    * Block test.  Create pendingTaskCountMax tasks.  Verify that we block adding the
    * pendingTaskCountMax + 1th task.  Verify that we unblock when a task completes */
 
-  bool blockTest(int64_t timeout=100LL, size_t workerCount=2) {
-    (void) timeout;
+  bool blockTest(int64_t timeout = 100LL, size_t workerCount = 2) {
+    (void)timeout;
     bool success = false;
 
     try {
@@ -242,9 +247,11 @@ public:
 
       size_t activeCounts[] = {workerCount, pendingTaskMaxCount, 1};
 
-      shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
+      shared_ptr<ThreadManager> threadManager
+          = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
 
-      shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+      shared_ptr<PlatformThreadFactory> threadFactory
+          = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
 #ifndef USE_BOOST_THREAD
       threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -257,43 +264,49 @@ public:
 
       for (size_t ix = 0; ix < workerCount; ix++) {
 
-        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[0])));
+        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+            new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[0])));
       }
 
       for (size_t ix = 0; ix < pendingTaskMaxCount; ix++) {
 
-        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[1])));
+        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+            new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[1])));
       }
 
-      for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+      for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin();
+           ix != tasks.end();
+           ix++) {
         threadManager->add(*ix);
       }
 
-      if(!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
+      if (!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
         throw TException("Unexpected pending task count");
       }
 
-      shared_ptr<ThreadManagerTests::BlockTask> extraTask(new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
+      shared_ptr<ThreadManagerTests::BlockTask> extraTask(
+          new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
 
       try {
         threadManager->add(extraTask, 1);
         throw TException("Unexpected success adding task in excess of pending task count");
-      } catch(TooManyPendingTasksException& e) {
+      } catch (TooManyPendingTasksException& e) {
         throw TException("Should have timed out adding task in excess of pending task count");
-      } catch(TimedOutException& e) {
+      } catch (TimedOutException& e) {
         // Expected result
       }
 
       try {
         threadManager->add(extraTask, -1);
         throw TException("Unexpected success adding task in excess of pending task count");
-      } catch(TimedOutException& e) {
+      } catch (TimedOutException& e) {
         throw TException("Unexpected timeout adding task in excess of pending task count");
-      } catch(TooManyPendingTasksException& e) {
+      } catch (TooManyPendingTasksException& e) {
         // Expected result
       }
 
-      std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount()  << std::endl;
+      std::cout << "\t\t\t"
+                << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
 
       {
         Synchronized s(bmonitor);
@@ -304,21 +317,24 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[0] != 0) {
+        while (activeCounts[0] != 0) {
           monitor.wait();
         }
       }
 
-      std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+      std::cout << "\t\t\t"
+                << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
 
       try {
         threadManager->add(extraTask, 1);
-      } catch(TimedOutException& e) {
-        std::cout << "\t\t\t" << "add timed out unexpectedly"  << std::endl;
+      } catch (TimedOutException& e) {
+        std::cout << "\t\t\t"
+                  << "add timed out unexpectedly" << std::endl;
         throw TException("Unexpected timeout adding task");
 
-      } catch(TooManyPendingTasksException& e) {
-        std::cout << "\t\t\t" << "add encountered too many pending exepctions" << std::endl;
+      } catch (TooManyPendingTasksException& e) {
+        std::cout << "\t\t\t"
+                  << "add encountered too many pending exepctions" << std::endl;
         throw TException("Unexpected timeout adding task");
       }
 
@@ -333,7 +349,7 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[1] != 0) {
+        while (activeCounts[1] != 0) {
           monitor.wait();
         }
       }
@@ -349,26 +365,28 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[2] != 0) {
+        while (activeCounts[2] != 0) {
           monitor.wait();
         }
       }
 
-      if(!(success = (threadManager->totalTaskCount() == 0))) {
+      if (!(success = (threadManager->totalTaskCount() == 0))) {
         throw TException("Unexpected pending task count");
       }
 
-    } catch(TException& e) {
+    } catch (TException& e) {
       std::cout << "ERROR: " << e.what() << std::endl;
     }
 
     std::cout << "\t\t\t" << (success ? "Success" : "Failure") << std::endl;
     return success;
- }
+  }
 };
 
 const double ThreadManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency
 
 using namespace apache::thrift::concurrency::test;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/TimerManagerTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index 62eb4f4..dda16ed 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -25,7 +25,10 @@
 #include <assert.h>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using namespace apache::thrift::concurrency;
 
@@ -33,16 +36,15 @@ class TimerManagerTests {
 
   static const double TEST_TOLERANCE;
 
- public:
-  class Task: public Runnable {
-   public:
-
-    Task(Monitor& monitor, int64_t timeout) :
-      _timeout(timeout),
-      _startTime(Util::currentTime()),
-      _monitor(monitor),
-      _success(false),
-      _done(false) {}
+public:
+  class Task : public Runnable {
+  public:
+    Task(Monitor& monitor, int64_t timeout)
+      : _timeout(timeout),
+        _startTime(Util::currentTime()),
+        _monitor(monitor),
+        _success(false),
+        _done(false) {}
 
     ~Task() { std::cerr << this << std::endl; }
 
@@ -54,20 +56,20 @@ class TimerManagerTests {
 
       int64_t delta = _endTime - _startTime;
 
-
-      delta = delta > _timeout ?  delta - _timeout : _timeout - delta;
+      delta = delta > _timeout ? delta - _timeout : _timeout - delta;
 
       float error = delta / _timeout;
 
-      if(error < TEST_TOLERANCE) {
+      if (error < TEST_TOLERANCE) {
         _success = true;
       }
 
       _done = true;
 
-      std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; //debug
+      std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; // debug
 
-      {Synchronized s(_monitor);
+      {
+        Synchronized s(_monitor);
         _monitor.notifyAll();
       }
     }
@@ -86,9 +88,10 @@ class TimerManagerTests {
    * properly clean up itself and the remaining orphaned timeout task when the
    * manager goes out of scope and its destructor is called.
    */
-  bool test00(int64_t timeout=1000LL) {
+  bool test00(int64_t timeout = 1000LL) {
 
-    shared_ptr<TimerManagerTests::Task> orphanTask = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
+    shared_ptr<TimerManagerTests::Task> orphanTask
+        = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
 
     {
 
@@ -113,12 +116,13 @@ class TimerManagerTests {
           // Wait for 1 second in order to give timerManager a chance to start sleeping in response
           // to adding orphanTask. We need to do this so we can verify that adding the second task
           // kicks the dispatcher out of the current wait and starts the new 1 second wait.
-          _monitor.wait (1000);
-          assert (0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
-        } catch (TimedOutException &ex) {
+          _monitor.wait(1000);
+          assert(
+              0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
+        } catch (TimedOutException& ex) {
         }
 
-        task.reset (new TimerManagerTests::Task(_monitor, timeout));
+        task.reset(new TimerManagerTests::Task(_monitor, timeout));
 
         timerManager.add(task, timeout);
 
@@ -127,7 +131,6 @@ class TimerManagerTests {
 
       assert(task->_done);
 
-
       std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << std::endl;
     }
 
@@ -144,5 +147,7 @@ class TimerManagerTests {
 };
 
 const double TimerManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/EventLog.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/EventLog.cpp b/lib/cpp/test/processor/EventLog.cpp
index 0ac3028..d4b8372 100644
--- a/lib/cpp/test/processor/EventLog.cpp
+++ b/lib/cpp/test/processor/EventLog.cpp
@@ -36,10 +36,11 @@ void debug(const char* fmt, ...) {
 
   fprintf(stderr, "\n");
 }
-
 }
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 uint32_t EventLog::nextId_ = 0;
 
@@ -74,11 +75,12 @@ EventLog::EventLog() {
   debug("New log: %d", id_);
 }
 
-void EventLog::append(EventType type, uint32_t connectionId, uint32_t callId,
+void EventLog::append(EventType type,
+                      uint32_t connectionId,
+                      uint32_t callId,
                       const string& message) {
   Synchronized s(monitor_);
-  debug("%d <-- %u, %u, %s \"%s\"", id_, connectionId, callId, type,
-        message.c_str());
+  debug("%d <-- %u, %u, %s \"%s\"", id_, connectionId, callId, type, message.c_str());
 
   Event e(type, connectionId, callId, message);
   events_.push_back(e);
@@ -125,5 +127,6 @@ Event EventLog::waitForConnEvent(uint32_t connId, int64_t timeout) {
     }
   }
 }
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/EventLog.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/EventLog.h b/lib/cpp/test/processor/EventLog.h
index d731cec..4f8275d 100644
--- a/lib/cpp/test/processor/EventLog.h
+++ b/lib/cpp/test/processor/EventLog.h
@@ -21,7 +21,9 @@
 
 #include <thrift/concurrency/Monitor.h>
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 // Initially I made EventType an enum, but using char* results
 // in much more readable error messages when there is a mismatch.
@@ -31,21 +33,17 @@ namespace apache { namespace thrift { namespace test {
 typedef const char* EventType;
 
 struct Event {
-  Event(EventType type, uint32_t connectionId, uint32_t callId,
-        const std::string& message) :
-      type(type),
-      connectionId(connectionId),
-      callId(callId),
-      message(message) {}
+  Event(EventType type, uint32_t connectionId, uint32_t callId, const std::string& message)
+    : type(type), connectionId(connectionId), callId(callId), message(message) {}
 
   EventType type;
-  uint32_t  connectionId;
-  uint32_t  callId;
-  std::string    message;
+  uint32_t connectionId;
+  uint32_t callId;
+  std::string message;
 };
 
 class EventLog {
- public:
+public:
   static EventType ET_LOG_END;
   static EventType ET_CONN_CREATED;
   static EventType ET_CONN_DESTROYED;
@@ -73,13 +71,15 @@ class EventLog {
 
   EventLog();
 
-  void append(EventType type, uint32_t connectionId, uint32_t callId,
+  void append(EventType type,
+              uint32_t connectionId,
+              uint32_t callId,
               const std::string& message = "");
 
   Event waitForEvent(int64_t timeout = 500);
   Event waitForConnEvent(uint32_t connId, int64_t timeout = 500);
 
- protected:
+protected:
   typedef std::list<Event> EventList;
 
   concurrency::Monitor monitor_;
@@ -88,7 +88,8 @@ class EventLog {
 
   static uint32_t nextId_;
 };
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_TEST_EVENTLOG_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/Handlers.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/Handlers.h b/lib/cpp/test/processor/Handlers.h
index 75f4349..d894107 100644
--- a/lib/cpp/test/processor/Handlers.h
+++ b/lib/cpp/test/processor/Handlers.h
@@ -23,15 +23,14 @@
 #include "gen-cpp/ParentService.h"
 #include "gen-cpp/ChildService.h"
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 class ParentHandler : virtual public ParentServiceIf {
- public:
-  ParentHandler(const boost::shared_ptr<EventLog>& log) :
-      triggerMonitor(&mutex_),
-      generation_(0),
-      wait_(false),
-      log_(log) { }
+public:
+  ParentHandler(const boost::shared_ptr<EventLog>& log)
+    : triggerMonitor(&mutex_), generation_(0), wait_(false), log_(log) {}
 
   int32_t incrementGeneration() {
     concurrency::Guard g(mutex_);
@@ -116,7 +115,7 @@ class ParentHandler : virtual public ParentServiceIf {
     triggerMonitor.notifyAll();
   }
 
- protected:
+protected:
   /**
    * blockUntilTriggered() won't return until triggerPendingCalls() is invoked
    * in another thread.
@@ -141,10 +140,8 @@ class ParentHandler : virtual public ParentServiceIf {
 };
 
 class ChildHandler : public ParentHandler, virtual public ChildServiceIf {
- public:
-  ChildHandler(const boost::shared_ptr<EventLog>& log) :
-      ParentHandler(log),
-      value_(0) {}
+public:
+  ChildHandler(const boost::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {}
 
   int32_t setValue(int32_t value) {
     concurrency::Guard g(mutex_);
@@ -162,18 +159,16 @@ class ChildHandler : public ParentHandler, virtual public ChildServiceIf {
     return value_;
   }
 
- protected:
+protected:
   int32_t value_;
 };
 
 struct ConnContext {
- public:
+public:
   ConnContext(boost::shared_ptr<protocol::TProtocol> in,
               boost::shared_ptr<protocol::TProtocol> out,
-              uint32_t id) :
-      input(in),
-      output(out),
-      id(id) {}
+              uint32_t id)
+    : input(in), output(out), id(id) {}
 
   boost::shared_ptr<protocol::TProtocol> input;
   boost::shared_ptr<protocol::TProtocol> output;
@@ -181,22 +176,18 @@ struct ConnContext {
 };
 
 struct CallContext {
- public:
-  CallContext(ConnContext *context, uint32_t id, const std::string& name) :
-      connContext(context),
-      name(name),
-      id(id) {}
+public:
+  CallContext(ConnContext* context, uint32_t id, const std::string& name)
+    : connContext(context), name(name), id(id) {}
 
-  ConnContext *connContext;
+  ConnContext* connContext;
   std::string name;
   uint32_t id;
 };
 
 class ServerEventHandler : public server::TServerEventHandler {
- public:
-  ServerEventHandler(const boost::shared_ptr<EventLog>& log) :
-      nextId_(1),
-      log_(log) {}
+public:
+  ServerEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
 
   virtual void preServe() {}
 
@@ -209,8 +200,8 @@ class ServerEventHandler : public server::TServerEventHandler {
   }
 
   virtual void deleteContext(void* serverContext,
-                             boost::shared_ptr<protocol::TProtocol>input,
-                             boost::shared_ptr<protocol::TProtocol>output) {
+                             boost::shared_ptr<protocol::TProtocol> input,
+                             boost::shared_ptr<protocol::TProtocol> output) {
     ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
 
     if (input != context->input) {
@@ -225,22 +216,21 @@ class ServerEventHandler : public server::TServerEventHandler {
     delete context;
   }
 
-  virtual void processContext(
-      void* serverContext,
-      boost::shared_ptr<transport::TTransport> transport) {
-    // TODO: We currently don't test the behavior of the processContext()
-    // calls.  The various server implementations call processContext() at
-    // slightly different times, and it is too annoying to try and account for
-    // their various differences.
-    //
-    // TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
-    // they see the first byte of a request before calling processContext().
-    // However, they don't wait for the first byte of the very first request,
-    // and instead immediately call processContext() before any data is
-    // received.
-    //
-    // TNonblockingServer always waits until receiving the full request before
-    // calling processContext().
+  virtual void processContext(void* serverContext,
+                              boost::shared_ptr<transport::TTransport> transport) {
+// TODO: We currently don't test the behavior of the processContext()
+// calls.  The various server implementations call processContext() at
+// slightly different times, and it is too annoying to try and account for
+// their various differences.
+//
+// TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
+// they see the first byte of a request before calling processContext().
+// However, they don't wait for the first byte of the very first request,
+// and instead immediately call processContext() before any data is
+// received.
+//
+// TNonblockingServer always waits until receiving the full request before
+// calling processContext().
 #if 0
     ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
     log_->append(EventLog::ET_PROCESS, context->id, 0);
@@ -250,16 +240,14 @@ class ServerEventHandler : public server::TServerEventHandler {
 #endif
   }
 
- protected:
+protected:
   uint32_t nextId_;
   boost::shared_ptr<EventLog> log_;
 };
 
 class ProcessorEventHandler : public TProcessorEventHandler {
- public:
-  ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) :
-      nextId_(1),
-      log_(log) {}
+public:
+  ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
 
   void* getContext(const char* fnName, void* serverContext) {
     ConnContext* connContext = reinterpret_cast<ConnContext*>(serverContext);
@@ -267,71 +255,65 @@ class ProcessorEventHandler : public TProcessorEventHandler {
     CallContext* context = new CallContext(connContext, nextId_, fnName);
     ++nextId_;
 
-    log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id, fnName);
     return context;
   }
 
   void freeContext(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id, context->id, fnName);
     delete context;
   }
 
   void preRead(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id, fnName);
   }
 
   void postRead(void* ctx, const char* fnName, uint32_t bytes) {
     THRIFT_UNUSED_VARIABLE(bytes);
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id, fnName);
   }
 
   void preWrite(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id, fnName);
   }
 
   void postWrite(void* ctx, const char* fnName, uint32_t bytes) {
     THRIFT_UNUSED_VARIABLE(bytes);
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_POST_WRITE, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_POST_WRITE, context->connContext->id, context->id, fnName);
   }
 
   void asyncComplete(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id, context->id, fnName);
   }
 
   void handlerError(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id, context->id, fnName);
   }
 
- protected:
+protected:
   void checkName(const CallContext* context, const char* fnName) {
     // Note: we can't use BOOST_CHECK_EQUAL here, since the handler runs in a
     // different thread from the test functions.  Just abort if the names are
     // different
     if (context->name != fnName) {
-      fprintf(stderr, "call context name mismatch: \"%s\" != \"%s\"\n",
-              context->name.c_str(), fnName);
+      fprintf(stderr,
+              "call context name mismatch: \"%s\" != \"%s\"\n",
+              context->name.c_str(),
+              fnName);
       fflush(stderr);
       abort();
     }
@@ -340,7 +322,8 @@ class ProcessorEventHandler : public TProcessorEventHandler {
   uint32_t nextId_;
   boost::shared_ptr<EventLog> log_;
 };
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_PROCESSOR_TEST_HANDLERS_H_


[17/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_php_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index ae57ec3..827af9f 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -35,27 +35,24 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
-#define NSGLOBAL  (nsglobal_.size() ? nsglobal_ : "")
-#define NSGLOBAL_A ("\\" + NSGLOBAL )
-#define NSGLOBAL_B ( NSGLOBAL + "\\")
+#define NSGLOBAL (nsglobal_.size() ? nsglobal_ : "")
+#define NSGLOBAL_A ("\\" + NSGLOBAL)
+#define NSGLOBAL_B (NSGLOBAL + "\\")
 #define NSGLOBAL_AB ("\\" + NSGLOBAL + "\\")
 
-
 /**
  * PHP code generator.
  *
  */
 class t_php_generator : public t_oop_generator {
- public:
-  t_php_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_php_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("inlined");
@@ -77,10 +74,9 @@ class t_php_generator : public t_oop_generator {
     json_serializable_ = (iter != parsed_options.end());
 
     iter = parsed_options.find("nsglobal");
-    if(iter != parsed_options.end()) {
+    if (iter != parsed_options.end()) {
       nsglobal_ = iter->second;
-    }
-    else {
+    } else {
       nsglobal_ = ""; // by default global namespace is empty
     }
 
@@ -105,13 +101,13 @@ class t_php_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_consts   (vector<t_const*> consts);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_consts(vector<t_const*> consts);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
@@ -120,11 +116,17 @@ class t_php_generator : public t_oop_generator {
    */
 
   void generate_php_struct(t_struct* tstruct, bool is_exception);
-  void generate_php_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool is_result=false);
+  void generate_php_struct_definition(std::ofstream& out,
+                                      t_struct* tstruct,
+                                      bool is_xception = false,
+                                      bool is_result = false);
   void generate_php_struct_reader(std::ofstream& out, t_struct* tstruct, bool is_result);
   void generate_php_struct_writer(std::ofstream& out, t_struct* tstruct, bool is_result);
   void generate_php_function_helpers(t_function* tfunction);
-  void generate_php_struct_required_validator(ofstream& out, t_struct* tstruct, std::string method_name, bool write_mode);
+  void generate_php_struct_required_validator(ofstream& out,
+                                              t_struct* tstruct,
+                                              std::string method_name,
+                                              bool write_mode);
   void generate_php_struct_read_validator(ofstream& out, t_struct* tstruct);
   void generate_php_struct_write_validator(ofstream& out, t_struct* tstruct);
   void generate_php_struct_json_serialize(ofstream& out, t_struct* tstruct, bool is_result);
@@ -132,93 +134,71 @@ class t_php_generator : public t_oop_generator {
   bool needs_php_read_validator(t_struct* tstruct, bool is_result);
   int get_php_num_required_fields(const vector<t_field*>& fields, bool write_mode);
 
-  void generate_php_type_spec(std::ofstream &out, t_type* t);
-  void generate_php_struct_spec(std::ofstream &out, t_struct* tstruct);
+  void generate_php_type_spec(std::ofstream& out, t_type* t);
+  void generate_php_struct_spec(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_rest      (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_processor (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_rest(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_processor(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool inclass=false);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool inclass = false);
 
-  void generate_deserialize_struct       (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream &out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element    (std::ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_php_doc                  (std::ofstream& out,
-                                          t_doc*      tdoc);
+  void generate_php_doc(std::ofstream& out, t_doc* tdoc);
 
-  void generate_php_doc                  (std::ofstream& out,
-                                          t_field*    tfield);
+  void generate_php_doc(std::ofstream& out, t_field* tfield);
 
-  void generate_php_doc                  (std::ofstream& out,
-                                          t_function* tfunction);
+  void generate_php_doc(std::ofstream& out, t_function* tfunction);
 
-  void generate_php_docstring_comment    (std::ofstream &out,
-                                          string contents);
+  void generate_php_docstring_comment(std::ofstream& out, string contents);
 
   /**
    * Helper rendering functions
    */
 
   std::string php_includes();
-  std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string declare_field(t_field* tfield, bool init = false, bool obj = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
   std::string argument_list(t_struct* tstruct, bool addTypeHints = true);
   std::string type_to_cast(t_type* ttype);
   std::string type_to_enum(t_type* ttype);
@@ -226,7 +206,7 @@ class t_php_generator : public t_oop_generator {
 
   std::string php_namespace_base(const t_program* p) {
     std::string ns = p->get_namespace("php");
-    const char * delimiter = "\\";
+    const char* delimiter = "\\";
     size_t position = ns.find('.');
     while (position != string::npos) {
       ns.replace(position, 1, delimiter);
@@ -235,39 +215,37 @@ class t_php_generator : public t_oop_generator {
     return ns;
   }
 
-  //general use namespace prefixing: \my\namespace\ or my_namespace_
+  // general use namespace prefixing: \my\namespace\ or my_namespace_
   string php_namespace(const t_program* p) {
     string ns = php_namespace_base(p);
     return (nsglobal_.size() ? NSGLOBAL_AB : NSGLOBAL_B) + (ns.size() ? (ns + "\\") : "");
   }
 
-  //setting the namespace of a file: my\namespace
+  // setting the namespace of a file: my\namespace
   string php_namespace_suffix(const t_program* p) {
     string ns = php_namespace_base(p);
 
     return (nsglobal_.size() ? NSGLOBAL_B : NSGLOBAL) + ns;
   }
 
-  //add a directory to allready existing namespace
+  // add a directory to allready existing namespace
   string php_namespace_directory(string directory, bool end = true) {
-    (void) directory;
-    if(end) {
+    (void)directory;
+    if (end) {
       return ";";
     } else {
       return "";
     }
   }
 
-  //writing an autload identifier into globa;ls: my\namespace\ or my_namespace_
+  // writing an autload identifier into globa;ls: my\namespace\ or my_namespace_
   string php_namespace_autoload(const t_program* p) {
     std::string ns = php_namespace_base(p);
     return (nsglobal_.size() ? NSGLOBAL_B : NSGLOBAL) + (ns.size() ? (ns + "\\") : "");
   }
 
-  //declaring a type: typename or my_namespace_typename
-  string php_namespace_declaration(t_type* t) {
-    return t->get_name();
-  }
+  // declaring a type: typename or my_namespace_typename
+  string php_namespace_declaration(t_type* t) { return t->get_name(); }
 
   std::string php_path(t_program* p) {
     std::string ns = p->get_namespace("php.path");
@@ -291,8 +269,7 @@ class t_php_generator : public t_oop_generator {
    * @param str
    * @return stirng
    */
-  string classify(string str)
-  {
+  string classify(string str) {
     string classe = "";
 
     vector<string> x = split(str, '_');
@@ -311,18 +288,18 @@ class t_php_generator : public t_oop_generator {
    * @param elems
    * @return
    */
-  vector<string> &split(const string &s, char delim, vector<string> &elems) {
+  vector<string>& split(const string& s, char delim, vector<string>& elems) {
     stringstream ss(s);
     string item;
 
-    while(getline(ss, item, delim)) {
+    while (getline(ss, item, delim)) {
       elems.push_back(item);
     }
 
     return elems;
   }
 
-  vector<string> split(const string &s, char delim) {
+  vector<string> split(const string& s, char delim) {
     vector<string> elems;
 
     return split(s, delim, elems);
@@ -333,22 +310,20 @@ class t_php_generator : public t_oop_generator {
    * @param str
    * @return
    */
-  string capitalize(string str)
-  {
+  string capitalize(string str) {
     string::iterator it(str.begin());
 
     if (it != str.end())
-        str[0] = toupper((unsigned char)str[0]);
+      str[0] = toupper((unsigned char)str[0]);
 
-//    while(++it != str.end())
-//    {
-//      *it = tolower((unsigned char)*it);
-//    }
+    //    while(++it != str.end())
+    //    {
+    //      *it = tolower((unsigned char)*it);
+    //    }
     return str;
   }
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -393,12 +368,10 @@ class t_php_generator : public t_oop_generator {
   std::string nsglobal_;
 };
 
-
 bool t_php_generator::is_valid_namespace(const std::string& sub_namespace) {
   return sub_namespace == "path";
 }
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -419,13 +392,12 @@ void t_php_generator::init_generator() {
   }
 
   // Make output file
-  string f_types_name = package_dir_+"Types.php";
+  string f_types_name = package_dir_ + "Types.php";
   f_types_.open(f_types_name.c_str());
 
   // Print header
-  f_types_ <<
-    "<?php" << endl;
-    f_types_ << "namespace " << php_namespace_suffix(get_program()) << ";" << endl << endl;
+  f_types_ << "<?php" << endl;
+  f_types_ << "namespace " << php_namespace_suffix(get_program()) << ";" << endl << endl;
   f_types_ << autogen_comment() << php_includes();
 
   f_types_ << endl;
@@ -435,20 +407,18 @@ void t_php_generator::init_generator() {
  * Prints standard php includes
  */
 string t_php_generator::php_includes() {
-  string includes =
-    "use Thrift\\Base\\TBase;\n"
-    "use Thrift\\Type\\TType;\n"
-    "use Thrift\\Type\\TMessageType;\n"
-    "use Thrift\\Exception\\TException;\n"
-    "use Thrift\\Exception\\TProtocolException;\n"
-    "use Thrift\\Protocol\\TProtocol;\n"
-    "use Thrift\\Protocol\\TBinaryProtocolAccelerated;\n"
-    "use Thrift\\Exception\\TApplicationException;\n";
+  string includes = "use Thrift\\Base\\TBase;\n"
+                    "use Thrift\\Type\\TType;\n"
+                    "use Thrift\\Type\\TMessageType;\n"
+                    "use Thrift\\Exception\\TException;\n"
+                    "use Thrift\\Exception\\TProtocolException;\n"
+                    "use Thrift\\Protocol\\TProtocol;\n"
+                    "use Thrift\\Protocol\\TBinaryProtocolAccelerated;\n"
+                    "use Thrift\\Exception\\TApplicationException;\n";
 
   if (json_serializable_) {
-    includes +=
-      "use JsonSerializable;\n"
-      "use stdClass;\n";
+    includes += "use JsonSerializable;\n"
+                "use stdClass;\n";
   }
 
   return includes + "\n";
@@ -459,7 +429,7 @@ string t_php_generator::php_includes() {
  */
 void t_php_generator::close_generator() {
   // Close types file
-    f_types_ << endl;
+  f_types_ << endl;
   f_types_.close();
 }
 
@@ -469,7 +439,7 @@ void t_php_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_php_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -486,26 +456,21 @@ void t_php_generator::generate_enum(t_enum* tenum) {
   // code but you can't do things like an 'extract' on it, which is a bit of
   // a downer.
   generate_php_doc(f_types_, tenum);
-  f_types_ <<
-    "final class " << tenum->get_name() << " {" << endl;
+  f_types_ << "final class " << tenum->get_name() << " {" << endl;
   indent_up();
 
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     generate_php_doc(f_types_, *c_iter);
-    indent(f_types_) <<
-      "const " << (*c_iter)->get_name() << " = " << value << ";" << endl;
+    indent(f_types_) << "const " << (*c_iter)->get_name() << " = " << value << ";" << endl;
   }
 
-  indent(f_types_) <<
-    "static public $__names = array(" << endl;
+  indent(f_types_) << "static public $__names = array(" << endl;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
-    indent(f_types_) <<
-      "  " << value << " => '" << (*c_iter)->get_name() << "'," << endl;
+    indent(f_types_) << "  " << value << " => '" << (*c_iter)->get_name() << "'," << endl;
   }
-  indent(f_types_) <<
-    ");" << endl;
+  indent(f_types_) << ");" << endl;
 
   indent_down();
   f_types_ << "}" << endl << endl;
@@ -517,41 +482,40 @@ void t_php_generator::generate_enum(t_enum* tenum) {
  * Override the one from t_generator
  */
 void t_php_generator::generate_consts(vector<t_const*> consts) {
-    vector<t_const*>::iterator c_iter;
+  vector<t_const*>::iterator c_iter;
 
-    // Create class only if needed
-    if(consts.size() > 0)
-    {
-        f_types_ << "final class Constant extends \\Thrift\\Type\\TConstant {" << endl;
-        indent_up();
-
-        // Create static property
-        for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-            string name = (*c_iter)->get_name();
+  // Create class only if needed
+  if (consts.size() > 0) {
+    f_types_ << "final class Constant extends \\Thrift\\Type\\TConstant {" << endl;
+    indent_up();
 
-            indent(f_types_) << "static protected $" << name << ";" << endl;
-        }
+    // Create static property
+    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
+      string name = (*c_iter)->get_name();
 
-        // Create init function
-        for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-            string name = (*c_iter)->get_name();
+      indent(f_types_) << "static protected $" << name << ";" << endl;
+    }
 
-            f_types_ << endl;
+    // Create init function
+    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
+      string name = (*c_iter)->get_name();
 
-            indent(f_types_) << "static protected function init_" << name << "() {" << endl;
-            indent_up();
+      f_types_ << endl;
 
-            indent(f_types_) << "return ";
-            generate_const(*c_iter);
-            f_types_ << ";" << endl;
+      indent(f_types_) << "static protected function init_" << name << "() {" << endl;
+      indent_up();
 
-            indent_down();
-            indent(f_types_) << "}" << endl;
-        }
+      indent(f_types_) << "return ";
+      generate_const(*c_iter);
+      f_types_ << ";" << endl;
 
-        indent_down();
-        f_types_ << "}" << endl << endl;
+      indent_down();
+      indent(f_types_) << "}" << endl;
     }
+
+    indent_down();
+    f_types_ << "}" << endl << endl;
+  }
 }
 
 /**
@@ -686,20 +650,19 @@ void t_php_generator::generate_xception(t_struct* txception) {
 /**
  * Structs can be normal or exceptions.
  */
-void t_php_generator::generate_php_struct(t_struct* tstruct,
-                                          bool is_exception) {
+void t_php_generator::generate_php_struct(t_struct* tstruct, bool is_exception) {
   generate_php_struct_definition(f_types_, tstruct, is_exception);
 }
 
-void t_php_generator::generate_php_type_spec(ofstream& out,
-                                             t_type* t) {
+void t_php_generator::generate_php_type_spec(ofstream& out, t_type* t) {
   t = get_true_type(t);
   indent(out) << "'type' => " << type_to_enum(t) << "," << endl;
 
   if (t->is_base_type() || t->is_enum()) {
     // Noop, type is all we need
   } else if (t->is_struct() || t->is_xception()) {
-    indent(out) << "'class' => '" << php_namespace(t->get_program()) << t->get_name() <<"'," << endl;
+    indent(out) << "'class' => '" << php_namespace(t->get_program()) << t->get_name() << "',"
+                << endl;
   } else if (t->is_map()) {
     t_type* ktype = get_true_type(((t_map*)t)->get_key_type());
     t_type* vtype = get_true_type(((t_map*)t)->get_val_type());
@@ -722,7 +685,7 @@ void t_php_generator::generate_php_type_spec(ofstream& out,
     } else {
       etype = get_true_type(((t_set*)t)->get_elem_type());
     }
-    indent(out) << "'etype' => " << type_to_enum(etype) <<"," << endl;
+    indent(out) << "'etype' => " << type_to_enum(etype) << "," << endl;
     indent(out) << "'elem' => array(" << endl;
     indent_up();
     generate_php_type_spec(out, etype);
@@ -731,15 +694,13 @@ void t_php_generator::generate_php_type_spec(ofstream& out,
   } else {
     throw "compiler error: no type for php struct spec field";
   }
-
 }
 
 /**
  * Generates the struct specification structure, which fully qualifies enough
  * type information to generalize serialization routines.
  */
-void t_php_generator::generate_php_struct_spec(ofstream& out,
-                                               t_struct* tstruct) {
+void t_php_generator::generate_php_struct_spec(ofstream& out, t_struct* tstruct) {
   indent(out) << "if (!isset(self::$_TSPEC)) {" << endl;
   indent_up();
 
@@ -752,8 +713,7 @@ void t_php_generator::generate_php_struct_spec(ofstream& out,
     t_type* t = get_true_type((*m_iter)->get_type());
     indent(out) << (*m_iter)->get_key() << " => array(" << endl;
     indent_up();
-    out <<
-      indent() << "'var' => '" << (*m_iter)->get_name() << "'," << endl;
+    out << indent() << "'var' => '" << (*m_iter)->get_name() << "'," << endl;
     generate_php_type_spec(out, t);
     indent(out) << ")," << endl;
     indent_down();
@@ -780,18 +740,18 @@ void t_php_generator::generate_php_struct_definition(ofstream& out,
   vector<t_field*>::const_iterator m_iter;
 
   generate_php_doc(out, tstruct);
-  out <<
-    "class " << php_namespace_declaration(tstruct);
+  out << "class " << php_namespace_declaration(tstruct);
   if (is_exception) {
-    out << " extends " << "TException";
+    out << " extends "
+        << "TException";
   } else if (oop_) {
-    out << " extends " << "TBase";
+    out << " extends "
+        << "TBase";
   }
   if (json_serializable_) {
     out << " implements JsonSerializable";
   }
-  out <<
-    " {" << endl;
+  out << " {" << endl;
   indent_up();
 
   indent(out) << "static $_TSPEC;" << endl << endl;
@@ -803,16 +763,14 @@ void t_php_generator::generate_php_struct_definition(ofstream& out,
       dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
     }
     generate_php_doc(out, *m_iter);
-    indent(out) <<
-      "public $" << (*m_iter)->get_name() << " = " << dval << ";" << endl;
+    indent(out) << "public $" << (*m_iter)->get_name() << " = " << dval << ";" << endl;
   }
 
   out << endl;
 
   // Generate constructor from array
   string param = (members.size() > 0) ? "$vals=null" : "";
-  out <<
-    indent() << "public function __construct(" << param << ") {" << endl;
+  out << indent() << "public function __construct(" << param << ") {" << endl;
   indent_up();
 
   generate_php_struct_spec(out, tstruct);
@@ -821,34 +779,29 @@ void t_php_generator::generate_php_struct_definition(ofstream& out,
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       t_type* t = get_true_type((*m_iter)->get_type());
       if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
-        indent(out) << "$this->" << (*m_iter)->get_name() << " = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
+        indent(out) << "$this->" << (*m_iter)->get_name() << " = "
+                    << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
       }
     }
-    out <<
-      indent() << "if (is_array($vals)) {" << endl;
+    out << indent() << "if (is_array($vals)) {" << endl;
     indent_up();
     if (oop_) {
       out << indent() << "parent::__construct(self::$_TSPEC, $vals);" << endl;
     } else {
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        out <<
-          indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << endl <<
-          indent() << "  $this->" << (*m_iter)->get_name() << " = $vals['" << (*m_iter)->get_name() << "'];" << endl <<
-          indent() << "}" << endl;
+        out << indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << endl
+            << indent() << "  $this->" << (*m_iter)->get_name() << " = $vals['"
+            << (*m_iter)->get_name() << "'];" << endl << indent() << "}" << endl;
       }
     }
     indent_down();
-    out <<
-      indent() << "}" << endl;
+    out << indent() << "}" << endl;
   }
   scope_down(out);
   out << endl;
 
-  out <<
-    indent() << "public function getName() {" << endl <<
-    indent() << "  return '" << tstruct->get_name() << "';" << endl <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "public function getName() {" << endl << indent() << "  return '"
+      << tstruct->get_name() << "';" << endl << indent() << "}" << endl << endl;
 
   generate_php_struct_reader(out, tstruct, is_result);
   generate_php_struct_writer(out, tstruct, is_result);
@@ -863,161 +816,135 @@ void t_php_generator::generate_php_struct_definition(ofstream& out,
   }
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
  * Generates the read() method for a struct
  */
-void t_php_generator::generate_php_struct_reader(ofstream& out,
-                                                 t_struct* tstruct,
-                                                 bool is_result) {
+void t_php_generator::generate_php_struct_reader(ofstream& out, t_struct* tstruct, bool is_result) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  indent(out) <<
-    "public function read($input)" << endl;
+  indent(out) << "public function read($input)" << endl;
   scope_up(out);
 
   if (oop_) {
     if (needs_php_read_validator(tstruct, is_result)) {
-      indent(out) << "$tmp = $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);" << endl;
+      indent(out) << "$tmp = $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);"
+                  << endl;
       indent(out) << "$this->_validateForRead();" << endl;
       indent(out) << "return $tmp;" << endl;
     } else {
-      indent(out) << "return $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);" << endl;
+      indent(out) << "return $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);"
+                  << endl;
     }
     scope_down(out);
     out << endl;
     return;
   }
 
-  out <<
-    indent() << "$xfer = 0;" << endl <<
-    indent() << "$fname = null;" << endl <<
-    indent() << "$ftype = 0;" << endl <<
-    indent() << "$fid = 0;" << endl;
+  out << indent() << "$xfer = 0;" << endl << indent() << "$fname = null;" << endl << indent()
+      << "$ftype = 0;" << endl << indent() << "$fid = 0;" << endl;
 
   // Declare stack tmp variables
   if (!binary_inline_) {
-    indent(out) <<
-      "$xfer += $input->readStructBegin($fname);" << endl;
+    indent(out) << "$xfer += $input->readStructBegin($fname);" << endl;
   }
 
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
+  indent(out) << "while (true)" << endl;
 
-    scope_up(out);
+  scope_up(out);
 
-    // Read beginning field marker
-    if (binary_inline_) {
-      t_field fftype(g_type_byte, "ftype");
-      t_field ffid(g_type_i16, "fid");
-      generate_deserialize_field(out, &fftype);
-      out <<
-        indent() << "if ($ftype == " << "TType::STOP) {" << endl <<
-        indent() << "  break;" << endl <<
-        indent() << "}" << endl;
-      generate_deserialize_field(out, &ffid);
-    } else {
-      indent(out) <<
-        "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << endl;
-      // Check for field STOP marker and break
-      indent(out) <<
-        "if ($ftype == " << "TType::STOP) {" << endl;
-      indent_up();
-      indent(out) <<
-        "break;" << endl;
-      indent_down();
-      indent(out) <<
-        "}" << endl;
-    }
+  // Read beginning field marker
+  if (binary_inline_) {
+    t_field fftype(g_type_byte, "ftype");
+    t_field ffid(g_type_i16, "fid");
+    generate_deserialize_field(out, &fftype);
+    out << indent() << "if ($ftype == "
+        << "TType::STOP) {" << endl << indent() << "  break;" << endl << indent() << "}" << endl;
+    generate_deserialize_field(out, &ffid);
+  } else {
+    indent(out) << "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << endl;
+    // Check for field STOP marker and break
+    indent(out) << "if ($ftype == "
+                << "TType::STOP) {" << endl;
+    indent_up();
+    indent(out) << "break;" << endl;
+    indent_down();
+    indent(out) << "}" << endl;
+  }
 
-    // Switch statement on the field we are reading
-    indent(out) <<
-      "switch ($fid)" << endl;
+  // Switch statement on the field we are reading
+  indent(out) << "switch ($fid)" << endl;
 
-      scope_up(out);
+  scope_up(out);
 
-      // Generate deserialization code for known cases
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent(out) <<
-          "case " << (*f_iter)->get_key() << ":" << endl;
-        indent_up();
-        indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-        indent_up();
-        generate_deserialize_field(out, *f_iter, "this->");
-        indent_down();
-        out <<
-          indent() << "} else {" << endl;
-        if (binary_inline_) {
-          indent(out) <<  "  $xfer += " << "TProtocol::skipBinary($input, $ftype);" << endl;
-        } else {
-          indent(out) <<  "  $xfer += $input->skip($ftype);" << endl;
-        }
-        out <<
-          indent() << "}" << endl <<
-          indent() << "break;" << endl;
-        indent_down();
-      }
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+    indent_up();
+    indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent_up();
+    generate_deserialize_field(out, *f_iter, "this->");
+    indent_down();
+    out << indent() << "} else {" << endl;
+    if (binary_inline_) {
+      indent(out) << "  $xfer += "
+                  << "TProtocol::skipBinary($input, $ftype);" << endl;
+    } else {
+      indent(out) << "  $xfer += $input->skip($ftype);" << endl;
+    }
+    out << indent() << "}" << endl << indent() << "break;" << endl;
+    indent_down();
+  }
 
-      // In the default case we skip the field
-      indent(out) <<  "default:" << endl;
-      if (binary_inline_) {
-        indent(out) <<  "  $xfer += " << "TProtocol::skipBinary($input, $ftype);" << endl;
-      } else {
-        indent(out) <<  "  $xfer += $input->skip($ftype);" << endl;
-      }
-      indent(out) <<  "  break;" << endl;
+  // In the default case we skip the field
+  indent(out) << "default:" << endl;
+  if (binary_inline_) {
+    indent(out) << "  $xfer += "
+                << "TProtocol::skipBinary($input, $ftype);" << endl;
+  } else {
+    indent(out) << "  $xfer += $input->skip($ftype);" << endl;
+  }
+  indent(out) << "  break;" << endl;
 
-      scope_down(out);
+  scope_down(out);
 
-    if (!binary_inline_) {
-      // Read field end marker
-      indent(out) <<
-        "$xfer += $input->readFieldEnd();" << endl;
-    }
+  if (!binary_inline_) {
+    // Read field end marker
+    indent(out) << "$xfer += $input->readFieldEnd();" << endl;
+  }
 
-    scope_down(out);
+  scope_down(out);
 
   if (!binary_inline_) {
-    indent(out) <<
-      "$xfer += $input->readStructEnd();" << endl;
+    indent(out) << "$xfer += $input->readStructEnd();" << endl;
   }
 
   if (needs_php_read_validator(tstruct, is_result)) {
-    indent(out) <<
-      "$this->_validateForRead();" << endl;
+    indent(out) << "$this->_validateForRead();" << endl;
   }
 
-  indent(out) <<
-    "return $xfer;" << endl;
+  indent(out) << "return $xfer;" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
  * Generates the write() method for a struct
  */
-void t_php_generator::generate_php_struct_writer(ofstream& out,
-                                                 t_struct* tstruct,
-                                                 bool is_result) {
+void t_php_generator::generate_php_struct_writer(ofstream& out, t_struct* tstruct, bool is_result) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
 
   if (binary_inline_) {
-    indent(out) <<
-      "public function write(&$output) {" << endl;
+    indent(out) << "public function write(&$output) {" << endl;
   } else {
-    indent(out) <<
-      "public function write($output) {" << endl;
+    indent(out) << "public function write($output) {" << endl;
   }
   indent_up();
 
@@ -1026,23 +953,21 @@ void t_php_generator::generate_php_struct_writer(ofstream& out,
   }
 
   if (oop_) {
-    indent(out) << "return $this->_write('" << tstruct->get_name() << "', self::$_TSPEC, $output);" << endl;
+    indent(out) << "return $this->_write('" << tstruct->get_name() << "', self::$_TSPEC, $output);"
+                << endl;
     scope_down(out);
     out << endl;
     return;
   }
 
-  indent(out) <<
-    "$xfer = 0;" << endl;
+  indent(out) << "$xfer = 0;" << endl;
 
   if (!binary_inline_) {
-    indent(out) <<
-      "$xfer += $output->writeStructBegin('" << name << "');" << endl;
+    indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << endl;
   }
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    out <<
-      indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << endl;
+    out << indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << endl;
     indent_up();
 
     t_type* type = get_true_type((*f_iter)->get_type());
@@ -1053,25 +978,23 @@ void t_php_generator::generate_php_struct_writer(ofstream& out,
       expect = "object";
     }
     if (!expect.empty()) {
-      out <<
-        indent() << "if (!is_" << expect << "($this->" << (*f_iter)->get_name() << ")) {" << endl;
+      out << indent() << "if (!is_" << expect << "($this->" << (*f_iter)->get_name() << ")) {"
+          << endl;
       indent_up();
-      out <<
-        indent() << "throw new " << "TProtocolException('Bad type in structure.', " << "TProtocolException::INVALID_DATA);" << endl;
+      out << indent() << "throw new "
+          << "TProtocolException('Bad type in structure.', "
+          << "TProtocolException::INVALID_DATA);" << endl;
       scope_down(out);
     }
 
     // Write field header
     if (binary_inline_) {
-      out <<
-        indent() << "$output .= pack('c', " << type_to_enum((*f_iter)->get_type()) << ");" << endl <<
-        indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << endl;
+      out << indent() << "$output .= pack('c', " << type_to_enum((*f_iter)->get_type()) << ");"
+          << endl << indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << endl;
     } else {
-      indent(out) <<
-        "$xfer += $output->writeFieldBegin(" <<
-        "'" << (*f_iter)->get_name() << "', " <<
-        type_to_enum((*f_iter)->get_type()) << ", " <<
-        (*f_iter)->get_key() << ");" << endl;
+      indent(out) << "$xfer += $output->writeFieldBegin("
+                  << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
+                  << ", " << (*f_iter)->get_key() << ");" << endl;
     }
 
     // Write field contents
@@ -1079,38 +1002,32 @@ void t_php_generator::generate_php_struct_writer(ofstream& out,
 
     // Write field closer
     if (!binary_inline_) {
-      indent(out) <<
-        "$xfer += $output->writeFieldEnd();" << endl;
+      indent(out) << "$xfer += $output->writeFieldEnd();" << endl;
     }
 
     indent_down();
-    indent(out) <<
-      "}" << endl;
+    indent(out) << "}" << endl;
   }
 
   if (binary_inline_) {
-    out <<
-      indent() << "$output .= pack('c', " << "TType::STOP);" << endl;
+    out << indent() << "$output .= pack('c', "
+        << "TType::STOP);" << endl;
   } else {
-    out <<
-      indent() << "$xfer += $output->writeFieldStop();" << endl <<
-      indent() << "$xfer += $output->writeStructEnd();" << endl;
+    out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent()
+        << "$xfer += $output->writeStructEnd();" << endl;
   }
 
-  out <<
-    indent() << "return $xfer;" << endl;
+  out << indent() << "return $xfer;" << endl;
 
   indent_down();
   out << indent() << "}" << endl << endl;
 }
 
-void t_php_generator::generate_php_struct_read_validator(ofstream& out,
-                                                          t_struct* tstruct) {
+void t_php_generator::generate_php_struct_read_validator(ofstream& out, t_struct* tstruct) {
   generate_php_struct_required_validator(out, tstruct, "_validateForRead", false);
 }
 
-void t_php_generator::generate_php_struct_write_validator(ofstream& out,
-                                                          t_struct* tstruct) {
+void t_php_generator::generate_php_struct_write_validator(ofstream& out, t_struct* tstruct) {
   generate_php_struct_required_validator(out, tstruct, "_validateForWrite", true);
 }
 
@@ -1118,8 +1035,7 @@ void t_php_generator::generate_php_struct_required_validator(ofstream& out,
                                                              t_struct* tstruct,
                                                              std::string method_name,
                                                              bool write_mode) {
-  indent(out) <<
-    "private function " << method_name << "() {" << endl;
+  indent(out) << "private function " << method_name << "() {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1129,17 +1045,14 @@ void t_php_generator::generate_php_struct_required_validator(ofstream& out,
 
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       t_field* field = (*f_iter);
-      if (field->get_req() == t_field::T_REQUIRED ||
-          (field->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) {
-        indent(out) <<
-          "if ($this->" << field->get_name() << " === null) {" << endl;
+      if (field->get_req() == t_field::T_REQUIRED
+          || (field->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) {
+        indent(out) << "if ($this->" << field->get_name() << " === null) {" << endl;
         indent_up();
-        indent(out) <<
-          "throw new TProtocolException('Required field " <<
-          tstruct->get_name() << "." << field->get_name() << " is unset!');" << endl;
+        indent(out) << "throw new TProtocolException('Required field " << tstruct->get_name() << "."
+                    << field->get_name() << " is unset!');" << endl;
         indent_down();
-        indent(out) <<
-          "}" << endl;
+        indent(out) << "}" << endl;
       }
     }
   }
@@ -1148,13 +1061,10 @@ void t_php_generator::generate_php_struct_required_validator(ofstream& out,
   indent(out) << "}" << endl << endl;
 }
 
-
-
 void t_php_generator::generate_php_struct_json_serialize(ofstream& out,
                                                          t_struct* tstruct,
                                                          bool is_result) {
-  indent(out) <<
-    "public function jsonSerialize() {" << endl;
+  indent(out) << "public function jsonSerialize() {" << endl;
   indent_up();
 
   if (needs_php_write_validator(tstruct, is_result)) {
@@ -1189,15 +1099,14 @@ void t_php_generator::generate_php_struct_json_serialize(ofstream& out,
   indent(out) << "}" << endl << endl;
 }
 
-int t_php_generator::get_php_num_required_fields(const vector<t_field*>& fields,
-                                                 bool write_mode) {
+int t_php_generator::get_php_num_required_fields(const vector<t_field*>& fields, bool write_mode) {
   int num_req = 0;
 
   if (fields.size() > 0) {
     vector<t_field*>::const_iterator f_iter;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      if ((*f_iter)->get_req() == t_field::T_REQUIRED ||
-          ((*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) {
+      if ((*f_iter)->get_req() == t_field::T_REQUIRED
+          || ((*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) {
         ++num_req;
       }
     }
@@ -1206,16 +1115,13 @@ int t_php_generator::get_php_num_required_fields(const vector<t_field*>& fields,
 }
 
 bool t_php_generator::needs_php_write_validator(t_struct* tstruct, bool is_result) {
-  return (validate_ &&
-          !is_result &&
-          !tstruct->is_union() &&
-          get_php_num_required_fields(tstruct->get_members(), true) > 0);
+  return (validate_ && !is_result && !tstruct->is_union()
+          && get_php_num_required_fields(tstruct->get_members(), true) > 0);
 }
 
 bool t_php_generator::needs_php_read_validator(t_struct* tstruct, bool is_result) {
-  return (validate_ &&
-          !is_result &&
-          (get_php_num_required_fields(tstruct->get_members(), false) > 0));
+  return (validate_ && !is_result
+          && (get_php_num_required_fields(tstruct->get_members(), false) > 0));
 }
 
 /**
@@ -1224,16 +1130,14 @@ bool t_php_generator::needs_php_read_validator(t_struct* tstruct, bool is_result
  * @param tservice The service definition
  */
 void t_php_generator::generate_service(t_service* tservice) {
-  string f_service_name = package_dir_+service_name_+".php";
+  string f_service_name = package_dir_ + service_name_ + ".php";
   f_service_.open(f_service_name.c_str());
 
   f_service_ << "<?php" << endl;
   f_service_ << "namespace " << php_namespace_suffix(tservice->get_program()) << ";" << endl;
-  f_service_ << autogen_comment() <<
-    php_includes();
+  f_service_ << autogen_comment() << php_includes();
 
-  f_service_ <<
-    endl;
+  f_service_ << endl;
 
   // Generate the three main parts of the service (well, two for now in PHP)
   generate_service_interface(tservice);
@@ -1265,42 +1169,32 @@ void t_php_generator::generate_service_processor(t_service* tservice) {
   string extends_processor = "";
   if (tservice->get_extends() != NULL) {
     extends = tservice->get_extends()->get_name();
-    extends_processor = " extends " + php_namespace(tservice->get_extends()->get_program()) + extends + "Processor";
+    extends_processor = " extends " + php_namespace(tservice->get_extends()->get_program())
+                        + extends + "Processor";
   }
 
   // Generate the header portion
-  f_service_ <<
-    "class " << service_name_ << "Processor" << extends_processor << " {" << endl;
+  f_service_ << "class " << service_name_ << "Processor" << extends_processor << " {" << endl;
   indent_up();
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected $handler_ = null;" << endl;
+    f_service_ << indent() << "protected $handler_ = null;" << endl;
   }
 
-  f_service_ <<
-    indent() << "public function __construct($handler) {" << endl;
+  f_service_ << indent() << "public function __construct($handler) {" << endl;
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "  $this->handler_ = $handler;" << endl;
+    f_service_ << indent() << "  $this->handler_ = $handler;" << endl;
   } else {
-    f_service_ <<
-      indent() << "  parent::__construct($handler);" << endl;
+    f_service_ << indent() << "  parent::__construct($handler);" << endl;
   }
-  f_service_ <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "}" << endl << endl;
 
   // Generate the server implementation
-  indent(f_service_) <<
-    "public function process($input, $output) {" << endl;
+  indent(f_service_) << "public function process($input, $output) {" << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "$rseqid = 0;" << endl <<
-    indent() << "$fname = null;" << endl <<
-    indent() << "$mtype = 0;" << endl <<
-    endl;
+  f_service_ << indent() << "$rseqid = 0;" << endl << indent() << "$fname = null;" << endl
+             << indent() << "$mtype = 0;" << endl << endl;
 
   if (binary_inline_) {
     t_field ffname(g_type_string, "fname");
@@ -1310,36 +1204,32 @@ void t_php_generator::generate_service_processor(t_service* tservice) {
     generate_deserialize_field(f_service_, &fmtype, "", true);
     generate_deserialize_field(f_service_, &fseqid, "", true);
   } else {
-    f_service_ <<
-      indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << endl;
+    f_service_ << indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << endl;
   }
 
   // HOT: check for method implementation
-  f_service_ <<
-    indent() << "$methodname = 'process_'.$fname;" << endl <<
-    indent() << "if (!method_exists($this, $methodname)) {" << endl;
+  f_service_ << indent() << "$methodname = 'process_'.$fname;" << endl << indent()
+             << "if (!method_exists($this, $methodname)) {" << endl;
   if (binary_inline_) {
-    f_service_ <<
-      indent() << "  throw new \\Exception('Function '.$fname.' not implemented.');" << endl;
+    f_service_ << indent() << "  throw new \\Exception('Function '.$fname.' not implemented.');"
+               << endl;
   } else {
-    f_service_ <<
-      indent() << "  $input->skip(" << "TType::STRUCT);" << endl <<
-      indent() << "  $input->readMessageEnd();" << endl <<
-      indent() << "  $x = new " << "TApplicationException('Function '.$fname.' not implemented.', " << "TApplicationException::UNKNOWN_METHOD);" << endl <<
-      indent() << "  $output->writeMessageBegin($fname, " << "TMessageType::EXCEPTION, $rseqid);" << endl <<
-      indent() << "  $x->write($output);" << endl <<
-      indent() << "  $output->writeMessageEnd();" << endl <<
-      indent() << "  $output->getTransport()->flush();" << endl <<
-      indent() << "  return;" << endl;
-  }
-  f_service_ <<
-    indent() << "}" << endl <<
-    indent() << "$this->$methodname($rseqid, $input, $output);" << endl <<
-    indent() << "return true;" << endl;
+    f_service_ << indent() << "  $input->skip("
+               << "TType::STRUCT);" << endl << indent() << "  $input->readMessageEnd();" << endl
+               << indent() << "  $x = new "
+               << "TApplicationException('Function '.$fname.' not implemented.', "
+               << "TApplicationException::UNKNOWN_METHOD);" << endl << indent()
+               << "  $output->writeMessageBegin($fname, "
+               << "TMessageType::EXCEPTION, $rseqid);" << endl << indent()
+               << "  $x->write($output);" << endl << indent() << "  $output->writeMessageEnd();"
+               << endl << indent() << "  $output->getTransport()->flush();" << endl << indent()
+               << "  return;" << endl;
+  }
+  f_service_ << indent() << "}" << endl << indent()
+             << "$this->$methodname($rseqid, $input, $output);" << endl << indent()
+             << "return true;" << endl;
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "}" << endl << endl;
 
   // Generate the process subfunctions
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1355,23 +1245,21 @@ void t_php_generator::generate_service_processor(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_php_generator::generate_process_function(t_service* tservice,
-                                                t_function* tfunction) {
+void t_php_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
   // Open function
-  indent(f_service_) <<
-    "protected function process_" << tfunction->get_name() <<
-    "($seqid, $input, $output) {" << endl;
+  indent(f_service_) << "protected function process_" << tfunction->get_name()
+                     << "($seqid, $input, $output) {" << endl;
   indent_up();
 
-  string argsname = php_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_args";
-  string resultname = php_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_result";
+  string argsname = php_namespace(tservice->get_program()) + service_name_ + "_"
+                    + tfunction->get_name() + "_args";
+  string resultname = php_namespace(tservice->get_program()) + service_name_ + "_"
+                      + tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << "$args = new " << argsname << "();" << endl <<
-    indent() << "$args->read($input);" << endl;
+  f_service_ << indent() << "$args = new " << argsname << "();" << endl << indent()
+             << "$args->read($input);" << endl;
   if (!binary_inline_) {
-    f_service_ <<
-      indent() << "$input->readMessageEnd();" << endl;
+    f_service_ << indent() << "$input->readMessageEnd();" << endl;
   }
 
   t_struct* xs = tfunction->get_xceptions();
@@ -1380,14 +1268,12 @@ void t_php_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "$result = new " << resultname << "();" << endl;
+    f_service_ << indent() << "$result = new " << resultname << "();" << endl;
   }
 
   // Try block for a function with exceptions
   if (xceptions.size() > 0) {
-    f_service_ <<
-      indent() << "try {" << endl;
+    f_service_ << indent() << "try {" << endl;
     indent_up();
   }
 
@@ -1400,8 +1286,7 @@ void t_php_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << "$result->success = ";
   }
-  f_service_ <<
-    "$this->handler_->" << tfunction->get_name() << "(";
+  f_service_ << "$this->handler_->" << tfunction->get_name() << "(";
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
@@ -1416,12 +1301,14 @@ void t_php_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && xceptions.size() > 0) {
     indent_down();
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_ <<
-        indent() << "} catch (" << php_namespace(get_true_type((*x_iter)->get_type())->get_program()) << (*x_iter)->get_type()->get_name() << " $" << (*x_iter)->get_name() << ") {" << endl;
+      f_service_ << indent() << "} catch ("
+                 << php_namespace(get_true_type((*x_iter)->get_type())->get_program())
+                 << (*x_iter)->get_type()->get_name() << " $" << (*x_iter)->get_name() << ") {"
+                 << endl;
       if (!tfunction->is_oneway()) {
         indent_up();
-        f_service_ <<
-          indent() << "$result->" << (*x_iter)->get_name() << " = $" << (*x_iter)->get_name() << ";" << endl;
+        f_service_ << indent() << "$result->" << (*x_iter)->get_name() << " = $"
+                   << (*x_iter)->get_name() << ";" << endl;
         indent_down();
         f_service_ << indent();
       }
@@ -1431,53 +1318,47 @@ void t_php_generator::generate_process_function(t_service* tservice,
 
   // Shortcut out here for oneway functions
   if (tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "return;" << endl;
+    f_service_ << indent() << "return;" << endl;
     indent_down();
-    f_service_ <<
-      indent() << "}" << endl;
+    f_service_ << indent() << "}" << endl;
     return;
   }
 
-  f_service_ <<
-    indent() << "$bin_accel = ($output instanceof " << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');" << endl;
+  f_service_ << indent() << "$bin_accel = ($output instanceof "
+             << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');"
+             << endl;
 
-  f_service_ <<
-    indent() << "if ($bin_accel)" << endl;
+  f_service_ << indent() << "if ($bin_accel)" << endl;
   scope_up(f_service_);
 
-  f_service_ <<
-    indent() << "thrift_protocol_write_binary($output, '" << tfunction->get_name() << "', " << "TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());" << endl;
+  f_service_ << indent() << "thrift_protocol_write_binary($output, '" << tfunction->get_name()
+             << "', "
+             << "TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());" << endl;
 
   scope_down(f_service_);
-  f_service_ <<
-    indent() << "else" << endl;
+  f_service_ << indent() << "else" << endl;
   scope_up(f_service_);
 
   // Serialize the request header
   if (binary_inline_) {
-    f_service_ <<
-      indent() << "$buff = pack('N', (0x80010000 | " << "TMessageType::REPLY)); " << endl <<
-      indent() << "$buff .= pack('N', strlen('" << tfunction->get_name() << "'));" << endl <<
-      indent() << "$buff .= '" << tfunction->get_name() << "';" << endl <<
-      indent() << "$buff .= pack('N', $seqid);" << endl <<
-      indent() << "$result->write($buff);" << endl <<
-      indent() << "$output->write($buff);" << endl <<
-      indent() << "$output->flush();" << endl;
+    f_service_ << indent() << "$buff = pack('N', (0x80010000 | "
+               << "TMessageType::REPLY)); " << endl << indent() << "$buff .= pack('N', strlen('"
+               << tfunction->get_name() << "'));" << endl << indent() << "$buff .= '"
+               << tfunction->get_name() << "';" << endl << indent() << "$buff .= pack('N', $seqid);"
+               << endl << indent() << "$result->write($buff);" << endl << indent()
+               << "$output->write($buff);" << endl << indent() << "$output->flush();" << endl;
   } else {
-    f_service_ <<
-      indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', " << "TMessageType::REPLY, $seqid);" << endl <<
-      indent() << "$result->write($output);" << endl <<
-      indent() << "$output->writeMessageEnd();" << endl <<
-      indent() << "$output->getTransport()->flush();" << endl;
+    f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', "
+               << "TMessageType::REPLY, $seqid);" << endl << indent() << "$result->write($output);"
+               << endl << indent() << "$output->writeMessageEnd();" << endl << indent()
+               << "$output->getTransport()->flush();" << endl;
   }
 
   scope_down(f_service_);
 
   // Close function
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl;
+  f_service_ << indent() << "}" << endl;
 }
 
 /**
@@ -1489,8 +1370,7 @@ void t_php_generator::generate_service_helpers(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
-  f_service_ <<
-    "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+  f_service_ << "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_struct* ts = (*f_iter)->get_arglist();
@@ -1535,23 +1415,23 @@ void t_php_generator::generate_service_interface(t_service* tservice) {
   string extends = "";
   string extends_if = "";
   if (tservice->get_extends() != NULL) {
-    extends = " extends " + php_namespace(tservice->get_extends()->get_program()) + tservice->get_extends()->get_name();
-    extends_if = " extends " + php_namespace(tservice->get_extends()->get_program()) + tservice->get_extends()->get_name() + "If";
+    extends = " extends " + php_namespace(tservice->get_extends()->get_program())
+              + tservice->get_extends()->get_name();
+    extends_if = " extends " + php_namespace(tservice->get_extends()->get_program())
+                 + tservice->get_extends()->get_name() + "If";
   }
   generate_php_doc(f_service_, tservice);
-  f_service_ <<
-    "interface " << php_namespace_declaration(tservice) << "If" << extends_if << " {" << endl;
+  f_service_ << "interface " << php_namespace_declaration(tservice) << "If" << extends_if << " {"
+             << endl;
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     generate_php_doc(f_service_, *f_iter);
-    indent(f_service_) <<
-      "public function " << function_signature(*f_iter) << ";" << endl;
+    indent(f_service_) << "public function " << function_signature(*f_iter) << ";" << endl;
   }
   indent_down();
-  f_service_ <<
-    "}" << endl << endl;
+  f_service_ << "}" << endl << endl;
 }
 
 /**
@@ -1561,30 +1441,25 @@ void t_php_generator::generate_service_rest(t_service* tservice) {
   string extends = "";
   string extends_if = "";
   if (tservice->get_extends() != NULL) {
-    extends = " extends " + php_namespace(tservice->get_extends()->get_program()) + tservice->get_extends()->get_name();
-    extends_if = " extends " + php_namespace(tservice->get_extends()->get_program()) + tservice->get_extends()->get_name() + "Rest";
+    extends = " extends " + php_namespace(tservice->get_extends()->get_program())
+              + tservice->get_extends()->get_name();
+    extends_if = " extends " + php_namespace(tservice->get_extends()->get_program())
+                 + tservice->get_extends()->get_name() + "Rest";
   }
-  f_service_ <<
-    "class " << service_name_ << "Rest" << extends_if << " {" << endl;
+  f_service_ << "class " << service_name_ << "Rest" << extends_if << " {" << endl;
   indent_up();
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected $impl_;" << endl <<
-      endl;
+    f_service_ << indent() << "protected $impl_;" << endl << endl;
   }
 
-  f_service_ <<
-    indent() << "public function __construct($impl) {" << endl <<
-    indent() << "  $this->impl_ = $impl;" << endl <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "public function __construct($impl) {" << endl << indent()
+             << "  $this->impl_ = $impl;" << endl << indent() << "}" << endl << endl;
 
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    indent(f_service_) <<
-      "public function " << (*f_iter)->get_name() << "($request) {" << endl;
+    indent(f_service_) << "public function " << (*f_iter)->get_name() << "($request) {" << endl;
     indent_up();
     const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
     vector<t_field*>::const_iterator a_iter;
@@ -1593,39 +1468,35 @@ void t_php_generator::generate_service_rest(t_service* tservice) {
       string cast = type_to_cast(atype);
       string req = "$request['" + (*a_iter)->get_name() + "']";
       if (atype->is_bool()) {
-        f_service_ <<
-          indent() << "$" << (*a_iter)->get_name() << " = " << cast << "(!empty(" << req << ") && (" << req << " !== 'false'));" << endl;
+        f_service_ << indent() << "$" << (*a_iter)->get_name() << " = " << cast << "(!empty(" << req
+                   << ") && (" << req << " !== 'false'));" << endl;
       } else {
-        f_service_ <<
-          indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? " << cast << req << " : null;" << endl;
+        f_service_ << indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? "
+                   << cast << req << " : null;" << endl;
       }
-      if (atype->is_string() &&
-          ((t_base_type*)atype)->is_string_list()) {
-        f_service_ <<
-          indent() << "$" << (*a_iter)->get_name() << " = explode(',', $" << (*a_iter)->get_name() << ");" << endl;
+      if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
+        f_service_ << indent() << "$" << (*a_iter)->get_name() << " = explode(',', $"
+                   << (*a_iter)->get_name() << ");" << endl;
       } else if (atype->is_map() || atype->is_list()) {
-        f_service_ <<
-          indent() << "$" << (*a_iter)->get_name() << " = json_decode($" << (*a_iter)->get_name() << ", true);" << endl;
+        f_service_ << indent() << "$" << (*a_iter)->get_name() << " = json_decode($"
+                   << (*a_iter)->get_name() << ", true);" << endl;
       } else if (atype->is_set()) {
-        f_service_ <<
-          indent() << "$" << (*a_iter)->get_name() << " = array_fill_keys(json_decode($" << (*a_iter)->get_name() << ", true), 1);" << endl;
+        f_service_ << indent() << "$" << (*a_iter)->get_name() << " = array_fill_keys(json_decode($"
+                   << (*a_iter)->get_name() << ", true), 1);" << endl;
       } else if (atype->is_struct() || atype->is_xception()) {
-        f_service_ <<
-          indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << endl <<
-          indent() << "  $" << (*a_iter)->get_name() << " = new " << php_namespace(atype->get_program()) << atype->get_name() << "(json_decode($" << (*a_iter)->get_name() << ", true));" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << endl
+                   << indent() << "  $" << (*a_iter)->get_name() << " = new "
+                   << php_namespace(atype->get_program()) << atype->get_name() << "(json_decode($"
+                   << (*a_iter)->get_name() << ", true));" << endl << indent() << "}" << endl;
       }
     }
-    f_service_ <<
-      indent() << "return $this->impl_->" << (*f_iter)->get_name() << "(" << argument_list((*f_iter)->get_arglist(), false) << ");" << endl;
+    f_service_ << indent() << "return $this->impl_->" << (*f_iter)->get_name() << "("
+               << argument_list((*f_iter)->get_arglist(), false) << ");" << endl;
     indent_down();
-    indent(f_service_) <<
-      "}" << endl <<
-      endl;
+    indent(f_service_) << "}" << endl << endl;
   }
   indent_down();
-  f_service_ <<
-    "}" << endl << endl;
+  f_service_ << "}" << endl << endl;
 }
 
 /**
@@ -1638,37 +1509,31 @@ void t_php_generator::generate_service_client(t_service* tservice) {
   string extends_client = "";
   if (tservice->get_extends() != NULL) {
     extends = tservice->get_extends()->get_name();
-    extends_client = " extends " + php_namespace(tservice->get_extends()->get_program()) + extends + "Client";
+    extends_client = " extends " + php_namespace(tservice->get_extends()->get_program()) + extends
+                     + "Client";
   }
 
-  f_service_ <<
-    "class " << php_namespace_declaration(tservice) << "Client" << extends_client << " implements " <<  php_namespace(tservice->get_program()) << service_name_ << "If {" << endl;
+  f_service_ << "class " << php_namespace_declaration(tservice) << "Client" << extends_client
+             << " implements " << php_namespace(tservice->get_program()) << service_name_ << "If {"
+             << endl;
   indent_up();
 
   // Private members
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected $input_ = null;" << endl <<
-      indent() << "protected $output_ = null;" << endl <<
-      endl;
-    f_service_ <<
-      indent() << "protected $seqid_ = 0;" << endl <<
-      endl;
+    f_service_ << indent() << "protected $input_ = null;" << endl << indent()
+               << "protected $output_ = null;" << endl << endl;
+    f_service_ << indent() << "protected $seqid_ = 0;" << endl << endl;
   }
 
   // Constructor function
-  f_service_ <<
-    indent() << "public function __construct($input, $output=null) {" << endl;
+  f_service_ << indent() << "public function __construct($input, $output=null) {" << endl;
   if (!extends.empty()) {
-    f_service_ <<
-      indent() << "  parent::__construct($input, $output);" << endl;
+    f_service_ << indent() << "  parent::__construct($input, $output);" << endl;
   } else {
-    f_service_ <<
-      indent() << "  $this->input_ = $input;" << endl <<
-      indent() << "  $this->output_ = $output ? $output : $input;" << endl;
+    f_service_ << indent() << "  $this->input_ = $input;" << endl << indent()
+               << "  $this->output_ = $output ? $output : $input;" << endl;
   }
-  f_service_ <<
-    indent() << "}" << endl << endl;
+  f_service_ << indent() << "}" << endl << endl;
 
   // Generate client method implementations
   vector<t_function*> functions = tservice->get_functions();
@@ -1680,220 +1545,192 @@ void t_php_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    indent(f_service_) <<
-      "public function " << function_signature(*f_iter) << endl;
+    indent(f_service_) << "public function " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
-      indent(f_service_) <<
-        "$this->send_" << funname << "(";
-
-      bool first = true;
-      for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-        if (first) {
-          first = false;
-        } else {
-          f_service_ << ", ";
-        }
-        f_service_ << "$" << (*fld_iter)->get_name();
+    indent(f_service_) << "$this->send_" << funname << "(";
+
+    bool first = true;
+    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
+      if (first) {
+        first = false;
+      } else {
+        f_service_ << ", ";
       }
-      f_service_ << ");" << endl;
+      f_service_ << "$" << (*fld_iter)->get_name();
+    }
+    f_service_ << ");" << endl;
 
-      if (!(*f_iter)->is_oneway()) {
-        f_service_ << indent();
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          f_service_ << "return ";
-        }
-        f_service_ <<
-          "$this->recv_" << funname << "();" << endl;
+    if (!(*f_iter)->is_oneway()) {
+      f_service_ << indent();
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        f_service_ << "return ";
       }
+      f_service_ << "$this->recv_" << funname << "();" << endl;
+    }
     scope_down(f_service_);
     f_service_ << endl;
 
-    indent(f_service_) <<
-      "public function send_" << function_signature(*f_iter) << endl;
+    indent(f_service_) << "public function send_" << function_signature(*f_iter) << endl;
     scope_up(f_service_);
 
-      std::string argsname = php_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_args";
+    std::string argsname = php_namespace(tservice->get_program()) + service_name_ + "_"
+                           + (*f_iter)->get_name() + "_args";
 
-      f_service_ <<
-        indent() << "$args = new " << argsname << "();" << endl;
+    f_service_ << indent() << "$args = new " << argsname << "();" << endl;
 
-      for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-        f_service_ <<
-          indent() << "$args->" << (*fld_iter)->get_name() << " = $" << (*fld_iter)->get_name() << ";" << endl;
-      }
+    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
+      f_service_ << indent() << "$args->" << (*fld_iter)->get_name() << " = $"
+                 << (*fld_iter)->get_name() << ";" << endl;
+    }
 
-      f_service_ <<
-        indent() << "$bin_accel = ($this->output_ instanceof " << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');" << endl;
+    f_service_ << indent() << "$bin_accel = ($this->output_ instanceof "
+               << "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');"
+               << endl;
 
-      f_service_ <<
-        indent() << "if ($bin_accel)" << endl;
-      scope_up(f_service_);
+    f_service_ << indent() << "if ($bin_accel)" << endl;
+    scope_up(f_service_);
 
-      string messageType = (*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL";
+    string messageType = (*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL";
 
-      f_service_ <<
-        indent() << "thrift_protocol_write_binary($this->output_, '"
-                 << (*f_iter)->get_name() << "', " << messageType
-                 << ", $args, $this->seqid_, $this->output_->isStrictWrite());" << endl;
+    f_service_ << indent() << "thrift_protocol_write_binary($this->output_, '"
+               << (*f_iter)->get_name() << "', " << messageType
+               << ", $args, $this->seqid_, $this->output_->isStrictWrite());" << endl;
 
-      scope_down(f_service_);
-      f_service_ <<
-        indent() << "else" << endl;
-      scope_up(f_service_);
+    scope_down(f_service_);
+    f_service_ << indent() << "else" << endl;
+    scope_up(f_service_);
 
-      // Serialize the request header
-      if (binary_inline_) {
-        f_service_ <<
-          indent() << "$buff = pack('N', (0x80010000 | " << messageType
-                   << "));" << endl <<
-          indent() << "$buff .= pack('N', strlen('" << funname << "'));" << endl <<
-          indent() << "$buff .= '" << funname << "';" << endl <<
-          indent() << "$buff .= pack('N', $this->seqid_);" << endl;
-      } else {
-        f_service_ <<
-          indent() << "$this->output_->writeMessageBegin('" << (*f_iter)->get_name() << "', "
-                   << messageType << ", $this->seqid_);" << endl;
-      }
+    // Serialize the request header
+    if (binary_inline_) {
+      f_service_ << indent() << "$buff = pack('N', (0x80010000 | " << messageType << "));" << endl
+                 << indent() << "$buff .= pack('N', strlen('" << funname << "'));" << endl
+                 << indent() << "$buff .= '" << funname << "';" << endl << indent()
+                 << "$buff .= pack('N', $this->seqid_);" << endl;
+    } else {
+      f_service_ << indent() << "$this->output_->writeMessageBegin('" << (*f_iter)->get_name()
+                 << "', " << messageType << ", $this->seqid_);" << endl;
+    }
 
-      // Write to the stream
-      if (binary_inline_) {
-        f_service_ <<
-          indent() << "$args->write($buff);" << endl <<
-          indent() << "$this->output_->write($buff);" << endl <<
-          indent() << "$this->output_->flush();" << endl;
-      } else {
-        f_service_ <<
-          indent() << "$args->write($this->output_);" << endl <<
-          indent() << "$this->output_->writeMessageEnd();" << endl <<
-          indent() << "$this->output_->getTransport()->flush();" << endl;
-      }
+    // Write to the stream
+    if (binary_inline_) {
+      f_service_ << indent() << "$args->write($buff);" << endl << indent()
+                 << "$this->output_->write($buff);" << endl << indent()
+                 << "$this->output_->flush();" << endl;
+    } else {
+      f_service_ << indent() << "$args->write($this->output_);" << endl << indent()
+                 << "$this->output_->writeMessageEnd();" << endl << indent()
+                 << "$this->output_->getTransport()->flush();" << endl;
+    }
 
     scope_down(f_service_);
 
     scope_down(f_service_);
 
-
     if (!(*f_iter)->is_oneway()) {
-      std::string resultname = php_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result";
+      std::string resultname = php_namespace(tservice->get_program()) + service_name_ + "_"
+                               + (*f_iter)->get_name() + "_result";
       t_struct noargs(program_);
 
       t_function recv_function((*f_iter)->get_returntype(),
                                string("recv_") + (*f_iter)->get_name(),
                                &noargs);
       // Open function
-      f_service_ <<
-        endl <<
-        indent() << "public function " << function_signature(&recv_function) << endl;
+      f_service_ << endl << indent() << "public function " << function_signature(&recv_function)
+                 << endl;
       scope_up(f_service_);
 
-      f_service_ <<
-        indent() << "$bin_accel = ($this->input_ instanceof " << "TBinaryProtocolAccelerated)"
+      f_service_ << indent() << "$bin_accel = ($this->input_ instanceof "
+                 << "TBinaryProtocolAccelerated)"
                  << " && function_exists('thrift_protocol_read_binary');" << endl;
 
-      f_service_ <<
-        indent() << "if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '" << resultname << "', $this->input_->isStrictRead());" << endl;
-      f_service_ <<
-        indent() << "else" << endl;
+      f_service_ << indent()
+                 << "if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '"
+                 << resultname << "', $this->input_->isStrictRead());" << endl;
+      f_service_ << indent() << "else" << endl;
       scope_up(f_service_);
 
-      f_service_ <<
-        indent() << "$rseqid = 0;" << endl <<
-        indent() << "$fname = null;" << endl <<
-        indent() << "$mtype = 0;" << endl <<
-        endl;
+      f_service_ << indent() << "$rseqid = 0;" << endl << indent() << "$fname = null;" << endl
+                 << indent() << "$mtype = 0;" << endl << endl;
 
       if (binary_inline_) {
         t_field ffname(g_type_string, "fname");
         t_field fseqid(g_type_i32, "rseqid");
-        f_service_ <<
-          indent() << "$ver = unpack('N', $this->input_->readAll(4));" << endl <<
-          indent() << "$ver = $ver[1];" << endl <<
-          indent() << "$mtype = $ver & 0xff;" << endl <<
-          indent() << "$ver = $ver & 0xffff0000;" << endl <<
-          indent() << "if ($ver != 0x80010000) throw new " << "TProtocolException('Bad version identifier: '.$ver, " << "TProtocolException::BAD_VERSION);" << endl;
+        f_service_ << indent() << "$ver = unpack('N', $this->input_->readAll(4));" << endl
+                   << indent() << "$ver = $ver[1];" << endl << indent() << "$mtype = $ver & 0xff;"
+                   << endl << indent() << "$ver = $ver & 0xffff0000;" << endl << indent()
+                   << "if ($ver != 0x80010000) throw new "
+                   << "TProtocolException('Bad version identifier: '.$ver, "
+                   << "TProtocolException::BAD_VERSION);" << endl;
         generate_deserialize_field(f_service_, &ffname, "", true);
         generate_deserialize_field(f_service_, &fseqid, "", true);
       } else {
-        f_service_ <<
-          indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);" << endl <<
-          indent() << "if ($mtype == " << "TMessageType::EXCEPTION) {" << endl <<
-          indent() << "  $x = new " << "TApplicationException();" << endl <<
-          indent() << "  $x->read($this->input_);" << endl <<
-          indent() << "  $this->input_->readMessageEnd();" << endl <<
-          indent() << "  throw $x;" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);"
+                   << endl << indent() << "if ($mtype == "
+                   << "TMessageType::EXCEPTION) {" << endl << indent() << "  $x = new "
+                   << "TApplicationException();" << endl << indent() << "  $x->read($this->input_);"
+                   << endl << indent() << "  $this->input_->readMessageEnd();" << endl << indent()
+                   << "  throw $x;" << endl << indent() << "}" << endl;
       }
 
-      f_service_ <<
-        indent() << "$result = new " << resultname << "();" << endl <<
-        indent() << "$result->read($this->input_);" << endl;
+      f_service_ << indent() << "$result = new " << resultname << "();" << endl << indent()
+                 << "$result->read($this->input_);" << endl;
 
       if (!binary_inline_) {
-        f_service_ <<
-          indent() << "$this->input_->readMessageEnd();" << endl;
+        f_service_ << indent() << "$this->input_->readMessageEnd();" << endl;
       }
 
       scope_down(f_service_);
 
       // Careful, only return result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if ($result->success !== null) {" << endl <<
-          indent() << "  return $result->success;" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if ($result->success !== null) {" << endl << indent()
+                   << "  return $result->success;" << endl << indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << endl <<
-          indent() << "  throw $result->" << (*x_iter)->get_name() << ";" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << endl
+                   << indent() << "  throw $result->" << (*x_iter)->get_name() << ";" << endl
+                   << indent() << "}" << endl;
       }
 
       // Careful, only return _result if not a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "return;" << endl;
+        indent(f_service_) << "return;" << endl;
       } else {
-        f_service_ <<
-          indent() << "throw new \\Exception(\"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+        f_service_ << indent() << "throw new \\Exception(\"" << (*f_iter)->get_name()
+                   << " failed: unknown result\");" << endl;
       }
 
-    // Close function
-    scope_down(f_service_);
-    f_service_ << endl;
-
+      // Close function
+      scope_down(f_service_);
+      f_service_ << endl;
     }
   }
 
   indent_down();
-  f_service_ <<
-    "}" << endl << endl;
+  f_service_ << "}" << endl << endl;
 }
 
 /**
  * Deserializes a field of any type.
  */
-void t_php_generator::generate_deserialize_field(ofstream &out,
+void t_php_generator::generate_deserialize_field(ofstream& out,
                                                  t_field* tfield,
                                                  string prefix,
                                                  bool inclass) {
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = prefix + tfield->get_name();
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                 name);
+    generate_deserialize_struct(out, (t_struct*)type, name);
   } else {
 
     if (type->is_container()) {
@@ -1907,85 +1744,67 @@ void t_php_generator::generate_deserialize_field(ofstream &out,
           t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
           switch (tbase) {
           case t_base_type::TYPE_VOID:
-            throw "compiler error: cannot serialize void field in a struct: " +
-              name;
+            throw "compiler error: cannot serialize void field in a struct: " + name;
             break;
           case t_base_type::TYPE_STRING:
-            out <<
-              indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << endl <<
-              indent() << "$len = $len[1];" << endl <<
-              indent() << "if ($len > 0x7fffffff) {" << endl <<
-              indent() << "  $len = 0 - (($len - 1) ^ 0xffffffff);" << endl <<
-              indent() << "}" << endl <<
-              indent() << "$" << name << " = " << itrans << "->readAll($len);" << endl;
+            out << indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << endl
+                << indent() << "$len = $len[1];" << endl << indent() << "if ($len > 0x7fffffff) {"
+                << endl << indent() << "  $len = 0 - (($len - 1) ^ 0xffffffff);" << endl << indent()
+                << "}" << endl << indent() << "$" << name << " = " << itrans << "->readAll($len);"
+                << endl;
             break;
           case t_base_type::TYPE_BOOL:
-            out <<
-              indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));" << endl <<
-              indent() << "$" << name << " = (bool)$" << name << "[1];" << endl;
+            out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));"
+                << endl << indent() << "$" << name << " = (bool)$" << name << "[1];" << endl;
             break;
           case t_base_type::TYPE_BYTE:
-            out <<
-              indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));" << endl <<
-              indent() << "$" << name << " = $" << name << "[1];" << endl;
+            out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));"
+                << endl << indent() << "$" << name << " = $" << name << "[1];" << endl;
             break;
           case t_base_type::TYPE_I16:
-            out <<
-              indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << endl <<
-              indent() << "$val = $val[1];" << endl <<
-              indent() << "if ($val > 0x7fff) {" << endl <<
-              indent() << "  $val = 0 - (($val - 1) ^ 0xffff);" << endl <<
-              indent() << "}" << endl <<
-              indent() << "$" << name << " = $val;" << endl;
+            out << indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << endl
+                << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fff) {"
+                << endl << indent() << "  $val = 0 - (($val - 1) ^ 0xffff);" << endl << indent()
+                << "}" << endl << indent() << "$" << name << " = $val;" << endl;
             break;
           case t_base_type::TYPE_I32:
-            out <<
-              indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl <<
-              indent() << "$val = $val[1];" << endl <<
-              indent() << "if ($val > 0x7fffffff) {" << endl <<
-              indent() << "  $val = 0 - (($val - 1) ^ 0xffffffff);" << endl <<
-              indent() << "}" << endl <<
-              indent() << "$" << name << " = $val;" << endl;
+            out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl
+                << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {"
+                << endl << indent() << "  $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent()
+                << "}" << endl << indent() << "$" << name << " = $val;" << endl;
             break;
           case t_base_type::TYPE_I64:
-            out <<
-              indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << endl <<
-              indent() << "if ($arr[1] & 0x80000000) {" << endl <<
-              indent() << "  $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << endl <<
-              indent() << "  $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << endl <<
-              indent() << "  $" << name << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << endl <<
-              indent() << "} else {" << endl <<
-              indent() << "  $" << name << " = $arr[1]*4294967296 + $arr[2];" << endl <<
-              indent() << "}" << endl;
+            out << indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << endl
+                << indent() << "if ($arr[1] & 0x80000000) {" << endl << indent()
+                << "  $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << endl << indent()
+                << "  $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << endl << indent() << "  $" << name
+                << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << endl << indent() << "} else {"
+                << endl << indent() << "  $" << name << " = $arr[1]*4294967296 + $arr[2];" << endl
+                << indent() << "}" << endl;
             break;
           case t_base_type::TYPE_DOUBLE:
-            out <<
-              indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << endl <<
-              indent() << "$" << name << " = $arr[1];" << endl;
+            out << indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << endl
+                << indent() << "$" << name << " = $arr[1];" << endl;
             break;
           default:
-            throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase) + tfield->get_name();
+            throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase)
+                + tfield->get_name();
           }
         } else if (type->is_enum()) {
-            out <<
-              indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl <<
-              indent() << "$val = $val[1];" << endl <<
-              indent() << "if ($val > 0x7fffffff) {" << endl <<
-              indent() << "  $val = 0 - (($val - 1) ^ 0xffffffff);" << endl <<
-              indent() << "}" << endl <<
-              indent() << "$" << name << " = $val;" << endl;
+          out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl << indent()
+              << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {" << endl
+              << indent() << "  $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent() << "}"
+              << endl << indent() << "$" << name << " = $val;" << endl;
         }
       } else {
 
-        indent(out) <<
-          "$xfer += $input->";
+        indent(out) << "$xfer += $input->";
 
         if (type->is_base_type()) {
           t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
           switch (tbase) {
           case t_base_type::TYPE_VOID:
-            throw "compiler error: cannot serialize void field in a struct: " +
-              name;
+            throw "compiler error: cannot serialize void field in a struct: " + name;
             break;
           case t_base_type::TYPE_STRING:
             out << "readString($" << name << ");";
@@ -2018,7 +1837,8 @@ void t_php_generator::generate_deserialize_field(ofstream &out,
       }
     } else {
       printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-             tfield->get_name().c_str(), type->get_name().c_str());
+             tfield->get_name().c_str(),
+             type->get_name().c_str());
     }
   }
 }
@@ -2029,17 +1849,13 @@ void t_php_generator::generate_deserialize_field(ofstream &out,
  * buffer for deserialization, and that there is a variable protocol which
  * is a reference to a TProtocol serialization object.
  */
-void t_php_generator::generate_deserialize_struct(ofstream &out,
-                                                  t_struct* tstruct,
-                                                  string prefix) {
-  out <<
-    indent() << "$" << prefix << " = new " << php_namespace(tstruct->get_program()) << tstruct->get_name() << "();" << endl <<
-    indent() << "$xfer += $" << prefix << "->read($input);" << endl;
+void t_php_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  out << indent() << "$" << prefix << " = new " << php_namespace(tstruct->get_program())
+      << ts

<TRUNCATED>

[05/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index af7240a..ea85bfb 100644
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -46,24 +46,26 @@
 #include <thrift/transport/PlatformSocket.h>
 
 #ifndef SOCKOPT_CAST_T
-#   ifndef _WIN32
-#       define SOCKOPT_CAST_T void
-#   else
-#       define SOCKOPT_CAST_T char
-#   endif // _WIN32
+#ifndef _WIN32
+#define SOCKOPT_CAST_T void
+#else
+#define SOCKOPT_CAST_T char
+#endif // _WIN32
 #endif
 
-template<class T>
+template <class T>
 inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) {
-    return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
+  return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
 }
 
-template<class T>
+template <class T>
 inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
-    return reinterpret_cast<SOCKOPT_CAST_T*>(v);
+  return reinterpret_cast<SOCKOPT_CAST_T*>(v);
 }
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
@@ -75,66 +77,66 @@ uint32_t g_socket_syscalls = 0;
  *
  */
 
-TSocket::TSocket(string host, int port) :
-  host_(host),
-  port_(port),
-  path_(""),
-  socket_(THRIFT_INVALID_SOCKET),
-  connTimeout_(0),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  keepAlive_(false),
-  lingerOn_(1),
-  lingerVal_(0),
-  noDelay_(1),
-  maxRecvRetries_(5) {
-}
-
-TSocket::TSocket(string path) :
-  host_(""),
-  port_(0),
-  path_(path),
-  socket_(THRIFT_INVALID_SOCKET),
-  connTimeout_(0),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  keepAlive_(false),
-  lingerOn_(1),
-  lingerVal_(0),
-  noDelay_(1),
-  maxRecvRetries_(5) {
+TSocket::TSocket(string host, int port)
+  : host_(host),
+    port_(port),
+    path_(""),
+    socket_(THRIFT_INVALID_SOCKET),
+    connTimeout_(0),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    keepAlive_(false),
+    lingerOn_(1),
+    lingerVal_(0),
+    noDelay_(1),
+    maxRecvRetries_(5) {
+}
+
+TSocket::TSocket(string path)
+  : host_(""),
+    port_(0),
+    path_(path),
+    socket_(THRIFT_INVALID_SOCKET),
+    connTimeout_(0),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    keepAlive_(false),
+    lingerOn_(1),
+    lingerVal_(0),
+    noDelay_(1),
+    maxRecvRetries_(5) {
   cachedPeerAddr_.ipv4.sin_family = AF_UNSPEC;
 }
 
-TSocket::TSocket() :
-  host_(""),
-  port_(0),
-  path_(""),
-  socket_(THRIFT_INVALID_SOCKET),
-  connTimeout_(0),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  keepAlive_(false),
-  lingerOn_(1),
-  lingerVal_(0),
-  noDelay_(1),
-  maxRecvRetries_(5) {
+TSocket::TSocket()
+  : host_(""),
+    port_(0),
+    path_(""),
+    socket_(THRIFT_INVALID_SOCKET),
+    connTimeout_(0),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    keepAlive_(false),
+    lingerOn_(1),
+    lingerVal_(0),
+    noDelay_(1),
+    maxRecvRetries_(5) {
   cachedPeerAddr_.ipv4.sin_family = AF_UNSPEC;
 }
 
-TSocket::TSocket(THRIFT_SOCKET socket) :
-  host_(""),
-  port_(0),
-  path_(""),
-  socket_(socket),
-  connTimeout_(0),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  keepAlive_(false),
-  lingerOn_(1),
-  lingerVal_(0),
-  noDelay_(1),
-  maxRecvRetries_(5) {
+TSocket::TSocket(THRIFT_SOCKET socket)
+  : host_(""),
+    port_(0),
+    path_(""),
+    socket_(socket),
+    connTimeout_(0),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    keepAlive_(false),
+    lingerOn_(1),
+    lingerVal_(0),
+    noDelay_(1),
+    maxRecvRetries_(5) {
   cachedPeerAddr_.ipv4.sin_family = AF_UNSPEC;
 #ifdef SO_NOSIGPIPE
   {
@@ -160,30 +162,29 @@ bool TSocket::peek() {
   int r = static_cast<int>(recv(socket_, cast_sockopt(&buf), 1, MSG_PEEK));
   if (r == -1) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
-    #if defined __FreeBSD__ || defined __MACH__
+#if defined __FreeBSD__ || defined __MACH__
     /* shigin:
      * freebsd returns -1 and THRIFT_ECONNRESET if socket was closed by
      * the other side
      */
-    if (errno_copy == THRIFT_ECONNRESET)
-    {
+    if (errno_copy == THRIFT_ECONNRESET) {
       close();
       return false;
     }
-    #endif
+#endif
     GlobalOutput.perror("TSocket::peek() recv() " + getSocketInfo(), errno_copy);
     throw TTransportException(TTransportException::UNKNOWN, "recv()", errno_copy);
   }
   return (r > 0);
 }
 
-void TSocket::openConnection(struct addrinfo *res) {
+void TSocket::openConnection(struct addrinfo* res) {
 
   if (isOpen()) {
     return;
   }
 
-  if (! path_.empty()) {
+  if (!path_.empty()) {
     socket_ = socket(PF_UNIX, SOCK_STREAM, IPPROTO_IP);
   } else {
     socket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -205,7 +206,7 @@ void TSocket::openConnection(struct addrinfo *res) {
     setRecvTimeout(recvTimeout_);
   }
 
-  if(keepAlive_) {
+  if (keepAlive_) {
     setKeepAlive(keepAlive_);
   }
 
@@ -222,7 +223,7 @@ void TSocket::openConnection(struct addrinfo *res) {
   }
 #endif
 
-  // Uses a low min RTO if asked to.
+// Uses a low min RTO if asked to.
 #ifdef TCP_LOW_MIN_RTO
   if (getUseLowMinRto()) {
     int one = 1;
@@ -230,7 +231,6 @@ void TSocket::openConnection(struct addrinfo *res) {
   }
 #endif
 
-
   // Set the socket to be non blocking for connect if a timeout exists
   int flags = THRIFT_FCNTL(socket_, THRIFT_F_GETFL, 0);
   if (connTimeout_ > 0) {
@@ -249,7 +249,7 @@ void TSocket::openConnection(struct addrinfo *res) {
 
   // Connect the socket
   int ret;
-  if (! path_.empty()) {
+  if (!path_.empty()) {
 
 #ifndef _WIN32
     size_t len = path_.size() + 1;
@@ -263,10 +263,11 @@ void TSocket::openConnection(struct addrinfo *res) {
     address.sun_family = AF_UNIX;
     memcpy(address.sun_path, path_.c_str(), len);
     socklen_t structlen = static_cast<socklen_t>(sizeof(address));
-    ret = connect(socket_, (struct sockaddr *) &address, structlen);
+    ret = connect(socket_, (struct sockaddr*)&address, structlen);
 #else
-      GlobalOutput.perror("TSocket::open() Unix Domain socket path not supported on windows", -99);
-      throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path not supported");
+    GlobalOutput.perror("TSocket::open() Unix Domain socket path not supported on windows", -99);
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              " Unix Domain socket path not supported");
 #endif
 
   } else {
@@ -278,15 +279,15 @@ void TSocket::openConnection(struct addrinfo *res) {
     goto done;
   }
 
-  if ((THRIFT_GET_SOCKET_ERROR != THRIFT_EINPROGRESS) && (THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK)) {
+  if ((THRIFT_GET_SOCKET_ERROR != THRIFT_EINPROGRESS)
+      && (THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK)) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
     GlobalOutput.perror("TSocket::open() connect() " + getSocketInfo(), errno_copy);
     throw TTransportException(TTransportException::NOT_OPEN, "connect() failed", errno_copy);
   }
 
-
   struct THRIFT_POLLFD fds[1];
-  std::memset(fds, 0 , sizeof(fds));
+  std::memset(fds, 0, sizeof(fds));
   fds[0].fd = socket_;
   fds[0].events = THRIFT_POLLOUT;
   ret = THRIFT_POLL(fds, 1, connTimeout_);
@@ -306,7 +307,8 @@ void TSocket::openConnection(struct addrinfo *res) {
     if (val == 0) {
       goto done;
     }
-    GlobalOutput.perror("TSocket::open() error on socket (after THRIFT_POLL) " + getSocketInfo(), val);
+    GlobalOutput.perror("TSocket::open() error on socket (after THRIFT_POLL) " + getSocketInfo(),
+                        val);
     throw TTransportException(TTransportException::NOT_OPEN, "socket open() error", val);
   } else if (ret == 0) {
     // socket timed out
@@ -320,7 +322,7 @@ void TSocket::openConnection(struct addrinfo *res) {
     throw TTransportException(TTransportException::NOT_OPEN, "THRIFT_POLL() failed", errno_copy);
   }
 
- done:
+done:
   // Set socket back to normal mode (blocking)
   THRIFT_FCNTL(socket_, THRIFT_F_SETFL, flags);
 
@@ -333,24 +335,24 @@ void TSocket::open() {
   if (isOpen()) {
     return;
   }
-  if (! path_.empty()) {
+  if (!path_.empty()) {
     unix_open();
   } else {
     local_open();
   }
 }
 
-void TSocket::unix_open(){
-  if (! path_.empty()) {
+void TSocket::unix_open() {
+  if (!path_.empty()) {
     // Unix Domain SOcket does not need addrinfo struct, so we pass NULL
     openConnection(NULL);
   }
 }
 
-void TSocket::local_open(){
+void TSocket::local_open() {
 
 #ifdef _WIN32
-    TWinsockSingleton::create();
+  TWinsockSingleton::create();
 #endif // _WIN32
 
   if (isOpen()) {
@@ -383,10 +385,12 @@ void TSocket::local_open(){
 #endif
 
   if (error) {
-    string errStr = "TSocket::open() getaddrinfo() " + getSocketInfo() + string(THRIFT_GAI_STRERROR(error));
+    string errStr = "TSocket::open() getaddrinfo() " + getSocketInfo()
+                    + string(THRIFT_GAI_STRERROR(error));
     GlobalOutput(errStr.c_str());
     close();
-    throw TTransportException(TTransportException::NOT_OPEN, "Could not resolve host for client socket.");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "Could not resolve host for client socket.");
   }
 
   // Cycle through all the returned addresses until one
@@ -441,10 +445,10 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
     // if a readTimeout is specified along with a max number of recv retries, then
     // the threshold will ensure that the read timeout is not exceeded even in the
     // case of resource errors
-    eagainThresholdMicros = (recvTimeout_*1000)/ ((maxRecvRetries_>0) ? maxRecvRetries_ : 2);
+    eagainThresholdMicros = (recvTimeout_ * 1000) / ((maxRecvRetries_ > 0) ? maxRecvRetries_ : 2);
   }
 
- try_again:
+try_again:
   // Read from the socket
   struct timeval begin;
   if (recvTimeout_ > 0) {
@@ -455,7 +459,8 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
     begin.tv_sec = begin.tv_usec = 0;
   }
   int got = static_cast<int>(recv(socket_, cast_sockopt(buf), len, 0));
-  int errno_copy = THRIFT_GET_SOCKET_ERROR; //THRIFT_GETTIMEOFDAY can change THRIFT_GET_SOCKET_ERROR
+  int errno_copy = THRIFT_GET_SOCKET_ERROR; // THRIFT_GETTIMEOFDAY can change
+                                            // THRIFT_GET_SOCKET_ERROR
   ++g_socket_syscalls;
 
   // Check for error on read
@@ -464,14 +469,14 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
       // if no timeout we can assume that resource exhaustion has occurred.
       if (recvTimeout_ == 0) {
         throw TTransportException(TTransportException::TIMED_OUT,
-                                    "THRIFT_EAGAIN (unavailable resources)");
+                                  "THRIFT_EAGAIN (unavailable resources)");
       }
       // check if this is the lack of resources or timeout case
       struct timeval end;
       THRIFT_GETTIMEOFDAY(&end, NULL);
-      uint32_t readElapsedMicros =  static_cast<uint32_t>(
-         ((end.tv_sec - begin.tv_sec) * 1000 * 1000)
-         + (((uint64_t)(end.tv_usec - begin.tv_usec))));
+      uint32_t readElapsedMicros
+          = static_cast<uint32_t>(((end.tv_sec - begin.tv_sec) * 1000 * 1000)
+                                  + (((uint64_t)(end.tv_usec - begin.tv_usec))));
 
       if (!eagainThresholdMicros || (readElapsedMicros < eagainThresholdMicros)) {
         if (retries++ < maxRecvRetries_) {
@@ -483,8 +488,7 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
         }
       } else {
         // infer that timeout has been hit
-        throw TTransportException(TTransportException::TIMED_OUT,
-                                  "THRIFT_EAGAIN (timed out)");
+        throw TTransportException(TTransportException::TIMED_OUT, "THRIFT_EAGAIN (timed out)");
       }
     }
 
@@ -493,7 +497,7 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
       goto try_again;
     }
 
-    #if defined __FreeBSD__ || defined __MACH__
+#if defined __FreeBSD__ || defined __MACH__
     if (errno_copy == THRIFT_ECONNRESET) {
       /* shigin: freebsd doesn't follow POSIX semantic of recv and fails with
        * THRIFT_ECONNRESET if peer performed shutdown
@@ -501,10 +505,10 @@ uint32_t TSocket::read(uint8_t* buf, uint32_t len) {
        */
       return 0;
     }
-    #endif
+#endif
 
 #ifdef _WIN32
-    if(errno_copy == WSAECONNRESET) {
+    if (errno_copy == WSAECONNRESET) {
       return 0; // EOF
     }
 #endif
@@ -550,8 +554,7 @@ void TSocket::write(const uint8_t* buf, uint32_t len) {
     if (b == 0) {
       // This should only happen if the timeout set with SO_SNDTIMEO expired.
       // Raise an exception.
-      throw TTransportException(TTransportException::TIMED_OUT,
-                                "send timeout expired");
+      throw TTransportException(TTransportException::TIMED_OUT, "send timeout expired");
     }
     sent += b;
   }
@@ -582,7 +585,8 @@ uint32_t TSocket::write_partial(const uint8_t* buf, uint32_t len) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
     GlobalOutput.perror("TSocket::write_partial() send() " + getSocketInfo(), errno_copy);
 
-    if (errno_copy == THRIFT_EPIPE || errno_copy == THRIFT_ECONNRESET || errno_copy == THRIFT_ENOTCONN) {
+    if (errno_copy == THRIFT_EPIPE || errno_copy == THRIFT_ECONNRESET
+        || errno_copy == THRIFT_ENOTCONN) {
       close();
       throw TTransportException(TTransportException::NOT_OPEN, "write() send()", errno_copy);
     }
@@ -628,7 +632,8 @@ void TSocket::setLinger(bool on, int linger) {
 
   int ret = setsockopt(socket_, SOL_SOCKET, SO_LINGER, cast_sockopt(&l), sizeof(l));
   if (ret == -1) {
-    int errno_copy = THRIFT_GET_SOCKET_ERROR;  // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
+    int errno_copy
+        = THRIFT_GET_SOCKET_ERROR; // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
     GlobalOutput.perror("TSocket::setLinger() setsockopt() " + getSocketInfo(), errno_copy);
   }
 }
@@ -643,7 +648,8 @@ void TSocket::setNoDelay(bool noDelay) {
   int v = noDelay_ ? 1 : 0;
   int ret = setsockopt(socket_, IPPROTO_TCP, TCP_NODELAY, cast_sockopt(&v), sizeof(v));
   if (ret == -1) {
-    int errno_copy = THRIFT_GET_SOCKET_ERROR;  // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
+    int errno_copy
+        = THRIFT_GET_SOCKET_ERROR; // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
     GlobalOutput.perror("TSocket::setNoDelay() setsockopt() " + getSocketInfo(), errno_copy);
   }
 }
@@ -652,8 +658,7 @@ void TSocket::setConnTimeout(int ms) {
   connTimeout_ = ms;
 }
 
-void setGenericTimeout(THRIFT_SOCKET s, int timeout_ms, int optname)
-{
+void setGenericTimeout(THRIFT_SOCKET s, int timeout_ms, int optname) {
   if (timeout_ms < 0) {
     char errBuf[512];
     sprintf(errBuf, "TSocket::setGenericTimeout with negative input: %d\n", timeout_ms);
@@ -665,17 +670,16 @@ void setGenericTimeout(THRIFT_SOCKET s, int timeout_ms, int optname)
     return;
   }
 
-  #ifdef _WIN32
+#ifdef _WIN32
   DWORD platform_time = static_cast<DWORD>(timeout_ms);
-  #else
-  struct timeval platform_time = {
-    (int)(timeout_ms/1000),
-    (int)((timeout_ms%1000)*1000)};
-  #endif
+#else
+  struct timeval platform_time = {(int)(timeout_ms / 1000), (int)((timeout_ms % 1000) * 1000)};
+#endif
 
   int ret = setsockopt(s, SOL_SOCKET, optname, cast_sockopt(&platform_time), sizeof(platform_time));
   if (ret == -1) {
-    int errno_copy = THRIFT_GET_SOCKET_ERROR;  // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
+    int errno_copy
+        = THRIFT_GET_SOCKET_ERROR; // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
     GlobalOutput.perror("TSocket::setGenericTimeout() setsockopt() ", errno_copy);
   }
 }
@@ -698,10 +702,12 @@ void TSocket::setKeepAlive(bool keepAlive) {
   }
 
   int value = keepAlive_;
-  int ret = setsockopt(socket_, SOL_SOCKET, SO_KEEPALIVE, const_cast_sockopt(&value), sizeof(value));
+  int ret
+      = setsockopt(socket_, SOL_SOCKET, SO_KEEPALIVE, const_cast_sockopt(&value), sizeof(value));
 
   if (ret == -1) {
-    int errno_copy = THRIFT_GET_SOCKET_ERROR;  // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
+    int errno_copy
+        = THRIFT_GET_SOCKET_ERROR; // Copy THRIFT_GET_SOCKET_ERROR because we're allocating memory.
     GlobalOutput.perror("TSocket::setKeepAlive() setsockopt() " + getSocketInfo(), errno_copy);
   }
 }
@@ -735,7 +741,7 @@ std::string TSocket::getPeerHost() {
 
     if (addrPtr == NULL) {
       addrLen = sizeof(addr);
-      if (getpeername(socket_, (sockaddr*) &addr, &addrLen) != 0) {
+      if (getpeername(socket_, (sockaddr*)&addr, &addrLen) != 0) {
         return peerHost_;
       }
       addrPtr = (sockaddr*)&addr;
@@ -746,9 +752,13 @@ std::string TSocket::getPeerHost() {
     char clienthost[NI_MAXHOST];
     char clientservice[NI_MAXSERV];
 
-    getnameinfo((sockaddr*) addrPtr, addrLen,
-                clienthost, sizeof(clienthost),
-                clientservice, sizeof(clientservice), 0);
+    getnameinfo((sockaddr*)addrPtr,
+                addrLen,
+                clienthost,
+                sizeof(clienthost),
+                clientservice,
+                sizeof(clientservice),
+                0);
 
     peerHost_ = clienthost;
   }
@@ -769,7 +779,7 @@ std::string TSocket::getPeerAddress() {
 
     if (addrPtr == NULL) {
       addrLen = sizeof(addr);
-      if (getpeername(socket_, (sockaddr*) &addr, &addrLen) != 0) {
+      if (getpeername(socket_, (sockaddr*)&addr, &addrLen) != 0) {
         return peerAddress_;
       }
       addrPtr = (sockaddr*)&addr;
@@ -780,10 +790,13 @@ std::string TSocket::getPeerAddress() {
     char clienthost[NI_MAXHOST];
     char clientservice[NI_MAXSERV];
 
-    getnameinfo(addrPtr, addrLen,
-                clienthost, sizeof(clienthost),
-                clientservice, sizeof(clientservice),
-                NI_NUMERICHOST|NI_NUMERICSERV);
+    getnameinfo(addrPtr,
+                addrLen,
+                clienthost,
+                sizeof(clienthost),
+                clientservice,
+                sizeof(clientservice),
+                NI_NUMERICHOST | NI_NUMERICSERV);
 
     peerAddress_ = clienthost;
     peerPort_ = std::atoi(clientservice);
@@ -820,11 +833,11 @@ sockaddr* TSocket::getCachedAddress(socklen_t* len) const {
   switch (cachedPeerAddr_.ipv4.sin_family) {
   case AF_INET:
     *len = sizeof(sockaddr_in);
-    return (sockaddr*) &cachedPeerAddr_.ipv4;
+    return (sockaddr*)&cachedPeerAddr_.ipv4;
 
   case AF_INET6:
     *len = sizeof(sockaddr_in6);
-    return (sockaddr*) &cachedPeerAddr_.ipv6;
+    return (sockaddr*)&cachedPeerAddr_.ipv6;
 
   default:
     return NULL;
@@ -844,5 +857,6 @@ const std::string TSocket::getOrigin() {
   oss << getPeerHost() << ":" << getPeerPort();
   return oss.str();
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSocket.h b/lib/cpp/src/thrift/transport/TSocket.h
index c873218..38bd789 100644
--- a/lib/cpp/src/thrift/transport/TSocket.h
+++ b/lib/cpp/src/thrift/transport/TSocket.h
@@ -37,14 +37,16 @@
 #include <netdb.h>
 #endif
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * TCP Socket implementation of the TTransport interface.
  *
  */
 class TSocket : public TVirtualTransport<TSocket> {
- public:
+public:
   /**
    * Constructs a new socket. Note that this does NOT actually connect the
    * socket.
@@ -206,9 +208,7 @@ class TSocket : public TVirtualTransport<TSocket> {
   /**
    * Returns the underlying socket file descriptor.
    */
-  THRIFT_SOCKET getSocketFD() {
-    return socket_;
-  }
+  THRIFT_SOCKET getSocketFD() { return socket_; }
 
   /**
    * (Re-)initialize a TSocket for the supplied descriptor.  This is only
@@ -252,9 +252,9 @@ class TSocket : public TVirtualTransport<TSocket> {
    */
   void setCachedAddress(const sockaddr* addr, socklen_t len);
 
- protected:
+protected:
   /** connect, called by open */
-  void openConnection(struct addrinfo *res);
+  void openConnection(struct addrinfo* res);
 
   /** Host to connect to */
   std::string host_;
@@ -310,12 +310,12 @@ class TSocket : public TVirtualTransport<TSocket> {
   /** Whether to use low minimum TCP retransmission timeout */
   static bool useLowMinRto_;
 
- private:
+private:
   void unix_open();
   void local_open();
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSOCKET_H_
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSocketPool.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSocketPool.cpp b/lib/cpp/src/thrift/transport/TSocketPool.cpp
index e0b286a..ccab258 100644
--- a/lib/cpp/src/thrift/transport/TSocketPool.cpp
+++ b/lib/cpp/src/thrift/transport/TSocketPool.cpp
@@ -24,7 +24,9 @@
 
 #include <thrift/transport/TSocketPool.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
@@ -35,43 +37,41 @@ using boost::shared_ptr;
  *
  */
 TSocketPoolServer::TSocketPoolServer()
-  : host_(""),
-    port_(0),
-    socket_(THRIFT_INVALID_SOCKET),
-    lastFailTime_(0),
-    consecutiveFailures_(0) {}
+  : host_(""), port_(0), socket_(THRIFT_INVALID_SOCKET), lastFailTime_(0), consecutiveFailures_(0) {
+}
 
 /**
  * Constructor for TSocketPool server
  */
-TSocketPoolServer::TSocketPoolServer(const string &host, int port)
+TSocketPoolServer::TSocketPoolServer(const string& host, int port)
   : host_(host),
     port_(port),
     socket_(THRIFT_INVALID_SOCKET),
     lastFailTime_(0),
-    consecutiveFailures_(0) {}
+    consecutiveFailures_(0) {
+}
 
 /**
  * TSocketPool implementation.
  *
  */
 
-TSocketPool::TSocketPool() : TSocket(),
-  numRetries_(1),
-  retryInterval_(60),
-  maxConsecutiveFailures_(1),
-  randomize_(true),
-  alwaysTryLast_(true) {
-}
-
-TSocketPool::TSocketPool(const vector<string> &hosts,
-                         const vector<int> &ports) : TSocket(),
-  numRetries_(1),
-  retryInterval_(60),
-  maxConsecutiveFailures_(1),
-  randomize_(true),
-  alwaysTryLast_(true)
-{
+TSocketPool::TSocketPool()
+  : TSocket(),
+    numRetries_(1),
+    retryInterval_(60),
+    maxConsecutiveFailures_(1),
+    randomize_(true),
+    alwaysTryLast_(true) {
+}
+
+TSocketPool::TSocketPool(const vector<string>& hosts, const vector<int>& ports)
+  : TSocket(),
+    numRetries_(1),
+    retryInterval_(60),
+    maxConsecutiveFailures_(1),
+    randomize_(true),
+    alwaysTryLast_(true) {
   if (hosts.size() != ports.size()) {
     GlobalOutput("TSocketPool::TSocketPool: hosts.size != ports.size");
     throw TTransportException(TTransportException::BAD_ARGS);
@@ -82,41 +82,41 @@ TSocketPool::TSocketPool(const vector<string> &hosts,
   }
 }
 
-TSocketPool::TSocketPool(const vector<pair<string, int> >& servers) : TSocket(),
-  numRetries_(1),
-  retryInterval_(60),
-  maxConsecutiveFailures_(1),
-  randomize_(true),
-  alwaysTryLast_(true)
-{
+TSocketPool::TSocketPool(const vector<pair<string, int> >& servers)
+  : TSocket(),
+    numRetries_(1),
+    retryInterval_(60),
+    maxConsecutiveFailures_(1),
+    randomize_(true),
+    alwaysTryLast_(true) {
   for (unsigned i = 0; i < servers.size(); ++i) {
     addServer(servers[i].first, servers[i].second);
   }
 }
 
-TSocketPool::TSocketPool(const vector< shared_ptr<TSocketPoolServer> >& servers) : TSocket(),
-  servers_(servers),
-  numRetries_(1),
-  retryInterval_(60),
-  maxConsecutiveFailures_(1),
-  randomize_(true),
-  alwaysTryLast_(true)
-{
+TSocketPool::TSocketPool(const vector<shared_ptr<TSocketPoolServer> >& servers)
+  : TSocket(),
+    servers_(servers),
+    numRetries_(1),
+    retryInterval_(60),
+    maxConsecutiveFailures_(1),
+    randomize_(true),
+    alwaysTryLast_(true) {
 }
 
-TSocketPool::TSocketPool(const string& host, int port) : TSocket(),
-  numRetries_(1),
-  retryInterval_(60),
-  maxConsecutiveFailures_(1),
-  randomize_(true),
-  alwaysTryLast_(true)
-{
+TSocketPool::TSocketPool(const string& host, int port)
+  : TSocket(),
+    numRetries_(1),
+    retryInterval_(60),
+    maxConsecutiveFailures_(1),
+    randomize_(true),
+    alwaysTryLast_(true) {
   addServer(host, port);
 }
 
 TSocketPool::~TSocketPool() {
-  vector< shared_ptr<TSocketPoolServer> >::const_iterator iter = servers_.begin();
-  vector< shared_ptr<TSocketPoolServer> >::const_iterator iterEnd = servers_.end();
+  vector<shared_ptr<TSocketPoolServer> >::const_iterator iter = servers_.begin();
+  vector<shared_ptr<TSocketPoolServer> >::const_iterator iterEnd = servers_.end();
   for (; iter != iterEnd; ++iter) {
     setCurrentServer(*iter);
     TSocketPool::close();
@@ -127,17 +127,17 @@ void TSocketPool::addServer(const string& host, int port) {
   servers_.push_back(shared_ptr<TSocketPoolServer>(new TSocketPoolServer(host, port)));
 }
 
-void TSocketPool::addServer(shared_ptr<TSocketPoolServer> &server) {
+void TSocketPool::addServer(shared_ptr<TSocketPoolServer>& server) {
   if (server) {
     servers_.push_back(server);
   }
 }
 
-void TSocketPool::setServers(const vector< shared_ptr<TSocketPoolServer> >& servers) {
+void TSocketPool::setServers(const vector<shared_ptr<TSocketPoolServer> >& servers) {
   servers_ = servers;
 }
 
-void TSocketPool::getServers(vector< shared_ptr<TSocketPoolServer> >& servers) {
+void TSocketPool::getServers(vector<shared_ptr<TSocketPoolServer> >& servers) {
   servers = servers_;
 }
 
@@ -149,7 +149,6 @@ void TSocketPool::setRetryInterval(int retryInterval) {
   retryInterval_ = retryInterval;
 }
 
-
 void TSocketPool::setMaxConsecutiveFailures(int maxConsecutiveFailures) {
   maxConsecutiveFailures_ = maxConsecutiveFailures;
 }
@@ -162,7 +161,7 @@ void TSocketPool::setAlwaysTryLast(bool alwaysTryLast) {
   alwaysTryLast_ = alwaysTryLast;
 }
 
-void TSocketPool::setCurrentServer(const shared_ptr<TSocketPoolServer> &server) {
+void TSocketPool::setCurrentServer(const shared_ptr<TSocketPoolServer>& server) {
   currentServer_ = server;
   host_ = server->host_;
   port_ = server->port_;
@@ -192,7 +191,7 @@ void TSocketPool::open() {
 
   for (size_t i = 0; i < numServers; ++i) {
 
-    shared_ptr<TSocketPoolServer> &server = servers_[i];
+    shared_ptr<TSocketPoolServer>& server = servers_[i];
     // Impersonate the server socket
     setCurrentServer(server);
 
@@ -217,7 +216,7 @@ void TSocketPool::open() {
         try {
           TSocket::open();
         } catch (TException e) {
-          string errStr = "TSocketPool::open failed "+getSocketInfo()+": "+e.what();
+          string errStr = "TSocketPool::open failed " + getSocketInfo() + ": " + e.what();
           GlobalOutput(errStr.c_str());
           socket_ = THRIFT_INVALID_SOCKET;
           continue;
@@ -250,5 +249,6 @@ void TSocketPool::close() {
     currentServer_->socket_ = THRIFT_INVALID_SOCKET;
   }
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSocketPool.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSocketPool.h b/lib/cpp/src/thrift/transport/TSocketPool.h
index 7728257..78f0ebf 100644
--- a/lib/cpp/src/thrift/transport/TSocketPool.h
+++ b/lib/cpp/src/thrift/transport/TSocketPool.h
@@ -23,15 +23,17 @@
 #include <vector>
 #include <thrift/transport/TSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
- /**
-  * Class to hold server information for TSocketPool
-  *
-  */
+/**
+ * Class to hold server information for TSocketPool
+ *
+ */
 class TSocketPoolServer {
 
-  public:
+public:
   /**
    * Default constructor for server info
    */
@@ -40,7 +42,7 @@ class TSocketPoolServer {
   /**
    * Constructor for TSocketPool server
    */
-  TSocketPoolServer(const std::string &host, int port);
+  TSocketPoolServer(const std::string& host, int port);
 
   // Host name
   std::string host_;
@@ -64,133 +66,130 @@ class TSocketPoolServer {
  */
 class TSocketPool : public TSocket {
 
- public:
-
-   /**
-    * Socket pool constructor
-    */
-   TSocketPool();
-
-   /**
-    * Socket pool constructor
-    *
-    * @param hosts list of host names
-    * @param ports list of port names
-    */
-   TSocketPool(const std::vector<std::string> &hosts,
-               const std::vector<int> &ports);
-
-   /**
-    * Socket pool constructor
-    *
-    * @param servers list of pairs of host name and port
-    */
-   TSocketPool(const std::vector<std::pair<std::string, int> >& servers);
-
-   /**
-    * Socket pool constructor
-    *
-    * @param servers list of TSocketPoolServers
-    */
-  TSocketPool(const std::vector< boost::shared_ptr<TSocketPoolServer> >& servers);
-
-   /**
-    * Socket pool constructor
-    *
-    * @param host single host
-    * @param port single port
-    */
-   TSocketPool(const std::string& host, int port);
-
-   /**
-    * Destroyes the socket object, closing it if necessary.
-    */
-   virtual ~TSocketPool();
-
-   /**
-    * Add a server to the pool
-    */
-   void addServer(const std::string& host, int port);
-
-   /**
-    * Add a server to the pool
-    */
-  void addServer(boost::shared_ptr<TSocketPoolServer> &server);
-
-   /**
-    * Set list of servers in this pool
-    */
-  void setServers(const std::vector< boost::shared_ptr<TSocketPoolServer> >& servers);
-
-   /**
-    * Get list of servers in this pool
-    */
-  void getServers(std::vector< boost::shared_ptr<TSocketPoolServer> >& servers);
-
-   /**
-    * Sets how many times to keep retrying a host in the connect function.
-    */
-   void setNumRetries(int numRetries);
-
-   /**
-    * Sets how long to wait until retrying a host if it was marked down
-    */
-   void setRetryInterval(int retryInterval);
-
-   /**
-    * Sets how many times to keep retrying a host before marking it as down.
-    */
-   void setMaxConsecutiveFailures(int maxConsecutiveFailures);
-
-   /**
-    * Turns randomization in connect order on or off.
-    */
-   void setRandomize(bool randomize);
-
-   /**
-    * Whether to always try the last server.
-    */
-   void setAlwaysTryLast(bool alwaysTryLast);
-
-   /**
-    * Creates and opens the UNIX socket.
-    */
-   void open();
-
-   /*
-    * Closes the UNIX socket
-    */
-   void close();
-
- protected:
-
-  void setCurrentServer(const boost::shared_ptr<TSocketPoolServer> &server);
-
-   /** List of servers to connect to */
-  std::vector< boost::shared_ptr<TSocketPoolServer> > servers_;
+public:
+  /**
+   * Socket pool constructor
+   */
+  TSocketPool();
+
+  /**
+   * Socket pool constructor
+   *
+   * @param hosts list of host names
+   * @param ports list of port names
+   */
+  TSocketPool(const std::vector<std::string>& hosts, const std::vector<int>& ports);
+
+  /**
+   * Socket pool constructor
+   *
+   * @param servers list of pairs of host name and port
+   */
+  TSocketPool(const std::vector<std::pair<std::string, int> >& servers);
+
+  /**
+   * Socket pool constructor
+   *
+   * @param servers list of TSocketPoolServers
+   */
+  TSocketPool(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers);
+
+  /**
+   * Socket pool constructor
+   *
+   * @param host single host
+   * @param port single port
+   */
+  TSocketPool(const std::string& host, int port);
+
+  /**
+   * Destroyes the socket object, closing it if necessary.
+   */
+  virtual ~TSocketPool();
+
+  /**
+   * Add a server to the pool
+   */
+  void addServer(const std::string& host, int port);
+
+  /**
+   * Add a server to the pool
+   */
+  void addServer(boost::shared_ptr<TSocketPoolServer>& server);
+
+  /**
+   * Set list of servers in this pool
+   */
+  void setServers(const std::vector<boost::shared_ptr<TSocketPoolServer> >& servers);
+
+  /**
+   * Get list of servers in this pool
+   */
+  void getServers(std::vector<boost::shared_ptr<TSocketPoolServer> >& servers);
+
+  /**
+   * Sets how many times to keep retrying a host in the connect function.
+   */
+  void setNumRetries(int numRetries);
+
+  /**
+   * Sets how long to wait until retrying a host if it was marked down
+   */
+  void setRetryInterval(int retryInterval);
+
+  /**
+   * Sets how many times to keep retrying a host before marking it as down.
+   */
+  void setMaxConsecutiveFailures(int maxConsecutiveFailures);
+
+  /**
+   * Turns randomization in connect order on or off.
+   */
+  void setRandomize(bool randomize);
+
+  /**
+   * Whether to always try the last server.
+   */
+  void setAlwaysTryLast(bool alwaysTryLast);
+
+  /**
+   * Creates and opens the UNIX socket.
+   */
+  void open();
+
+  /*
+   * Closes the UNIX socket
+   */
+  void close();
+
+protected:
+  void setCurrentServer(const boost::shared_ptr<TSocketPoolServer>& server);
+
+  /** List of servers to connect to */
+  std::vector<boost::shared_ptr<TSocketPoolServer> > servers_;
 
   /** Current server */
   boost::shared_ptr<TSocketPoolServer> currentServer_;
 
-   /** How many times to retry each host in connect */
-   int numRetries_;
+  /** How many times to retry each host in connect */
+  int numRetries_;
 
-   /** Retry interval in seconds, how long to not try a host if it has been
-    * marked as down.
-    */
-   time_t retryInterval_;
+  /** Retry interval in seconds, how long to not try a host if it has been
+   * marked as down.
+   */
+  time_t retryInterval_;
 
-   /** Max consecutive failures before marking a host down. */
-   int maxConsecutiveFailures_;
+  /** Max consecutive failures before marking a host down. */
+  int maxConsecutiveFailures_;
 
-   /** Try hosts in order? or Randomized? */
-   bool randomize_;
+  /** Try hosts in order? or Randomized? */
+  bool randomize_;
 
-   /** Always try last host, even if marked down? */
-   bool alwaysTryLast_;
+  /** Always try last host, even if marked down? */
+  bool alwaysTryLast_;
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSOCKETPOOL_H_
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h
index 6e9a698..d06b0f8 100644
--- a/lib/cpp/src/thrift/transport/TTransport.h
+++ b/lib/cpp/src/thrift/transport/TTransport.h
@@ -25,21 +25,22 @@
 #include <thrift/transport/TTransportException.h>
 #include <string>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Helper template to hoist readAll implementation out of TTransport
  */
 template <class Transport_>
-uint32_t readAll(Transport_ &trans, uint8_t* buf, uint32_t len) {
+uint32_t readAll(Transport_& trans, uint8_t* buf, uint32_t len) {
   uint32_t have = 0;
   uint32_t get = 0;
 
   while (have < len) {
-    get = trans.read(buf+have, len-have);
+    get = trans.read(buf + have, len - have);
     if (get <= 0) {
-      throw TTransportException(TTransportException::END_OF_FILE,
-                                "No more data to read.");
+      throw TTransportException(TTransportException::END_OF_FILE, "No more data to read.");
     }
     have += get;
   }
@@ -47,14 +48,13 @@ uint32_t readAll(Transport_ &trans, uint8_t* buf, uint32_t len) {
   return have;
 }
 
-
 /**
  * Generic interface for a method of transporting data. A TTransport may be
  * capable of either reading or writing, but not necessarily both.
  *
  */
 class TTransport {
- public:
+public:
   /**
    * Virtual deconstructor.
    */
@@ -63,9 +63,7 @@ class TTransport {
   /**
    * Whether this transport is open.
    */
-  virtual bool isOpen() {
-    return false;
-  }
+  virtual bool isOpen() { return false; }
 
   /**
    * Tests whether there is more data to read or if the remote side is
@@ -75,9 +73,7 @@ class TTransport {
    * This is used by a server to check if it should listen for another
    * request.
    */
-  virtual bool peek() {
-    return isOpen();
-  }
+  virtual bool peek() { return isOpen(); }
 
   /**
    * Opens the transport for communications.
@@ -109,8 +105,7 @@ class TTransport {
     return read_virt(buf, len);
   }
   virtual uint32_t read_virt(uint8_t* /* buf */, uint32_t /* len */) {
-    throw TTransportException(TTransportException::NOT_OPEN,
-                              "Base TTransport cannot read.");
+    throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot read.");
   }
 
   /**
@@ -158,8 +153,7 @@ class TTransport {
     write_virt(buf, len);
   }
   virtual void write_virt(const uint8_t* /* buf */, uint32_t /* len */) {
-    throw TTransportException(TTransportException::NOT_OPEN,
-                              "Base TTransport cannot write.");
+    throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot write.");
   }
 
   /**
@@ -215,9 +209,7 @@ class TTransport {
     T_VIRTUAL_CALL();
     return borrow_virt(buf, len);
   }
-  virtual const uint8_t* borrow_virt(uint8_t* /* buf */, uint32_t* /* len */) {
-    return NULL;
-  }
+  virtual const uint8_t* borrow_virt(uint8_t* /* buf */, uint32_t* /* len */) { return NULL; }
 
   /**
    * Remove len bytes from the transport.  This should always follow a borrow
@@ -233,8 +225,7 @@ class TTransport {
     consume_virt(len);
   }
   virtual void consume_virt(uint32_t /* len */) {
-    throw TTransportException(TTransportException::NOT_OPEN,
-                              "Base TTransport cannot consume.");
+    throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot consume.");
   }
 
   /**
@@ -245,11 +236,9 @@ class TTransport {
    *
    * The returned value can be used in a log message for example
    */
-  virtual const std::string getOrigin() {
-    return "Unknown";
-  }
+  virtual const std::string getOrigin() { return "Unknown"; }
 
- protected:
+protected:
   /**
    * Simple constructor.
    */
@@ -263,7 +252,7 @@ class TTransport {
  *
  */
 class TTransportFactory {
- public:
+public:
   TTransportFactory() {}
 
   virtual ~TTransportFactory() {}
@@ -274,9 +263,9 @@ class TTransportFactory {
   virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
     return trans;
   }
-
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TTransportException.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TTransportException.cpp b/lib/cpp/src/thrift/transport/TTransportException.cpp
index 2b1430c..612e7b7 100644
--- a/lib/cpp/src/thrift/transport/TTransportException.cpp
+++ b/lib/cpp/src/thrift/transport/TTransportException.cpp
@@ -26,25 +26,36 @@
 using std::string;
 using boost::lexical_cast;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
-  const char* TTransportException::what() const throw() {
-    if (message_.empty()) {
-      switch (type_) {
-        case UNKNOWN        : return "TTransportException: Unknown transport exception";
-        case NOT_OPEN       : return "TTransportException: Transport not open";
-        case TIMED_OUT      : return "TTransportException: Timed out";
-        case END_OF_FILE    : return "TTransportException: End of file";
-        case INTERRUPTED    : return "TTransportException: Interrupted";
-        case BAD_ARGS       : return "TTransportException: Invalid arguments";
-        case CORRUPTED_DATA : return "TTransportException: Corrupted Data";
-        case INTERNAL_ERROR : return "TTransportException: Internal error";
-        default             : return "TTransportException: (Invalid exception type)";
-      }
-    } else {
-      return message_.c_str();
+const char* TTransportException::what() const throw() {
+  if (message_.empty()) {
+    switch (type_) {
+    case UNKNOWN:
+      return "TTransportException: Unknown transport exception";
+    case NOT_OPEN:
+      return "TTransportException: Transport not open";
+    case TIMED_OUT:
+      return "TTransportException: Timed out";
+    case END_OF_FILE:
+      return "TTransportException: End of file";
+    case INTERRUPTED:
+      return "TTransportException: Interrupted";
+    case BAD_ARGS:
+      return "TTransportException: Invalid arguments";
+    case CORRUPTED_DATA:
+      return "TTransportException: Corrupted Data";
+    case INTERNAL_ERROR:
+      return "TTransportException: Internal error";
+    default:
+      return "TTransportException: (Invalid exception type)";
     }
+  } else {
+    return message_.c_str();
   }
-
-
-}}} // apache::thrift::transport
+}
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TTransportException.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TTransportException.h b/lib/cpp/src/thrift/transport/TTransportException.h
index 8558837..83e876a 100644
--- a/lib/cpp/src/thrift/transport/TTransportException.h
+++ b/lib/cpp/src/thrift/transport/TTransportException.h
@@ -23,7 +23,9 @@
 #include <string>
 #include <thrift/Thrift.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Class to encapsulate all the possible types of transport errors that may
@@ -34,42 +36,33 @@ namespace apache { namespace thrift { namespace transport {
  *
  */
 class TTransportException : public apache::thrift::TException {
- public:
+public:
   /**
    * Error codes for the various types of exceptions.
    */
-  enum TTransportExceptionType
-  { UNKNOWN = 0
-  , NOT_OPEN = 1
-  , TIMED_OUT = 2
-  , END_OF_FILE = 3
-  , INTERRUPTED = 4
-  , BAD_ARGS = 5
-  , CORRUPTED_DATA = 6
-  , INTERNAL_ERROR = 7
+  enum TTransportExceptionType {
+    UNKNOWN = 0,
+    NOT_OPEN = 1,
+    TIMED_OUT = 2,
+    END_OF_FILE = 3,
+    INTERRUPTED = 4,
+    BAD_ARGS = 5,
+    CORRUPTED_DATA = 6,
+    INTERNAL_ERROR = 7
   };
 
-  TTransportException() :
-    apache::thrift::TException(),
-    type_(UNKNOWN) {}
+  TTransportException() : apache::thrift::TException(), type_(UNKNOWN) {}
 
-  TTransportException(TTransportExceptionType type) :
-    apache::thrift::TException(),
-    type_(type) {}
+  TTransportException(TTransportExceptionType type) : apache::thrift::TException(), type_(type) {}
 
-  TTransportException(const std::string& message) :
-    apache::thrift::TException(message),
-    type_(UNKNOWN) {}
+  TTransportException(const std::string& message)
+    : apache::thrift::TException(message), type_(UNKNOWN) {}
 
-  TTransportException(TTransportExceptionType type, const std::string& message) :
-    apache::thrift::TException(message),
-    type_(type) {}
+  TTransportException(TTransportExceptionType type, const std::string& message)
+    : apache::thrift::TException(message), type_(type) {}
 
-  TTransportException(TTransportExceptionType type,
-                      const std::string& message,
-                      int errno_copy) :
-    apache::thrift::TException(message + ": " + TOutput::strerror_s(errno_copy)),
-    type_(type) {}
+  TTransportException(TTransportExceptionType type, const std::string& message, int errno_copy)
+    : apache::thrift::TException(message + ": " + TOutput::strerror_s(errno_copy)), type_(type) {}
 
   virtual ~TTransportException() throw() {}
 
@@ -79,21 +72,19 @@ class TTransportException : public apache::thrift::TException {
    *
    * @return Error code
    */
-  TTransportExceptionType getType() const throw() {
-    return type_;
-  }
+  TTransportExceptionType getType() const throw() { return type_; }
 
   virtual const char* what() const throw();
 
- protected:
+protected:
   /** Just like strerror_r but returns a C++ string object. */
   std::string strerror_s(int errno_copy);
 
   /** Error code */
   TTransportExceptionType type_;
-
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TTRANSPORTEXCEPTION_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TTransportUtils.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.cpp b/lib/cpp/src/thrift/transport/TTransportUtils.cpp
index 44f6101..0f24c95 100644
--- a/lib/cpp/src/thrift/transport/TTransportUtils.cpp
+++ b/lib/cpp/src/thrift/transport/TTransportUtils.cpp
@@ -21,39 +21,40 @@
 
 using std::string;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 uint32_t TPipedTransport::read(uint8_t* buf, uint32_t len) {
   uint32_t need = len;
 
   // We don't have enough data yet
-  if (rLen_-rPos_ < need) {
+  if (rLen_ - rPos_ < need) {
     // Copy out whatever we have
-    if (rLen_-rPos_ > 0) {
-      memcpy(buf, rBuf_+rPos_, rLen_-rPos_);
-      need -= rLen_-rPos_;
-      buf += rLen_-rPos_;
+    if (rLen_ - rPos_ > 0) {
+      memcpy(buf, rBuf_ + rPos_, rLen_ - rPos_);
+      need -= rLen_ - rPos_;
+      buf += rLen_ - rPos_;
       rPos_ = rLen_;
     }
 
     // Double the size of the underlying buffer if it is full
     if (rLen_ == rBufSize_) {
-      rBufSize_ *=2;
-      rBuf_ = (uint8_t *)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
+      rBufSize_ *= 2;
+      rBuf_ = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
     }
 
     // try to fill up the buffer
-    rLen_ += srcTrans_->read(rBuf_+rPos_, rBufSize_ - rPos_);
+    rLen_ += srcTrans_->read(rBuf_ + rPos_, rBufSize_ - rPos_);
   }
 
-
   // Hand over whatever we have
   uint32_t give = need;
-  if (rLen_-rPos_ < give) {
-    give = rLen_-rPos_;
+  if (rLen_ - rPos_ < give) {
+    give = rLen_ - rPos_;
   }
   if (give > 0) {
-    memcpy(buf, rBuf_+rPos_, give);
+    memcpy(buf, rBuf_ + rPos_, give);
     rPos_ += give;
     need -= give;
   }
@@ -68,11 +69,11 @@ void TPipedTransport::write(const uint8_t* buf, uint32_t len) {
 
   // Make the buffer as big as it needs to be
   if ((len + wLen_) >= wBufSize_) {
-    uint32_t newBufSize = wBufSize_*2;
+    uint32_t newBufSize = wBufSize_ * 2;
     while ((len + wLen_) >= newBufSize) {
       newBufSize *= 2;
     }
-    wBuf_ = (uint8_t *)std::realloc(wBuf_, sizeof(uint8_t) * newBufSize);
+    wBuf_ = (uint8_t*)std::realloc(wBuf_, sizeof(uint8_t) * newBufSize);
     wBufSize_ = newBufSize;
   }
 
@@ -81,7 +82,7 @@ void TPipedTransport::write(const uint8_t* buf, uint32_t len) {
   wLen_ += len;
 }
 
-void TPipedTransport::flush()  {
+void TPipedTransport::flush() {
   // Write out any data waiting in the write buffer
   if (wLen_ > 0) {
     srcTrans_->write(wBuf_, wLen_);
@@ -92,9 +93,10 @@ void TPipedTransport::flush()  {
   srcTrans_->flush();
 }
 
-TPipedFileReaderTransport::TPipedFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans, boost::shared_ptr<TTransport> dstTrans)
-  : TPipedTransport(srcTrans, dstTrans),
-    srcTrans_(srcTrans) {
+TPipedFileReaderTransport::TPipedFileReaderTransport(
+    boost::shared_ptr<TFileReaderTransport> srcTrans,
+    boost::shared_ptr<TTransport> dstTrans)
+  : TPipedTransport(srcTrans, dstTrans), srcTrans_(srcTrans) {
 }
 
 TPipedFileReaderTransport::~TPipedFileReaderTransport() {
@@ -125,7 +127,7 @@ uint32_t TPipedFileReaderTransport::readAll(uint8_t* buf, uint32_t len) {
   uint32_t get = 0;
 
   while (have < len) {
-    get = read(buf+have, len-have);
+    get = read(buf + have, len - have);
     if (get <= 0) {
       throw TEOFException();
     }
@@ -174,5 +176,6 @@ void TPipedFileReaderTransport::seekToChunk(int32_t chunk) {
 void TPipedFileReaderTransport::seekToEnd() {
   srcTrans_->seekToEnd();
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TTransportUtils.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.h b/lib/cpp/src/thrift/transport/TTransportUtils.h
index aa294b4..c221836 100644
--- a/lib/cpp/src/thrift/transport/TTransportUtils.h
+++ b/lib/cpp/src/thrift/transport/TTransportUtils.h
@@ -29,7 +29,9 @@
 #include <thrift/transport/TBufferTransports.h>
 #include <thrift/transport/TFileTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * The null transport is a dummy transport that doesn't actually do anything.
@@ -39,24 +41,18 @@ namespace apache { namespace thrift { namespace transport {
  *
  */
 class TNullTransport : public TVirtualTransport<TNullTransport> {
- public:
+public:
   TNullTransport() {}
 
   ~TNullTransport() {}
 
-  bool isOpen() {
-    return true;
-  }
+  bool isOpen() { return true; }
 
   void open() {}
 
-  void write(const uint8_t* /* buf */, uint32_t /* len */) {
-    return;
-  }
-
+  void write(const uint8_t* /* buf */, uint32_t /* len */) { return; }
 };
 
-
 /**
  * TPipedTransport. This transport allows piping of a request from one
  * transport to another either when readEnd() or writeEnd(). The typical
@@ -66,23 +62,25 @@ class TNullTransport : public TVirtualTransport<TNullTransport> {
  *
  */
 class TPipedTransport : virtual public TTransport {
- public:
-  TPipedTransport(boost::shared_ptr<TTransport> srcTrans,
-                  boost::shared_ptr<TTransport> dstTrans) :
-    srcTrans_(srcTrans),
-    dstTrans_(dstTrans),
-    rBufSize_(512), rPos_(0), rLen_(0),
-    wBufSize_(512), wLen_(0) {
+public:
+  TPipedTransport(boost::shared_ptr<TTransport> srcTrans, boost::shared_ptr<TTransport> dstTrans)
+    : srcTrans_(srcTrans),
+      dstTrans_(dstTrans),
+      rBufSize_(512),
+      rPos_(0),
+      rLen_(0),
+      wBufSize_(512),
+      wLen_(0) {
 
     // default is to to pipe the request when readEnd() is called
     pipeOnRead_ = true;
     pipeOnWrite_ = false;
 
-    rBuf_ = (uint8_t*) std::malloc(sizeof(uint8_t) * rBufSize_);
+    rBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * rBufSize_);
     if (rBuf_ == NULL) {
       throw std::bad_alloc();
     }
-    wBuf_ = (uint8_t*) std::malloc(sizeof(uint8_t) * wBufSize_);
+    wBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * wBufSize_);
     if (wBuf_ == NULL) {
       throw std::bad_alloc();
     }
@@ -90,17 +88,20 @@ class TPipedTransport : virtual public TTransport {
 
   TPipedTransport(boost::shared_ptr<TTransport> srcTrans,
                   boost::shared_ptr<TTransport> dstTrans,
-                  uint32_t sz) :
-    srcTrans_(srcTrans),
-    dstTrans_(dstTrans),
-    rBufSize_(512), rPos_(0), rLen_(0),
-    wBufSize_(sz), wLen_(0) {
-
-    rBuf_ = (uint8_t*) std::malloc(sizeof(uint8_t) * rBufSize_);
+                  uint32_t sz)
+    : srcTrans_(srcTrans),
+      dstTrans_(dstTrans),
+      rBufSize_(512),
+      rPos_(0),
+      rLen_(0),
+      wBufSize_(sz),
+      wLen_(0) {
+
+    rBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * rBufSize_);
     if (rBuf_ == NULL) {
       throw std::bad_alloc();
     }
-    wBuf_ = (uint8_t*) std::malloc(sizeof(uint8_t) * wBufSize_);
+    wBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * wBufSize_);
     if (wBuf_ == NULL) {
       throw std::bad_alloc();
     }
@@ -111,40 +112,29 @@ class TPipedTransport : virtual public TTransport {
     std::free(wBuf_);
   }
 
-  bool isOpen() {
-    return srcTrans_->isOpen();
-  }
+  bool isOpen() { return srcTrans_->isOpen(); }
 
   bool peek() {
     if (rPos_ >= rLen_) {
       // Double the size of the underlying buffer if it is full
       if (rLen_ == rBufSize_) {
-        rBufSize_ *=2;
-        rBuf_ = (uint8_t *)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
+        rBufSize_ *= 2;
+        rBuf_ = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
       }
 
       // try to fill up the buffer
-      rLen_ += srcTrans_->read(rBuf_+rPos_, rBufSize_ - rPos_);
+      rLen_ += srcTrans_->read(rBuf_ + rPos_, rBufSize_ - rPos_);
     }
     return (rLen_ > rPos_);
   }
 
+  void open() { srcTrans_->open(); }
 
-  void open() {
-    srcTrans_->open();
-  }
-
-  void close() {
-    srcTrans_->close();
-  }
+  void close() { srcTrans_->close(); }
 
-  void setPipeOnRead(bool pipeVal) {
-    pipeOnRead_ = pipeVal;
-  }
+  void setPipeOnRead(bool pipeVal) { pipeOnRead_ = pipeVal; }
 
-  void setPipeOnWrite(bool pipeVal) {
-    pipeOnWrite_ = pipeVal;
-  }
+  void setPipeOnWrite(bool pipeVal) { pipeOnWrite_ = pipeVal; }
 
   uint32_t read(uint8_t* buf, uint32_t len);
 
@@ -180,23 +170,17 @@ class TPipedTransport : virtual public TTransport {
 
   void flush();
 
-  boost::shared_ptr<TTransport> getTargetTransport() {
-    return dstTrans_;
-  }
+  boost::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; }
 
   /*
    * Override TTransport *_virt() functions to invoke our implementations.
    * We cannot use TVirtualTransport to provide these, since we need to inherit
    * virtually from TTransport.
    */
-  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) {
-    return this->read(buf, len);
-  }
-  virtual void write_virt(const uint8_t* buf, uint32_t len) {
-    this->write(buf, len);
-  }
+  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) { return this->read(buf, len); }
+  virtual void write_virt(const uint8_t* buf, uint32_t len) { this->write(buf, len); }
 
- protected:
+protected:
   boost::shared_ptr<TTransport> srcTrans_;
   boost::shared_ptr<TTransport> dstTrans_;
 
@@ -213,13 +197,12 @@ class TPipedTransport : virtual public TTransport {
   bool pipeOnWrite_;
 };
 
-
 /**
  * Wraps a transport into a pipedTransport instance.
  *
  */
 class TPipedTransportFactory : public TTransportFactory {
- public:
+public:
   TPipedTransportFactory() {}
   TPipedTransportFactory(boost::shared_ptr<TTransport> dstTrans) {
     initializeTargetTransport(dstTrans);
@@ -241,7 +224,7 @@ class TPipedTransportFactory : public TTransportFactory {
     }
   }
 
- protected:
+protected:
   boost::shared_ptr<TTransport> dstTrans_;
 };
 
@@ -251,10 +234,10 @@ class TPipedTransportFactory : public TTransportFactory {
  * TTransport can still access the original transport.
  *
  */
-class TPipedFileReaderTransport : public TPipedTransport,
-                                  public TFileReaderTransport {
- public:
-  TPipedFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans, boost::shared_ptr<TTransport> dstTrans);
+class TPipedFileReaderTransport : public TPipedTransport, public TFileReaderTransport {
+public:
+  TPipedFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans,
+                            boost::shared_ptr<TTransport> dstTrans);
 
   ~TPipedFileReaderTransport();
 
@@ -283,17 +266,11 @@ class TPipedFileReaderTransport : public TPipedTransport,
    * We cannot use TVirtualTransport to provide these, since we need to inherit
    * virtually from TTransport.
    */
-  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) {
-    return this->read(buf, len);
-  }
-  virtual uint32_t readAll_virt(uint8_t* buf, uint32_t len) {
-    return this->readAll(buf, len);
-  }
-  virtual void write_virt(const uint8_t* buf, uint32_t len) {
-    this->write(buf, len);
-  }
+  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) { return this->read(buf, len); }
+  virtual uint32_t readAll_virt(uint8_t* buf, uint32_t len) { return this->readAll(buf, len); }
+  virtual void write_virt(const uint8_t* buf, uint32_t len) { this->write(buf, len); }
 
- protected:
+protected:
   // shouldn't be used
   TPipedFileReaderTransport();
   boost::shared_ptr<TFileReaderTransport> srcTrans_;
@@ -304,15 +281,15 @@ class TPipedFileReaderTransport : public TPipedTransport,
  *
  */
 class TPipedFileReaderTransportFactory : public TPipedTransportFactory {
- public:
+public:
   TPipedFileReaderTransportFactory() {}
   TPipedFileReaderTransportFactory(boost::shared_ptr<TTransport> dstTrans)
-    : TPipedTransportFactory(dstTrans)
-  {}
+    : TPipedTransportFactory(dstTrans) {}
   virtual ~TPipedFileReaderTransportFactory() {}
 
   boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> srcTrans) {
-    boost::shared_ptr<TFileReaderTransport> pFileReaderTransport = boost::dynamic_pointer_cast<TFileReaderTransport>(srcTrans);
+    boost::shared_ptr<TFileReaderTransport> pFileReaderTransport
+        = boost::dynamic_pointer_cast<TFileReaderTransport>(srcTrans);
     if (pFileReaderTransport.get() != NULL) {
       return getFileReaderTransport(pFileReaderTransport);
     } else {
@@ -320,11 +297,14 @@ class TPipedFileReaderTransportFactory : public TPipedTransportFactory {
     }
   }
 
-  boost::shared_ptr<TFileReaderTransport> getFileReaderTransport(boost::shared_ptr<TFileReaderTransport> srcTrans) {
-    return boost::shared_ptr<TFileReaderTransport>(new TPipedFileReaderTransport(srcTrans, dstTrans_));
+  boost::shared_ptr<TFileReaderTransport> getFileReaderTransport(
+      boost::shared_ptr<TFileReaderTransport> srcTrans) {
+    return boost::shared_ptr<TFileReaderTransport>(
+        new TPipedFileReaderTransport(srcTrans, dstTrans_));
   }
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TTRANSPORTUTILS_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TVirtualTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TVirtualTransport.h b/lib/cpp/src/thrift/transport/TVirtualTransport.h
index 575f547..0cacf61 100644
--- a/lib/cpp/src/thrift/transport/TVirtualTransport.h
+++ b/lib/cpp/src/thrift/transport/TVirtualTransport.h
@@ -22,8 +22,9 @@
 
 #include <thrift/transport/TTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
-
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Helper class that provides default implementations of TTransport methods.
@@ -42,28 +43,20 @@ namespace apache { namespace thrift { namespace transport {
  * read_virt().)
  */
 class TTransportDefaults : public TTransport {
- public:
+public:
   /*
    * TTransport *_virt() methods provide reasonable default implementations.
    * Invoke them non-virtually.
    */
-  uint32_t read(uint8_t* buf, uint32_t len) {
-    return this->TTransport::read_virt(buf, len);
-  }
-  uint32_t readAll(uint8_t* buf, uint32_t len) {
-    return this->TTransport::readAll_virt(buf, len);
-  }
-  void write(const uint8_t* buf, uint32_t len) {
-    this->TTransport::write_virt(buf, len);
-  }
+  uint32_t read(uint8_t* buf, uint32_t len) { return this->TTransport::read_virt(buf, len); }
+  uint32_t readAll(uint8_t* buf, uint32_t len) { return this->TTransport::readAll_virt(buf, len); }
+  void write(const uint8_t* buf, uint32_t len) { this->TTransport::write_virt(buf, len); }
   const uint8_t* borrow(uint8_t* buf, uint32_t* len) {
     return this->TTransport::borrow_virt(buf, len);
   }
-  void consume(uint32_t len) {
-    this->TTransport::consume_virt(len);
-  }
+  void consume(uint32_t len) { this->TTransport::consume_virt(len); }
 
- protected:
+protected:
   TTransportDefaults() {}
 };
 
@@ -84,9 +77,9 @@ class TTransportDefaults : public TTransport {
  *
  * @author Chad Walters <ch...@powerset.com>
  */
-template <class Transport_, class Super_=TTransportDefaults>
+template <class Transport_, class Super_ = TTransportDefaults>
 class TVirtualTransport : public Super_ {
- public:
+public:
   /*
    * Implementations of the *_virt() functions, to call the subclass's
    * non-virtual implementation function.
@@ -107,9 +100,7 @@ class TVirtualTransport : public Super_ {
     return static_cast<Transport_*>(this)->borrow(buf, len);
   }
 
-  virtual void consume_virt(uint32_t len) {
-    static_cast<Transport_*>(this)->consume(len);
-  }
+  virtual void consume_virt(uint32_t len) { static_cast<Transport_*>(this)->consume(len); }
 
   /*
    * Provide a default readAll() implementation that invokes
@@ -126,7 +117,7 @@ class TVirtualTransport : public Super_ {
     return ::apache::thrift::transport::readAll(*trans, buf, len);
   }
 
- protected:
+protected:
   TVirtualTransport() {}
 
   /*
@@ -135,12 +126,15 @@ class TVirtualTransport : public Super_ {
    * additional versions can be added as needed.
    */
   template <typename Arg_>
-  TVirtualTransport(Arg_ const& arg) : Super_(arg) { }
+  TVirtualTransport(Arg_ const& arg)
+    : Super_(arg) {}
 
   template <typename Arg1_, typename Arg2_>
-  TVirtualTransport(Arg1_ const& a1, Arg2_ const& a2) : Super_(a1, a2) { }
+  TVirtualTransport(Arg1_ const& a1, Arg2_ const& a2)
+    : Super_(a1, a2) {}
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TVIRTUALTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TZlibTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.cpp b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
index cdde7c3..fb5cc5d 100644
--- a/lib/cpp/src/thrift/transport/TZlibTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
@@ -24,7 +24,9 @@
 
 using std::string;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 // Don't call this outside of the constructor.
 void TZlibTransport::initZlib() {
@@ -36,17 +38,17 @@ void TZlibTransport::initZlib() {
 
     rstream_->zalloc = Z_NULL;
     wstream_->zalloc = Z_NULL;
-    rstream_->zfree  = Z_NULL;
-    wstream_->zfree  = Z_NULL;
+    rstream_->zfree = Z_NULL;
+    wstream_->zfree = Z_NULL;
     rstream_->opaque = Z_NULL;
     wstream_->opaque = Z_NULL;
 
-    rstream_->next_in   = crbuf_;
-    wstream_->next_in   = uwbuf_;
-    rstream_->next_out  = urbuf_;
-    wstream_->next_out  = cwbuf_;
-    rstream_->avail_in  = 0;
-    wstream_->avail_in  = 0;
+    rstream_->next_in = crbuf_;
+    wstream_->next_in = uwbuf_;
+    rstream_->next_out = urbuf_;
+    wstream_->next_out = cwbuf_;
+    rstream_->avail_in = 0;
+    wstream_->avail_in = 0;
     rstream_->avail_out = urbuf_size_;
     wstream_->avail_out = cwbuf_size_;
 
@@ -79,8 +81,8 @@ inline void TZlibTransport::checkZlibRv(int status, const char* message) {
 
 inline void TZlibTransport::checkZlibRvNothrow(int status, const char* message) {
   if (status != Z_OK) {
-    string output = "TZlibTransport: zlib failure in destructor: " +
-      TZlibTransportException::errorMessage(status, message);
+    string output = "TZlibTransport: zlib failure in destructor: "
+                    + TZlibTransportException::errorMessage(status, message);
     GlobalOutput(output.c_str());
   }
 }
@@ -116,8 +118,6 @@ bool TZlibTransport::peek() {
   return (readAvail() > 0) || (rstream_->avail_in > 0) || transport_->peek();
 }
 
-
-
 // READING STRATEGY
 //
 // We have two buffers for reading: one containing the compressed data (crbuf_)
@@ -143,7 +143,7 @@ uint32_t TZlibTransport::read(uint8_t* buf, uint32_t len) {
   while (true) {
     // Copy out whatever we have available, then give them the min of
     // what we have and what they want, then advance indices.
-    int give = (std::min)((uint32_t) readAvail(), need);
+    int give = (std::min)((uint32_t)readAvail(), need);
     memcpy(buf, urbuf_ + urpos_, give);
     need -= give;
     buf += give;
@@ -170,7 +170,7 @@ uint32_t TZlibTransport::read(uint8_t* buf, uint32_t len) {
     }
 
     // The uncompressed read buffer is empty, so reset the stream fields.
-    rstream_->next_out  = urbuf_;
+    rstream_->next_out = urbuf_;
     rstream_->avail_out = urbuf_size_;
     urpos_ = 0;
 
@@ -195,7 +195,7 @@ bool TZlibTransport::readFromZlib() {
     if (got == 0) {
       return false;
     }
-    rstream_->next_in  = crbuf_;
+    rstream_->next_in = crbuf_;
     rstream_->avail_in = got;
   }
 
@@ -211,7 +211,6 @@ bool TZlibTransport::readFromZlib() {
   return true;
 }
 
-
 // WRITING STRATEGY
 //
 // We buffer up small writes before sending them to zlib, so our logic is:
@@ -232,8 +231,7 @@ bool TZlibTransport::readFromZlib() {
 
 void TZlibTransport::write(const uint8_t* buf, uint32_t len) {
   if (output_finished_) {
-    throw TTransportException(TTransportException::BAD_ARGS,
-                              "write() called after finish()");
+    throw TTransportException(TTransportException::BAD_ARGS, "write() called after finish()");
   }
 
   // zlib's "deflate" function has enough logic in it that I think
@@ -252,25 +250,23 @@ void TZlibTransport::write(const uint8_t* buf, uint32_t len) {
   }
 }
 
-void TZlibTransport::flush()  {
+void TZlibTransport::flush() {
   if (output_finished_) {
-    throw TTransportException(TTransportException::BAD_ARGS,
-                              "flush() called after finish()");
+    throw TTransportException(TTransportException::BAD_ARGS, "flush() called after finish()");
   }
 
   flushToTransport(Z_FULL_FLUSH);
 }
 
-void TZlibTransport::finish()  {
+void TZlibTransport::finish() {
   if (output_finished_) {
-    throw TTransportException(TTransportException::BAD_ARGS,
-                              "finish() called more than once");
+    throw TTransportException(TTransportException::BAD_ARGS, "finish() called more than once");
   }
 
   flushToTransport(Z_FINISH);
 }
 
-void TZlibTransport::flushToTransport(int flush)  {
+void TZlibTransport::flushToTransport(int flush) {
   // write pending data in uwbuf_ to zlib
   flushToZlib(uwbuf_, uwpos_, flush);
   uwpos_ = 0;
@@ -285,7 +281,7 @@ void TZlibTransport::flushToTransport(int flush)  {
 }
 
 void TZlibTransport::flushToZlib(const uint8_t* buf, int len, int flush) {
-  wstream_->next_in  = const_cast<uint8_t*>(buf);
+  wstream_->next_in = const_cast<uint8_t*>(buf);
   wstream_->avail_in = len;
 
   while (true) {
@@ -296,7 +292,7 @@ void TZlibTransport::flushToZlib(const uint8_t* buf, int len, int flush) {
     // If our ouput buffer is full, flush to the underlying transport.
     if (wstream_->avail_out == 0) {
       transport_->write(cwbuf_, cwbuf_size_);
-      wstream_->next_out  = cwbuf_;
+      wstream_->next_out = cwbuf_;
       wstream_->avail_out = cwbuf_size_;
     }
 
@@ -310,15 +306,15 @@ void TZlibTransport::flushToZlib(const uint8_t* buf, int len, int flush) {
 
     checkZlibRv(zlib_rv, wstream_->msg);
 
-    if ((flush == Z_SYNC_FLUSH || flush == Z_FULL_FLUSH) &&
-        wstream_->avail_in == 0 && wstream_->avail_out != 0) {
+    if ((flush == Z_SYNC_FLUSH || flush == Z_FULL_FLUSH) && wstream_->avail_in == 0
+        && wstream_->avail_out != 0) {
       break;
     }
   }
 }
 
 const uint8_t* TZlibTransport::borrow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
+  (void)buf;
   // Don't try to be clever with shifting buffers.
   // If we have enough data, give a pointer to it,
   // otherwise let the protcol use its slow path.
@@ -333,8 +329,7 @@ void TZlibTransport::consume(uint32_t len) {
   if (readAvail() >= (int)len) {
     urpos_ += len;
   } else {
-    throw TTransportException(TTransportException::BAD_ARGS,
-                              "consume did not follow a borrow.");
+    throw TTransportException(TTransportException::BAD_ARGS, "consume did not follow a borrow.");
   }
 }
 
@@ -348,14 +343,13 @@ void TZlibTransport::verifyChecksum() {
   // This should only be called when reading is complete.
   // If the caller still has unread data, throw an exception.
   if (readAvail() > 0) {
-    throw TTransportException(
-        TTransportException::CORRUPTED_DATA,
-        "verifyChecksum() called before end of zlib stream");
+    throw TTransportException(TTransportException::CORRUPTED_DATA,
+                              "verifyChecksum() called before end of zlib stream");
   }
 
   // Reset the rstream fields, in case avail_out is 0.
   // (Since readAvail() is 0, we know there is no unread data in urbuf_)
-  rstream_->next_out  = urbuf_;
+  rstream_->next_out = urbuf_;
   rstream_->avail_out = urbuf_size_;
   urpos_ = 0;
 
@@ -394,6 +388,6 @@ void TZlibTransport::verifyChecksum() {
                             "verifyChecksum() called before end of "
                             "zlib stream");
 }
-
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TZlibTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.h b/lib/cpp/src/thrift/transport/TZlibTransport.h
index 565ecaa..1e7b5ec 100644
--- a/lib/cpp/src/thrift/transport/TZlibTransport.h
+++ b/lib/cpp/src/thrift/transport/TZlibTransport.h
@@ -27,15 +27,16 @@
 
 struct z_stream_s;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class TZlibTransportException : public TTransportException {
- public:
-  TZlibTransportException(int status, const char* msg) :
-    TTransportException(TTransportException::INTERNAL_ERROR,
-                        errorMessage(status, msg)),
-    zlib_status_(status),
-    zlib_msg_(msg == NULL ? "(null)" : msg) {}
+public:
+  TZlibTransportException(int status, const char* msg)
+    : TTransportException(TTransportException::INTERNAL_ERROR, errorMessage(status, msg)),
+      zlib_status_(status),
+      zlib_msg_(msg == NULL ? "(null)" : msg) {}
 
   virtual ~TZlibTransportException() throw() {}
 
@@ -67,8 +68,7 @@ class TZlibTransportException : public TTransportException {
  *
  */
 class TZlibTransport : public TVirtualTransport<TZlibTransport> {
- public:
-
+public:
   /**
    * @param transport    The transport to read compressed data from
    *                     and write compressed data to.
@@ -83,31 +83,29 @@ class TZlibTransport : public TVirtualTransport<TZlibTransport> {
                  int crbuf_size = DEFAULT_CRBUF_SIZE,
                  int uwbuf_size = DEFAULT_UWBUF_SIZE,
                  int cwbuf_size = DEFAULT_CWBUF_SIZE,
-                 int16_t comp_level = Z_DEFAULT_COMPRESSION) :
-    transport_(transport),
-    urpos_(0),
-    uwpos_(0),
-    input_ended_(false),
-    output_finished_(false),
-    urbuf_size_(urbuf_size),
-    crbuf_size_(crbuf_size),
-    uwbuf_size_(uwbuf_size),
-    cwbuf_size_(cwbuf_size),
-    urbuf_(NULL),
-    crbuf_(NULL),
-    uwbuf_(NULL),
-    cwbuf_(NULL),
-    rstream_(NULL),
-    wstream_(NULL),
-    comp_level_(comp_level)
-  {
+                 int16_t comp_level = Z_DEFAULT_COMPRESSION)
+    : transport_(transport),
+      urpos_(0),
+      uwpos_(0),
+      input_ended_(false),
+      output_finished_(false),
+      urbuf_size_(urbuf_size),
+      crbuf_size_(crbuf_size),
+      uwbuf_size_(uwbuf_size),
+      cwbuf_size_(cwbuf_size),
+      urbuf_(NULL),
+      crbuf_(NULL),
+      uwbuf_(NULL),
+      cwbuf_(NULL),
+      rstream_(NULL),
+      wstream_(NULL),
+      comp_level_(comp_level) {
     if (uwbuf_size_ < MIN_DIRECT_DEFLATE_SIZE) {
       // Have to copy this into a local because of a linking issue.
       int minimum = MIN_DIRECT_DEFLATE_SIZE;
-      throw TTransportException(
-          TTransportException::BAD_ARGS,
-          "TZLibTransport: uncompressed write buffer must be at least"
-          + boost::lexical_cast<std::string>(minimum) + ".");
+      throw TTransportException(TTransportException::BAD_ARGS,
+                                "TZLibTransport: uncompressed write buffer must be at least"
+                                + boost::lexical_cast<std::string>(minimum) + ".");
     }
 
     try {
@@ -143,13 +141,9 @@ class TZlibTransport : public TVirtualTransport<TZlibTransport> {
   bool isOpen();
   bool peek();
 
-  void open() {
-    transport_->open();
-  }
+  void open() { transport_->open(); }
 
-  void close() {
-    transport_->close();
-  }
+  void close() { transport_->close(); }
 
   uint32_t read(uint8_t* buf, uint32_t len);
 
@@ -178,16 +172,15 @@ class TZlibTransport : public TVirtualTransport<TZlibTransport> {
    */
   void verifyChecksum();
 
-   /**
-    * TODO(someone_smart): Choose smart defaults.
-    */
+  /**
+   * TODO(someone_smart): Choose smart defaults.
+   */
   static const int DEFAULT_URBUF_SIZE = 128;
   static const int DEFAULT_CRBUF_SIZE = 1024;
   static const int DEFAULT_UWBUF_SIZE = 128;
   static const int DEFAULT_CWBUF_SIZE = 1024;
 
- protected:
-
+protected:
   inline void checkZlibRv(int status, const char* msg);
   inline void checkZlibRvNothrow(int status, const char* msg);
   inline int readAvail();
@@ -195,7 +188,7 @@ class TZlibTransport : public TVirtualTransport<TZlibTransport> {
   void flushToZlib(const uint8_t* buf, int len, int flush);
   bool readFromZlib();
 
- protected:
+protected:
   // Writes smaller than this are buffered up.
   // Larger (or equal) writes are dumped straight to zlib.
   static const uint32_t MIN_DIRECT_DEFLATE_SIZE = 32;
@@ -226,24 +219,22 @@ class TZlibTransport : public TVirtualTransport<TZlibTransport> {
   const int comp_level_;
 };
 
-
 /**
  * Wraps a transport into a zlibbed one.
  *
  */
 class TZlibTransportFactory : public TTransportFactory {
- public:
+public:
   TZlibTransportFactory() {}
 
   virtual ~TZlibTransportFactory() {}
 
-  virtual boost::shared_ptr<TTransport> getTransport(
-                                         boost::shared_ptr<TTransport> trans) {
+  virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
     return boost::shared_ptr<TTransport>(new TZlibTransport(trans));
   }
 };
-
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TZLIBTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
index c5667e4..654d005 100644
--- a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
+++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
@@ -24,89 +24,73 @@
 #include <time.h>
 
 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
-#   define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
 #else
-#   define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
+#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
 #endif
 
-struct timezone
-{
-    int  tz_minuteswest; /* minutes W of Greenwich */
-    int  tz_dsttime;     /* type of dst correction */
+struct timezone {
+  int tz_minuteswest; /* minutes W of Greenwich */
+  int tz_dsttime;     /* type of dst correction */
 };
 
-int thrift_gettimeofday(struct timeval * tv, struct timezone * tz)
-{
-    FILETIME         ft;
-    unsigned __int64 tmpres(0);
-    static int       tzflag;
-
-    if (NULL != tv)
-    {
-        GetSystemTimeAsFileTime(&ft);
-
-        tmpres |= ft.dwHighDateTime;
-        tmpres <<= 32;
-        tmpres |= ft.dwLowDateTime;
-
-        /*converting file time to unix epoch*/
-        tmpres -= DELTA_EPOCH_IN_MICROSECS;
-        tmpres /= 10;  /*convert into microseconds*/
-        tv->tv_sec = (long)(tmpres / 1000000UL);
-        tv->tv_usec = (long)(tmpres % 1000000UL);
+int thrift_gettimeofday(struct timeval* tv, struct timezone* tz) {
+  FILETIME ft;
+  unsigned __int64 tmpres(0);
+  static int tzflag;
+
+  if (NULL != tv) {
+    GetSystemTimeAsFileTime(&ft);
+
+    tmpres |= ft.dwHighDateTime;
+    tmpres <<= 32;
+    tmpres |= ft.dwLowDateTime;
+
+    /*converting file time to unix epoch*/
+    tmpres -= DELTA_EPOCH_IN_MICROSECS;
+    tmpres /= 10; /*convert into microseconds*/
+    tv->tv_sec = (long)(tmpres / 1000000UL);
+    tv->tv_usec = (long)(tmpres % 1000000UL);
+  }
+
+  if (NULL != tz) {
+    if (!tzflag) {
+      _tzset();
+      tzflag++;
     }
 
-    if (NULL != tz)
-    {
-        if (!tzflag)
-        {
-            _tzset();
-            tzflag++;
-        }
-
-        long time_zone(0);
-        errno_t err(_get_timezone(&time_zone));
-        if (err == NO_ERROR)
-        {
-            tz->tz_minuteswest = time_zone / 60;
-        }
-        else
-        {
-            return -1;
-        }
+    long time_zone(0);
+    errno_t err(_get_timezone(&time_zone));
+    if (err == NO_ERROR) {
+      tz->tz_minuteswest = time_zone / 60;
+    } else {
+      return -1;
+    }
 
-        int day_light(0);
-        err = (_get_daylight(&day_light));
-        if (err == NO_ERROR)
-        {
-            tz->tz_dsttime = day_light;
-            return 0;
-        }
-        else
-        {
-            return -1;
-        }
+    int day_light(0);
+    err = (_get_daylight(&day_light));
+    if (err == NO_ERROR) {
+      tz->tz_dsttime = day_light;
+      return 0;
+    } else {
+      return -1;
     }
+  }
 
-    return 0;
+  return 0;
 }
 
-int thrift_sleep(unsigned int seconds)
-{
+int thrift_sleep(unsigned int seconds) {
   ::Sleep(seconds * 1000);
   return 0;
 }
-int thrift_usleep(unsigned int microseconds)
-{
-  unsigned int milliseconds = (microseconds + 999)/ 1000;
+int thrift_usleep(unsigned int microseconds) {
+  unsigned int milliseconds = (microseconds + 999) / 1000;
   ::Sleep(milliseconds);
   return 0;
 }
 
-char *thrift_ctime_r(const time_t *_clock, char *_buf)
-{
-   strcpy(_buf, ctime(_clock));
-   return _buf;
+char* thrift_ctime_r(const time_t* _clock, char* _buf) {
+  strcpy(_buf, ctime(_clock));
+  return _buf;
 }
-
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/GetTimeOfDay.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.h b/lib/cpp/src/thrift/windows/GetTimeOfDay.h
index 27b8a84..6e90ba1 100644
--- a/lib/cpp/src/thrift/windows/GetTimeOfDay.h
+++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.h
@@ -35,9 +35,9 @@ struct thrift_timespec {
   int64_t tv_nsec;
 };
 
-int thrift_gettimeofday(struct timeval * tv, struct timezone * tz);
+int thrift_gettimeofday(struct timeval* tv, struct timezone* tz);
 int thrift_sleep(unsigned int seconds);
 int thrift_usleep(unsigned int micro_seconds);
-char *thrift_ctime_r(const time_t *_clock, char *_buf);
+char* thrift_ctime_r(const time_t* _clock, char* _buf);
 
 #endif // _THRIFT_WINDOWS_GETTIMEOFDAY_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/Operators.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/Operators.h b/lib/cpp/src/thrift/windows/Operators.h
index 95d8e3e..9b86096 100644
--- a/lib/cpp/src/thrift/windows/Operators.h
+++ b/lib/cpp/src/thrift/windows/Operators.h
@@ -24,17 +24,17 @@
 #pragma once
 #endif // _MSC_VER
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 class TEnumIterator;
 
-inline bool operator == (const TEnumIterator&, const TEnumIterator&)
-{
-    // Not entirely sure what the test should be here. It is only to enable
-    // iterator debugging and is not used in release mode.
-    return true;
+inline bool operator==(const TEnumIterator&, const TEnumIterator&) {
+  // Not entirely sure what the test should be here. It is only to enable
+  // iterator debugging and is not used in release mode.
+  return true;
 }
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // _THRIFT_WINDOWS_OPERATORS_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp
index 5dec390..5ac6fe0 100644
--- a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp
+++ b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp
@@ -23,21 +23,23 @@
 #include <boost/scope_exit.hpp>
 #include <process.h>
 
-namespace apache { namespace thrift { namespace transport {
-
-TOverlappedWorkItem::TOverlappedWorkItem() :
-  SLIST_ENTRY(),
-  action(UNKNOWN),
-  h(INVALID_HANDLE_VALUE),
-  buffer(NULL),
-  buffer_len(0),
-  overlap(),
-  last_error(0),
-  success(TRUE)
-{}
+namespace apache {
+namespace thrift {
+namespace transport {
+
+TOverlappedWorkItem::TOverlappedWorkItem()
+  : SLIST_ENTRY(),
+    action(UNKNOWN),
+    h(INVALID_HANDLE_VALUE),
+    buffer(NULL),
+    buffer_len(0),
+    overlap(),
+    last_error(0),
+    success(TRUE) {
+}
 
-void TOverlappedWorkItem::reset(uint8_t *buf, uint32_t len, HANDLE event) {
-  memset( &overlap, 0, sizeof(overlap));
+void TOverlappedWorkItem::reset(uint8_t* buf, uint32_t len, HANDLE event) {
+  memset(&overlap, 0, sizeof(overlap));
   overlap.hEvent = event;
   buffer = buf;
   buffer_len = len;
@@ -48,7 +50,7 @@ void TOverlappedWorkItem::reset(uint8_t *buf, uint32_t len, HANDLE event) {
 uint32_t TOverlappedWorkItem::overlappedResults(bool signal_failure) {
   DWORD bytes = 0;
   BOOL result = ::GetOverlappedResult(h, &overlap, &bytes, TRUE);
-  if(signal_failure && !result) //get overlapped error case
+  if (signal_failure && !result) // get overlapped error case
   {
     GlobalOutput.perror("TPipe ::GetOverlappedResult errored GLE=", ::GetLastError());
     throw TTransportException(TTransportException::UNKNOWN, "TPipe: GetOverlappedResult failed");
@@ -57,42 +59,40 @@ uint32_t TOverlappedWorkItem::overlappedResults(bool signal_failure) {
 }
 
 bool TOverlappedWorkItem::process() {
-  BOOST_SCOPE_EXIT( (&doneSubmittingEvent) ) {
-    SetEvent(doneSubmittingEvent.h);
-  } BOOST_SCOPE_EXIT_END
+  BOOST_SCOPE_EXIT((&doneSubmittingEvent)) { SetEvent(doneSubmittingEvent.h); }
+  BOOST_SCOPE_EXIT_END
 
-  switch(action) {
-  case(CONNECT):
+  switch (action) {
+  case (CONNECT):
     success = ::ConnectNamedPipe(h, &overlap);
-    if(success == FALSE)
+    if (success == FALSE)
       last_error = ::GetLastError();
     return true;
-  case(READ):
+  case (READ):
     success = ::ReadFile(h, buffer, buffer_len, NULL, &overlap);
-    if(success == FALSE)
+    if (success == FALSE)
       last_error = ::GetLastError();
     return true;
-  case(CANCELIO):
+  case (CANCELIO):
     success = ::CancelIo(h);
-    if(success == FALSE)
+    if (success == FALSE)
       last_error = ::GetLastError();
     return true;
-  case(STOP):
+  case (STOP):
   default:
     return false;
   }
 }
 
-void TOverlappedSubmissionThread::addWorkItem(TOverlappedWorkItem *item) {
+void TOverlappedSubmissionThread::addWorkItem(TOverlappedWorkItem* item) {
   InterlockedPushEntrySList(&workList_, item);
   SetEvent(workAvailableEvent_.h);
   WaitForSingleObject(item->doneSubmittingEvent.h, INFINITE);
 }
 
-TOverlappedSubmissionThread *TOverlappedSubmissionThread::acquire_instance() {
+TOverlappedSubmissionThread* TOverlappedSubmissionThread::acquire_instance() {
   TAutoCrit lock(instanceGuard_);
-  if(instance_ == NULL)
-  {
+  if (instance_ == NULL) {
     assert(instanceRefCount_ == 0);
     instance_ = new TOverlappedSubmissionThread;
   }
@@ -101,8 +101,7 @@ TOverlappedSubmissionThread *TOverlappedSubmissionThread::acquire_instance() {
 }
 void TOverlappedSubmissionThread::release_instance() {
   TAutoCrit lock(instanceGuard_);
-  if(--instanceRefCount_ == 0)
-  {
+  if (--instanceRefCount_ == 0) {
     delete instance_;
     instance_ = NULL;
   }
@@ -112,16 +111,11 @@ TOverlappedSubmissionThread::TOverlappedSubmissionThread() {
   stopItem_.action = TOverlappedWorkItem::STOP;
 
   InitializeSListHead(&workList_);
-  thread_ = (HANDLE)_beginthreadex(
-    NULL,
-    0,
-    thread_proc,
-    this,
-    0,
-    NULL);
-  if(thread_ == 0) {
+  thread_ = (HANDLE)_beginthreadex(NULL, 0, thread_proc, this, 0, NULL);
+  if (thread_ == 0) {
     GlobalOutput.perror("TOverlappedSubmissionThread unable to create thread, errno=", errno);
-    throw TTransportException(TTransportException::NOT_OPEN, " TOverlappedSubmissionThread unable to create thread");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              " TOverlappedSubmissionThread unable to create thread");
   }
 }
 
@@ -132,25 +126,26 @@ TOverlappedSubmissionThread::~TOverlappedSubmissionThread() {
 }
 
 void TOverlappedSubmissionThread::run() {
-  for(;;) {
+  for (;;) {
     WaitForSingleObject(workAvailableEvent_.h, INFINITE);
-    //todo check result
-    SLIST_ENTRY *entry = NULL;
-    while( (entry = InterlockedPopEntrySList(&workList_)) != NULL) {
-      TOverlappedWorkItem &item = *static_cast<TOverlappedWorkItem *>(entry);
-      if(!item.process())
+    // todo check result
+    SLIST_ENTRY* entry = NULL;
+    while ((entry = InterlockedPopEntrySList(&workList_)) != NULL) {
+      TOverlappedWorkItem& item = *static_cast<TOverlappedWorkItem*>(entry);
+      if (!item.process())
         return;
     }
   }
 }
 
-unsigned __stdcall TOverlappedSubmissionThread::thread_proc(void *addr) {
-  static_cast<TOverlappedSubmissionThread *>(addr)->run();
+unsigned __stdcall TOverlappedSubmissionThread::thread_proc(void* addr) {
+  static_cast<TOverlappedSubmissionThread*>(addr)->run();
   return 0;
 }
 
 TCriticalSection TOverlappedSubmissionThread::instanceGuard_;
 TOverlappedSubmissionThread* TOverlappedSubmissionThread::instance_;
-uint32_t TOverlappedSubmissionThread::instanceRefCount_=0;
-
-}}} //apach::thrift::transport
+uint32_t TOverlappedSubmissionThread::instanceRefCount_ = 0;
+}
+}
+} // apach::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
index 16b7e24..56684bb 100644
--- a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
+++ b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
@@ -59,13 +59,15 @@
   until the operation has completed.
 */
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) struct TOverlappedWorkItem : public SLIST_ENTRY {
   TOverlappedWorkItem();
 
   enum action_t {
-    UNKNOWN  = 3000,
+    UNKNOWN = 3000,
     CONNECT,
     READ,
     CANCELIO,
@@ -75,38 +77,38 @@ DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) struct TOverlappedWorkItem : public
   TAutoResetEvent doneSubmittingEvent;
   action_t action;
   HANDLE h;
-  uint8_t *buffer;
+  uint8_t* buffer;
   uint32_t buffer_len;
   OVERLAPPED overlap;
 
   DWORD last_error;
   BOOL success;
 
-  void reset(uint8_t *buf, uint32_t len, HANDLE event);
+  void reset(uint8_t* buf, uint32_t len, HANDLE event);
   uint32_t overlappedResults(bool signal_failure = true);
   bool process();
 };
 
-class TOverlappedSubmissionThread : boost::noncopyable
-{
+class TOverlappedSubmissionThread : boost::noncopyable {
 public:
-  void addWorkItem(TOverlappedWorkItem *item);
+  void addWorkItem(TOverlappedWorkItem* item);
 
-//singleton stuff
+  // singleton stuff
 public:
-  static TOverlappedSubmissionThread *acquire_instance();
+  static TOverlappedSubmissionThread* acquire_instance();
   static void release_instance();
+
 private:
   static TCriticalSection instanceGuard_;
-  static TOverlappedSubmissionThread *instance_;
+  static TOverlappedSubmissionThread* instance_;
   static uint32_t instanceRefCount_;
 
-//thread details
+  // thread details
 private:
   TOverlappedSubmissionThread();
   ~TOverlappedSubmissionThread();
   void run();
-  static unsigned __stdcall thread_proc(void *addr);
+  static unsigned __stdcall thread_proc(void* addr);
 
 private:
   DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) SLIST_HEADER workList_;
@@ -117,13 +119,15 @@ private:
 
 class TAutoOverlapThread : boost::noncopyable {
 private:
-  TOverlappedSubmissionThread *p;
+  TOverlappedSubmissionThread* p;
+
 public:
   TAutoOverlapThread() : p(TOverlappedSubmissionThread::acquire_instance()) {}
-  ~TAutoOverlapThread() {TOverlappedSubmissionThread::release_instance();}
-  TOverlappedSubmissionThread *operator->() {return p;}
+  ~TAutoOverlapThread() { TOverlappedSubmissionThread::release_instance(); }
+  TOverlappedSubmissionThread* operator->() { return p; }
 };
-
-}}} //apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif


[36/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_as3_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc
index a8c4889..2c43430 100644
--- a/compiler/cpp/src/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/generate/t_as3_generator.cc
@@ -37,21 +37,19 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * AS3 code generator.
  *
  */
 class t_as3_generator : public t_oop_generator {
- public:
-  t_as3_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_as3_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("bindable");
@@ -73,14 +71,22 @@ class t_as3_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_xception(t_struct*   txception);
-  void generate_service (t_service*  tservice);
-
-  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
-  std::string render_const_value(ofstream& out, std::string name, t_type* type, t_const_value* value);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  void print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool in_static,
+                         bool defval = false);
+  std::string render_const_value(ofstream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
 
   /**
    * Service-level generation functions
@@ -88,8 +94,12 @@ class t_as3_generator : public t_oop_generator {
 
   void generate_as3_struct(t_struct* tstruct, bool is_exception);
 
-  void generate_as3_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
-  //removed -- equality,compare_to
+  void generate_as3_struct_definition(std::ofstream& out,
+                                      t_struct* tstruct,
+                                      bool is_xception = false,
+                                      bool in_class = false,
+                                      bool is_result = false);
+  // removed -- equality,compare_to
   void generate_as3_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_as3_validator(std::ofstream& out, t_struct* tstruct);
   void generate_as3_struct_result_writer(std::ofstream& out, t_struct* tstruct);
@@ -98,8 +108,14 @@ class t_as3_generator : public t_oop_generator {
   void generate_as3_meta_data_map(std::ofstream& out, t_struct* tstruct);
   void generate_field_value_meta_data(std::ofstream& out, t_type* type);
   std::string get_as3_type_string(t_type* type);
-  void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
-  void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
+  void generate_reflection_setters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
+  void generate_reflection_getters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
   void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
   void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
   void generate_as3_bean_boilerplate(std::ofstream& out, t_struct* tstruct, bool bindable);
@@ -109,72 +125,50 @@ class t_as3_generator : public t_oop_generator {
   std::string generate_isset_check(t_field* field);
   std::string generate_isset_check(std::string field);
   void generate_isset_set(ofstream& out, t_field* field);
-  //removed std::string isset_field_id(t_field* field);
+  // removed std::string isset_field_id(t_field* field);
 
-  void generate_service_interface (t_service* tservice);
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter,
-                                          std::string map);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map);
 
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_as3_doc                 (std::ofstream& out,
-                                          t_doc*     tdoc);
+  void generate_as3_doc(std::ofstream& out, t_doc* tdoc);
 
-  void generate_as3_doc                 (std::ofstream& out,
-                                          t_function* tdoc);
+  void generate_as3_doc(std::ofstream& out, t_function* tdoc);
 
   /**
    * Helper rendering functions
@@ -185,10 +179,10 @@ class t_as3_generator : public t_oop_generator {
   std::string as3_thrift_imports();
   std::string as3_thrift_gen_imports(t_struct* tstruct, string& imports);
   std::string as3_thrift_gen_imports(t_service* tservice);
-  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false);
-  std::string base_type_name(t_base_type* tbase, bool in_container=false);
-  std::string declare_field(t_field* tfield, bool init=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string type_name(t_type* ttype, bool in_container = false, bool in_init = false);
+  std::string base_type_name(t_base_type* tbase, bool in_container = false);
+  std::string declare_field(t_field* tfield, bool init = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
   std::string get_enum_class_name(t_type* type);
@@ -196,17 +190,13 @@ class t_as3_generator : public t_oop_generator {
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return
-      ttype->is_container() ||
-      ttype->is_struct() ||
-      ttype->is_xception() ||
-      ttype->is_string();
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
+           || ttype->is_string();
   }
 
   std::string constant_name(std::string name);
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -218,7 +208,6 @@ class t_as3_generator : public t_oop_generator {
   bool bindable_;
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -236,7 +225,7 @@ void t_as3_generator::init_generator() {
   while ((loc = dir.find(".")) != string::npos) {
     subdir = subdir + "/" + dir.substr(0, loc);
     MKDIR(subdir.c_str());
-    dir = dir.substr(loc+1);
+    dir = dir.substr(loc + 1);
   }
   if (dir.size() > 0) {
     subdir = subdir + "/" + dir;
@@ -264,11 +253,8 @@ string t_as3_generator::as3_package() {
  * @return List of imports for As3 types that are used in here
  */
 string t_as3_generator::as3_type_imports() {
-  return
-    string() +
-    "import org.apache.thrift.Set;\n" +
-    "import flash.utils.ByteArray;\n" +
-    "import flash.utils.Dictionary;\n\n";
+  return string() + "import org.apache.thrift.Set;\n" + "import flash.utils.ByteArray;\n"
+         + "import flash.utils.Dictionary;\n\n";
 }
 
 /**
@@ -277,11 +263,8 @@ string t_as3_generator::as3_type_imports() {
  * @return List of imports necessary for thrift
  */
 string t_as3_generator::as3_thrift_imports() {
-  return
-    string() +
-    "import org.apache.thrift.*;\n" +
-    "import org.apache.thrift.meta_data.*;\n" +
-    "import org.apache.thrift.protocol.*;\n\n";
+  return string() + "import org.apache.thrift.*;\n" + "import org.apache.thrift.meta_data.*;\n"
+         + "import org.apache.thrift.protocol.*;\n\n";
 }
 
 /**
@@ -294,7 +277,7 @@ string t_as3_generator::as3_thrift_gen_imports(t_struct* tstruct, string& import
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  //For each type check if it is from a differnet namespace
+  // For each type check if it is from a differnet namespace
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_program* program = (*m_iter)->get_type()->get_program();
     if (program != NULL && program != program_) {
@@ -309,7 +292,6 @@ string t_as3_generator::as3_thrift_gen_imports(t_struct* tstruct, string& import
   return imports;
 }
 
-
 /**
  * Prints imports needed for a given type
  *
@@ -320,31 +302,31 @@ string t_as3_generator::as3_thrift_gen_imports(t_service* tservice) {
   const vector<t_function*>& functions = tservice->get_functions();
   vector<t_function*>::const_iterator f_iter;
 
-  //For each type check if it is from a differnet namespace
+  // For each type check if it is from a differnet namespace
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_program* program = (*f_iter)->get_returntype()->get_program();
     if (program != NULL && program != program_) {
       string package = program->get_namespace("as3");
       if (!package.empty()) {
         if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) {
-          imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name() + ";\n");
+          imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name()
+                         + ";\n");
         }
       }
     }
 
     as3_thrift_gen_imports((*f_iter)->get_arglist(), imports);
     as3_thrift_gen_imports((*f_iter)->get_xceptions(), imports);
-
   }
 
   return imports;
-
 }
 
 /**
  * Nothing in As3
  */
-void t_as3_generator::close_generator() {}
+void t_as3_generator::close_generator() {
+}
 
 /**
  * Generates a typedef. This is not done in As3, since it does
@@ -354,7 +336,7 @@ void t_as3_generator::close_generator() {}
  * @param ttypedef The type definition
  */
 void t_as3_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -364,32 +346,27 @@ void t_as3_generator::generate_typedef(t_typedef* ttypedef) {
  */
 void t_as3_generator::generate_enum(t_enum* tenum) {
   // Make output file
-  string f_enum_name = package_dir_+"/"+(tenum->get_name())+".as";
+  string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".as";
   ofstream f_enum;
   f_enum.open(f_enum_name.c_str());
 
   // Comment and package it
-  f_enum <<
-    autogen_comment() <<
-    as3_package() << endl;
+  f_enum << autogen_comment() << as3_package() << endl;
 
   scope_up(f_enum);
   // Add as3 imports
-  f_enum << string() +
-  "import org.apache.thrift.Set;" << endl <<
-  "import flash.utils.Dictionary;" << endl;
+  f_enum << string() + "import org.apache.thrift.Set;" << endl << "import flash.utils.Dictionary;"
+         << endl;
 
-  indent(f_enum) <<
-    "public class " << tenum->get_name() << " ";
+  indent(f_enum) << "public class " << tenum->get_name() << " ";
   scope_up(f_enum);
 
   vector<t_enum_value*> constants = tenum->get_constants();
   vector<t_enum_value*>::iterator c_iter;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
-    indent(f_enum) <<
-      "public static const " << (*c_iter)->get_name() <<
-      ":int = " << value << ";" << endl;
+    indent(f_enum) << "public static const " << (*c_iter)->get_name() << ":int = " << value << ";"
+                   << endl;
   }
 
   // Create a static Set with all valid values for this enum
@@ -410,7 +387,8 @@ void t_as3_generator::generate_enum(t_enum* tenum) {
 
   scope_up(f_enum);
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
-    indent(f_enum) << "VALUES_TO_NAMES[" << (*c_iter)->get_name() << "] = \"" << (*c_iter)->get_name() << "\";" << endl;
+    indent(f_enum) << "VALUES_TO_NAMES[" << (*c_iter)->get_name() << "] = \""
+                   << (*c_iter)->get_name() << "\";" << endl;
   }
   f_enum << endl;
 
@@ -431,24 +409,19 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
     return;
   }
 
-  string f_consts_name = package_dir_+ "/" + program_name_ +  "Constants.as";
+  string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.as";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
   // Print header
-  f_consts <<
-    autogen_comment() << as3_package();
+  f_consts << autogen_comment() << as3_package();
 
   scope_up(f_consts);
   f_consts << endl;
 
   f_consts << as3_type_imports();
 
-
-
-  indent(f_consts) <<
-    "public class " << program_name_ << "Constants {" << endl <<
-    endl;
+  indent(f_consts) << "public class " << program_name_ << "Constants {" << endl << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -459,19 +432,22 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
                       false);
   }
   indent_down();
-  indent(f_consts) <<
-    "}" << endl;
+  indent(f_consts) << "}" << endl;
   scope_down(f_consts);
   f_consts.close();
 }
 
-void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
+void t_as3_generator::print_const_value(std::ofstream& out,
+                                        string name,
+                                        t_type* type,
+                                        t_const_value* value,
+                                        bool in_static,
+                                        bool defval) {
   type = get_true_type(type);
 
   indent(out);
   if (!defval) {
-    out <<
-    (in_static ? "var " : "public static const ");
+    out << (in_static ? "var " : "public static const ");
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
@@ -482,7 +458,7 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
     out << " = " << v2 << ";" << endl << endl;
   } else if (type->is_enum()) {
     out << name;
-    if(!defval) {
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = " << value->get_integer() << ";" << endl << endl;
@@ -491,7 +467,8 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
     vector<t_field*>::const_iterator f_iter;
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
-    out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();" << endl;
+    out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();"
+        << endl;
     if (!in_static) {
       indent(out) << "{" << endl;
       indent_up();
@@ -521,7 +498,7 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
     out << endl;
   } else if (type->is_map()) {
     out << name;
-    if(!defval){
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = new " << type_name(type, false, true) << "();" << endl;
@@ -549,7 +526,7 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
     out << endl;
   } else if (type->is_list() || type->is_set()) {
     out << name;
-    if(!defval) {
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = new " << type_name(type, false, true) << "();" << endl;
@@ -569,7 +546,8 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
     vector<t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string val = render_const_value(out, name, etype, *v_iter);
-      indent(out) << name << "." << (type->is_list() ? "push" : "add") << "(" << val << ");" << endl;
+      indent(out) << name << "." << (type->is_list() ? "push" : "add") << "(" << val << ");"
+                  << endl;
     }
     if (!in_static) {
       indent_down();
@@ -583,41 +561,44 @@ void t_as3_generator::print_const_value(std::ofstream& out, string name, t_type*
   }
 }
 
-string t_as3_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+string t_as3_generator::render_const_value(ofstream& out,
+                                           string name,
+                                           t_type* type,
+                                           t_const_value* value) {
+  (void)name;
   type = get_true_type(type);
   std::ostringstream render;
 
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-        case t_base_type::TYPE_STRING:
-          render << '"' << get_escaped_string(value) << '"';
-          break;
-        case t_base_type::TYPE_BOOL:
-          render << ((value->get_integer() > 0) ? "true" : "false");
-          break;
-        case t_base_type::TYPE_BYTE:
-          render << "(byte)" << value->get_integer();
-          break;
-        case t_base_type::TYPE_I16:
-          render << "(short)" << value->get_integer();
-          break;
-        case t_base_type::TYPE_I32:
-          render << value->get_integer();
-          break;
-        case t_base_type::TYPE_I64:
-          render << value->get_integer() << "L";
-          break;
-        case t_base_type::TYPE_DOUBLE:
-          if (value->get_type() == t_const_value::CV_INTEGER) {
-            render << "(double)" << value->get_integer();
-          } else {
-            render << value->get_double();
-          }
-          break;
-        default:
-          throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    case t_base_type::TYPE_STRING:
+      render << '"' << get_escaped_string(value) << '"';
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() > 0) ? "true" : "false");
+      break;
+    case t_base_type::TYPE_BYTE:
+      render << "(byte)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I16:
+      render << "(short)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I32:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_I64:
+      render << value->get_integer() << "L";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        render << "(double)" << value->get_integer();
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
     render << value->get_integer();
@@ -630,7 +611,6 @@ string t_as3_generator::render_const_value(ofstream& out, string name, t_type* t
   return render.str();
 }
 
-
 /**
  * Generates a struct definition for a thrift data type. This is a class
  * with data members, read(), write(), and an inner Isset class.
@@ -650,42 +630,33 @@ void t_as3_generator::generate_xception(t_struct* txception) {
   generate_as3_struct(txception, true);
 }
 
-
 /**
  * As3 struct definition.
  *
  * @param tstruct The struct definition
  */
-void t_as3_generator::generate_as3_struct(t_struct* tstruct,
-                                            bool is_exception) {
+void t_as3_generator::generate_as3_struct(t_struct* tstruct, bool is_exception) {
   // Make output file
-  string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".as";
+  string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".as";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-  as3_package();
+  f_struct << autogen_comment() << as3_package();
 
   scope_up(f_struct);
   f_struct << endl;
 
   string imports;
 
-  f_struct <<
-    as3_type_imports() <<
-    as3_thrift_imports() <<
-    as3_thrift_gen_imports(tstruct, imports) << endl;
+  f_struct << as3_type_imports() << as3_thrift_imports() << as3_thrift_gen_imports(tstruct, imports)
+           << endl;
 
-  if (bindable_ && ! is_exception) {
-    f_struct << "import flash.events.Event;" << endl <<
-    "import flash.events.EventDispatcher;" << endl <<
-    "import mx.events.PropertyChangeEvent;" << endl;
+  if (bindable_ && !is_exception) {
+    f_struct << "import flash.events.Event;" << endl << "import flash.events.EventDispatcher;"
+             << endl << "import mx.events.PropertyChangeEvent;" << endl;
   }
 
-  generate_as3_struct_definition(f_struct,
-                                  tstruct,
-                                  is_exception);
+  generate_as3_struct_definition(f_struct, tstruct, is_exception);
 
   scope_down(f_struct); // end of package
   f_struct.close();
@@ -701,51 +672,51 @@ void t_as3_generator::generate_as3_struct(t_struct* tstruct,
  * @param in_class     If inside a class, needs to be static class
  * @param is_result    If this is a result it needs a different writer
  */
-void t_as3_generator::generate_as3_struct_definition(ofstream &out,
-                                                       t_struct* tstruct,
-                                                       bool is_exception,
-                                                       bool in_class,
-                                                       bool is_result) {
+void t_as3_generator::generate_as3_struct_definition(ofstream& out,
+                                                     t_struct* tstruct,
+                                                     bool is_exception,
+                                                     bool in_class,
+                                                     bool is_result) {
   generate_as3_doc(out, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
-  bool bindable = ! is_exception && ! in_class && bindable_;
+  bool bindable = !is_exception && !in_class && bindable_;
 
-  indent(out) << (in_class ? "" : "public ") << (is_final ? "final " : "") <<
-     "class " << tstruct->get_name() << " ";
+  indent(out) << (in_class ? "" : "public ") << (is_final ? "final " : "") << "class "
+              << tstruct->get_name() << " ";
 
   if (is_exception) {
     out << "extends Error ";
-  }
-  else if (bindable) {
+  } else if (bindable) {
     out << "extends EventDispatcher ";
   }
   out << "implements TBase ";
 
   scope_up(out);
 
-  indent(out) <<
-    "private static const STRUCT_DESC:TStruct = new TStruct(\"" << tstruct->get_name() << "\");" << endl;
+  indent(out) << "private static const STRUCT_DESC:TStruct = new TStruct(\"" << tstruct->get_name()
+              << "\");" << endl;
 
   // Members are public for -as3, private for -as3bean
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) <<
-      "private static const " << constant_name((*m_iter)->get_name()) <<
-      "_FIELD_DESC:TField = new TField(\"" << (*m_iter)->get_name() << "\", " <<
-      type_to_enum((*m_iter)->get_type()) << ", " <<
-      (*m_iter)->get_key() << ");" << endl;
+    indent(out) << "private static const " << constant_name((*m_iter)->get_name())
+                << "_FIELD_DESC:TField = new TField(\"" << (*m_iter)->get_name() << "\", "
+                << type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << ");"
+                << endl;
   }
 
   out << endl;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     generate_as3_doc(out, *m_iter);
-    indent(out) << "private var _" << (*m_iter)->get_name() + ":" + type_name((*m_iter)->get_type()) << ";" << endl;
+    indent(out) << "private var _" << (*m_iter)->get_name() + ":" + type_name((*m_iter)->get_type())
+                << ";" << endl;
 
-    indent(out) << "public static const " << upcase_string((*m_iter)->get_name()) << ":int = " << (*m_iter)->get_key() << ";" << endl;
+    indent(out) << "public static const " << upcase_string((*m_iter)->get_name())
+                << ":int = " << (*m_iter)->get_key() << ";" << endl;
   }
 
   out << endl;
@@ -753,11 +724,11 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
   // Inner Isset class
   if (members.size() > 0) {
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        if (!type_can_be_null((*m_iter)->get_type())){
-          indent(out) <<
-            "private var __isset_" << (*m_iter)->get_name() << ":Boolean = false;" <<  endl;
-        }
+      if (!type_can_be_null((*m_iter)->get_type())) {
+        indent(out) << "private var __isset_" << (*m_iter)->get_name() << ":Boolean = false;"
+                    << endl;
       }
+    }
   }
 
   out << endl;
@@ -767,18 +738,18 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
   // Static initializer to populate global class to struct metadata map
   indent(out) << "{" << endl;
   indent_up();
-  indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);" << endl;
+  indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);"
+              << endl;
   indent_down();
   indent(out) << "}" << endl << endl;
 
   // Default constructor
-  indent(out) <<
-  "public function " << tstruct->get_name() << "() {" << endl;
+  indent(out) << "public function " << tstruct->get_name() << "() {" << endl;
   indent_up();
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     if ((*m_iter)->get_value() != NULL) {
-      indent(out) << "this._" << (*m_iter)->get_name() << " = " << (*m_iter)->get_value()->get_integer() << ";" <<
-      endl;
+      indent(out) << "this._" << (*m_iter)->get_name() << " = "
+                  << (*m_iter)->get_value()->get_integer() << ";" << endl;
     }
   }
   indent_down();
@@ -805,107 +776,87 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out,
  *
  * @param tstruct The struct definition
  */
-void t_as3_generator::generate_as3_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public function read(iprot:TProtocol):void {" << endl;
+void t_as3_generator::generate_as3_struct_reader(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function read(iprot:TProtocol):void {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables and read struct header
-  out <<
-    indent() << "var field:TField;" << endl <<
-    indent() << "iprot.readStructBegin();" << endl;
+  out << indent() << "var field:TField;" << endl << indent() << "iprot.readStructBegin();" << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
-    scope_up(out);
+  indent(out) << "while (true)" << endl;
+  scope_up(out);
 
-    // Read beginning field marker
-    indent(out) <<
-      "field = iprot.readFieldBegin();" << endl;
+  // Read beginning field marker
+  indent(out) << "field = iprot.readFieldBegin();" << endl;
 
-    // Check for field STOP marker and break
-    indent(out) <<
-      "if (field.type == TType.STOP) { " << endl;
-    indent_up();
-    indent(out) <<
-      "break;" << endl;
-    indent_down();
-    indent(out) <<
-      "}" << endl;
+  // Check for field STOP marker and break
+  indent(out) << "if (field.type == TType.STOP) { " << endl;
+  indent_up();
+  indent(out) << "break;" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    // Switch statement on the field we are reading
-    indent(out) <<
-      "switch (field.id)" << endl;
+  // Switch statement on the field we are reading
+  indent(out) << "switch (field.id)" << endl;
 
-      scope_up(out);
+  scope_up(out);
 
-      // Generate deserialization code for known cases
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent(out) <<
-          "case " << upcase_string((*f_iter)->get_name()) << ":" << endl;
-        indent_up();
-        indent(out) <<
-          "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-        indent_up();
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << endl;
+    indent_up();
+    indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent_up();
 
-        generate_deserialize_field(out, *f_iter, "this.");
-        generate_isset_set(out, *f_iter);
-        indent_down();
-        out <<
-          indent() << "} else { " << endl <<
-          indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl <<
-          indent() << "}" << endl <<
-          indent() << "break;" << endl;
-        indent_down();
-      }
+    generate_deserialize_field(out, *f_iter, "this.");
+    generate_isset_set(out, *f_iter);
+    indent_down();
+    out << indent() << "} else { " << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
+        << endl << indent() << "}" << endl << indent() << "break;" << endl;
+    indent_down();
+  }
 
-      // In the default case we skip the field
-      out <<
-        indent() << "default:" << endl <<
-        indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl <<
-        indent() << "  break;" << endl;
+  // In the default case we skip the field
+  out << indent() << "default:" << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
+      << endl << indent() << "  break;" << endl;
 
-      scope_down(out);
+  scope_down(out);
 
-    // Read field end marker
-    indent(out) <<
-      "iprot.readFieldEnd();" << endl;
+  // Read field end marker
+  indent(out) << "iprot.readFieldEnd();" << endl;
 
-    scope_down(out);
+  scope_down(out);
 
-    out <<
-      indent() << "iprot.readStructEnd();" << endl << endl;
+  out << indent() << "iprot.readStructEnd();" << endl << endl;
 
-    // in non-beans style, check for required fields of primitive type
-    // (which can be checked here but not in the general validate method)
-    out << endl << indent() << "// check for required fields of primitive type, which can't be checked in the validate method" << endl;
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
-        out <<
-          indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl <<
-          indent() << "  throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl <<
-          indent() << "}" << endl;
-      }
+  // in non-beans style, check for required fields of primitive type
+  // (which can be checked here but not in the general validate method)
+  out << endl << indent() << "// check for required fields of primitive type, which can't be "
+                             "checked in the validate method" << endl;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
+      out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl << indent()
+          << "  throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '"
+          << (*f_iter)->get_name()
+          << "' was not found in serialized data! Struct: \" + toString());" << endl << indent()
+          << "}" << endl;
     }
+  }
 
-    // performs various checks (e.g. check that all required fields are set)
-    indent(out) << "validate();" << endl;
+  // performs various checks (e.g. check that all required fields are set)
+  indent(out) << "validate();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 // generates as3 method to perform various checks
 // (e.g. check that all required fields are set)
-void t_as3_generator::generate_as3_validator(ofstream& out,
-                                                   t_struct* tstruct){
+void t_as3_generator::generate_as3_validator(ofstream& out, t_struct* tstruct) {
   indent(out) << "public function validate():void {" << endl;
   indent_up();
 
@@ -917,10 +868,13 @@ void t_as3_generator::generate_as3_validator(ofstream& out,
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
       if (type_can_be_null((*f_iter)->get_type())) {
         indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
-        indent(out) << "  throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
+        indent(out) << "  throw new TProtocolError(TProtocolError.UNKNOWN, \"Required field '"
+                    << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());"
+                    << endl;
         indent(out) << "}" << endl;
       } else {
-        indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." << endl;
+        indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
+                    << "' because it's a primitive and you chose the non-beans generator." << endl;
       }
     }
   }
@@ -931,10 +885,13 @@ void t_as3_generator::generate_as3_validator(ofstream& out,
     t_field* field = (*f_iter);
     t_type* type = field->get_type();
     // if field is an enum, check that its value is valid
-    if (type->is_enum()){
-      indent(out) << "if (" << generate_isset_check(field) << " && !" << get_enum_class_name(type) << ".VALID_VALUES.contains(" << field->get_name() << ")){" << endl;
+    if (type->is_enum()) {
+      indent(out) << "if (" << generate_isset_check(field) << " && !" << get_enum_class_name(type)
+                  << ".VALID_VALUES.contains(" << field->get_name() << ")){" << endl;
       indent_up();
-      indent(out) << "throw new TProtocolError(TProtocolError.UNKNOWN, \"The field '" << field->get_name() << "' has been assigned the invalid value \" + " << field->get_name() << ");" << endl;
+      indent(out) << "throw new TProtocolError(TProtocolError.UNKNOWN, \"The field '"
+                  << field->get_name() << "' has been assigned the invalid value \" + "
+                  << field->get_name() << ");" << endl;
       indent_down();
       indent(out) << "}" << endl;
     }
@@ -949,10 +906,8 @@ void t_as3_generator::generate_as3_validator(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_as3_generator::generate_as3_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public function write(oprot:TProtocol):void {" << endl;
+void t_as3_generator::generate_as3_struct_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function write(oprot:TProtocol):void {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -967,19 +922,18 @@ void t_as3_generator::generate_as3_struct_writer(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out <<
-        indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+      out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
       indent_up();
     }
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     if (null_allowed) {
       indent_down();
@@ -987,14 +941,11 @@ void t_as3_generator::generate_as3_struct_writer(ofstream& out,
     }
   }
   // Write the struct map
-  out <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
+      << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1005,10 +956,8 @@ void t_as3_generator::generate_as3_struct_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_as3_generator::generate_as3_struct_result_writer(ofstream& out,
-                                                          t_struct* tstruct) {
-  out <<
-    indent() << "public function write(oprot:TProtocol):void {" << endl;
+void t_as3_generator::generate_as3_struct_result_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function write(oprot:TProtocol):void {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1021,9 +970,7 @@ void t_as3_generator::generate_as3_struct_result_writer(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out <<
-        endl <<
-        indent() << "if ";
+      out << endl << indent() << "if ";
     } else {
       out << " else if ";
     }
@@ -1032,42 +979,44 @@ void t_as3_generator::generate_as3_struct_result_writer(ofstream& out,
 
     indent_up();
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}";
   }
   // Write the struct map
-  out <<
-    endl <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
+      << "oprot.writeStructEnd();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
-void t_as3_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
-  (void) type;
-  (void) cap_name;
+void t_as3_generator::generate_reflection_getters(ostringstream& out,
+                                                  t_type* type,
+                                                  string field_name,
+                                                  string cap_name) {
+  (void)type;
+  (void)cap_name;
   indent(out) << "case " << upcase_string(field_name) << ":" << endl;
   indent_up();
   indent(out) << "return this." << field_name << ";" << endl;
   indent_down();
 }
 
-void t_as3_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
-  (void) type;
-  (void) cap_name;
+void t_as3_generator::generate_reflection_setters(ostringstream& out,
+                                                  t_type* type,
+                                                  string field_name,
+                                                  string cap_name) {
+  (void)type;
+  (void)cap_name;
   indent(out) << "case " << upcase_string(field_name) << ":" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
@@ -1080,7 +1029,8 @@ void t_as3_generator::generate_reflection_setters(ostringstream& out, t_type* ty
   indent_down();
 }
 
-void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
+void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out,
+                                                             t_struct* tstruct) {
 
   std::ostringstream getter_stream;
   std::ostringstream setter_stream;
@@ -1100,7 +1050,6 @@ void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out,
     indent_down();
   }
 
-
   // create the setter
   indent(out) << "public function setFieldValue(fieldID:int, value:*):void {" << endl;
   indent_up();
@@ -1136,12 +1085,13 @@ void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out,
 }
 
 // Creates a generic isSet method that takes the field number as argument
-void t_as3_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct){
+void t_as3_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // create the isSet method
-  indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise" << endl;
+  indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a "
+                 "value) and false otherwise" << endl;
   indent(out) << "public function isSet(fieldID:int):Boolean {" << endl;
   indent_up();
   indent(out) << "switch (fieldID) {" << endl;
@@ -1170,7 +1120,8 @@ void t_as3_generator::generate_generic_isset_method(std::ofstream& out, t_struct
  * @param tstruct The struct definition
  */
 void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
-                                                      t_struct* tstruct, bool bindable) {
+                                                    t_struct* tstruct,
+                                                    bool bindable) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1181,8 +1132,7 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
 
     // Simple getter
     generate_as3_doc(out, field);
-    indent(out) << "public function get " << field_name << "():" <<
-      type_name(type) << " {" << endl;
+    indent(out) << "public function get " << field_name << "():" << type_name(type) << " {" << endl;
     indent_up();
     indent(out) << "return this._" << field_name << ";" << endl;
     indent_down();
@@ -1194,23 +1144,27 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
     if (bindable) {
       indent(out) << "[Bindable(event=\"" << propName << "\")]" << endl;
     }
-    indent(out) << "public function set " << field_name << "(" << field_name
-      << ":" << type_name(type) << "):void {" << endl;
+    indent(out) << "public function set " << field_name << "(" << field_name << ":"
+                << type_name(type) << "):void {" << endl;
     indent_up();
-    indent(out) << "this._" << field_name << " = " << field_name << ";" <<
-    endl;
+    indent(out) << "this._" << field_name << " = " << field_name << ";" << endl;
     generate_isset_set(out, field);
 
     if (bindable) {
       // We have to use a custom event rather than the default, because if you use the default,
-      // the setter only gets called if the value has changed - this means calling foo.setIntValue(0)
-      // will not cause foo.isIntValueSet() to return true since the value of foo._intValue wasn't changed
+      // the setter only gets called if the value has changed - this means calling
+      // foo.setIntValue(0)
+      // will not cause foo.isIntValueSet() to return true since the value of foo._intValue wasn't
+      // changed
       // so the setter was never called.
       indent(out) << "dispatchEvent(new Event(\"" << propName << "\"));" << endl;
 
-      // However, if you just use a custom event, then collections won't be able to detect when elements
-      // in the collections have changed since they listed for PropertyChangeEvents.  So, we dispatch both.
-      indent(out) << "dispatchEvent(new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE));" << endl;
+      // However, if you just use a custom event, then collections won't be able to detect when
+      // elements
+      // in the collections have changed since they listed for PropertyChangeEvents.  So, we
+      // dispatch both.
+      indent(out) << "dispatchEvent(new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE));"
+                  << endl;
     }
     indent_down();
     indent(out) << "}" << endl << endl;
@@ -1227,8 +1181,10 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
     indent(out) << "}" << endl << endl;
 
     // isSet method
-    indent(out) << "// Returns true if field " << field_name << " is set (has been assigned a value) and false otherwise" << endl;
-    indent(out) << "public function is" << get_cap_name("set") << cap_name << "():Boolean {" << endl;
+    indent(out) << "// Returns true if field " << field_name
+                << " is set (has been assigned a value) and false otherwise" << endl;
+    indent(out) << "public function is" << get_cap_name("set") << cap_name << "():Boolean {"
+                << endl;
     indent_up();
     if (type_can_be_null(type)) {
       indent(out) << "return this." << field_name << " != null;" << endl;
@@ -1246,13 +1202,14 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
  * @param tstruct The struct definition
  */
 void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
-                                                     t_struct* tstruct, bool bindable) {
+                                                   t_struct* tstruct,
+                                                   bool bindable) {
   // If it's bindable, it extends EventDispatcher so toString is an override.
-  out << indent() << "public " << (bindable ? "override " : "") << "function toString():String {" << endl;
+  out << indent() << "public " << (bindable ? "override " : "") << "function toString():String {"
+      << endl;
   indent_up();
 
-  out <<
-    indent() << "var ret:String = new String(\"" << tstruct->get_name() << "(\");" << endl;
+  out << indent() << "var ret:String = new String(\"" << tstruct->get_name() << "(\");" << endl;
   out << indent() << "var first:Boolean = true;" << endl << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1260,7 +1217,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
       indent_up();
     }
@@ -1281,8 +1238,10 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
 
     if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
       indent(out) << "  ret += \"BINARY\";" << endl;
-    } else if(field->get_type()->is_enum()) {
-      indent(out) << "var " << field->get_name() << "_name:String = " << get_enum_class_name(field->get_type()) << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];"<< endl;
+    } else if (field->get_type()->is_enum()) {
+      indent(out) << "var " << field->get_name()
+                  << "_name:String = " << get_enum_class_name(field->get_type())
+                  << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << endl;
       indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
       indent(out) << "  ret += " << field->get_name() << "_name;" << endl;
       indent(out) << "  ret += \" (\";" << endl;
@@ -1301,19 +1260,16 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
     }
     indent(out) << "first = false;" << endl;
 
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent_down();
       indent(out) << "}" << endl;
     }
     first = false;
   }
-  out <<
-    indent() << "ret += \")\";" << endl <<
-    indent() << "return ret;" << endl;
+  out << indent() << "ret += \")\";" << endl << indent() << "return ret;" << endl;
 
   indent_down();
-  indent(out) << "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1322,8 +1278,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_as3_generator::generate_as3_meta_data_map(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
@@ -1336,7 +1291,8 @@ void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       t_field* field = *f_iter;
       std::string field_name = field->get_name();
-      indent(out) << "metaDataMap[" << upcase_string(field_name) << "] = new FieldMetaData(\"" << field_name << "\", ";
+      indent(out) << "metaDataMap[" << upcase_string(field_name) << "] = new FieldMetaData(\""
+                  << field_name << "\", ";
 
       // Set field requirement type (required, optional, etc.)
       if (field->get_req() == t_field::T_REQUIRED) {
@@ -1349,7 +1305,7 @@ void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
 
       // Create value meta data
       generate_field_value_meta_data(out, field->get_type());
-      out  << ");" << endl;
+      out << ");" << endl;
     }
     scope_down(out);
   }
@@ -1360,7 +1316,7 @@ void t_as3_generator::generate_as3_meta_data_map(ofstream& out,
  * (e.g. for the type struct it returns "TType.STRUCT")
  */
 std::string t_as3_generator::get_as3_type_string(t_type* type) {
-  if (type->is_list()){
+  if (type->is_list()) {
     return "TType.LIST";
   } else if (type->is_map()) {
     return "TType.MAP";
@@ -1374,37 +1330,58 @@ std::string t_as3_generator::get_as3_type_string(t_type* type) {
     return get_as3_type_string(((t_typedef*)type)->get_type());
   } else if (type->is_base_type()) {
     switch (((t_base_type*)type)->get_base()) {
-      case t_base_type::TYPE_VOID   : return      "TType.VOID"; break;
-      case t_base_type::TYPE_STRING : return    "TType.STRING"; break;
-      case t_base_type::TYPE_BOOL   : return      "TType.BOOL"; break;
-      case t_base_type::TYPE_BYTE   : return      "TType.BYTE"; break;
-      case t_base_type::TYPE_I16    : return       "TType.I16"; break;
-      case t_base_type::TYPE_I32    : return       "TType.I32"; break;
-      case t_base_type::TYPE_I64    : return       "TType.I64"; break;
-      case t_base_type::TYPE_DOUBLE : return    "TType.DOUBLE"; break;
-      default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_as3_generator::get_as3_type_string!"); break; // This should never happen!
+    case t_base_type::TYPE_VOID:
+      return "TType.VOID";
+      break;
+    case t_base_type::TYPE_STRING:
+      return "TType.STRING";
+      break;
+    case t_base_type::TYPE_BOOL:
+      return "TType.BOOL";
+      break;
+    case t_base_type::TYPE_BYTE:
+      return "TType.BYTE";
+      break;
+    case t_base_type::TYPE_I16:
+      return "TType.I16";
+      break;
+    case t_base_type::TYPE_I32:
+      return "TType.I32";
+      break;
+    case t_base_type::TYPE_I64:
+      return "TType.I64";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      return "TType.DOUBLE";
+      break;
+    default:
+      throw std::runtime_error("Unknown thrift type \"" + type->get_name()
+                               + "\" passed to t_as3_generator::get_as3_type_string!");
+      break; // This should never happen!
     }
   } else {
-    throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_as3_generator::get_as3_type_string!"); // This should never happen!
+    throw std::runtime_error(
+        "Unknown thrift type \"" + type->get_name()
+        + "\" passed to t_as3_generator::get_as3_type_string!"); // This should never happen!
   }
 }
 
-void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type){
+void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
   out << endl;
   indent_up();
   indent_up();
-  if (type->is_struct()){
+  if (type->is_struct()) {
     indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type);
-  } else if (type->is_container()){
-    if (type->is_list()){
+  } else if (type->is_container()) {
+    if (type->is_list()) {
       indent(out) << "new ListMetaData(TType.LIST, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else if (type->is_set()){
+    } else if (type->is_set()) {
       indent(out) << "new SetMetaData(TType.SET, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else{ // map
+    } else { // map
       indent(out) << "new MapMetaData(TType.MAP, ";
       t_type* key_type = ((t_map*)type)->get_key_type();
       t_type* val_type = ((t_map*)type)->get_val_type();
@@ -1420,7 +1397,6 @@ void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type*
   indent_down();
 }
 
-
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1431,23 +1407,20 @@ void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type*
  */
 void t_as3_generator::generate_service(t_service* tservice) {
   // Make interface file
-  string f_service_name = package_dir_+"/"+service_name_+".as";
+  string f_service_name = package_dir_ + "/" + service_name_ + ".as";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    autogen_comment() << as3_package();
+  f_service_ << autogen_comment() << as3_package();
 
   scope_up(f_service_);
 
-  f_service_ << endl <<
-    as3_type_imports() <<
-    as3_thrift_imports() <<
-    as3_thrift_gen_imports(tservice);
+  f_service_ << endl << as3_type_imports() << as3_thrift_imports()
+             << as3_thrift_gen_imports(tservice);
 
-  if(tservice->get_extends() != NULL) {
+  if (tservice->get_extends() != NULL) {
     t_type* parent = tservice->get_extends();
     string parent_namespace = parent->get_program()->get_namespace("as3");
-    if(!parent_namespace.empty() && parent_namespace != package_name_) {
+    if (!parent_namespace.empty() && parent_namespace != package_name_) {
       f_service_ << "import " << type_name(parent) << ";" << endl;
     }
   }
@@ -1460,24 +1433,20 @@ void t_as3_generator::generate_service(t_service* tservice) {
   f_service_.close();
 
   // Now make the implementation/client file
-  f_service_name = package_dir_+"/"+service_name_+"Impl.as";
+  f_service_name = package_dir_ + "/" + service_name_ + "Impl.as";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-  autogen_comment() << as3_package();
+  f_service_ << autogen_comment() << as3_package();
 
   scope_up(f_service_);
 
-  f_service_ << endl <<
-  as3_type_imports() <<
-  as3_thrift_imports() <<
-  as3_thrift_gen_imports(tservice);
+  f_service_ << endl << as3_type_imports() << as3_thrift_imports()
+             << as3_thrift_gen_imports(tservice);
 
-
-  if(tservice->get_extends() != NULL) {
+  if (tservice->get_extends() != NULL) {
     t_type* parent = tservice->get_extends();
     string parent_namespace = parent->get_program()->get_namespace("as3");
-    if(!parent_namespace.empty() && parent_namespace != package_name_) {
+    if (!parent_namespace.empty() && parent_namespace != package_name_) {
       f_service_ << "import " << type_name(parent) << "Impl;" << endl;
     }
   }
@@ -1490,7 +1459,7 @@ void t_as3_generator::generate_service(t_service* tservice) {
   f_service_ << as3_type_imports();
   f_service_ << as3_thrift_imports();
   f_service_ << as3_thrift_gen_imports(tservice);
-  if(!package_name_.empty()) {
+  if (!package_name_.empty()) {
     f_service_ << "import " << package_name_ << ".*;" << endl;
   }
 
@@ -1499,33 +1468,29 @@ void t_as3_generator::generate_service(t_service* tservice) {
   f_service_.close();
 
   // Now make the processor/server file
-  f_service_name = package_dir_+"/"+service_name_+"Processor.as";
+  f_service_name = package_dir_ + "/" + service_name_ + "Processor.as";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-  autogen_comment() << as3_package();
+  f_service_ << autogen_comment() << as3_package();
 
   scope_up(f_service_);
 
-  f_service_ << endl <<
-  as3_type_imports() <<
-  as3_thrift_imports() <<
-  as3_thrift_gen_imports(tservice) << endl;
+  f_service_ << endl << as3_type_imports() << as3_thrift_imports()
+             << as3_thrift_gen_imports(tservice) << endl;
 
   generate_service_server(tservice);
   scope_down(f_service_);
 
   f_service_ << as3_type_imports();
   f_service_ << as3_thrift_imports();
-  f_service_ << as3_thrift_gen_imports(tservice) <<endl;
-  if(!package_name_.empty()) {
+  f_service_ << as3_thrift_gen_imports(tservice) << endl;
+  if (!package_name_.empty()) {
     f_service_ << "import " << package_name_ << ".*;" << endl;
   }
 
   generate_service_helpers(tservice);
 
   f_service_.close();
-
 }
 
 /**
@@ -1540,8 +1505,8 @@ void t_as3_generator::generate_service_interface(t_service* tservice) {
   }
 
   generate_as3_doc(f_service_, tservice);
-  f_service_ << indent() << "public interface " << service_name_ << extends_iface <<
-    " {" << endl << endl;
+  f_service_ << indent() << "public interface " << service_name_ << extends_iface << " {" << endl
+             << endl;
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
@@ -1551,19 +1516,16 @@ void t_as3_generator::generate_service_interface(t_service* tservice) {
       if ((*f_iter)->get_returntype()->is_void()) {
         indent(f_service_) << "//function onError(Error):void;" << endl;
         indent(f_service_) << "//function onSuccess():void;" << endl;
-      }
-      else {
+      } else {
         indent(f_service_) << "//function onError(Error):void;" << endl;
-        indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype()) << "):void;" << endl;
+        indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype())
+                           << "):void;" << endl;
       }
     }
-    indent(f_service_) << function_signature(*f_iter) << ";" <<
-      endl << endl;
+    indent(f_service_) << function_signature(*f_iter) << ";" << endl << endl;
   }
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1594,16 +1556,15 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
     extends_client = " extends " + extends + "Impl";
   }
 
-  indent(f_service_) <<
-    "public class " << service_name_ << "Impl" << extends_client << " implements " << service_name_ << " {" << endl;
+  indent(f_service_) << "public class " << service_name_ << "Impl" << extends_client
+                     << " implements " << service_name_ << " {" << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public function " << service_name_ << "Impl" << "(iprot:TProtocol, oprot:TProtocol=null)" << endl;
+  indent(f_service_) << "public function " << service_name_ << "Impl"
+                     << "(iprot:TProtocol, oprot:TProtocol=null)" << endl;
   scope_up(f_service_);
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "iprot_ = iprot;" << endl;
+    f_service_ << indent() << "iprot_ = iprot;" << endl;
     f_service_ << indent() << "if (oprot == null) {" << endl;
     indent_up();
     f_service_ << indent() << "oprot_ = iprot;" << endl;
@@ -1614,36 +1575,27 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
     indent_down();
     f_service_ << indent() << "}";
   } else {
-    f_service_ <<
-      indent() << "super(iprot, oprot);" << endl;
+    f_service_ << indent() << "super(iprot, oprot);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected var iprot_:TProtocol;"  << endl <<
-      indent() << "protected var oprot_:TProtocol;"  << endl <<
-      endl <<
-      indent() << "protected var seqid_:int;" << endl <<
-      endl;
-
-    indent(f_service_) <<
-      "public function getInputProtocol():TProtocol" << endl;
+    f_service_ << indent() << "protected var iprot_:TProtocol;" << endl << indent()
+               << "protected var oprot_:TProtocol;" << endl << endl << indent()
+               << "protected var seqid_:int;" << endl << endl;
+
+    indent(f_service_) << "public function getInputProtocol():TProtocol" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.iprot_;" << endl;
+    indent(f_service_) << "return this.iprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
 
-    indent(f_service_) <<
-      "public function getOutputProtocol():TProtocol" << endl;
+    indent(f_service_) << "public function getOutputProtocol():TProtocol" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.oprot_;" << endl;
+    indent(f_service_) << "return this.oprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
-
   }
 
   // Generate client method implementations
@@ -1657,17 +1609,15 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
       if ((*f_iter)->get_returntype()->is_void()) {
         indent(f_service_) << "//function onError(Error):void;" << endl;
         indent(f_service_) << "//function onSuccess():void;" << endl;
-      }
-      else {
+      } else {
         indent(f_service_) << "//function onError(Error):void;" << endl;
-        indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype()) << "):void;" << endl;
+        indent(f_service_) << "//function onSuccess(" << type_name((*f_iter)->get_returntype())
+                           << "):void;" << endl;
       }
     }
-    indent(f_service_) <<
-      "public " << function_signature(*f_iter) << endl;
+    indent(f_service_) << "public " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
 
-
     // Get the struct of function call params
     t_struct* arg_struct = (*f_iter)->get_arglist();
 
@@ -1676,85 +1626,71 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
     const vector<t_field*>& fields = arg_struct->get_members();
 
     // Serialize the request
-    f_service_ <<
-      indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", " <<
-      ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") <<
-      ", seqid_));" << endl <<
-      indent() << "var args:" << argsname << " = new " << argsname << "();" << endl;
+    f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", "
+               << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
+               << ", seqid_));" << endl << indent() << "var args:" << argsname << " = new "
+               << argsname << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args." << (*fld_iter)->get_name() << " = " << (*fld_iter)->get_name() << ";" << endl;
+      f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
+                 << (*fld_iter)->get_name() << ";" << endl;
     }
 
-    f_service_ <<
-      indent() << "args.write(oprot_);" << endl <<
-    indent() << "oprot_.writeMessageEnd();" << endl;
+    f_service_ << indent() << "args.write(oprot_);" << endl << indent()
+               << "oprot_.writeMessageEnd();" << endl;
 
     if ((*f_iter)->is_oneway()) {
       f_service_ << indent() << "oprot_.getTransport().flush();" << endl;
-    }
-    else {
+    } else {
       f_service_ << indent() << "oprot_.getTransport().flush(function(error:Error):void {" << endl;
       indent_up();
       f_service_ << indent() << "try {" << endl;
       indent_up();
       string resultname = (*f_iter)->get_name() + "_result";
-      f_service_ <<
-        indent() << "if (error != null) {" << endl <<
-        indent() << "  if (onError != null) onError(error);" << endl <<
-        indent() << "  return;" << endl <<
-        indent() << "}" << endl <<
-        indent() << "var msg:TMessage = iprot_.readMessageBegin();" << endl <<
-        indent() << "if (msg.type == TMessageType.EXCEPTION) {" << endl <<
-        indent() << "  var x:TApplicationError = TApplicationError.read(iprot_);" << endl <<
-        indent() << "  iprot_.readMessageEnd();" << endl <<
-        indent() << "  if (onError != null) onError(x);" << endl <<
-        indent() << "  return;" << endl <<
-        indent() << "}" << endl <<
-        indent() << "var result :" << resultname << " = new " << resultname << "();" << endl <<
-        indent() << "result.read(iprot_);" << endl <<
-        indent() << "iprot_.readMessageEnd();" << endl;
+      f_service_ << indent() << "if (error != null) {" << endl << indent()
+                 << "  if (onError != null) onError(error);" << endl << indent() << "  return;"
+                 << endl << indent() << "}" << endl << indent()
+                 << "var msg:TMessage = iprot_.readMessageBegin();" << endl << indent()
+                 << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent()
+                 << "  var x:TApplicationError = TApplicationError.read(iprot_);" << endl
+                 << indent() << "  iprot_.readMessageEnd();" << endl << indent()
+                 << "  if (onError != null) onError(x);" << endl << indent() << "  return;" << endl
+                 << indent() << "}" << endl << indent() << "var result :" << resultname << " = new "
+                 << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl
+                 << indent() << "iprot_.readMessageEnd();" << endl;
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
-          indent() << "  if (onSuccess != null) onSuccess(result.success);" << endl <<
-          indent() << "  return;" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
+                   << indent() << "  if (onSuccess != null) onSuccess(result.success);" << endl
+                   << indent() << "  return;" << endl << indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
-          indent() << "  if (onError != null) onError(result." << (*x_iter)->get_name() << ");" << endl <<
-          indent() << "  return;" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl
+                   << indent() << "  if (onError != null) onError(result." << (*x_iter)->get_name()
+                   << ");" << endl << indent() << "  return;" << endl << indent() << "}" << endl;
       }
 
       // If you get here it's an exception, unless a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if (onSuccess != null) onSuccess();" << endl <<
-          indent() << "return;" << endl;
+        f_service_ << indent() << "if (onSuccess != null) onSuccess();" << endl << indent()
+                   << "return;" << endl;
       } else {
 
-        f_service_ <<
-          indent() << "if (onError != null) onError(new TApplicationError(TApplicationError.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\"));" << endl;
+        f_service_ << indent() << "if (onError != null) onError(new "
+                                  "TApplicationError(TApplicationError.MISSING_RESULT, \""
+                   << (*f_iter)->get_name() << " failed: unknown result\"));" << endl;
       }
       indent_down();
-      f_service_ << indent() << "} catch (e:TError) {" << endl <<
-        indent() << "  if (onError != null) onError(e);" << endl <<
-        indent() << "}" << endl;
-
+      f_service_ << indent() << "} catch (e:TError) {" << endl << indent()
+                 << "  if (onError != null) onError(e);" << endl << indent() << "}" << endl;
 
       indent_down();
-      indent(f_service_) <<
-      "});" << endl;
+      indent(f_service_) << "});" << endl;
     }
     // Close function
     scope_down(f_service_);
@@ -1762,8 +1698,7 @@ void t_as3_generator::generate_service_client(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl;
+  indent(f_service_) << "}" << endl;
 }
 
 /**
@@ -1785,34 +1720,30 @@ void t_as3_generator::generate_service_server(t_service* tservice) {
   }
 
   // Generate the header portion
-  indent(f_service_) <<
-    "public class " << service_name_ << "Processor" << extends_processor << " implements TProcessor {" << endl;
+  indent(f_service_) << "public class " << service_name_ << "Processor" << extends_processor
+                     << " implements TProcessor {" << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public function " << service_name_ << "Processor(iface:" << service_name_ << ")" << endl;
+  indent(f_service_) << "public function " << service_name_ << "Processor(iface:" << service_name_
+                     << ")" << endl;
   scope_up(f_service_);
   if (!extends.empty()) {
-    f_service_ <<
-      indent() << "super(iface);" << endl;
+    f_service_ << indent() << "super(iface);" << endl;
   }
-  f_service_ <<
-    indent() << "iface_ = iface;" << endl;
+  f_service_ << indent() << "iface_ = iface;" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "PROCESS_MAP[\"" << (*f_iter)->get_name() << "\"] = " << (*f_iter)->get_name() << "();" << endl;
+    f_service_ << indent() << "PROCESS_MAP[\"" << (*f_iter)->get_name()
+               << "\"] = " << (*f_iter)->get_name() << "();" << endl;
   }
 
   scope_down(f_service_);
   f_service_ << endl;
 
-  f_service_ <<
-    indent() << "private var iface_:"  << service_name_ << ";" << endl;
+  f_service_ << indent() << "private var iface_:" << service_name_ << ";" << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected const PROCESS_MAP:Dictionary = new Dictionary();" << endl;
+    f_service_ << indent() << "protected const PROCESS_MAP:Dictionary = new Dictionary();" << endl;
   }
 
   f_service_ << endl;
@@ -1820,34 +1751,31 @@ void t_as3_generator::generate_service_server(t_service* tservice) {
   // Generate the server implementation
   string override = "";
   if (tservice->get_extends() != NULL) {
-      override = "override ";
+    override = "override ";
   }
-  indent(f_service_) << override << "public function process(iprot:TProtocol, oprot:TProtocol):Boolean" << endl;
+  indent(f_service_) << override
+                     << "public function process(iprot:TProtocol, oprot:TProtocol):Boolean" << endl;
   scope_up(f_service_);
 
-  f_service_ <<
-  indent() << "var msg:TMessage = iprot.readMessageBegin();" << endl;
+  f_service_ << indent() << "var msg:TMessage = iprot.readMessageBegin();" << endl;
 
   // TODO(mcslee): validate message, was the seqid etc. legit?
   // AS- If all method is oneway:
   // do you have an oprot?
   // do you you need nullcheck?
-  f_service_ <<
-    indent() << "var fn:Function = PROCESS_MAP[msg.name];" << endl <<
-    indent() << "if (fn == null) {" << endl <<
-    indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl <<
-    indent() << "  iprot.readMessageEnd();" << endl <<
-    indent() << "  var x:TApplicationError = new TApplicationError(TApplicationError.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl <<
-    indent() << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl <<
-    indent() << "  x.write(oprot);" << endl <<
-    indent() << "  oprot.writeMessageEnd();" << endl <<
-    indent() << "  oprot.getTransport().flush();" << endl <<
-    indent() << "  return true;" << endl <<
-    indent() << "}" << endl <<
-    indent() << "fn.call(this,msg.seqid, iprot, oprot);" << endl;
-
-  f_service_ <<
-    indent() << "return true;" << endl;
+  f_service_
+      << indent() << "var fn:Function = PROCESS_MAP[msg.name];" << endl << indent()
+      << "if (fn == null) {" << endl << indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);"
+      << endl << indent() << "  iprot.readMessageEnd();" << endl << indent()
+      << "  var x:TApplicationError = new TApplicationError(TApplicationError.UNKNOWN_METHOD, "
+         "\"Invalid method name: '\"+msg.name+\"'\");" << endl << indent()
+      << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
+      << endl << indent() << "  x.write(oprot);" << endl << indent() << "  oprot.writeMessageEnd();"
+      << endl << indent() << "  oprot.getTransport().flush();" << endl << indent()
+      << "  return true;" << endl << indent() << "}" << endl << indent()
+      << "fn.call(this,msg.seqid, iprot, oprot);" << endl;
+
+  f_service_ << indent() << "return true;" << endl;
 
   scope_down(f_service_);
   f_service_ << endl;
@@ -1858,9 +1786,7 @@ void t_as3_generator::generate_service_server(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl <<
-    endl;
+  indent(f_service_) << "}" << endl << endl;
 }
 
 /**
@@ -1894,27 +1820,22 @@ void t_as3_generator::generate_function_helpers(t_function* tfunction) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_as3_generator::generate_process_function(t_service* tservice,
-                                                 t_function* tfunction) {
-  (void) tservice;
+void t_as3_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open class
-  indent(f_service_) <<
-  "private function " << tfunction->get_name() << "():Function {" << endl;
+  indent(f_service_) << "private function " << tfunction->get_name() << "():Function {" << endl;
   indent_up();
 
   // Open function
-  indent(f_service_) <<
-    "return function(seqid:int, iprot:TProtocol, oprot:TProtocol):void"
-    << endl;
+  indent(f_service_) << "return function(seqid:int, iprot:TProtocol, oprot:TProtocol):void" << endl;
   scope_up(f_service_);
 
   string argsname = tfunction->get_name() + "_args";
   string resultname = tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << "var args:"<< argsname << " = new " << argsname << "();" << endl <<
-    indent() << "args.read(iprot);" << endl <<
-    indent() << "iprot.readMessageEnd();" << endl;
+  f_service_ << indent() << "var args:" << argsname << " = new " << argsname << "();" << endl
+             << indent() << "args.read(iprot);" << endl << indent() << "iprot.readMessageEnd();"
+             << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1922,14 +1843,13 @@ void t_as3_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "var result:" << resultname << " = new " << resultname << "();" << endl;
+    f_service_ << indent() << "var result:" << resultname << " = new " << resultname << "();"
+               << endl;
   }
 
   // Try block for a function with exceptions
   if (xceptions.size() > 0) {
-    f_service_ <<
-      indent() << "try {" << endl;
+    f_service_ << indent() << "try {" << endl;
     indent_up();
   }
 
@@ -1939,9 +1859,8 @@ void t_as3_generator::generate_process_function(t_service* tservice,
   vector<t_field*>::const_iterator f_iter;
 
   f_service_ << indent();
-  if (tfunction->is_oneway()){
-    f_service_ <<
-      "iface_." << tfunction->get_name() << "(";
+  if (tfunction->is_oneway()) {
+    f_service_ << "iface_." << tfunction->get_name() << "(";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
@@ -1958,20 +1877,22 @@ void t_as3_generator::generate_process_function(t_service* tservice,
   }
 
   // Set isset on success field
-  if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) {
-    f_service_ <<
-      indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet") << "(true);" << endl;
+  if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()
+      && !type_can_be_null(tfunction->get_returntype())) {
+    f_service_ << indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet")
+               << "(true);" << endl;
   }
 
   if (!tfunction->is_oneway() && xceptions.size() > 0) {
     indent_down();
     f_service_ << indent() << "}";
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_ << " catch (" << (*x_iter)->get_name() << ":" << type_name((*x_iter)->get_type(), false, false) << ") {" << endl;
+      f_service_ << " catch (" << (*x_iter)->get_name() << ":"
+                 << type_name((*x_iter)->get_type(), false, false) << ") {" << endl;
       if (!tfunction->is_oneway()) {
         indent_up();
-        f_service_ <<
-          indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << ";" << endl;
+        f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
+                   << (*x_iter)->get_name() << ";" << endl;
         indent_down();
         f_service_ << indent() << "}";
       } else {
@@ -1980,37 +1901,34 @@ void t_as3_generator::generate_process_function(t_service* tservice,
     }
     f_service_ << " catch (th:Error) {" << endl;
     indent_up();
-    f_service_ <<
-      indent() << "trace(\"Internal error processing " << tfunction->get_name() << "\", th);" << endl <<
-      indent() << "var x:TApplicationError = new TApplicationError(TApplicationError.INTERNAL_ERROR, \"Internal error processing " << tfunction->get_name() << "\");" << endl <<
-      indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl <<
-      indent() << "x.write(oprot);" << endl <<
-      indent() << "oprot.writeMessageEnd();" << endl <<
-      indent() << "oprot.getTransport().flush();" << endl <<
-      indent() << "return;" << endl;
+    f_service_ << indent() << "trace(\"Internal error processing " << tfunction->get_name()
+               << "\", th);" << endl << indent()
+               << "var x:TApplicationError = new "
+                  "TApplicationError(TApplicationError.INTERNAL_ERROR, \"Internal error processing "
+               << tfunction->get_name() << "\");" << endl << indent()
+               << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
+               << "\", TMessageType.EXCEPTION, seqid));" << endl << indent() << "x.write(oprot);"
+               << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
+               << "oprot.getTransport().flush();" << endl << indent() << "return;" << endl;
     indent_down();
     f_service_ << indent() << "}" << endl;
   }
 
   // Shortcut out here for oneway functions
   if (tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "return;" << endl;
+    f_service_ << indent() << "return;" << endl;
     scope_down(f_service_);
 
     // Close class
     indent_down();
-    f_service_ <<
-      indent() << "}" << endl <<
-      endl;
+    f_service_ << indent() << "}" << endl << endl;
     return;
   }
 
-  f_service_ <<
-    indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.REPLY, seqid));" << endl <<
-    indent() << "result.write(oprot);" << endl <<
-    indent() << "oprot.writeMessageEnd();" << endl <<
-    indent() << "oprot.getTransport().flush();" << endl;
+  f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
+             << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);"
+             << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
+             << "oprot.getTransport().flush();" << endl;
 
   // Close function
   scope_down(f_service_);
@@ -2018,9 +1936,7 @@ void t_as3_generator::generate_process_function(t_service* tservice,
 
   // Close class
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "}" << endl << endl;
 }
 
 /**
@@ -2029,35 +1945,28 @@ void t_as3_generator::generate_process_function(t_service* tservice,
  * @param tfield The field
  * @param prefix The variable name or container for this field
  */
-void t_as3_generator::generate_deserialize_field(ofstream& out,
-                                                  t_field* tfield,
-                                                  string prefix) {
+void t_as3_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = prefix + tfield->get_name();
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                name);
+    generate_deserialize_struct(out, (t_struct*)type, name);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
 
-    indent(out) <<
-      name << " = iprot.";
+    indent(out) << name << " = iprot.";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         if (((t_base_type*)type)->is_binary()) {
@@ -2090,31 +1999,26 @@ void t_as3_generator::generate_deserialize_field(ofstream& out,
     } else if (type->is_enum()) {
       out << "readI32();";
     }
-    out <<
-      endl;
+    out << endl;
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type_name(type).c_str());
+           tfield->get_name().c_str(),
+           type_name(type).c_str());
   }
 }
 
 /**

<TRUNCATED>

[31/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_d_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_d_generator.cc b/compiler/cpp/src/generate/t_d_generator.cc
index 622fb29..ca76485 100644
--- a/compiler/cpp/src/generate/t_d_generator.cc
+++ b/compiler/cpp/src/generate/t_d_generator.cc
@@ -43,7 +43,7 @@ using std::set;
 using std::string;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * D code generator.
@@ -54,19 +54,17 @@ static const string endl = "\n";  // avoid ostream << std::endl flushes
  * the passed entity.
  */
 class t_d_generator : public t_oop_generator {
- public:
-  t_d_generator(
-      t_program* program,
-      const std::map<string, string>& parsed_options,
-      const string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_d_generator(t_program* program,
+                const std::map<string, string>& parsed_options,
+                const string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-d";
   }
 
- protected:
+protected:
   virtual void init_generator() {
     // Make output directory
     MKDIR(get_out_dir().c_str());
@@ -77,7 +75,7 @@ class t_d_generator : public t_oop_generator {
     while ((loc = dir.find(".")) != string::npos) {
       subdir = subdir + "/" + dir.substr(0, loc);
       MKDIR(subdir.c_str());
-      dir = dir.substr(loc+1);
+      dir = dir.substr(loc + 1);
     }
     if (!dir.empty()) {
       subdir = subdir + "/" + dir;
@@ -91,21 +89,19 @@ class t_d_generator : public t_oop_generator {
     f_types_.open(f_types_name.c_str());
 
     // Print header
-    f_types_ <<
-      autogen_comment() <<
-      "module " << render_package(*program_) << program_name_ << "_types;" << endl <<
-      endl;
+    f_types_ << autogen_comment() << "module " << render_package(*program_) << program_name_
+             << "_types;" << endl << endl;
 
     print_default_imports(f_types_);
 
     // Include type modules from other imported programs.
     const vector<t_program*>& includes = program_->get_includes();
     for (size_t i = 0; i < includes.size(); ++i) {
-      f_types_ <<
-        "import " << render_package(*(includes[i])) <<
-        includes[i]->get_name() << "_types;" << endl;
+      f_types_ << "import " << render_package(*(includes[i])) << includes[i]->get_name()
+               << "_types;" << endl;
     }
-    if (!includes.empty()) f_types_ << endl;
+    if (!includes.empty())
+      f_types_ << endl;
   }
 
   virtual void close_generator() {
@@ -115,32 +111,26 @@ class t_d_generator : public t_oop_generator {
 
   virtual void generate_consts(std::vector<t_const*> consts) {
     if (!consts.empty()) {
-      string f_consts_name = package_dir_+program_name_+"_constants.d";
+      string f_consts_name = package_dir_ + program_name_ + "_constants.d";
       ofstream f_consts;
       f_consts.open(f_consts_name.c_str());
 
-      f_consts <<
-        autogen_comment() <<
-        "module " << render_package(*program_) << program_name_ << "_constants;" << endl
-        << endl;
+      f_consts << autogen_comment() << "module " << render_package(*program_) << program_name_
+               << "_constants;" << endl << endl;
 
       print_default_imports(f_consts);
 
-      f_consts <<
-        "import " << render_package(*get_program()) << program_name_ << "_types;" << endl <<
-        endl;
+      f_consts << "import " << render_package(*get_program()) << program_name_ << "_types;" << endl
+               << endl;
 
       vector<t_const*>::iterator c_iter;
       for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
         string name = (*c_iter)->get_name();
         t_type* type = (*c_iter)->get_type();
-        indent(f_consts) << "immutable(" << render_type_name(type) << ") " <<
-          name << ";" << endl;
+        indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << endl;
       }
 
-      f_consts <<
-        endl <<
-        "static this() {" << endl;
+      f_consts << endl << "static this() {" << endl;
       indent_up();
 
       bool first = true;
@@ -155,27 +145,23 @@ class t_d_generator : public t_oop_generator {
         if (!is_immutable_type(type)) {
           f_consts << "cast(immutable(" << render_type_name(type) << ")) ";
         }
-        f_consts <<
-          render_const_value(type, (*c_iter)->get_value()) << ";" << endl;
+        f_consts << render_const_value(type, (*c_iter)->get_value()) << ";" << endl;
       }
       indent_down();
-      indent(f_consts) <<
-        "}" << endl;
+      indent(f_consts) << "}" << endl;
     }
   }
 
   virtual void generate_typedef(t_typedef* ttypedef) {
-    f_types_ <<
-      indent() << "alias " << render_type_name(ttypedef->get_type()) << " " <<
-      ttypedef->get_symbolic() << ";" << endl << endl;
+    f_types_ << indent() << "alias " << render_type_name(ttypedef->get_type()) << " "
+             << ttypedef->get_symbolic() << ";" << endl << endl;
   }
 
   virtual void generate_enum(t_enum* tenum) {
     vector<t_enum_value*> constants = tenum->get_constants();
 
     string enum_name = tenum->get_name();
-    f_types_ <<
-      indent() << "enum " << enum_name << " {" << endl;
+    f_types_ << indent() << "enum " << enum_name << " {" << endl;
 
     indent_up();
 
@@ -213,21 +199,17 @@ class t_d_generator : public t_oop_generator {
     string f_servicename = package_dir_ + svc_name + ".d";
     std::ofstream f_service;
     f_service.open(f_servicename.c_str());
-    f_service <<
-      autogen_comment() <<
-      "module " << render_package(*program_) << svc_name << ";" << endl <<
-      endl;
+    f_service << autogen_comment() << "module " << render_package(*program_) << svc_name << ";"
+              << endl << endl;
 
     print_default_imports(f_service);
 
-    f_service << "import " << render_package(*get_program()) << program_name_ <<
-      "_types;" << endl;
+    f_service << "import " << render_package(*get_program()) << program_name_ << "_types;" << endl;
 
     t_service* extends_service = tservice->get_extends();
     if (extends_service != NULL) {
-      f_service <<
-        "import " << render_package(*(extends_service->get_program())) <<
-        extends_service->get_name() << ";" << endl;
+      f_service << "import " << render_package(*(extends_service->get_program()))
+                << extends_service->get_name() << ";" << endl;
     }
 
     f_service << endl;
@@ -237,8 +219,7 @@ class t_d_generator : public t_oop_generator {
       extends = " : " + render_type_name(tservice->get_extends());
     }
 
-    f_service <<
-      indent() << "interface " << svc_name << extends << " {" << endl;
+    f_service << indent() << "interface " << svc_name << extends << " {" << endl;
     indent_up();
 
     // Collect all the exception types service methods can throw so we can
@@ -261,12 +242,14 @@ class t_d_generator : public t_oop_generator {
     }
 
     // Alias the exception types into the current scope.
-    if (!exception_types.empty()) f_service << endl;
+    if (!exception_types.empty())
+      f_service << endl;
     set<t_type*>::const_iterator et_iter;
     for (et_iter = exception_types.begin(); et_iter != exception_types.end(); ++et_iter) {
-      indent(f_service) << "alias " << render_package(*(*et_iter)->get_program()) <<
-        (*et_iter)->get_program()->get_name() << "_types" << "." <<
-        (*et_iter)->get_name() << " " << (*et_iter)->get_name() << ";" << endl;
+      indent(f_service) << "alias " << render_package(*(*et_iter)->get_program())
+                        << (*et_iter)->get_program()->get_name() << "_types"
+                        << "." << (*et_iter)->get_name() << " " << (*et_iter)->get_name() << ";"
+                        << endl;
     }
 
     // Write the method metadata.
@@ -274,9 +257,8 @@ class t_d_generator : public t_oop_generator {
     indent_up();
     bool first = true;
     for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) {
-      if ((*fn_iter)->get_arglist()->get_members().empty() &&
-        (*fn_iter)->get_xceptions()->get_members().empty() &&
-        !(*fn_iter)->is_oneway()) {
+      if ((*fn_iter)->get_arglist()->get_members().empty()
+          && (*fn_iter)->get_xceptions()->get_members().empty() && !(*fn_iter)->is_oneway()) {
         continue;
       }
 
@@ -286,13 +268,12 @@ class t_d_generator : public t_oop_generator {
         meta << ",";
       }
 
-      meta << endl <<
-        indent() << "TMethodMeta(`" << (*fn_iter)->get_name() << "`, " << endl;
+      meta << endl << indent() << "TMethodMeta(`" << (*fn_iter)->get_name() << "`, " << endl;
       indent_up();
       indent(meta) << "[";
 
       bool first = true;
-      const vector<t_field*> &params = (*fn_iter)->get_arglist()->get_members();
+      const vector<t_field*>& params = (*fn_iter)->get_arglist()->get_members();
       vector<t_field*>::const_iterator p_iter;
       for (p_iter = params.begin(); p_iter != params.end(); ++p_iter) {
         if (first) {
@@ -312,14 +293,11 @@ class t_d_generator : public t_oop_generator {
 
       meta << "]";
 
-      if (!(*fn_iter)->get_xceptions()->get_members().empty() ||
-        (*fn_iter)->is_oneway()) {
-        meta << "," << endl <<
-          indent() << "[";
+      if (!(*fn_iter)->get_xceptions()->get_members().empty() || (*fn_iter)->is_oneway()) {
+        meta << "," << endl << indent() << "[";
 
         bool first = true;
-        const vector<t_field*>& exceptions =
-          (*fn_iter)->get_xceptions()->get_members();
+        const vector<t_field*>& exceptions = (*fn_iter)->get_xceptions()->get_members();
         vector<t_field*>::const_iterator ex_iter;
         for (ex_iter = exceptions.begin(); ex_iter != exceptions.end(); ++ex_iter) {
           if (first) {
@@ -328,36 +306,31 @@ class t_d_generator : public t_oop_generator {
             meta << ", ";
           }
 
-          meta << "TExceptionMeta(`" << (*ex_iter)->get_name() <<
-            "`, " << (*ex_iter)->get_key() << ", `" <<
-            (*ex_iter)->get_type()->get_name() << "`)";
+          meta << "TExceptionMeta(`" << (*ex_iter)->get_name() << "`, " << (*ex_iter)->get_key()
+               << ", `" << (*ex_iter)->get_type()->get_name() << "`)";
         }
 
         meta << "]";
       }
 
       if ((*fn_iter)->is_oneway()) {
-        meta << "," << endl <<
-          indent() << "TMethodType.ONEWAY";
+        meta << "," << endl << indent() << "TMethodType.ONEWAY";
       }
 
       indent_down();
-      meta << endl <<
-        indent() << ")";
+      meta << endl << indent() << ")";
     }
     indent_down();
 
     string meta_str(meta.str());
     if (!meta_str.empty()) {
-      f_service << endl <<
-        indent() << "enum methodMeta = [" << meta_str << endl <<
-        indent() << "];" << endl;
+      f_service << endl << indent() << "enum methodMeta = [" << meta_str << endl << indent() << "];"
+                << endl;
     }
 
     indent_down();
     indent(f_service) << "}" << endl;
 
-
     // Server skeleton generation.
     string f_skeletonname = package_dir_ + svc_name + "_server.skeleton.d";
     std::ofstream f_skeleton;
@@ -366,89 +339,68 @@ class t_d_generator : public t_oop_generator {
     f_skeleton.close();
   }
 
- private:
-    /**
-     * Writes a server skeleton for the passed service to out.
-     */
-    void print_server_skeleton(ostream &out, t_service* tservice) {
-      string svc_name = tservice->get_name();
-
-      out <<
-        "/*" << endl <<
-        " * This auto-generated skeleton file illustrates how to build a server. If you" << endl <<
-        " * intend to customize it, you should edit a copy with another file name to " << endl <<
-        " * avoid overwriting it when running the generator again." << endl <<
-        " */" << endl <<
-        "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << endl <<
-        endl <<
-        "import std.stdio;" << endl <<
-        "import thrift.codegen.processor;" << endl <<
-        "import thrift.protocol.binary;" << endl <<
-        "import thrift.server.simple;" << endl <<
-        "import thrift.server.transport.socket;" << endl <<
-        "import thrift.transport.buffered;" << endl <<
-        "import thrift.util.hashset;" << endl <<
-        endl <<
-        "import " << render_package(*tservice->get_program()) << svc_name << ";" << endl <<
-        "import " << render_package(*get_program()) << program_name_ << "_types;" << endl <<
-        endl <<
-        endl <<
-        "class " << svc_name << "Handler : " << svc_name << " {" << endl;
+private:
+  /**
+   * Writes a server skeleton for the passed service to out.
+   */
+  void print_server_skeleton(ostream& out, t_service* tservice) {
+    string svc_name = tservice->get_name();
+
+    out << "/*" << endl
+        << " * This auto-generated skeleton file illustrates how to build a server. If you" << endl
+        << " * intend to customize it, you should edit a copy with another file name to " << endl
+        << " * avoid overwriting it when running the generator again." << endl << " */" << endl
+        << "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << endl
+        << endl << "import std.stdio;" << endl << "import thrift.codegen.processor;" << endl
+        << "import thrift.protocol.binary;" << endl << "import thrift.server.simple;" << endl
+        << "import thrift.server.transport.socket;" << endl << "import thrift.transport.buffered;"
+        << endl << "import thrift.util.hashset;" << endl << endl << "import "
+        << render_package(*tservice->get_program()) << svc_name << ";" << endl << "import "
+        << render_package(*get_program()) << program_name_ << "_types;" << endl << endl << endl
+        << "class " << svc_name << "Handler : " << svc_name << " {" << endl;
+
+    indent_up();
+    out << indent() << "this() {" << endl << indent() << "  // Your initialization goes here."
+        << endl << indent() << "}" << endl << endl;
+
+    vector<t_function*> functions = tservice->get_functions();
+    vector<t_function*>::iterator f_iter;
+    for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
+      out << indent();
+      print_function_signature(out, *f_iter);
+      out << " {" << endl;
 
       indent_up();
-      out <<
-        indent() << "this() {" << endl <<
-        indent() << "  // Your initialization goes here." << endl <<
-        indent() << "}" << endl <<
-        endl;
-
-      vector<t_function*> functions = tservice->get_functions();
-      vector<t_function*>::iterator f_iter;
-      for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-        out << indent();
-        print_function_signature(out, *f_iter);
-        out << " {" << endl;
-
-        indent_up();
-
-        out <<
-          indent() << "// Your implementation goes here." << endl <<
-          indent() << "writeln(\"" << (*f_iter)->get_name() << " called\");" << endl;
-
-        t_base_type* rt = (t_base_type*)(*f_iter)->get_returntype();
-        if (rt->get_base() != t_base_type::TYPE_VOID) {
-          indent(out) << "return typeof(return).init;" << endl;
-        }
 
-        indent_down();
+      out << indent() << "// Your implementation goes here." << endl << indent() << "writeln(\""
+          << (*f_iter)->get_name() << " called\");" << endl;
 
-        out <<
-          indent() << "}" << endl <<
-          endl;
+      t_base_type* rt = (t_base_type*)(*f_iter)->get_returntype();
+      if (rt->get_base() != t_base_type::TYPE_VOID) {
+        indent(out) << "return typeof(return).init;" << endl;
       }
 
       indent_down();
-      out <<
-        "}" << endl <<
-        endl;
 
-      out <<
-        indent() << "void main() {" << endl;
-      indent_up();
-      out <<
-        indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << endl <<
-        indent() << "auto processor = new TServiceProcessor!" << svc_name << "(new " << svc_name << "Handler);" << endl <<
-        indent() << "auto serverTransport = new TServerSocket(9090);" << endl <<
-        indent() << "auto transportFactory = new TBufferedTransportFactory;" << endl <<
-
-        indent() << "auto server = new TSimpleServer(" << endl <<
-        indent() << "  processor, serverTransport, transportFactory, protocolFactory);" << endl <<
-        indent() << "server.serve();" << endl;
-      indent_down();
-      out <<
-        "}" << endl;
+      out << indent() << "}" << endl << endl;
     }
 
+    indent_down();
+    out << "}" << endl << endl;
+
+    out << indent() << "void main() {" << endl;
+    indent_up();
+    out << indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << endl << indent()
+        << "auto processor = new TServiceProcessor!" << svc_name << "(new " << svc_name
+        << "Handler);" << endl << indent() << "auto serverTransport = new TServerSocket(9090);"
+        << endl << indent() << "auto transportFactory = new TBufferedTransportFactory;" << endl
+        << indent() << "auto server = new TSimpleServer(" << endl << indent()
+        << "  processor, serverTransport, transportFactory, protocolFactory);" << endl << indent()
+        << "server.serve();" << endl;
+    indent_down();
+    out << "}" << endl;
+  }
+
   /**
    * Writes the definition of a struct or an exception type to out.
    */
@@ -465,11 +417,12 @@ class t_d_generator : public t_oop_generator {
     // Declare all fields.
     vector<t_field*>::const_iterator m_iter;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-      indent(out) << render_type_name((*m_iter)->get_type()) << " " <<
-        (*m_iter)->get_name() << ";" << endl;
+      indent(out) << render_type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name() << ";"
+                  << endl;
     }
 
-    if (!members.empty()) indent(out) << endl;
+    if (!members.empty())
+      indent(out) << endl;
     indent(out) << "mixin TStructHelpers!(";
 
     if (!members.empty()) {
@@ -489,8 +442,7 @@ class t_d_generator : public t_oop_generator {
         }
         out << endl;
 
-        indent(out) << "TFieldMeta(`" << (*m_iter)->get_name() << "`, " <<
-          (*m_iter)->get_key();
+        indent(out) << "TFieldMeta(`" << (*m_iter)->get_name() << "`, " << (*m_iter)->get_key();
 
         t_const_value* cv = (*m_iter)->get_value();
         t_field::e_req req = (*m_iter)->get_req();
@@ -508,9 +460,7 @@ class t_d_generator : public t_oop_generator {
     out << ");" << endl;
 
     indent_down();
-    indent(out) <<
-      "}" << endl <<
-      endl;
+    indent(out) << "}" << endl << endl;
   }
 
   /**
@@ -518,8 +468,7 @@ class t_d_generator : public t_oop_generator {
    * method.
    */
   void print_function_signature(ostream& out, t_function* fn) {
-    out << render_type_name(fn->get_returntype()) <<
-      " " << fn->get_name() << "(";
+    out << render_type_name(fn->get_returntype()) << " " << fn->get_name() << "(";
 
     const vector<t_field*>& fields = fn->get_arglist()->get_members();
     vector<t_field*>::const_iterator f_iter;
@@ -530,8 +479,7 @@ class t_d_generator : public t_oop_generator {
       } else {
         out << ", ";
       }
-      out << render_type_name((*f_iter)->get_type(), true) << " " <<
-          (*f_iter)->get_name();
+      out << render_type_name((*f_iter)->get_type(), true) << " " << (*f_iter)->get_name();
     }
 
     out << ")";
@@ -574,8 +522,7 @@ class t_d_generator : public t_oop_generator {
         }
         break;
       default:
-        throw "Compiler error: No const of base type " +
-          t_base_type::t_base_name(tbase);
+        throw "Compiler error: No const of base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "cast(" << render_type_name(type) << ")" << value->get_integer();
@@ -585,8 +532,8 @@ class t_d_generator : public t_oop_generator {
 
       indent(out) << render_type_name(type) << " v;" << endl;
       if (type->is_struct() || type->is_xception()) {
-        indent(out) << "v = " << (type->is_xception() ? "new " : "") <<
-          render_type_name(type) << "();" << endl;
+        indent(out) << "v = " << (type->is_xception() ? "new " : "") << render_type_name(type)
+                    << "();" << endl;
 
         const vector<t_field*>& fields = ((t_struct*)type)->get_members();
         vector<t_field*>::const_iterator f_iter;
@@ -600,12 +547,11 @@ class t_d_generator : public t_oop_generator {
             }
           }
           if (field_type == NULL) {
-            throw "Type error: " + type->get_name() + " has no field " +
-              v_iter->first->get_string();
+            throw "Type error: " + type->get_name() + " has no field "
+                + v_iter->first->get_string();
           }
           string val = render_const_value(field_type, v_iter->second);
-          indent(out) << "v.set!`" << v_iter->first->get_string() <<
-            "`(" << val << ");" << endl;
+          indent(out) << "v.set!`" << v_iter->first->get_string() << "`(" << val << ");" << endl;
         }
       } else if (type->is_map()) {
         t_type* ktype = ((t_map*)type)->get_key_type();
@@ -638,8 +584,7 @@ class t_d_generator : public t_oop_generator {
           indent(out) << "v ~= " << val << ";" << endl;
         }
       } else {
-        throw "Compiler error: Invalid type in render_const_value: " +
-          type->get_name();
+        throw "Compiler error: Invalid type in render_const_value: " + type->get_name();
       }
       indent(out) << "return v;" << endl;
 
@@ -656,7 +601,8 @@ class t_d_generator : public t_oop_generator {
    */
   string render_package(const t_program& program) const {
     string package = program.get_namespace("d");
-    if (package.size() == 0) return "";
+    if (package.size() == 0)
+      return "";
     return package + ".";
   }
 
@@ -687,17 +633,16 @@ class t_d_generator : public t_oop_generator {
       case t_base_type::TYPE_DOUBLE:
         return "double";
       default:
-        throw "Compiler error: No D type name for base type " +
-          t_base_type::t_base_name(tbase);
+        throw "Compiler error: No D type name for base type " + t_base_type::t_base_name(tbase);
       }
     }
 
     if (ttype->is_container()) {
-      t_container* tcontainer = (t_container*) ttype;
+      t_container* tcontainer = (t_container*)ttype;
       if (tcontainer->has_cpp_name()) {
         return tcontainer->get_cpp_name();
       } else if (ttype->is_map()) {
-        t_map* tmap = (t_map*) ttype;
+        t_map* tmap = (t_map*)ttype;
         t_type* ktype = tmap->get_key_type();
 
         string name = render_type_name(tmap->get_val_type()) + "[";
@@ -711,10 +656,10 @@ class t_d_generator : public t_oop_generator {
         name += "]";
         return name;
       } else if (ttype->is_set()) {
-        t_set* tset = (t_set*) ttype;
+        t_set* tset = (t_set*)ttype;
         return "HashSet!(" + render_type_name(tset->get_elem_type()) + ")";
       } else if (ttype->is_list()) {
-        t_list* tlist = (t_list*) ttype;
+        t_list* tlist = (t_list*)ttype;
         return render_type_name(tlist->get_elem_type()) + "[]";
       }
     }
@@ -737,13 +682,11 @@ class t_d_generator : public t_oop_generator {
       return "TReq.OPTIONAL";
     case t_field::T_REQUIRED:
       return "TReq.REQUIRED";
-    default:
-      {
-        std::stringstream ss;
-        ss << "Compiler error: Invalid requirement level " << req;
-        throw ss.str();
-      }
-
+    default: {
+      std::stringstream ss;
+      ss << "Compiler error: Invalid requirement level " << req;
+      throw ss.str();
+    }
     }
   }
 
@@ -752,11 +695,8 @@ class t_d_generator : public t_oop_generator {
    * module) to f.
    */
   void print_default_imports(ostream& out) {
-    indent(out) <<
-      "import thrift.base;" << endl <<
-      "import thrift.codegen.base;" << endl <<
-      "import thrift.util.hashset;" << endl <<
-      endl;
+    indent(out) << "import thrift.base;" << endl << "import thrift.codegen.base;" << endl
+                << "import thrift.util.hashset;" << endl << endl;
   }
 
   /**
@@ -780,4 +720,3 @@ class t_d_generator : public t_oop_generator {
 };
 
 THRIFT_REGISTER_GENERATOR(d, "D", "")
-


[06/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TPipe.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TPipe.h b/lib/cpp/src/thrift/transport/TPipe.h
index 2e4539c..ef957c6 100644
--- a/lib/cpp/src/thrift/transport/TPipe.h
+++ b/lib/cpp/src/thrift/transport/TPipe.h
@@ -23,11 +23,13 @@
 #include <thrift/transport/TTransport.h>
 #include <thrift/transport/TVirtualTransport.h>
 #ifndef _WIN32
-#  include <thrift/transport/TSocket.h>
+#include <thrift/transport/TSocket.h>
 #endif
 #include <boost/noncopyable.hpp>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Windows Pipes implementation of the TTransport interface.
@@ -39,14 +41,14 @@ namespace apache { namespace thrift { namespace transport {
 class TPipeImpl;
 
 class TPipe : public TVirtualTransport<TPipe> {
- public:
+public:
   // Constructs a new pipe object.
   TPipe();
   // Named pipe constructors -
-  explicit TPipe(HANDLE Pipe); //HANDLE is a void*
-  //need a const char * overload so string literals don't go to the HANDLE overload
-  explicit TPipe(const char *pipename);
-  explicit TPipe(const std::string &pipename);
+  explicit TPipe(HANDLE Pipe); // HANDLE is a void*
+  // need a const char * overload so string literals don't go to the HANDLE overload
+  explicit TPipe(const char* pipename);
+  explicit TPipe(const std::string& pipename);
   // Anonymous pipe -
   TPipe(HANDLE PipeRd, HANDLE PipeWrt);
 
@@ -71,21 +73,21 @@ class TPipe : public TVirtualTransport<TPipe> {
   // Writes to the pipe.
   virtual void write(const uint8_t* buf, uint32_t len);
 
-
-  //Accessors
+  // Accessors
   std::string getPipename();
-  void setPipename(const std::string &pipename);
-  HANDLE getPipeHandle(); //doubles as the read handle for anon pipe
+  void setPipename(const std::string& pipename);
+  HANDLE getPipeHandle(); // doubles as the read handle for anon pipe
   void setPipeHandle(HANDLE pipehandle);
   HANDLE getWrtPipeHandle();
   void setWrtPipeHandle(HANDLE pipehandle);
   long getConnectTimeout();
   void setConnectTimeout(long seconds);
 
-  //this function is intended to be used in generic / template situations,
-  //so its name needs to be the same as TPipeServer's
+  // this function is intended to be used in generic / template situations,
+  // so its name needs to be the same as TPipeServer's
   HANDLE getNativeWaitHandle();
- private:
+
+private:
   boost::shared_ptr<TPipeImpl> impl_;
 
   std::string pipename_;
@@ -97,8 +99,8 @@ class TPipe : public TVirtualTransport<TPipe> {
 #else
 typedef TSocket TPipe;
 #endif
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TPIPE_H_
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TPipeServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp
index e14a94a..a8e72d0 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp
+++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp
@@ -26,12 +26,14 @@
 #include <boost/noncopyable.hpp>
 
 #ifdef _WIN32
-#  include <thrift/windows/OverlappedSubmissionThread.h>
-#  include <AccCtrl.h>
-#  include <Aclapi.h>
+#include <thrift/windows/OverlappedSubmissionThread.h>
+#include <AccCtrl.h>
+#include <Aclapi.h>
 #endif //_WIN32
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 #ifdef _WIN32
 
@@ -48,27 +50,27 @@ public:
 
   virtual HANDLE getPipeHandle() = 0;
   virtual HANDLE getWrtPipeHandle() = 0;
-  virtual HANDLE getClientRdPipeHandle()= 0;
-  virtual HANDLE getClientWrtPipeHandle()= 0;
-  virtual HANDLE getNativeWaitHandle() {return NULL;}
+  virtual HANDLE getClientRdPipeHandle() = 0;
+  virtual HANDLE getClientWrtPipeHandle() = 0;
+  virtual HANDLE getNativeWaitHandle() { return NULL; }
 };
 
 class TAnonPipeServer : public TPipeServerImpl {
 public:
-  TAnonPipeServer()
-  {
-    //The anonymous pipe needs to be created first so that the server can
-    //pass the handles on to the client before the serve (acceptImpl)
-    //blocking call.
+  TAnonPipeServer() {
+    // The anonymous pipe needs to be created first so that the server can
+    // pass the handles on to the client before the serve (acceptImpl)
+    // blocking call.
     if (!createAnonPipe()) {
       GlobalOutput.perror("TPipeServer Create(Anon)Pipe failed, GLE=", GetLastError());
-      throw TTransportException(TTransportException::NOT_OPEN, " TPipeServer Create(Anon)Pipe failed");
+      throw TTransportException(TTransportException::NOT_OPEN,
+                                " TPipeServer Create(Anon)Pipe failed");
     }
   }
 
   virtual ~TAnonPipeServer() {}
 
-  virtual void interrupt() {} //not currently implemented
+  virtual void interrupt() {} // not currently implemented
   virtual void close() {
     PipeR_.reset();
     PipeW_.reset();
@@ -78,17 +80,18 @@ public:
 
   virtual boost::shared_ptr<TTransport> acceptImpl();
 
-  virtual HANDLE getPipeHandle()          {return PipeR_.h;}
-  virtual HANDLE getWrtPipeHandle()       {return PipeW_.h;}
-  virtual HANDLE getClientRdPipeHandle()  {return ClientAnonRead_.h;}
-  virtual HANDLE getClientWrtPipeHandle() {return ClientAnonWrite_.h;}
+  virtual HANDLE getPipeHandle() { return PipeR_.h; }
+  virtual HANDLE getWrtPipeHandle() { return PipeW_.h; }
+  virtual HANDLE getClientRdPipeHandle() { return ClientAnonRead_.h; }
+  virtual HANDLE getClientWrtPipeHandle() { return ClientAnonWrite_.h; }
+
 private:
   bool createAnonPipe();
 
   TAutoHandle PipeR_; // Anonymous Pipe (R)
   TAutoHandle PipeW_; // Anonymous Pipe (W)
 
-  //Client side anonymous pipe handles
+  // Client side anonymous pipe handles
   //? Do we need duplicates to send to client?
   TAutoHandle ClientAnonRead_;
   TAutoHandle ClientAnonWrite_;
@@ -96,26 +99,18 @@ private:
 
 class TNamedPipeServer : public TPipeServerImpl {
 public:
-  TNamedPipeServer(
-    const std::string &pipename,
-    uint32_t bufsize,
-    uint32_t maxconnections) :
-      stopping_(false),
-      pipename_(pipename),
-      bufsize_(bufsize),
-      maxconns_(maxconnections)
-  {
+  TNamedPipeServer(const std::string& pipename, uint32_t bufsize, uint32_t maxconnections)
+    : stopping_(false), pipename_(pipename), bufsize_(bufsize), maxconns_(maxconnections) {
     connectOverlap_.action = TOverlappedWorkItem::CONNECT;
     cancelOverlap_.action = TOverlappedWorkItem::CANCELIO;
     initiateNamedConnect();
   }
   virtual ~TNamedPipeServer() {}
 
-  virtual void interrupt()
-  {
+  virtual void interrupt() {
     TAutoCrit lock(pipe_protect_);
     cached_client_.reset();
-    if(Pipe_.h != INVALID_HANDLE_VALUE) {
+    if (Pipe_.h != INVALID_HANDLE_VALUE) {
       stopping_ = true;
       cancelOverlap_.h = Pipe_.h;
       // This should wake up GetOverlappedResult
@@ -124,17 +119,16 @@ public:
     }
   }
 
-  virtual void close() {
-    Pipe_.reset();
-  }
+  virtual void close() { Pipe_.reset(); }
 
   virtual boost::shared_ptr<TTransport> acceptImpl();
 
-  virtual HANDLE getPipeHandle()          {return Pipe_.h;}
-  virtual HANDLE getWrtPipeHandle()       {return INVALID_HANDLE_VALUE;}
-  virtual HANDLE getClientRdPipeHandle()  {return INVALID_HANDLE_VALUE;}
-  virtual HANDLE getClientWrtPipeHandle() {return INVALID_HANDLE_VALUE;}
-  virtual HANDLE getNativeWaitHandle()    {return listen_event_.h;}
+  virtual HANDLE getPipeHandle() { return Pipe_.h; }
+  virtual HANDLE getWrtPipeHandle() { return INVALID_HANDLE_VALUE; }
+  virtual HANDLE getClientRdPipeHandle() { return INVALID_HANDLE_VALUE; }
+  virtual HANDLE getClientWrtPipeHandle() { return INVALID_HANDLE_VALUE; }
+  virtual HANDLE getNativeWaitHandle() { return listen_event_.h; }
+
 private:
   bool createNamedPipe();
   void initiateNamedConnect();
@@ -153,61 +147,50 @@ private:
   TCriticalSection pipe_protect_;
 };
 
-HANDLE TPipeServer::getNativeWaitHandle()
-{
-  if(impl_) return impl_->getNativeWaitHandle();
+HANDLE TPipeServer::getNativeWaitHandle() {
+  if (impl_)
+    return impl_->getNativeWaitHandle();
   return NULL;
 }
 
 //---- Constructors ----
-TPipeServer::TPipeServer(const std::string &pipename, uint32_t bufsize) :
-  bufsize_(bufsize),
-  isAnonymous_(false)
-{
+TPipeServer::TPipeServer(const std::string& pipename, uint32_t bufsize)
+  : bufsize_(bufsize), isAnonymous_(false) {
   setMaxConnections(TPIPE_SERVER_MAX_CONNS_DEFAULT);
   setPipename(pipename);
 }
 
-TPipeServer::TPipeServer(const std::string &pipename, uint32_t bufsize, uint32_t maxconnections) :
-  bufsize_(bufsize),
-  isAnonymous_(false)
-{
+TPipeServer::TPipeServer(const std::string& pipename, uint32_t bufsize, uint32_t maxconnections)
+  : bufsize_(bufsize), isAnonymous_(false) {
   setMaxConnections(maxconnections);
   setPipename(pipename);
 }
 
-TPipeServer::TPipeServer(const std::string &pipename) :
-  bufsize_(1024),
-  isAnonymous_(false)
-{
+TPipeServer::TPipeServer(const std::string& pipename) : bufsize_(1024), isAnonymous_(false) {
   setMaxConnections(TPIPE_SERVER_MAX_CONNS_DEFAULT);
   setPipename(pipename);
 }
 
-TPipeServer::TPipeServer(int bufsize) :
-  bufsize_(bufsize),
-  isAnonymous_(true)
-{
+TPipeServer::TPipeServer(int bufsize) : bufsize_(bufsize), isAnonymous_(true) {
   setMaxConnections(1);
   impl_.reset(new TAnonPipeServer);
 }
 
-TPipeServer::TPipeServer() :
-  bufsize_(1024),
-  isAnonymous_(true)
-{
+TPipeServer::TPipeServer() : bufsize_(1024), isAnonymous_(true) {
   setMaxConnections(1);
   impl_.reset(new TAnonPipeServer);
 }
 
 //---- Destructor ----
-TPipeServer::~TPipeServer() {}
+TPipeServer::~TPipeServer() {
+}
 
 //---------------------------------------------------------
 // Transport callbacks
 //---------------------------------------------------------
 void TPipeServer::listen() {
-  if(isAnonymous_) return;
+  if (isAnonymous_)
+    return;
   impl_.reset(new TNamedPipeServer(pipename_, bufsize_, maxconns_));
 }
 
@@ -216,26 +199,27 @@ shared_ptr<TTransport> TPipeServer::acceptImpl() {
 }
 
 shared_ptr<TTransport> TAnonPipeServer::acceptImpl() {
-  //This 0-byte read serves merely as a blocking call.
+  // This 0-byte read serves merely as a blocking call.
   byte buf;
   DWORD br;
-  int fSuccess = ReadFile(
-        PipeR_.h, // pipe handle
-        &buf,   // buffer to receive reply
-        0,      // size of buffer
-        &br,    // number of bytes read
-        NULL);  // not overlapped
-
-  if ( !fSuccess && GetLastError() != ERROR_MORE_DATA ) {
+  int fSuccess = ReadFile(PipeR_.h, // pipe handle
+                          &buf,     // buffer to receive reply
+                          0,        // size of buffer
+                          &br,      // number of bytes read
+                          NULL);    // not overlapped
+
+  if (!fSuccess && GetLastError() != ERROR_MORE_DATA) {
     GlobalOutput.perror("TPipeServer unable to initiate pipe comms, GLE=", GetLastError());
-    throw TTransportException(TTransportException::NOT_OPEN, " TPipeServer unable to initiate pipe comms");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              " TPipeServer unable to initiate pipe comms");
   }
   shared_ptr<TPipe> client(new TPipe(PipeR_.h, PipeW_.h));
   return client;
 }
 
 void TNamedPipeServer::initiateNamedConnect() {
-  if (stopping_) return;
+  if (stopping_)
+    return;
   if (!createNamedPipe()) {
     GlobalOutput.perror("TPipeServer CreateNamedPipe failed, GLE=", GetLastError());
     throw TTransportException(TTransportException::NOT_OPEN, " TPipeServer CreateNamedPipe failed");
@@ -250,8 +234,7 @@ void TNamedPipeServer::initiateNamedConnect() {
   // Wait for the client to connect; if it succeeds, the
   // function returns a nonzero value. If the function returns
   // zero, GetLastError should return ERROR_PIPE_CONNECTED.
-  if( connectOverlap_.success )
-  {
+  if (connectOverlap_.success) {
     GlobalOutput.printf("Client connected.");
     cached_client_.reset(new TPipe(Pipe_.h));
     Pipe_.release();
@@ -261,8 +244,7 @@ void TNamedPipeServer::initiateNamedConnect() {
   }
 
   DWORD dwErr = connectOverlap_.last_error;
-  switch( dwErr)
-  {
+  switch (dwErr) {
   case ERROR_PIPE_CONNECTED:
     GlobalOutput.printf("Client connected.");
     cached_client_.reset(new TPipe(Pipe_.h));
@@ -271,68 +253,68 @@ void TNamedPipeServer::initiateNamedConnect() {
     SetEvent(listen_event_.h);
     return;
   case ERROR_IO_PENDING:
-    return; //acceptImpl will do the appropriate WaitForMultipleObjects
+    return; // acceptImpl will do the appropriate WaitForMultipleObjects
   default:
     GlobalOutput.perror("TPipeServer ConnectNamedPipe failed, GLE=", dwErr);
-    throw TTransportException(TTransportException::NOT_OPEN, " TPipeServer ConnectNamedPipe failed");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              " TPipeServer ConnectNamedPipe failed");
   }
 }
 
 shared_ptr<TTransport> TNamedPipeServer::acceptImpl() {
   {
     TAutoCrit lock(pipe_protect_);
-    if(cached_client_.get() != NULL)
-    {
+    if (cached_client_.get() != NULL) {
       shared_ptr<TPipe> client;
-      //zero out cached_client, since we are about to return it.
+      // zero out cached_client, since we are about to return it.
       client.swap(cached_client_);
 
-      //kick off the next connection before returning
+      // kick off the next connection before returning
       initiateNamedConnect();
-      return client;  //success!
+      return client; // success!
     }
   }
 
-  if(Pipe_.h == INVALID_HANDLE_VALUE) {
-    throw TTransportException(
-      TTransportException::NOT_OPEN,
-      "TNamedPipeServer: someone called accept on a closed pipe server");
+  if (Pipe_.h == INVALID_HANDLE_VALUE) {
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "TNamedPipeServer: someone called accept on a closed pipe server");
   }
 
   DWORD dwDummy = 0;
-  if(GetOverlappedResult(Pipe_.h, &connectOverlap_.overlap, &dwDummy, TRUE))
-  {
+  if (GetOverlappedResult(Pipe_.h, &connectOverlap_.overlap, &dwDummy, TRUE)) {
     TAutoCrit lock(pipe_protect_);
     GlobalOutput.printf("Client connected.");
     shared_ptr<TPipe> client(new TPipe(Pipe_.h));
     Pipe_.release();
-    //kick off the next connection before returning
+    // kick off the next connection before returning
     initiateNamedConnect();
-    return client; //success!
+    return client; // success!
   }
-  //if we got here, then we are in an error / shutdown case
-  DWORD gle = GetLastError(); //save error before doing cleanup
+  // if we got here, then we are in an error / shutdown case
+  DWORD gle = GetLastError(); // save error before doing cleanup
   close();
   GlobalOutput.perror("TPipeServer ConnectNamedPipe GLE=", gle);
   throw TTransportException(TTransportException::NOT_OPEN, "TPipeServer: client connection failed");
 }
 
 void TPipeServer::interrupt() {
-  if(impl_) impl_->interrupt();
+  if (impl_)
+    impl_->interrupt();
 }
 
 void TPipeServer::close() {
-  if(impl_) impl_->close();
+  if (impl_)
+    impl_->close();
 }
 
-
 bool TNamedPipeServer::createNamedPipe() {
 
-  //Windows - set security to allow non-elevated apps
-  //to access pipes created by elevated apps.
+  // Windows - set security to allow non-elevated apps
+  // to access pipes created by elevated apps.
   SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
   PSID everyone_sid = NULL;
-  AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &everyone_sid);
+  AllocateAndInitializeSid(
+      &SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &everyone_sid);
 
   EXPLICIT_ACCESS ea;
   ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS));
@@ -341,12 +323,12 @@ bool TNamedPipeServer::createNamedPipe() {
   ea.grfInheritance = NO_INHERITANCE;
   ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
   ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
-  ea.Trustee.ptstrName  = (LPSTR)everyone_sid;
+  ea.Trustee.ptstrName = (LPSTR)everyone_sid;
 
   PACL acl = NULL;
   SetEntriesInAcl(1, &ea, NULL, &acl);
 
-  PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR,SECURITY_DESCRIPTOR_MIN_LENGTH);
+  PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
   InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION);
   SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE);
 
@@ -356,23 +338,23 @@ bool TNamedPipeServer::createNamedPipe() {
   sa.bInheritHandle = FALSE;
 
   // Create an instance of the named pipe
-  TAutoHandle hPipe(CreateNamedPipe(
-        pipename_.c_str(),        // pipe name
-        PIPE_ACCESS_DUPLEX |      // read/write access
-        FILE_FLAG_OVERLAPPED,     // async mode
-        PIPE_TYPE_BYTE |          // byte type pipe
-        PIPE_READMODE_BYTE,       // byte read mode
-        maxconns_,                // max. instances
-        bufsize_,                 // output buffer size
-        bufsize_,                 // input buffer size
-        0,                        // client time-out
-        &sa));                    // security attributes
-
-  if(hPipe.h == INVALID_HANDLE_VALUE)
-  {
+  TAutoHandle hPipe(CreateNamedPipe(pipename_.c_str(),    // pipe name
+                                    PIPE_ACCESS_DUPLEX |  // read/write access
+                                    FILE_FLAG_OVERLAPPED, // async mode
+                                    PIPE_TYPE_BYTE |      // byte type pipe
+                                    PIPE_READMODE_BYTE,   // byte read mode
+                                    maxconns_,            // max. instances
+                                    bufsize_,             // output buffer size
+                                    bufsize_,             // input buffer size
+                                    0,                    // client time-out
+                                    &sa));                // security attributes
+
+  if (hPipe.h == INVALID_HANDLE_VALUE) {
     Pipe_.reset();
     GlobalOutput.perror("TPipeServer::TCreateNamedPipe() GLE=", GetLastError());
-    throw TTransportException(TTransportException::NOT_OPEN, "TCreateNamedPipe() failed", GetLastError());
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "TCreateNamedPipe() failed",
+                              GetLastError());
     return false;
   }
 
@@ -382,21 +364,21 @@ bool TNamedPipeServer::createNamedPipe() {
 
 bool TAnonPipeServer::createAnonPipe() {
   SECURITY_ATTRIBUTES sa;
-  SECURITY_DESCRIPTOR sd; //security information for pipes
+  SECURITY_DESCRIPTOR sd; // security information for pipes
 
-  InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
+  InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
   SetSecurityDescriptorDacl(&sd, true, NULL, false);
   sa.lpSecurityDescriptor = &sd;
   sa.nLength = sizeof(SECURITY_ATTRIBUTES);
-  sa.bInheritHandle = true; //allow passing handle to child
+  sa.bInheritHandle = true; // allow passing handle to child
 
   HANDLE ClientAnonReadH, PipeW_H, ClientAnonWriteH, Pipe_H;
-  if (!CreatePipe(&ClientAnonReadH,&PipeW_H,&sa,0))   //create stdin pipe
+  if (!CreatePipe(&ClientAnonReadH, &PipeW_H, &sa, 0)) // create stdin pipe
   {
     GlobalOutput.perror("TPipeServer CreatePipe (anon) failed, GLE=", GetLastError());
     return false;
   }
-  if (!CreatePipe(&Pipe_H,&ClientAnonWriteH,&sa,0))  //create stdout pipe
+  if (!CreatePipe(&Pipe_H, &ClientAnonWriteH, &sa, 0)) // create stdout pipe
   {
     GlobalOutput.perror("TPipeServer CreatePipe (anon) failed, GLE=", GetLastError());
     CloseHandle(ClientAnonReadH);
@@ -415,29 +397,46 @@ bool TAnonPipeServer::createAnonPipe() {
 //---------------------------------------------------------
 // Accessors
 //---------------------------------------------------------
-string TPipeServer::getPipename() {return pipename_;}
+string TPipeServer::getPipename() {
+  return pipename_;
+}
 
-void TPipeServer::setPipename(const std::string &pipename) {
-  if(pipename.find("\\\\") == -1)
+void TPipeServer::setPipename(const std::string& pipename) {
+  if (pipename.find("\\\\") == -1)
     pipename_ = "\\\\.\\pipe\\" + pipename;
   else
     pipename_ = pipename;
 }
 
-int  TPipeServer::getBufferSize() {return bufsize_;}
-void TPipeServer::setBufferSize(int bufsize) {bufsize_ = bufsize;}
+int TPipeServer::getBufferSize() {
+  return bufsize_;
+}
+void TPipeServer::setBufferSize(int bufsize) {
+  bufsize_ = bufsize;
+}
 
-HANDLE TPipeServer::getPipeHandle()          {return impl_?impl_->getPipeHandle()         :INVALID_HANDLE_VALUE;}
-HANDLE TPipeServer::getWrtPipeHandle()       {return impl_?impl_->getWrtPipeHandle()      :INVALID_HANDLE_VALUE;}
-HANDLE TPipeServer::getClientRdPipeHandle()  {return impl_?impl_->getClientRdPipeHandle() :INVALID_HANDLE_VALUE;}
-HANDLE TPipeServer::getClientWrtPipeHandle() {return impl_?impl_->getClientWrtPipeHandle():INVALID_HANDLE_VALUE;}
+HANDLE TPipeServer::getPipeHandle() {
+  return impl_ ? impl_->getPipeHandle() : INVALID_HANDLE_VALUE;
+}
+HANDLE TPipeServer::getWrtPipeHandle() {
+  return impl_ ? impl_->getWrtPipeHandle() : INVALID_HANDLE_VALUE;
+}
+HANDLE TPipeServer::getClientRdPipeHandle() {
+  return impl_ ? impl_->getClientRdPipeHandle() : INVALID_HANDLE_VALUE;
+}
+HANDLE TPipeServer::getClientWrtPipeHandle() {
+  return impl_ ? impl_->getClientWrtPipeHandle() : INVALID_HANDLE_VALUE;
+}
 
-bool TPipeServer::getAnonymous() { return isAnonymous_; }
-void TPipeServer::setAnonymous(bool anon) { isAnonymous_ = anon;}
+bool TPipeServer::getAnonymous() {
+  return isAnonymous_;
+}
+void TPipeServer::setAnonymous(bool anon) {
+  isAnonymous_ = anon;
+}
 
-void TPipeServer::setMaxConnections(uint32_t maxconnections)
-{
-  if(maxconnections == 0)
+void TPipeServer::setMaxConnections(uint32_t maxconnections) {
+  if (maxconnections == 0)
     maxconns_ = 1;
   else if (maxconnections > PIPE_UNLIMITED_INSTANCES)
     maxconns_ = PIPE_UNLIMITED_INSTANCES;
@@ -446,5 +445,6 @@ void TPipeServer::setMaxConnections(uint32_t maxconnections)
 }
 
 #endif //_WIN32
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TPipeServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.h b/lib/cpp/src/thrift/transport/TPipeServer.h
old mode 100755
new mode 100644
index 98ecde0..405793e
--- a/lib/cpp/src/thrift/transport/TPipeServer.h
+++ b/lib/cpp/src/thrift/transport/TPipeServer.h
@@ -23,15 +23,17 @@
 #include <thrift/transport/TServerTransport.h>
 #include <boost/shared_ptr.hpp>
 #ifndef _WIN32
-#  include <thrift/transport/TServerSocket.h>
+#include <thrift/transport/TServerSocket.h>
 #endif
 #ifdef _WIN32
-#  include <thrift/windows/Sync.h>
+#include <thrift/windows/Sync.h>
 #endif
 
 #define TPIPE_SERVER_MAX_CONNS_DEFAULT PIPE_UNLIMITED_INSTANCES
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Windows Pipes implementation of TServerTransport.
@@ -44,30 +46,30 @@ class TPipeServerImpl;
 class TPipe;
 
 class TPipeServer : public TServerTransport {
- public:
-  //Constructors
+public:
+  // Constructors
   // Named Pipe -
-  TPipeServer(const std::string &pipename, uint32_t bufsize);
-  TPipeServer(const std::string &pipename, uint32_t bufsize, uint32_t maxconnections);
-  TPipeServer(const std::string &pipename);
+  TPipeServer(const std::string& pipename, uint32_t bufsize);
+  TPipeServer(const std::string& pipename, uint32_t bufsize, uint32_t maxconnections);
+  TPipeServer(const std::string& pipename);
   // Anonymous pipe -
   TPipeServer(int bufsize);
   TPipeServer();
 
-  //Destructor
+  // Destructor
   virtual ~TPipeServer();
 
-  //Standard transport callbacks
+  // Standard transport callbacks
   virtual void interrupt();
   virtual void close();
   virtual void listen();
 
-  //Accessors
+  // Accessors
   std::string getPipename();
-  void setPipename(const std::string &pipename);
-  int  getBufferSize();
+  void setPipename(const std::string& pipename);
+  int getBufferSize();
   void setBufferSize(int bufsize);
-  HANDLE getPipeHandle();  //Named Pipe R/W -or- Anonymous pipe Read handle
+  HANDLE getPipeHandle(); // Named Pipe R/W -or- Anonymous pipe Read handle
   HANDLE getWrtPipeHandle();
   HANDLE getClientRdPipeHandle();
   HANDLE getClientWrtPipeHandle();
@@ -75,13 +77,14 @@ class TPipeServer : public TServerTransport {
   void setAnonymous(bool anon);
   void setMaxConnections(uint32_t maxconnections);
 
-  //this function is intended to be used in generic / template situations,
-  //so its name needs to be the same as TPipe's
+  // this function is intended to be used in generic / template situations,
+  // so its name needs to be the same as TPipe's
   HANDLE getNativeWaitHandle();
+
 protected:
   virtual boost::shared_ptr<TTransport> acceptImpl();
 
- private:
+private:
   boost::shared_ptr<TPipeServerImpl> impl_;
 
   std::string pipename_;
@@ -93,7 +96,8 @@ protected:
 //*NIX named pipe implementation uses domain socket
 typedef TServerSocket TPipeServer;
 #endif
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSERVERWINPIPES_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
index 45301f8..cf686e0 100644
--- a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp
@@ -20,26 +20,29 @@
 #include <thrift/transport/TSSLServerSocket.h>
 #include <thrift/transport/TSSLSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * SSL server socket implementation.
  */
-TSSLServerSocket::TSSLServerSocket(THRIFT_SOCKET port,
-                                   boost::shared_ptr<TSSLSocketFactory> factory):
-                                   TServerSocket(port), factory_(factory) {
+TSSLServerSocket::TSSLServerSocket(THRIFT_SOCKET port, boost::shared_ptr<TSSLSocketFactory> factory)
+  : TServerSocket(port), factory_(factory) {
   factory_->server(true);
 }
 
-TSSLServerSocket::TSSLServerSocket(int port, int sendTimeout, int recvTimeout,
-                                   boost::shared_ptr<TSSLSocketFactory> factory):
-                                   TServerSocket(port, sendTimeout, recvTimeout),
-                                   factory_(factory) {
+TSSLServerSocket::TSSLServerSocket(int port,
+                                   int sendTimeout,
+                                   int recvTimeout,
+                                   boost::shared_ptr<TSSLSocketFactory> factory)
+  : TServerSocket(port, sendTimeout, recvTimeout), factory_(factory) {
   factory_->server(true);
 }
 
 boost::shared_ptr<TSocket> TSSLServerSocket::createSocket(THRIFT_SOCKET client) {
   return factory_->createSocket(client);
 }
-
-}}}
+}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSSLServerSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.h b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
index 3a4b44d..bb52b04 100644
--- a/lib/cpp/src/thrift/transport/TSSLServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
@@ -23,15 +23,17 @@
 #include <boost/shared_ptr.hpp>
 #include <thrift/transport/TServerSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class TSSLSocketFactory;
 
 /**
  * Server socket that accepts SSL connections.
  */
-class TSSLServerSocket: public TServerSocket {
- public:
+class TSSLServerSocket : public TServerSocket {
+public:
   /**
    * Constructor.
    *
@@ -47,13 +49,17 @@ class TSSLServerSocket: public TServerSocket {
    * @param recvTimeout Socket receive timeout
    * @param factory     SSL socket factory implementation
    */
-  TSSLServerSocket(int port, int sendTimeout, int recvTimeout,
+  TSSLServerSocket(int port,
+                   int sendTimeout,
+                   int recvTimeout,
                    boost::shared_ptr<TSSLSocketFactory> factory);
- protected:
+
+protected:
   boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket);
   boost::shared_ptr<TSSLSocketFactory> factory_;
 };
-
-}}}
+}
+}
+}
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSSLSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index fd285db..de5876c 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -47,7 +47,9 @@ struct CRYPTO_dynlock_value {
   Mutex mutex;
 };
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 // OpenSSL initialization/cleanup
 
@@ -64,7 +66,7 @@ static void callbackLocking(int mode, int n, const char*, int) {
 
 #if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
 static unsigned long callbackThreadID() {
-  return (unsigned long) pthread_self();
+  return (unsigned long)pthread_self();
 }
 #endif
 
@@ -72,9 +74,7 @@ static CRYPTO_dynlock_value* dyn_create(const char*, int) {
   return new CRYPTO_dynlock_value;
 }
 
-static void dyn_lock(int mode,
-                     struct CRYPTO_dynlock_value* lock,
-                     const char*, int) {
+static void dyn_lock(int mode, struct CRYPTO_dynlock_value* lock, const char*, int) {
   if (lock != NULL) {
     if (mode & CRYPTO_LOCK) {
       lock->mutex.lock();
@@ -96,11 +96,11 @@ void initializeOpenSSL() {
   SSL_library_init();
   SSL_load_error_strings();
   // static locking
-  mutexes = boost::shared_array<Mutex>(new Mutex[::CRYPTO_num_locks()]);
+  mutexes = boost::shared_array<Mutex>(new Mutex[ ::CRYPTO_num_locks()]);
   if (mutexes == NULL) {
     throw TTransportException(TTransportException::INTERNAL_ERROR,
-          "initializeOpenSSL() failed, "
-          "out of memory while creating mutex array");
+                              "initializeOpenSSL() failed, "
+                              "out of memory while creating mutex array");
   }
 #if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
   CRYPTO_set_id_callback(callbackThreadID);
@@ -137,28 +137,17 @@ static char uppercase(char c);
 
 // SSLContext implementation
 SSLContext::SSLContext(const SSLProtocol& protocol) {
-  if(protocol == SSLTLS)
-  {
+  if (protocol == SSLTLS) {
     ctx_ = SSL_CTX_new(SSLv23_method());
-  }
-  else if(protocol == SSLv3)
-  {
+  } else if (protocol == SSLv3) {
     ctx_ = SSL_CTX_new(SSLv3_method());
-  }
-  else if(protocol == TLSv1_0)
-  {
+  } else if (protocol == TLSv1_0) {
     ctx_ = SSL_CTX_new(TLSv1_method());
-  }
-  else if(protocol == TLSv1_1)
-  {
+  } else if (protocol == TLSv1_1) {
     ctx_ = SSL_CTX_new(TLSv1_1_method());
-  }
-  else if(protocol == TLSv1_2)
-  {
+  } else if (protocol == TLSv1_2) {
     ctx_ = SSL_CTX_new(TLSv1_2_method());
-  }
-  else
-  {
+  } else {
     /// UNKNOWN PROTOCOL!
     throw TSSLException("SSL_CTX_new: Unknown protocol");
   }
@@ -171,8 +160,7 @@ SSLContext::SSLContext(const SSLProtocol& protocol) {
   SSL_CTX_set_mode(ctx_, SSL_MODE_AUTO_RETRY);
 
   // Disable horribly insecure SSLv2!
-  if(protocol == SSLTLS)
-  {
+  if (protocol == SSLTLS) {
     SSL_CTX_set_options(ctx_, SSL_OP_NO_SSLv2);
   }
 }
@@ -195,16 +183,16 @@ SSL* SSLContext::createSSL() {
 }
 
 // TSSLSocket implementation
-TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx):
-  TSocket(), server_(false), ssl_(NULL), ctx_(ctx) {
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx)
+  : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) {
 }
 
-TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket):
-  TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) {
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket)
+  : TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) {
 }
 
-TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port):
-  TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) {
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port)
+  : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) {
 }
 
 TSSLSocket::~TSSLSocket() {
@@ -218,7 +206,7 @@ bool TSSLSocket::isOpen() {
   int shutdown = SSL_get_shutdown(ssl_);
   // "!!" is squelching C4800 "forcing bool -> true or false" perfomance warning
   bool shutdownReceived = !!(shutdown & SSL_RECEIVED_SHUTDOWN);
-  bool shutdownSent     = !!(shutdown & SSL_SENT_SHUTDOWN);
+  bool shutdownSent = !!(shutdown & SSL_SENT_SHUTDOWN);
   if (shutdownReceived && shutdownSent) {
     return false;
   }
@@ -274,7 +262,7 @@ void TSSLSocket::close() {
 uint32_t TSSLSocket::read(uint8_t* buf, uint32_t len) {
   checkHandshake();
   int32_t bytes = 0;
-  for (int32_t retries = 0; retries < maxRecvRetries_; retries++){
+  for (int32_t retries = 0; retries < maxRecvRetries_; retries++) {
     bytes = SSL_read(ssl_, buf, len);
     if (bytes >= 0)
       break;
@@ -352,9 +340,8 @@ void TSSLSocket::checkHandshake() {
 
 void TSSLSocket::authorize() {
   int rc = SSL_get_verify_result(ssl_);
-  if (rc != X509_V_OK) {  // verify authentication result
-    throw TSSLException(string("SSL_get_verify_result(), ") +
-                        X509_verify_cert_error_string(rc));
+  if (rc != X509_V_OK) { // verify authentication result
+    throw TSSLException(string("SSL_get_verify_result(), ") + X509_verify_cert_error_string(rc));
   }
 
   X509* cert = SSL_get_peer_certificate(ssl_);
@@ -395,8 +382,8 @@ void TSSLSocket::authorize() {
   }
 
   // extract subjectAlternativeName
-  STACK_OF(GENERAL_NAME)* alternatives = (STACK_OF(GENERAL_NAME)*)
-                       X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL);
+  STACK_OF(GENERAL_NAME)* alternatives
+      = (STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL);
   if (alternatives != NULL) {
     const int count = sk_GENERAL_NAME_num(alternatives);
     for (int i = 0; decision == AccessManager::SKIP && i < count; i++) {
@@ -407,15 +394,15 @@ void TSSLSocket::authorize() {
       char* data = (char*)ASN1_STRING_data(name->d.ia5);
       int length = ASN1_STRING_length(name->d.ia5);
       switch (name->type) {
-        case GEN_DNS:
-          if (host.empty()) {
-            host = (server() ? getPeerHost() : getHost());
-          }
-          decision = access_->verify(host, data, length);
-          break;
-        case GEN_IPADD:
-          decision = access_->verify(sa, data, length);
-          break;
+      case GEN_DNS:
+        if (host.empty()) {
+          host = (server() ? getPeerHost() : getHost());
+        }
+        decision = access_->verify(host, data, length);
+        break;
+      case GEN_IPADD:
+        decision = access_->verify(sa, data, length);
+        break;
       }
     }
     sk_GENERAL_NAME_pop_free(alternatives, GENERAL_NAME_free);
@@ -459,10 +446,10 @@ void TSSLSocket::authorize() {
 
 // TSSLSocketFactory implementation
 uint64_t TSSLSocketFactory::count_ = 0;
-Mutex    TSSLSocketFactory::mutex_;
-bool     TSSLSocketFactory::manualOpenSSLInitialization_ = false;
+Mutex TSSLSocketFactory::mutex_;
+bool TSSLSocketFactory::manualOpenSSLInitialization_ = false;
 
-TSSLSocketFactory::TSSLSocketFactory(const SSLProtocol& protocol): server_(false) {
+TSSLSocketFactory::TSSLSocketFactory(const SSLProtocol& protocol) : server_(false) {
   Guard guard(mutex_);
   if (count_ == 0) {
     if (!manualOpenSSLInitialization_) {
@@ -495,8 +482,7 @@ boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(THRIFT_SOCKET sock
   return ssl;
 }
 
-boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host,
-                                                       int port) {
+boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host, int port) {
   boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port));
   setup(ssl);
   return ssl;
@@ -527,7 +513,7 @@ void TSSLSocketFactory::ciphers(const string& enable) {
 void TSSLSocketFactory::authenticate(bool required) {
   int mode;
   if (required) {
-    mode  = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE;
+    mode = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE;
   } else {
     mode = SSL_VERIFY_NONE;
   }
@@ -537,7 +523,7 @@ void TSSLSocketFactory::authenticate(bool required) {
 void TSSLSocketFactory::loadCertificate(const char* path, const char* format) {
   if (path == NULL || format == NULL) {
     throw TTransportException(TTransportException::BAD_ARGS,
-         "loadCertificateChain: either <path> or <format> is NULL");
+                              "loadCertificateChain: either <path> or <format> is NULL");
   }
   if (strcmp(format, "PEM") == 0) {
     if (SSL_CTX_use_certificate_chain_file(ctx_->get(), path) == 0) {
@@ -554,7 +540,7 @@ void TSSLSocketFactory::loadCertificate(const char* path, const char* format) {
 void TSSLSocketFactory::loadPrivateKey(const char* path, const char* format) {
   if (path == NULL || format == NULL) {
     throw TTransportException(TTransportException::BAD_ARGS,
-         "loadPrivateKey: either <path> or <format> is NULL");
+                              "loadPrivateKey: either <path> or <format> is NULL");
   }
   if (strcmp(format, "PEM") == 0) {
     if (SSL_CTX_use_PrivateKey_file(ctx_->get(), path, SSL_FILETYPE_PEM) == 0) {
@@ -569,7 +555,7 @@ void TSSLSocketFactory::loadPrivateKey(const char* path, const char* format) {
 void TSSLSocketFactory::loadTrustedCertificates(const char* path) {
   if (path == NULL) {
     throw TTransportException(TTransportException::BAD_ARGS,
-         "loadTrustedCertificates: <path> is NULL");
+                              "loadTrustedCertificates: <path> is NULL");
   }
   if (SSL_CTX_load_verify_locations(ctx_->get(), path, NULL) == 0) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -588,10 +574,7 @@ void TSSLSocketFactory::overrideDefaultPasswordCallback() {
   SSL_CTX_set_default_passwd_cb_userdata(ctx_->get(), this);
 }
 
-int TSSLSocketFactory::passwordCallback(char* password,
-                                        int size,
-                                        int,
-                                        void* data) {
+int TSSLSocketFactory::passwordCallback(char* password, int size, int, void* data) {
   TSSLSocketFactory* factory = (TSSLSocketFactory*)data;
   string userPassword;
   factory->getPassword(userPassword, size);
@@ -605,8 +588,8 @@ int TSSLSocketFactory::passwordCallback(char* password,
 
 // extract error messages from error queue
 void buildErrors(string& errors, int errno_copy) {
-  unsigned long  errorCode;
-  char   message[256];
+  unsigned long errorCode;
+  char message[256];
 
   errors.reserve(512);
   while ((errorCode = ERR_get_error()) != 0) {
@@ -633,9 +616,8 @@ void buildErrors(string& errors, int errno_copy) {
 /**
  * Default implementation of AccessManager
  */
-Decision DefaultClientAccessManager::verify(const sockaddr_storage& sa)
-  throw() {
-  (void) sa;
+Decision DefaultClientAccessManager::verify(const sockaddr_storage& sa) throw() {
+  (void)sa;
   return SKIP;
 }
 
@@ -691,16 +673,16 @@ bool matchName(const char* host, const char* pattern, int size) {
     match = true;
   }
   return match;
-
 }
 
 // This is to work around the Turkish locale issue, i.e.,
 // toupper('i') != toupper('I') if locale is "tr_TR"
-char uppercase (char c) {
+char uppercase(char c) {
   if ('a' <= c && c <= 'z') {
     return c + ('A' - 'a');
   }
   return c;
 }
-
-}}}
+}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSSLSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h
index a4b805b..8d4277a 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.h
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.h
@@ -26,21 +26,22 @@
 #include <thrift/concurrency/Mutex.h>
 #include <thrift/transport/TSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class AccessManager;
 class SSLContext;
 
 enum SSLProtocol {
-	SSLTLS		= 0,	// Supports SSLv3 and TLSv1.
-	//SSLv2		= 1,	// HORRIBLY INSECURE!
-	SSLv3		= 2,	// Supports SSLv3 only.
-	TLSv1_0		= 3,	// Supports TLSv1_0 only.
-	TLSv1_1		= 4,	// Supports TLSv1_1 only.
-	TLSv1_2		= 5 	// Supports TLSv1_2 only.
+  SSLTLS = 0, // Supports SSLv3 and TLSv1.
+  // SSLv2		= 1,	// HORRIBLY INSECURE!
+  SSLv3 = 2,   // Supports SSLv3 only.
+  TLSv1_0 = 3, // Supports TLSv1_0 only.
+  TLSv1_1 = 4, // Supports TLSv1_1 only.
+  TLSv1_2 = 5  // Supports TLSv1_2 only.
 };
 
-
 /**
  * Initialize OpenSSL library.  This function, or some other
  * equivalent function to initialize OpenSSL, must be called before
@@ -61,24 +62,24 @@ void cleanupOpenSSL();
 /**
  * OpenSSL implementation for SSL socket interface.
  */
-class TSSLSocket: public TSocket {
- public:
- ~TSSLSocket();
+class TSSLSocket : public TSocket {
+public:
+  ~TSSLSocket();
   /**
    * TTransport interface.
    */
-  bool     isOpen();
-  bool     peek();
-  void     open();
-  void     close();
+  bool isOpen();
+  bool peek();
+  void open();
+  void close();
   uint32_t read(uint8_t* buf, uint32_t len);
-  void     write(const uint8_t* buf, uint32_t len);
-  void     flush();
-   /**
-   * Set whether to use client or server side SSL handshake protocol.
-   *
-   * @param flag  Use server side handshake protocol if true.
-   */
+  void write(const uint8_t* buf, uint32_t len);
+  void flush();
+  /**
+  * Set whether to use client or server side SSL handshake protocol.
+  *
+  * @param flag  Use server side handshake protocol if true.
+  */
   void server(bool flag) { server_ = flag; }
   /**
    * Determine whether the SSL socket is server or client mode.
@@ -89,9 +90,8 @@ class TSSLSocket: public TSocket {
    *
    * @param manager  Instance of AccessManager
    */
-  virtual void access(boost::shared_ptr<AccessManager> manager) {
-    access_ = manager;
-  }
+  virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; }
+
 protected:
   /**
    * Constructor.
@@ -109,9 +109,7 @@ protected:
    * @param host  Remote host name
    * @param port  Remote port number
    */
-  TSSLSocket(boost::shared_ptr<SSLContext> ctx,
-                               std::string host,
-                                       int port);
+  TSSLSocket(boost::shared_ptr<SSLContext> ctx, std::string host, int port);
   /**
    * Authorize peer access after SSL handshake completes.
    */
@@ -132,7 +130,7 @@ protected:
  * SSL socket factory. SSL sockets should be created via SSL factory.
  */
 class TSSLSocketFactory {
- public:
+public:
   /**
    * Constructor/Destructor
    *
@@ -150,14 +148,13 @@ class TSSLSocketFactory {
    * @param socket An existing socket.
    */
   virtual boost::shared_ptr<TSSLSocket> createSocket(THRIFT_SOCKET socket);
-   /**
-   * Create an instance of TSSLSocket.
-   *
-   * @param host  Remote host to be connected to
-   * @param port  Remote port to be connected to
-   */
-  virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host,
-                                                     int port);
+  /**
+  * Create an instance of TSSLSocket.
+  *
+  * @param host  Remote host to be connected to
+  * @param port  Remote port to be connected to
+  */
+  virtual boost::shared_ptr<TSSLSocket> createSocket(const std::string& host, int port);
   /**
    * Set ciphers to be used in SSL handshake process.
    *
@@ -215,13 +212,12 @@ class TSSLSocketFactory {
    *
    * @param manager  The AccessManager instance
    */
-  virtual void access(boost::shared_ptr<AccessManager> manager) {
-    access_ = manager;
-  }
+  virtual void access(boost::shared_ptr<AccessManager> manager) { access_ = manager; }
   static void setManualOpenSSLInitialization(bool manualOpenSSLInitialization) {
     manualOpenSSLInitialization_ = manualOpenSSLInitialization;
   }
- protected:
+
+protected:
   boost::shared_ptr<SSLContext> ctx_;
 
   /**
@@ -232,7 +228,8 @@ class TSSLSocketFactory {
    * @param size     Maximum length of password including NULL character
    */
   virtual void getPassword(std::string& /* password */, int /* size */) {}
- private:
+
+private:
   bool server_;
   boost::shared_ptr<AccessManager> access_;
   static concurrency::Mutex mutex_;
@@ -245,10 +242,10 @@ class TSSLSocketFactory {
 /**
  * SSL exception.
  */
-class TSSLException: public TTransportException {
- public:
-  TSSLException(const std::string& message):
-    TTransportException(TTransportException::INTERNAL_ERROR, message) {}
+class TSSLException : public TTransportException {
+public:
+  TSSLException(const std::string& message)
+    : TTransportException(TTransportException::INTERNAL_ERROR, message) {}
 
   virtual const char* what() const throw() {
     if (message_.empty()) {
@@ -263,12 +260,13 @@ class TSSLException: public TTransportException {
  * Wrap OpenSSL SSL_CTX into a class.
  */
 class SSLContext {
- public:
+public:
   SSLContext(const SSLProtocol& protocol = SSLTLS);
   virtual ~SSLContext();
   SSL* createSSL();
   SSL_CTX* get() { return ctx_; }
- private:
+
+private:
   SSL_CTX* ctx_;
 };
 
@@ -279,67 +277,73 @@ class SSLContext {
  * object.
  */
 class AccessManager {
- public:
+public:
   enum Decision {
-    DENY   = -1,    // deny access
-    SKIP   =  0,    // cannot make decision, move on to next (if any)
-    ALLOW  =  1     // allow access
+    DENY = -1, // deny access
+    SKIP = 0,  // cannot make decision, move on to next (if any)
+    ALLOW = 1  // allow access
   };
- /**
-  * Destructor
-  */
- virtual ~AccessManager() {}
- /**
-  * Determine whether the peer should be granted access or not. It's called
-  * once after the SSL handshake completes successfully, before peer certificate
-  * is examined.
-  *
-  * If a valid decision (ALLOW or DENY) is returned, the peer certificate is
-  * not to be verified.
-  *
-  * @param  sa Peer IP address
-  * @return True if the peer is trusted, false otherwise
-  */
- virtual Decision verify(const sockaddr_storage& /* sa */ ) throw() { return DENY; }
- /**
-  * Determine whether the peer should be granted access or not. It's called
-  * every time a DNS subjectAltName/common name is extracted from peer's
-  * certificate.
-  *
-  * @param  host Client mode: host name returned by TSocket::getHost()
-  *              Server mode: host name returned by TSocket::getPeerHost()
-  * @param  name SubjectAltName or common name extracted from peer certificate
-  * @param  size Length of name
-  * @return True if the peer is trusted, false otherwise
-  *
-  * Note: The "name" parameter may be UTF8 encoded.
-  */
- virtual Decision verify(const std::string& /* host */, const char* /* name */, int /* size */)
-   throw() { return DENY; }
- /**
-  * Determine whether the peer should be granted access or not. It's called
-  * every time an IP subjectAltName is extracted from peer's certificate.
-  *
-  * @param  sa   Peer IP address retrieved from the underlying socket
-  * @param  data IP address extracted from certificate
-  * @param  size Length of the IP address
-  * @return True if the peer is trusted, false otherwise
-  */
- virtual Decision verify(const sockaddr_storage& /* sa */, const char* /* data */, int /* size */)
-   throw() { return DENY; }
+  /**
+   * Destructor
+   */
+  virtual ~AccessManager() {}
+  /**
+   * Determine whether the peer should be granted access or not. It's called
+   * once after the SSL handshake completes successfully, before peer certificate
+   * is examined.
+   *
+   * If a valid decision (ALLOW or DENY) is returned, the peer certificate is
+   * not to be verified.
+   *
+   * @param  sa Peer IP address
+   * @return True if the peer is trusted, false otherwise
+   */
+  virtual Decision verify(const sockaddr_storage& /* sa */) throw() { return DENY; }
+  /**
+   * Determine whether the peer should be granted access or not. It's called
+   * every time a DNS subjectAltName/common name is extracted from peer's
+   * certificate.
+   *
+   * @param  host Client mode: host name returned by TSocket::getHost()
+   *              Server mode: host name returned by TSocket::getPeerHost()
+   * @param  name SubjectAltName or common name extracted from peer certificate
+   * @param  size Length of name
+   * @return True if the peer is trusted, false otherwise
+   *
+   * Note: The "name" parameter may be UTF8 encoded.
+   */
+  virtual Decision verify(const std::string& /* host */,
+                          const char* /* name */,
+                          int /* size */) throw() {
+    return DENY;
+  }
+  /**
+   * Determine whether the peer should be granted access or not. It's called
+   * every time an IP subjectAltName is extracted from peer's certificate.
+   *
+   * @param  sa   Peer IP address retrieved from the underlying socket
+   * @param  data IP address extracted from certificate
+   * @param  size Length of the IP address
+   * @return True if the peer is trusted, false otherwise
+   */
+  virtual Decision verify(const sockaddr_storage& /* sa */,
+                          const char* /* data */,
+                          int /* size */) throw() {
+    return DENY;
+  }
 };
 
 typedef AccessManager::Decision Decision;
 
-class DefaultClientAccessManager: public AccessManager {
- public:
+class DefaultClientAccessManager : public AccessManager {
+public:
   // AccessManager interface
   Decision verify(const sockaddr_storage& sa) throw();
   Decision verify(const std::string& host, const char* name, int size) throw();
   Decision verify(const sockaddr_storage& sa, const char* data, int size) throw();
 };
-
-
-}}}
+}
+}
+}
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TServerSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
old mode 100755
new mode 100644
index 0ce1bce..e228dab
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -52,76 +52,78 @@
 #endif
 
 #ifndef SOCKOPT_CAST_T
-#   ifndef _WIN32
-#       define SOCKOPT_CAST_T void
-#   else
-#       define SOCKOPT_CAST_T char
-#   endif // _WIN32
+#ifndef _WIN32
+#define SOCKOPT_CAST_T void
+#else
+#define SOCKOPT_CAST_T char
+#endif // _WIN32
 #endif
 
-template<class T>
+template <class T>
 inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) {
-    return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
+  return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
 }
 
-template<class T>
+template <class T>
 inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
-    return reinterpret_cast<SOCKOPT_CAST_T*>(v);
+  return reinterpret_cast<SOCKOPT_CAST_T*>(v);
 }
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 using boost::shared_ptr;
 
-TServerSocket::TServerSocket(int port) :
-  port_(port),
-  serverSocket_(THRIFT_INVALID_SOCKET),
-  acceptBacklog_(DEFAULT_BACKLOG),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  accTimeout_(-1),
-  retryLimit_(0),
-  retryDelay_(0),
-  tcpSendBuffer_(0),
-  tcpRecvBuffer_(0),
-  keepAlive_(false),
-  intSock1_(THRIFT_INVALID_SOCKET),
-  intSock2_(THRIFT_INVALID_SOCKET)
-{}
-
-TServerSocket::TServerSocket(int port, int sendTimeout, int recvTimeout) :
-  port_(port),
-  serverSocket_(THRIFT_INVALID_SOCKET),
-  acceptBacklog_(DEFAULT_BACKLOG),
-  sendTimeout_(sendTimeout),
-  recvTimeout_(recvTimeout),
-  accTimeout_(-1),
-  retryLimit_(0),
-  retryDelay_(0),
-  tcpSendBuffer_(0),
-  tcpRecvBuffer_(0),
-  keepAlive_(false),
-  intSock1_(THRIFT_INVALID_SOCKET),
-  intSock2_(THRIFT_INVALID_SOCKET)
-{}
-
-TServerSocket::TServerSocket(string path) :
-  port_(0),
-  path_(path),
-  serverSocket_(THRIFT_INVALID_SOCKET),
-  acceptBacklog_(DEFAULT_BACKLOG),
-  sendTimeout_(0),
-  recvTimeout_(0),
-  accTimeout_(-1),
-  retryLimit_(0),
-  retryDelay_(0),
-  tcpSendBuffer_(0),
-  tcpRecvBuffer_(0),
-  keepAlive_(false),
-  intSock1_(THRIFT_INVALID_SOCKET),
-  intSock2_(THRIFT_INVALID_SOCKET)
-{}
+TServerSocket::TServerSocket(int port)
+  : port_(port),
+    serverSocket_(THRIFT_INVALID_SOCKET),
+    acceptBacklog_(DEFAULT_BACKLOG),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    accTimeout_(-1),
+    retryLimit_(0),
+    retryDelay_(0),
+    tcpSendBuffer_(0),
+    tcpRecvBuffer_(0),
+    keepAlive_(false),
+    intSock1_(THRIFT_INVALID_SOCKET),
+    intSock2_(THRIFT_INVALID_SOCKET) {
+}
+
+TServerSocket::TServerSocket(int port, int sendTimeout, int recvTimeout)
+  : port_(port),
+    serverSocket_(THRIFT_INVALID_SOCKET),
+    acceptBacklog_(DEFAULT_BACKLOG),
+    sendTimeout_(sendTimeout),
+    recvTimeout_(recvTimeout),
+    accTimeout_(-1),
+    retryLimit_(0),
+    retryDelay_(0),
+    tcpSendBuffer_(0),
+    tcpRecvBuffer_(0),
+    keepAlive_(false),
+    intSock1_(THRIFT_INVALID_SOCKET),
+    intSock2_(THRIFT_INVALID_SOCKET) {
+}
+
+TServerSocket::TServerSocket(string path)
+  : port_(0),
+    path_(path),
+    serverSocket_(THRIFT_INVALID_SOCKET),
+    acceptBacklog_(DEFAULT_BACKLOG),
+    sendTimeout_(0),
+    recvTimeout_(0),
+    accTimeout_(-1),
+    retryLimit_(0),
+    retryDelay_(0),
+    tcpSendBuffer_(0),
+    tcpRecvBuffer_(0),
+    keepAlive_(false),
+    intSock1_(THRIFT_INVALID_SOCKET),
+    intSock2_(THRIFT_INVALID_SOCKET) {
+}
 
 TServerSocket::~TServerSocket() {
   close();
@@ -161,7 +163,7 @@ void TServerSocket::setTcpRecvBuffer(int tcpRecvBuffer) {
 
 void TServerSocket::listen() {
 #ifdef _WIN32
-    TWinsockSingleton::create();
+  TWinsockSingleton::create();
 #endif // _WIN32
   THRIFT_SOCKET sv[2];
   if (-1 == THRIFT_SOCKETPAIR(AF_LOCAL, SOCK_STREAM, 0, sv)) {
@@ -187,7 +189,8 @@ void TServerSocket::listen() {
   if (error) {
     GlobalOutput.printf("getaddrinfo %d: %s", error, THRIFT_GAI_STRERROR(error));
     close();
-    throw TTransportException(TTransportException::NOT_OPEN, "Could not resolve host for server socket.");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "Could not resolve host for server socket.");
   }
 
   // Pick the ipv6 address first since ipv4 addresses can be mapped
@@ -197,7 +200,7 @@ void TServerSocket::listen() {
       break;
   }
 
-  if (! path_.empty()) {
+  if (!path_.empty()) {
     serverSocket_ = socket(PF_UNIX, SOCK_STREAM, IPPROTO_IP);
   } else {
     serverSocket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -207,72 +210,93 @@ void TServerSocket::listen() {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
     GlobalOutput.perror("TServerSocket::listen() socket() ", errno_copy);
     close();
-    throw TTransportException(TTransportException::NOT_OPEN, "Could not create server socket.", errno_copy);
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "Could not create server socket.",
+                              errno_copy);
   }
 
   // Set THRIFT_NO_SOCKET_CACHING to prevent 2MSL delay on accept
   int one = 1;
-  if (-1 == setsockopt(serverSocket_, SOL_SOCKET, THRIFT_NO_SOCKET_CACHING,
-                       cast_sockopt(&one), sizeof(one))) {
-    //ignore errors coming out of this setsockopt on Windows.  This is because
-    //SO_EXCLUSIVEADDRUSE requires admin privileges on WinXP, but we don't
-    //want to force servers to be an admin.
+  if (-1 == setsockopt(serverSocket_,
+                       SOL_SOCKET,
+                       THRIFT_NO_SOCKET_CACHING,
+                       cast_sockopt(&one),
+                       sizeof(one))) {
+// ignore errors coming out of this setsockopt on Windows.  This is because
+// SO_EXCLUSIVEADDRUSE requires admin privileges on WinXP, but we don't
+// want to force servers to be an admin.
 #ifndef _WIN32
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
-    GlobalOutput.perror("TServerSocket::listen() setsockopt() THRIFT_NO_SOCKET_CACHING ", errno_copy);
+    GlobalOutput.perror("TServerSocket::listen() setsockopt() THRIFT_NO_SOCKET_CACHING ",
+                        errno_copy);
     close();
-    throw TTransportException(TTransportException::NOT_OPEN, "Could not set THRIFT_NO_SOCKET_CACHING", errno_copy);
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "Could not set THRIFT_NO_SOCKET_CACHING",
+                              errno_copy);
 #endif
   }
 
   // Set TCP buffer sizes
   if (tcpSendBuffer_ > 0) {
-    if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_SNDBUF,
-                         cast_sockopt(&tcpSendBuffer_), sizeof(tcpSendBuffer_))) {
+    if (-1 == setsockopt(serverSocket_,
+                         SOL_SOCKET,
+                         SO_SNDBUF,
+                         cast_sockopt(&tcpSendBuffer_),
+                         sizeof(tcpSendBuffer_))) {
       int errno_copy = THRIFT_GET_SOCKET_ERROR;
       GlobalOutput.perror("TServerSocket::listen() setsockopt() SO_SNDBUF ", errno_copy);
       close();
-      throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_SNDBUF", errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN,
+                                "Could not set SO_SNDBUF",
+                                errno_copy);
     }
   }
 
   if (tcpRecvBuffer_ > 0) {
-    if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_RCVBUF,
-                         cast_sockopt(&tcpRecvBuffer_), sizeof(tcpRecvBuffer_))) {
+    if (-1 == setsockopt(serverSocket_,
+                         SOL_SOCKET,
+                         SO_RCVBUF,
+                         cast_sockopt(&tcpRecvBuffer_),
+                         sizeof(tcpRecvBuffer_))) {
       int errno_copy = THRIFT_GET_SOCKET_ERROR;
       GlobalOutput.perror("TServerSocket::listen() setsockopt() SO_RCVBUF ", errno_copy);
       close();
-      throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_RCVBUF", errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN,
+                                "Could not set SO_RCVBUF",
+                                errno_copy);
     }
   }
 
-  // Defer accept
-  #ifdef TCP_DEFER_ACCEPT
+// Defer accept
+#ifdef TCP_DEFER_ACCEPT
   if (path_.empty()) {
-    if (-1 == setsockopt(serverSocket_, IPPROTO_TCP, TCP_DEFER_ACCEPT,
-                         &one, sizeof(one))) {
+    if (-1 == setsockopt(serverSocket_, IPPROTO_TCP, TCP_DEFER_ACCEPT, &one, sizeof(one))) {
       int errno_copy = THRIFT_GET_SOCKET_ERROR;
       GlobalOutput.perror("TServerSocket::listen() setsockopt() TCP_DEFER_ACCEPT ", errno_copy);
       close();
-      throw TTransportException(TTransportException::NOT_OPEN, "Could not set TCP_DEFER_ACCEPT", errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN,
+                                "Could not set TCP_DEFER_ACCEPT",
+                                errno_copy);
     }
   }
-  #endif // #ifdef TCP_DEFER_ACCEPT
+#endif // #ifdef TCP_DEFER_ACCEPT
 
-  #ifdef IPV6_V6ONLY
+#ifdef IPV6_V6ONLY
   if (res->ai_family == AF_INET6 && path_.empty()) {
     int zero = 0;
-    if (-1 == setsockopt(serverSocket_, IPPROTO_IPV6, IPV6_V6ONLY,
-          cast_sockopt(&zero), sizeof(zero))) {
+    if (-1 == setsockopt(serverSocket_,
+                         IPPROTO_IPV6,
+                         IPV6_V6ONLY,
+                         cast_sockopt(&zero),
+                         sizeof(zero))) {
       GlobalOutput.perror("TServerSocket::listen() IPV6_V6ONLY ", THRIFT_GET_SOCKET_ERROR);
     }
   }
-  #endif // #ifdef IPV6_V6ONLY
+#endif // #ifdef IPV6_V6ONLY
 
   // Turn linger off, don't want to block on calls to close
   struct linger ling = {0, 0};
-  if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_LINGER,
-                       cast_sockopt(&ling), sizeof(ling))) {
+  if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_LINGER, cast_sockopt(&ling), sizeof(ling))) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
     GlobalOutput.perror("TServerSocket::listen() setsockopt() SO_LINGER ", errno_copy);
     close();
@@ -282,12 +306,14 @@ void TServerSocket::listen() {
   // Unix Sockets do not need that
   if (path_.empty()) {
     // TCP Nodelay, speed over bandwidth
-    if (-1 == setsockopt(serverSocket_, IPPROTO_TCP, TCP_NODELAY,
-                         cast_sockopt(&one), sizeof(one))) {
+    if (-1
+        == setsockopt(serverSocket_, IPPROTO_TCP, TCP_NODELAY, cast_sockopt(&one), sizeof(one))) {
       int errno_copy = THRIFT_GET_SOCKET_ERROR;
       GlobalOutput.perror("TServerSocket::listen() setsockopt() TCP_NODELAY ", errno_copy);
       close();
-      throw TTransportException(TTransportException::NOT_OPEN, "Could not set TCP_NODELAY", errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN,
+                                "Could not set TCP_NODELAY",
+                                errno_copy);
     }
   }
 
@@ -310,7 +336,7 @@ void TServerSocket::listen() {
   // always seem to work. The client can configure the retry variables.
   int retries = 0;
 
-  if (! path_.empty()) {
+  if (!path_.empty()) {
 
 #ifndef _WIN32
 
@@ -328,14 +354,15 @@ void TServerSocket::listen() {
     socklen_t structlen = static_cast<socklen_t>(sizeof(address));
 
     do {
-      if (0 == ::bind(serverSocket_, (struct sockaddr *) &address, structlen)) {
+      if (0 == ::bind(serverSocket_, (struct sockaddr*)&address, structlen)) {
         break;
       }
       // use short circuit evaluation here to only sleep if we need to
     } while ((retries++ < retryLimit_) && (THRIFT_SLEEP_SEC(retryDelay_) == 0));
 #else
     GlobalOutput.perror("TSocket::open() Unix Domain socket path not supported on windows", -99);
-    throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path not supported");
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              " Unix Domain socket path not supported");
 #endif
   } else {
     do {
@@ -356,16 +383,12 @@ void TServerSocket::listen() {
       if (::getsockname(serverSocket_, &sa, &len) < 0) {
         int errno_copy = errno;
         GlobalOutput.perror("TServerSocket::getPort() getsockname() ", errno_copy);
-      }
-      else {
+      } else {
         if (sa.sa_family == AF_INET6) {
-          const struct sockaddr_in6*
-            sin = reinterpret_cast<const struct sockaddr_in6 *>(&sa);
+          const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
           port_ = ntohs(sin->sin6_port);
-        }
-        else {
-          const struct sockaddr_in*
-            sin = reinterpret_cast<const struct sockaddr_in *>(&sa);
+        } else {
+          const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&sa);
           port_ = ntohs(sin->sin_port);
         }
       }
@@ -375,19 +398,20 @@ void TServerSocket::listen() {
   // throw an error if we failed to bind properly
   if (retries > retryLimit_) {
     char errbuf[1024];
-    if (! path_.empty()) {
+    if (!path_.empty()) {
       sprintf(errbuf, "TServerSocket::listen() PATH %s", path_.c_str());
-    }
-    else {
+    } else {
       sprintf(errbuf, "TServerSocket::listen() BIND %d", port_);
     }
     GlobalOutput(errbuf);
     close();
-    throw TTransportException(TTransportException::NOT_OPEN, "Could not bind",
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "Could not bind",
                               THRIFT_GET_SOCKET_ERROR);
   }
 
-  if(listenCallback_) listenCallback_(serverSocket_);
+  if (listenCallback_)
+    listenCallback_(serverSocket_);
 
   // Call listen
   if (-1 == ::listen(serverSocket_, acceptBacklog_)) {
@@ -401,7 +425,7 @@ void TServerSocket::listen() {
 }
 
 int TServerSocket::getPort() {
-    return port_;
+  return port_;
 }
 
 shared_ptr<TTransport> TServerSocket::acceptImpl() {
@@ -415,7 +439,7 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
   int numEintrs = 0;
 
   while (true) {
-    std::memset(fds, 0 , sizeof(fds));
+    std::memset(fds, 0, sizeof(fds));
     fds[0].fd = serverSocket_;
     fds[0].events = THRIFT_POLLIN;
     if (intSock2_ != THRIFT_INVALID_SOCKET) {
@@ -440,11 +464,11 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
       throw TTransportException(TTransportException::UNKNOWN, "Unknown", errno_copy);
     } else if (ret > 0) {
       // Check for an interrupt signal
-      if (intSock2_ != THRIFT_INVALID_SOCKET
-          && (fds[1].revents & THRIFT_POLLIN)) {
+      if (intSock2_ != THRIFT_INVALID_SOCKET && (fds[1].revents & THRIFT_POLLIN)) {
         int8_t buf;
         if (-1 == recv(intSock2_, cast_sockopt(&buf), sizeof(int8_t), 0)) {
-          GlobalOutput.perror("TServerSocket::acceptImpl() recv() interrupt ", THRIFT_GET_SOCKET_ERROR);
+          GlobalOutput.perror("TServerSocket::acceptImpl() recv() interrupt ",
+                              THRIFT_GET_SOCKET_ERROR);
         }
         throw TTransportException(TTransportException::INTERRUPTED);
       }
@@ -461,9 +485,8 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
 
   struct sockaddr_storage clientAddress;
   int size = sizeof(clientAddress);
-  THRIFT_SOCKET clientSocket = ::accept(serverSocket_,
-                              (struct sockaddr *) &clientAddress,
-                              (socklen_t *) &size);
+  THRIFT_SOCKET clientSocket
+      = ::accept(serverSocket_, (struct sockaddr*)&clientAddress, (socklen_t*)&size);
 
   if (clientSocket == -1) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -476,13 +499,19 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
   if (flags == -1) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
     GlobalOutput.perror("TServerSocket::acceptImpl() THRIFT_FCNTL() THRIFT_F_GETFL ", errno_copy);
-    throw TTransportException(TTransportException::UNKNOWN, "THRIFT_FCNTL(THRIFT_F_GETFL)", errno_copy);
+    throw TTransportException(TTransportException::UNKNOWN,
+                              "THRIFT_FCNTL(THRIFT_F_GETFL)",
+                              errno_copy);
   }
 
   if (-1 == THRIFT_FCNTL(clientSocket, THRIFT_F_SETFL, flags & ~THRIFT_O_NONBLOCK)) {
     int errno_copy = THRIFT_GET_SOCKET_ERROR;
-    GlobalOutput.perror("TServerSocket::acceptImpl() THRIFT_FCNTL() THRIFT_F_SETFL ~THRIFT_O_NONBLOCK ", errno_copy);
-    throw TTransportException(TTransportException::UNKNOWN, "THRIFT_FCNTL(THRIFT_F_SETFL)", errno_copy);
+    GlobalOutput
+        .perror("TServerSocket::acceptImpl() THRIFT_FCNTL() THRIFT_F_SETFL ~THRIFT_O_NONBLOCK ",
+                errno_copy);
+    throw TTransportException(TTransportException::UNKNOWN,
+                              "THRIFT_FCNTL(THRIFT_F_SETFL)",
+                              errno_copy);
   }
 
   shared_ptr<TSocket> client = createSocket(clientSocket);
@@ -495,9 +524,10 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
   if (keepAlive_) {
     client->setKeepAlive(keepAlive_);
   }
-  client->setCachedAddress((sockaddr*) &clientAddress, size);
+  client->setCachedAddress((sockaddr*)&clientAddress, size);
 
-  if(acceptCallback_) acceptCallback_(clientSocket);
+  if (acceptCallback_)
+    acceptCallback_(clientSocket);
 
   return client;
 }
@@ -521,7 +551,7 @@ void TServerSocket::close() {
     ::THRIFT_CLOSESOCKET(serverSocket_);
   }
   if (intSock1_ != THRIFT_INVALID_SOCKET) {
-      ::THRIFT_CLOSESOCKET(intSock1_);
+    ::THRIFT_CLOSESOCKET(intSock1_);
   }
   if (intSock2_ != THRIFT_INVALID_SOCKET) {
     ::THRIFT_CLOSESOCKET(intSock2_);
@@ -530,5 +560,6 @@ void TServerSocket::close() {
   intSock1_ = THRIFT_INVALID_SOCKET;
   intSock2_ = THRIFT_INVALID_SOCKET;
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TServerSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.h b/lib/cpp/src/thrift/transport/TServerSocket.h
index 56ec2b5..1533937 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TServerSocket.h
@@ -25,7 +25,9 @@
 #include <thrift/cxxfunctional.h>
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class TSocket;
 
@@ -35,7 +37,7 @@ class TSocket;
  *
  */
 class TServerSocket : public TServerTransport {
- public:
+public:
   typedef apache::thrift::stdcxx::function<void(THRIFT_SOCKET fd)> socket_func_t;
 
   const static int DEFAULT_BACKLOG = 1024;
@@ -55,7 +57,7 @@ class TServerSocket : public TServerTransport {
   void setRetryLimit(int retryLimit);
   void setRetryDelay(int retryDelay);
 
-  void setKeepAlive(bool keepAlive) {keepAlive_ = keepAlive;}
+  void setKeepAlive(bool keepAlive) { keepAlive_ = keepAlive; }
 
   void setTcpSendBuffer(int tcpSendBuffer);
   void setTcpRecvBuffer(int tcpRecvBuffer);
@@ -63,13 +65,13 @@ class TServerSocket : public TServerTransport {
   // listenCallback gets called just before listen, and after all Thrift
   // setsockopt calls have been made.  If you have custom setsockopt
   // things that need to happen on the listening socket, this is the place to do it.
-  void setListenCallback(const socket_func_t &listenCallback) { listenCallback_ = listenCallback; }
+  void setListenCallback(const socket_func_t& listenCallback) { listenCallback_ = listenCallback; }
 
   // acceptCallback gets called after each accept call, on the newly created socket.
   // It is called after all Thrift setsockopt calls have been made.  If you have
   // custom setsockopt things that need to happen on the accepted
   // socket, this is the place to do it.
-  void setAcceptCallback(const socket_func_t &acceptCallback) { acceptCallback_ = acceptCallback; }
+  void setAcceptCallback(const socket_func_t& acceptCallback) { acceptCallback_ = acceptCallback; }
 
   void listen();
   void close();
@@ -77,11 +79,11 @@ class TServerSocket : public TServerTransport {
   void interrupt();
   int getPort();
 
- protected:
+protected:
   boost::shared_ptr<TTransport> acceptImpl();
   virtual boost::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client);
 
- private:
+private:
   int port_;
   std::string path_;
   THRIFT_SOCKET serverSocket_;
@@ -101,7 +103,8 @@ class TServerSocket : public TServerTransport {
   socket_func_t listenCallback_;
   socket_func_t acceptCallback_;
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TServerTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h
index 2ddee0d..7c4a7c3 100644
--- a/lib/cpp/src/thrift/transport/TServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TServerTransport.h
@@ -24,7 +24,9 @@
 #include <thrift/transport/TTransportException.h>
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Server transport framework. A server needs to have some facility for
@@ -32,7 +34,7 @@ namespace apache { namespace thrift { namespace transport {
  *
  */
 class TServerTransport {
- public:
+public:
   virtual ~TServerTransport() {}
 
   /**
@@ -74,7 +76,7 @@ class TServerTransport {
    */
   virtual void close() = 0;
 
- protected:
+protected:
   TServerTransport() {}
 
   /**
@@ -84,9 +86,9 @@ class TServerTransport {
    * @throw TTransportException If an error occurs
    */
   virtual boost::shared_ptr<TTransport> acceptImpl() = 0;
-
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSERVERTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TShortReadTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TShortReadTransport.h b/lib/cpp/src/thrift/transport/TShortReadTransport.h
index 8def354..f2ecae1 100644
--- a/lib/cpp/src/thrift/transport/TShortReadTransport.h
+++ b/lib/cpp/src/thrift/transport/TShortReadTransport.h
@@ -25,7 +25,10 @@
 #include <thrift/transport/TTransport.h>
 #include <thrift/transport/TVirtualTransport.h>
 
-namespace apache { namespace thrift { namespace transport { namespace test {
+namespace apache {
+namespace thrift {
+namespace transport {
+namespace test {
 
 /**
  * This class is only meant for testing.  It wraps another transport.
@@ -34,64 +37,46 @@ namespace apache { namespace thrift { namespace transport { namespace test {
  *
  */
 class TShortReadTransport : public TVirtualTransport<TShortReadTransport> {
- public:
+public:
   TShortReadTransport(boost::shared_ptr<TTransport> transport, double full_prob)
-    : transport_(transport)
-    , fullProb_(full_prob)
-  {}
+    : transport_(transport), fullProb_(full_prob) {}
 
-  bool isOpen() {
-    return transport_->isOpen();
-  }
+  bool isOpen() { return transport_->isOpen(); }
 
-  bool peek() {
-    return transport_->peek();
-  }
+  bool peek() { return transport_->peek(); }
 
-  void open() {
-    transport_->open();
-  }
+  void open() { transport_->open(); }
 
-  void close() {
-    transport_->close();
-  }
+  void close() { transport_->close(); }
 
   uint32_t read(uint8_t* buf, uint32_t len) {
     if (len == 0) {
       return 0;
     }
 
-    if (rand()/(double)RAND_MAX >= fullProb_) {
-      len = 1 + rand()%len;
+    if (rand() / (double)RAND_MAX >= fullProb_) {
+      len = 1 + rand() % len;
     }
     return transport_->read(buf, len);
   }
 
-  void write(const uint8_t* buf, uint32_t len) {
-    transport_->write(buf, len);
-  }
+  void write(const uint8_t* buf, uint32_t len) { transport_->write(buf, len); }
 
-  void flush() {
-    transport_->flush();
-  }
+  void flush() { transport_->flush(); }
 
-  const uint8_t* borrow(uint8_t* buf, uint32_t* len) {
-    return transport_->borrow(buf, len);
-  }
+  const uint8_t* borrow(uint8_t* buf, uint32_t* len) { return transport_->borrow(buf, len); }
 
-  void consume(uint32_t len) {
-    return transport_->consume(len);
-  }
+  void consume(uint32_t len) { return transport_->consume(len); }
 
-  boost::shared_ptr<TTransport> getUnderlyingTransport() {
-    return transport_;
-  }
+  boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; }
 
- protected:
+protected:
   boost::shared_ptr<TTransport> transport_;
   double fullProb_;
 };
-
-}}}} // apache::thrift::transport::test
+}
+}
+}
+} // apache::thrift::transport::test
 
 #endif // #ifndef _THRIFT_TRANSPORT_TSHORTREADTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSimpleFileTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSimpleFileTransport.cpp b/lib/cpp/src/thrift/transport/TSimpleFileTransport.cpp
index 6bd716e..4b1399e 100644
--- a/lib/cpp/src/thrift/transport/TSimpleFileTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TSimpleFileTransport.cpp
@@ -31,11 +31,12 @@
 #include <io.h>
 #endif
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
-TSimpleFileTransport::
-TSimpleFileTransport(const std::string& path, bool read, bool write)
-    : TFDTransport(-1, TFDTransport::CLOSE_ON_DESTROY) {
+TSimpleFileTransport::TSimpleFileTransport(const std::string& path, bool read, bool write)
+  : TFDTransport(-1, TFDTransport::CLOSE_ON_DESTROY) {
   int flags = 0;
   if (read && write) {
     flags = O_RDWR;
@@ -50,18 +51,17 @@ TSimpleFileTransport(const std::string& path, bool read, bool write)
     flags |= O_CREAT | O_APPEND;
   }
 #ifndef _WIN32
-  mode_t mode = S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH;
+  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 #else
   int mode = _S_IREAD | _S_IWRITE;
 #endif
-  int fd = ::THRIFT_OPEN(path.c_str(),
-                  flags,
-                  mode);
+  int fd = ::THRIFT_OPEN(path.c_str(), flags, mode);
   if (fd < 0) {
     throw TTransportException("failed to open file for writing: " + path);
   }
   setFD(fd);
   open();
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TSimpleFileTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSimpleFileTransport.h b/lib/cpp/src/thrift/transport/TSimpleFileTransport.h
index 985a1d3..32e1897 100644
--- a/lib/cpp/src/thrift/transport/TSimpleFileTransport.h
+++ b/lib/cpp/src/thrift/transport/TSimpleFileTransport.h
@@ -22,7 +22,9 @@
 
 #include <thrift/transport/TFDTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Dead-simple wrapper around a file.
@@ -30,12 +32,11 @@ namespace apache { namespace thrift { namespace transport {
  * Writeable files are opened with O_CREAT and O_APPEND
  */
 class TSimpleFileTransport : public TFDTransport {
- public:
-  TSimpleFileTransport(const std::string& path,
-                       bool read =  true,
-                       bool write = false);
+public:
+  TSimpleFileTransport(const std::string& path, bool read = true, bool write = false);
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif //  _THRIFT_TRANSPORT_TSIMPLEFILETRANSPORT_H_


[34/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_cocoa_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc
index cbed831..3ad6c31 100644
--- a/compiler/cpp/src/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/generate/t_cocoa_generator.cc
@@ -35,7 +35,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Objective-C code generator.
@@ -43,14 +43,12 @@ static const string endl = "\n";  // avoid ostream << std::endl flushes
  * mostly copy/pasting/tweaking from mcslee's work.
  */
 class t_cocoa_generator : public t_oop_generator {
- public:
-  t_cocoa_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_cocoa_generator(t_program* program,
+                    const std::map<std::string, std::string>& parsed_options,
+                    const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("log_unexpected");
@@ -75,26 +73,38 @@ class t_cocoa_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_xception(t_struct*   txception);
-  void generate_service (t_service*  tservice);
-
-  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool defval=false, bool is_property=false);
-  std::string render_const_value(ofstream& out, t_type* type, t_const_value* value, bool containerize_it=false);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  void print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool defval = false,
+                         bool is_property = false);
+  std::string render_const_value(ofstream& out,
+                                 t_type* type,
+                                 t_const_value* value,
+                                 bool containerize_it = false);
 
   void generate_cocoa_struct(t_struct* tstruct, bool is_exception);
-  void generate_cocoa_struct_interface(std::ofstream& out, t_struct* tstruct, bool is_xception=false);
-  void generate_cocoa_struct_implementation(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool is_result=false);
-  void generate_cocoa_struct_initializer_signature(std::ofstream& out,
-                                                   t_struct* tstruct);
-  void generate_cocoa_struct_init_with_coder_method(ofstream &out,
-                                                    t_struct* tstruct,
-                                                    bool is_exception);
-  void generate_cocoa_struct_encode_with_coder_method(ofstream &out,
+  void generate_cocoa_struct_interface(std::ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_xception = false);
+  void generate_cocoa_struct_implementation(std::ofstream& out,
+                                            t_struct* tstruct,
+                                            bool is_xception = false,
+                                            bool is_result = false);
+  void generate_cocoa_struct_initializer_signature(std::ofstream& out, t_struct* tstruct);
+  void generate_cocoa_struct_init_with_coder_method(ofstream& out,
                                                     t_struct* tstruct,
                                                     bool is_exception);
+  void generate_cocoa_struct_encode_with_coder_method(ofstream& out,
+                                                      t_struct* tstruct,
+                                                      bool is_exception);
   void generate_cocoa_struct_field_accessor_declarations(std::ofstream& out,
                                                          t_struct* tstruct,
                                                          bool is_exception);
@@ -115,69 +125,51 @@ class t_cocoa_generator : public t_oop_generator {
    * Service-level generation functions
    */
 
-  void generate_cocoa_service_protocol (std::ofstream& out, t_service* tservice);
-  void generate_cocoa_service_client_interface (std::ofstream& out, t_service* tservice);
-  void generate_cocoa_service_client_implementation (std::ofstream& out, t_service* tservice);
-  void generate_cocoa_service_server_interface (std::ofstream& out, t_service* tservice);
-  void generate_cocoa_service_server_implementation (std::ofstream& out, t_service* tservice);
-  void generate_cocoa_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_cocoa_service_protocol(std::ofstream& out, t_service* tservice);
+  void generate_cocoa_service_client_interface(std::ofstream& out, t_service* tservice);
+  void generate_cocoa_service_client_implementation(std::ofstream& out, t_service* tservice);
+  void generate_cocoa_service_server_interface(std::ofstream& out, t_service* tservice);
+  void generate_cocoa_service_server_implementation(std::ofstream& out, t_service* tservice);
+  void generate_cocoa_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string fieldName);
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string fieldName);
 
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string fieldName="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string fieldName = "");
 
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter,
-                                          std::string map);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map);
 
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string index,
-                                          std::string listName);
+  void generate_serialize_list_element(std::ofstream& out,
+                                       t_list* tlist,
+                                       std::string index,
+                                       std::string listName);
 
   /**
    * Helper rendering functions
@@ -186,7 +178,7 @@ class t_cocoa_generator : public t_oop_generator {
   std::string cocoa_prefix();
   std::string cocoa_imports();
   std::string cocoa_thrift_imports();
-  std::string type_name(t_type* ttype, bool class_ref=false);
+  std::string type_name(t_type* ttype, bool class_ref = false);
   std::string base_type_name(t_base_type* tbase);
   std::string declare_field(t_field* tfield);
   std::string declare_property(t_field* tfield);
@@ -195,21 +187,17 @@ class t_cocoa_generator : public t_oop_generator {
   std::string type_to_enum(t_type* ttype);
   std::string format_string_for_type(t_type* type);
   std::string call_field_setter(t_field* tfield, std::string fieldName);
-  std::string containerize(t_type * ttype, std::string fieldName);
-  std::string decontainerize(t_field * tfield, std::string fieldName);
+  std::string containerize(t_type* ttype, std::string fieldName);
+  std::string decontainerize(t_field* tfield, std::string fieldName);
 
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return
-      ttype->is_container() ||
-      ttype->is_struct() ||
-      ttype->is_xception() ||
-      ttype->is_string();
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
+           || ttype->is_string();
   }
 
- private:
-
+private:
   std::string cocoa_prefix_;
   std::string constants_declarations_;
 
@@ -224,7 +212,6 @@ class t_cocoa_generator : public t_oop_generator {
   bool validate_required_;
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -235,32 +222,22 @@ void t_cocoa_generator::init_generator() {
   cocoa_prefix_ = program_->get_namespace("cocoa");
 
   // we have a .h header file...
-  string f_header_name = program_name_+".h";
-  string f_header_fullname = get_out_dir()+f_header_name;
+  string f_header_name = program_name_ + ".h";
+  string f_header_fullname = get_out_dir() + f_header_name;
   f_header_.open(f_header_fullname.c_str());
 
-  f_header_ <<
-    autogen_comment() <<
-    endl;
+  f_header_ << autogen_comment() << endl;
 
-  f_header_ <<
-    cocoa_imports() <<
-    cocoa_thrift_imports();
+  f_header_ << cocoa_imports() << cocoa_thrift_imports();
 
   // ...and a .m implementation file
-  string f_impl_name = get_out_dir()+program_name_+".m";
+  string f_impl_name = get_out_dir() + program_name_ + ".m";
   f_impl_.open(f_impl_name.c_str());
 
-  f_impl_ <<
-    autogen_comment() <<
-    endl;
-
-  f_impl_ <<
-    cocoa_imports() <<
-    cocoa_thrift_imports() <<
-    "#import \"" << f_header_name << "\"" << endl <<
-    endl;
+  f_impl_ << autogen_comment() << endl;
 
+  f_impl_ << cocoa_imports() << cocoa_thrift_imports() << "#import \"" << f_header_name << "\""
+          << endl << endl;
 }
 
 /**
@@ -269,10 +246,7 @@ void t_cocoa_generator::init_generator() {
  * @return List of imports for Cocoa libraries
  */
 string t_cocoa_generator::cocoa_imports() {
-  return
-    string() +
-    "#import <Foundation/Foundation.h>\n" +
-    "\n";
+  return string() + "#import <Foundation/Foundation.h>\n" + "\n";
 }
 
 /**
@@ -281,15 +255,10 @@ string t_cocoa_generator::cocoa_imports() {
  * @return List of imports necessary for thrift runtime
  */
 string t_cocoa_generator::cocoa_thrift_imports() {
-  string result = string() +
-    "#import \"TProtocol.h\"\n" +
-    "#import \"TApplicationException.h\"\n" +
-    "#import \"TProtocolException.h\"\n" +
-    "#import \"TProtocolUtil.h\"\n" +
-    "#import \"TProcessor.h\"\n" +
-    "#import \"TObjective-C.h\"\n" +
-    "#import \"TBase.h\"\n" +
-    "\n";
+  string result = string() + "#import \"TProtocol.h\"\n" + "#import \"TApplicationException.h\"\n"
+                  + "#import \"TProtocolException.h\"\n" + "#import \"TProtocolUtil.h\"\n"
+                  + "#import \"TProcessor.h\"\n" + "#import \"TObjective-C.h\"\n"
+                  + "#import \"TBase.h\"\n" + "\n";
 
   // Include other Thrift includes
   const vector<t_program*>& includes = program_->get_includes();
@@ -301,12 +270,10 @@ string t_cocoa_generator::cocoa_thrift_imports() {
   return result;
 }
 
-
 /**
  * Finish up generation.
  */
-void t_cocoa_generator::close_generator()
-{
+void t_cocoa_generator::close_generator() {
   // stick our constants declarations at the end of the header file
   // since they refer to things we are defining.
   f_header_ << constants_declarations_ << endl;
@@ -318,9 +285,8 @@ void t_cocoa_generator::close_generator()
  * @param ttypedef The type definition
  */
 void t_cocoa_generator::generate_typedef(t_typedef* ttypedef) {
-  f_header_ <<
-    indent() << "typedef " << type_name(ttypedef->get_type()) << " " << cocoa_prefix_ << ttypedef->get_symbolic() << ";" << endl <<
-    endl;
+  f_header_ << indent() << "typedef " << type_name(ttypedef->get_type()) << " " << cocoa_prefix_
+            << ttypedef->get_symbolic() << ";" << endl << endl;
 }
 
 /**
@@ -332,8 +298,7 @@ void t_cocoa_generator::generate_typedef(t_typedef* ttypedef) {
  * @param tenum The enumeration
  */
 void t_cocoa_generator::generate_enum(t_enum* tenum) {
-  f_header_ <<
-    indent() << "enum " << cocoa_prefix_ << tenum->get_name() << " {" << endl;
+  f_header_ << indent() << "enum " << cocoa_prefix_ << tenum->get_name() << " {" << endl;
   indent_up();
 
   vector<t_enum_value*> constants = tenum->get_constants();
@@ -343,20 +308,14 @@ void t_cocoa_generator::generate_enum(t_enum* tenum) {
     if (first) {
       first = false;
     } else {
-      f_header_ <<
-        "," << endl;
+      f_header_ << "," << endl;
     }
-    f_header_ <<
-      indent() << tenum->get_name() << "_" << (*c_iter)->get_name();
-    f_header_ <<
-      " = " << (*c_iter)->get_value();
+    f_header_ << indent() << tenum->get_name() << "_" << (*c_iter)->get_name();
+    f_header_ << " = " << (*c_iter)->get_value();
   }
 
   indent_down();
-  f_header_ <<
-    endl <<
-    "};" << endl <<
-    endl;
+  f_header_ << endl << "};" << endl << endl;
 }
 
 /**
@@ -377,8 +336,7 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     t_type* type = (*c_iter)->get_type();
-    const_interface <<
-      "+ (" << type_name(type) << ") " << name << ";" << endl;
+    const_interface << "+ (" << type_name(type) << ") " << name << ";" << endl;
   }
 
   const_interface << "@end";
@@ -390,8 +348,7 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     t_type* type = (*c_iter)->get_type();
-    f_impl_ <<
-      "static " << type_name(type) << " " << cocoa_prefix_ << name;
+    f_impl_ << "static " << type_name(type) << " " << cocoa_prefix_ << name;
     if (!type->is_container() && !type->is_struct()) {
       f_impl_ << " = " << render_const_value(f_impl_, type, (*c_iter)->get_value());
     }
@@ -406,13 +363,13 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
   scope_up(f_impl_);
 
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    if ((*c_iter)->get_type()->is_container() ||
-        (*c_iter)->get_type()->is_struct()) {
+    if ((*c_iter)->get_type()->is_container() || (*c_iter)->get_type()->is_struct()) {
       print_const_value(f_impl_,
-           cocoa_prefix_+(*c_iter)->get_name(),
-           (*c_iter)->get_type(),
-           (*c_iter)->get_value(),
-           false, false);
+                        cocoa_prefix_ + (*c_iter)->get_name(),
+                        (*c_iter)->get_type(),
+                        (*c_iter)->get_value(),
+                        false,
+                        false);
       f_impl_ << ";" << endl;
     }
   }
@@ -422,8 +379,7 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     t_type* type = (*c_iter)->get_type();
-    f_impl_ <<
-      "+ (" << type_name(type) << ") " << name;
+    f_impl_ << "+ (" << type_name(type) << ") " << name;
     scope_up(f_impl_);
     indent(f_impl_) << "return " << cocoa_prefix_ << name << ";" << endl;
     scope_down(f_impl_);
@@ -432,7 +388,6 @@ void t_cocoa_generator::generate_consts(std::vector<t_const*> consts) {
   f_impl_ << "@end" << endl << endl;
 }
 
-
 /**
  * Generates a struct definition for a thrift data type. This is a class
  * with protected data members, read(), write(), and getters and setters.
@@ -454,15 +409,14 @@ void t_cocoa_generator::generate_xception(t_struct* txception) {
   generate_cocoa_struct_implementation(f_impl_, txception, true);
 }
 
-
 /**
  * Generate the interface for a struct
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_interface(ofstream &out,
-                                                      t_struct* tstruct,
-                                                      bool is_exception) {
+void t_cocoa_generator::generate_cocoa_struct_interface(ofstream& out,
+                                                        t_struct* tstruct,
+                                                        bool is_exception) {
   out << "@interface " << cocoa_prefix_ << tstruct->get_name() << " : ";
 
   if (is_exception) {
@@ -489,8 +443,7 @@ void t_cocoa_generator::generate_cocoa_struct_interface(ofstream &out,
     out << endl;
     // isset fields
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-      indent(out) <<
-        "BOOL __" << (*m_iter)->get_name() << "_isset;" <<  endl;
+      indent(out) << "BOOL __" << (*m_iter)->get_name() << "_isset;" << endl;
     }
   }
 
@@ -499,7 +452,8 @@ void t_cocoa_generator::generate_cocoa_struct_interface(ofstream &out,
 
   // properties
   if (members.size() > 0) {
-    out << "#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)" << endl;
+    out << "#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)"
+        << endl;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       out << indent() << declare_property(*m_iter) << endl;
     }
@@ -530,24 +484,22 @@ void t_cocoa_generator::generate_cocoa_struct_interface(ofstream &out,
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Generate signature for initializer of struct with a parameter for
  * each field.
  */
-void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ofstream &out,
-                                                                  t_struct* tstruct) {
+void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ofstream& out,
+                                                                    t_struct* tstruct) {
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
   indent(out) << "- (id) initWith";
-  for (m_iter = members.begin(); m_iter != members.end(); ) {
+  for (m_iter = members.begin(); m_iter != members.end();) {
     if (m_iter == members.begin()) {
       out << capitalize((*m_iter)->get_name());
     } else {
       out << (*m_iter)->get_name();
     }
-    out << ": (" << type_name((*m_iter)->get_type()) << ") " <<
-      (*m_iter)->get_name();
+    out << ": (" << type_name((*m_iter)->get_type()) << ") " << (*m_iter)->get_name();
     ++m_iter;
     if (m_iter != members.end()) {
       out << " ";
@@ -559,31 +511,30 @@ void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ofstream &ou
  * Generate getter and setter declarations for all fields, plus an
  * IsSet getter.
  */
-void t_cocoa_generator::generate_cocoa_struct_field_accessor_declarations(ofstream &out,
+void t_cocoa_generator::generate_cocoa_struct_field_accessor_declarations(ofstream& out,
                                                                           t_struct* tstruct,
                                                                           bool is_exception) {
-  (void) is_exception;
+  (void)is_exception;
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     out << indent() << "#if !__has_feature(objc_arc)" << endl;
-    out << indent() << "- (" << type_name((*m_iter)->get_type()) << ") " << decapitalize((*m_iter)->get_name()) << ";" << endl;
-    out << indent() << "- (void) set" << capitalize((*m_iter)->get_name()) <<
-      ": (" << type_name((*m_iter)->get_type()) << ") " << (*m_iter)->get_name() << ";" << endl;
+    out << indent() << "- (" << type_name((*m_iter)->get_type()) << ") "
+        << decapitalize((*m_iter)->get_name()) << ";" << endl;
+    out << indent() << "- (void) set" << capitalize((*m_iter)->get_name()) << ": ("
+        << type_name((*m_iter)->get_type()) << ") " << (*m_iter)->get_name() << ";" << endl;
     out << indent() << "#endif" << endl;
     out << indent() << "- (BOOL) " << (*m_iter)->get_name() << "IsSet;" << endl << endl;
   }
 }
 
-
 /**
  * Generate the initWithCoder method for this struct so it's compatible with
  * the NSCoding protocol
  */
-void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &out,
+void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream& out,
                                                                      t_struct* tstruct,
-                                                                     bool is_exception)
-{
+                                                                     bool is_exception) {
   indent(out) << "- (id) initWithCoder: (NSCoder *) decoder" << endl;
   scope_up(out);
   if (is_exception) {
@@ -598,42 +549,39 @@ void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &o
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* t = get_true_type((*m_iter)->get_type());
-    out << indent() << "if ([decoder containsValueForKey: @\""<< (*m_iter)->get_name() <<"\"])" << endl;
+    out << indent() << "if ([decoder containsValueForKey: @\"" << (*m_iter)->get_name() << "\"])"
+        << endl;
     scope_up(out);
     out << indent() << "__" << (*m_iter)->get_name() << " = ";
-    if (type_can_be_null(t))
-    {
-      out << "[[decoder decodeObjectForKey: @\"" << (*m_iter)->get_name() << "\"] retain_stub];" << endl;
-    }
-    else if (t->is_enum())
-    {
+    if (type_can_be_null(t)) {
+      out << "[[decoder decodeObjectForKey: @\"" << (*m_iter)->get_name() << "\"] retain_stub];"
+          << endl;
+    } else if (t->is_enum()) {
       out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-    }
-    else
-    {
-      t_base_type::t_base tbase = ((t_base_type *) t)->get_base();
-      switch (tbase)
-      {
-        case t_base_type::TYPE_BOOL:
-          out << "[decoder decodeBoolForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_BYTE:
-          out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I16:
-          out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I32:
-          out << "[decoder decodeInt32ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I64:
-          out << "[decoder decodeInt64ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_DOUBLE:
-          out << "[decoder decodeDoubleForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        default:
-          throw "compiler error: don't know how to decode thrift type: " + t_base_type::t_base_name(tbase);
+    } else {
+      t_base_type::t_base tbase = ((t_base_type*)t)->get_base();
+      switch (tbase) {
+      case t_base_type::TYPE_BOOL:
+        out << "[decoder decodeBoolForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_BYTE:
+        out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I16:
+        out << "[decoder decodeIntForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I32:
+        out << "[decoder decodeInt32ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I64:
+        out << "[decoder decodeInt64ForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_DOUBLE:
+        out << "[decoder decodeDoubleForKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      default:
+        throw "compiler error: don't know how to decode thrift type: "
+            + t_base_type::t_base_name(tbase);
       }
     }
     out << indent() << "__" << (*m_iter)->get_name() << "_isset = YES;" << endl;
@@ -645,15 +593,13 @@ void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream &o
   out << endl;
 }
 
-
 /**
  * Generate the encodeWithCoder method for this struct so it's compatible with
  * the NSCoding protocol
  */
-void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream &out,
+void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream& out,
                                                                        t_struct* tstruct,
-                                                                       bool is_exception)
-{
+                                                                       bool is_exception) {
   indent(out) << "- (void) encodeWithCoder: (NSCoder *) encoder" << endl;
   scope_up(out);
   if (is_exception) {
@@ -666,42 +612,45 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* t = get_true_type((*m_iter)->get_type());
-    out << indent() << "if (__"<< (*m_iter)->get_name() <<"_isset)" << endl;
+    out << indent() << "if (__" << (*m_iter)->get_name() << "_isset)" << endl;
     scope_up(out);
-    //out << indent() << "__" << (*m_iter)->get_name() << " = ";
-    if (type_can_be_null(t))
-    {
-      out << indent() << "[encoder encodeObject: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-    }
-    else if (t->is_enum())
-    {
-      out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-    }
-    else
-    {
-      t_base_type::t_base tbase = ((t_base_type *) t)->get_base();
-      switch (tbase)
-      {
-        case t_base_type::TYPE_BOOL:
-          out << indent() << "[encoder encodeBool: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_BYTE:
-          out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I16:
-          out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I32:
-          out << indent() << "[encoder encodeInt32: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_I64:
-          out << indent() << "[encoder encodeInt64: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        case t_base_type::TYPE_DOUBLE:
-          out << indent() << "[encoder encodeDouble: __" << (*m_iter)->get_name() << " forKey: @\"" << (*m_iter)->get_name() << "\"];" << endl;
-          break;
-        default:
-          throw "compiler error: don't know how to encode thrift type: " + t_base_type::t_base_name(tbase);
+    // out << indent() << "__" << (*m_iter)->get_name() << " = ";
+    if (type_can_be_null(t)) {
+      out << indent() << "[encoder encodeObject: __" << (*m_iter)->get_name() << " forKey: @\""
+          << (*m_iter)->get_name() << "\"];" << endl;
+    } else if (t->is_enum()) {
+      out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\""
+          << (*m_iter)->get_name() << "\"];" << endl;
+    } else {
+      t_base_type::t_base tbase = ((t_base_type*)t)->get_base();
+      switch (tbase) {
+      case t_base_type::TYPE_BOOL:
+        out << indent() << "[encoder encodeBool: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_BYTE:
+        out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I16:
+        out << indent() << "[encoder encodeInt: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I32:
+        out << indent() << "[encoder encodeInt32: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_I64:
+        out << indent() << "[encoder encodeInt64: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      case t_base_type::TYPE_DOUBLE:
+        out << indent() << "[encoder encodeDouble: __" << (*m_iter)->get_name() << " forKey: @\""
+            << (*m_iter)->get_name() << "\"];" << endl;
+        break;
+      default:
+        throw "compiler error: don't know how to encode thrift type: "
+            + t_base_type::t_base_name(tbase);
       }
     }
     scope_down(out);
@@ -711,7 +660,6 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream
   out << endl;
 }
 
-
 /**
  * Generate struct implementation.
  *
@@ -719,12 +667,11 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream
  * @param is_exception Is this an exception?
  * @param is_result    If this is a result it needs a different writer
  */
-void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream &out,
+void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream& out,
                                                              t_struct* tstruct,
                                                              bool is_exception,
                                                              bool is_result) {
-  indent(out) <<
-    "@implementation " << cocoa_prefix_ << tstruct->get_name() << endl << endl;
+  indent(out) << "@implementation " << cocoa_prefix_ << tstruct->get_name() << endl << endl;
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
@@ -733,8 +680,8 @@ void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream &out,
   if (is_exception) {
     out << indent() << "- (id) init" << endl;
     scope_up(out);
-    out << indent() << "return [super initWithName: @\"" << cocoa_prefix_ << tstruct->get_name() <<
-        "\" reason: @\"unknown\" userInfo: nil];" << endl;
+    out << indent() << "return [super initWithName: @\"" << cocoa_prefix_ << tstruct->get_name()
+        << "\" reason: @\"unknown\" userInfo: nil];" << endl;
     scope_down(out);
     out << endl;
   } else {
@@ -746,11 +693,17 @@ void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream &out,
     scope_up(out);
     indent(out) << "self = [super init];" << endl;
     if (members.size() > 0) {
-      out << "#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)" << endl;
+      out << "#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)"
+          << endl;
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
         t_type* t = get_true_type((*m_iter)->get_type());
         if ((*m_iter)->get_value() != NULL) {
-          print_const_value(out, "self."+(*m_iter)->get_name(), t, (*m_iter)->get_value(), false, true);
+          print_const_value(out,
+                            "self." + (*m_iter)->get_name(),
+                            t,
+                            (*m_iter)->get_value(),
+                            false,
+                            true);
         }
       }
       out << "#endif" << endl;
@@ -823,16 +776,13 @@ void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream &out,
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Generates a function to read all the fields of the struct.
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out,
-                                                     t_struct* tstruct) {
-  out <<
-    "- (void) read: (id <TProtocol>) inProtocol" << endl;
+void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out, t_struct* tstruct) {
+  out << "- (void) read: (id <TProtocol>) inProtocol" << endl;
   scope_up(out);
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -847,90 +797,80 @@ void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out,
   indent(out) << "[inProtocol readStructBeginReturningName: NULL];" << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
-    scope_up(out);
+  indent(out) << "while (true)" << endl;
+  scope_up(out);
 
-    // Read beginning field marker
-    indent(out) <<
-      "[inProtocol readFieldBeginReturningName: &fieldName type: &fieldType fieldID: &fieldID];" << endl;
+  // Read beginning field marker
+  indent(out)
+      << "[inProtocol readFieldBeginReturningName: &fieldName type: &fieldType fieldID: &fieldID];"
+      << endl;
 
-    // Check for field STOP marker and break
-    indent(out) <<
-      "if (fieldType == TType_STOP) { " << endl;
-    indent_up();
-    indent(out) <<
-      "break;" << endl;
-    indent_down();
-    indent(out) <<
-      "}" << endl;
+  // Check for field STOP marker and break
+  indent(out) << "if (fieldType == TType_STOP) { " << endl;
+  indent_up();
+  indent(out) << "break;" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    // Switch statement on the field we are reading
-    indent(out) <<
-      "switch (fieldID)" << endl;
+  // Switch statement on the field we are reading
+  indent(out) << "switch (fieldID)" << endl;
 
-      scope_up(out);
+  scope_up(out);
 
-      // Generate deserialization code for known cases
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent(out) <<
-          "case " << (*f_iter)->get_key() << ":" << endl;
-        indent_up();
-        indent(out) <<
-          "if (fieldType == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-        indent_up();
-
-        generate_deserialize_field(out, *f_iter, "fieldValue");
-        indent(out) << call_field_setter(*f_iter, "fieldValue") << endl;
-        // if this is an allocated field, release it since the struct
-        // is now retaining it
-        if (type_can_be_null((*f_iter)->get_type())) {
-          // deserialized strings are autorelease, so don't release them
-          if (!(get_true_type((*f_iter)->get_type())->is_string())) {
-            indent(out) << "[fieldValue release_stub];" << endl;
-          }
-        }
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+    indent_up();
+    indent(out) << "if (fieldType == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent_up();
 
-        indent_down();
-        out << indent() << "} else { " << endl;
-        if (log_unexpected_) {
-          out << indent() << "  NSLog(@\"%s: field ID %i has unexpected type %i.  Skipping.\", __PRETTY_FUNCTION__, fieldID, fieldType);" << endl;
-        }
-        out << indent() << "  [TProtocolUtil skipType: fieldType onProtocol: inProtocol];" << endl <<
-          indent() << "}" << endl <<
-          indent() << "break;" << endl;
-        indent_down();
+    generate_deserialize_field(out, *f_iter, "fieldValue");
+    indent(out) << call_field_setter(*f_iter, "fieldValue") << endl;
+    // if this is an allocated field, release it since the struct
+    // is now retaining it
+    if (type_can_be_null((*f_iter)->get_type())) {
+      // deserialized strings are autorelease, so don't release them
+      if (!(get_true_type((*f_iter)->get_type())->is_string())) {
+        indent(out) << "[fieldValue release_stub];" << endl;
       }
+    }
 
-      // In the default case we skip the field
-      out << indent() << "default:" << endl;
-      if (log_unexpected_) {
-        out << indent() << "  NSLog(@\"%s: unexpected field ID %i with type %i.  Skipping.\", __PRETTY_FUNCTION__, fieldID, fieldType);" << endl;
-      }
-      out << indent() << "  [TProtocolUtil skipType: fieldType onProtocol: inProtocol];" << endl <<
-        indent() << "  break;" << endl;
+    indent_down();
+    out << indent() << "} else { " << endl;
+    if (log_unexpected_) {
+      out << indent() << "  NSLog(@\"%s: field ID %i has unexpected type %i.  Skipping.\", "
+                         "__PRETTY_FUNCTION__, fieldID, fieldType);" << endl;
+    }
+    out << indent() << "  [TProtocolUtil skipType: fieldType onProtocol: inProtocol];" << endl
+        << indent() << "}" << endl << indent() << "break;" << endl;
+    indent_down();
+  }
 
-      scope_down(out);
+  // In the default case we skip the field
+  out << indent() << "default:" << endl;
+  if (log_unexpected_) {
+    out << indent() << "  NSLog(@\"%s: unexpected field ID %i with type %i.  Skipping.\", "
+                       "__PRETTY_FUNCTION__, fieldID, fieldType);" << endl;
+  }
+  out << indent() << "  [TProtocolUtil skipType: fieldType onProtocol: inProtocol];" << endl
+      << indent() << "  break;" << endl;
 
-    // Read field end marker
-    indent(out) <<
-      "[inProtocol readFieldEnd];" << endl;
+  scope_down(out);
 
-    scope_down(out);
+  // Read field end marker
+  indent(out) << "[inProtocol readFieldEnd];" << endl;
 
-    out <<
-      indent() << "[inProtocol readStructEnd];" << endl;
+  scope_down(out);
 
-    // performs various checks (e.g. check that all required fields are set)
-    if (validate_required_) {
-      out <<
-        indent() << "[self validate];" << endl;
-    }
+  out << indent() << "[inProtocol readStructEnd];" << endl;
+
+  // performs various checks (e.g. check that all required fields are set)
+  if (validate_required_) {
+    out << indent() << "[self validate];" << endl;
+  }
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -938,40 +878,34 @@ void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out,
-                                                     t_struct* tstruct) {
-  out <<
-    indent() << "- (void) write: (id <TProtocol>) outProtocol {" << endl;
+void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "- (void) write: (id <TProtocol>) outProtocol {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out <<
-    indent() << "[outProtocol writeStructBeginWithName: @\"" << name << "\"];" << endl;
+  out << indent() << "[outProtocol writeStructBeginWithName: @\"" << name << "\"];" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    out <<
-      indent() << "if (__" << (*f_iter)->get_name() << "_isset) {" << endl;
+    out << indent() << "if (__" << (*f_iter)->get_name() << "_isset) {" << endl;
     indent_up();
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out <<
-        indent() << "if (__" << (*f_iter)->get_name() << " != nil) {" << endl;
+      out << indent() << "if (__" << (*f_iter)->get_name() << " != nil) {" << endl;
       indent_up();
     }
 
-    indent(out) << "[outProtocol writeFieldBeginWithName: @\"" <<
-      (*f_iter)->get_name() << "\" type: " << type_to_enum((*f_iter)->get_type()) <<
-      " fieldID: " << (*f_iter)->get_key() << "];" << endl;
+    indent(out) << "[outProtocol writeFieldBeginWithName: @\"" << (*f_iter)->get_name()
+                << "\" type: " << type_to_enum((*f_iter)->get_type())
+                << " fieldID: " << (*f_iter)->get_key() << "];" << endl;
 
     // Write field contents
-    generate_serialize_field(out, *f_iter, "__"+(*f_iter)->get_name());
+    generate_serialize_field(out, *f_iter, "__" + (*f_iter)->get_name());
 
     // Write field closer
-    indent(out) <<
-      "[outProtocol writeFieldEnd];" << endl;
+    indent(out) << "[outProtocol writeFieldEnd];" << endl;
 
     if (null_allowed) {
       scope_down(out);
@@ -979,14 +913,11 @@ void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out,
     scope_down(out);
   }
   // Write the struct map
-  out <<
-    indent() << "[outProtocol writeFieldStop];" << endl <<
-    indent() << "[outProtocol writeStructEnd];" << endl;
+  out << indent() << "[outProtocol writeFieldStop];" << endl << indent()
+      << "[outProtocol writeStructEnd];" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -996,52 +927,43 @@ void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out,
-                                                            t_struct* tstruct) {
-  out <<
-    indent() << "- (void) write: (id <TProtocol>) outProtocol {" << endl;
+void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "- (void) write: (id <TProtocol>) outProtocol {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out <<
-    indent() << "[outProtocol writeStructBeginWithName: @\"" << name << "\"];" << endl;
+  out << indent() << "[outProtocol writeStructBeginWithName: @\"" << name << "\"];" << endl;
 
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out <<
-        endl <<
-        indent() << "if ";
+      out << endl << indent() << "if ";
     } else {
-      out <<
-        " else if ";
+      out << " else if ";
     }
 
-    out <<
-      "(__" << (*f_iter)->get_name() << "_isset) {" << endl;
+    out << "(__" << (*f_iter)->get_name() << "_isset) {" << endl;
     indent_up();
 
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out <<
-        indent() << "if (__" << (*f_iter)->get_name() << " != nil) {" << endl;
+      out << indent() << "if (__" << (*f_iter)->get_name() << " != nil) {" << endl;
       indent_up();
     }
 
-    indent(out) << "[outProtocol writeFieldBeginWithName: @\"" <<
-      (*f_iter)->get_name() << "\" type: " << type_to_enum((*f_iter)->get_type()) <<
-      " fieldID: " << (*f_iter)->get_key() << "];" << endl;
+    indent(out) << "[outProtocol writeFieldBeginWithName: @\"" << (*f_iter)->get_name()
+                << "\" type: " << type_to_enum((*f_iter)->get_type())
+                << " fieldID: " << (*f_iter)->get_key() << "];" << endl;
 
     // Write field contents
-    generate_serialize_field(out, *f_iter, "__"+(*f_iter)->get_name());
+    generate_serialize_field(out, *f_iter, "__" + (*f_iter)->get_name());
 
     // Write field closer
-    indent(out) <<
-      "[outProtocol writeFieldEnd];" << endl;
+    indent(out) << "[outProtocol writeFieldEnd];" << endl;
 
     if (null_allowed) {
       indent_down();
@@ -1052,15 +974,11 @@ void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out,
     indent(out) << "}";
   }
   // Write the struct map
-  out <<
-    endl <<
-    indent() << "[outProtocol writeFieldStop];" << endl <<
-    indent() << "[outProtocol writeStructEnd];" << endl;
+  out << endl << indent() << "[outProtocol writeFieldStop];" << endl << indent()
+      << "[outProtocol writeStructEnd];" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1069,10 +987,8 @@ void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out,
-                                                        t_struct* tstruct) {
-  out <<
-    indent() << "- (void) validate {" << endl;
+void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out, t_struct* tstruct) {
+  out << indent() << "- (void) validate {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1082,18 +998,15 @@ void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     t_field* field = (*f_iter);
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
-      out <<
-        indent() << "if (!__" << field->get_name() << "_isset) {" << endl <<
-        indent() << "  @throw [TProtocolException exceptionWithName: @\"TProtocolException\"" << endl <<
-        indent() << "                             reason: @\"Required field '" << (*f_iter)->get_name() << "' is not set.\"];" << endl <<
-        indent() << "}" << endl;
+      out << indent() << "if (!__" << field->get_name() << "_isset) {" << endl << indent()
+          << "  @throw [TProtocolException exceptionWithName: @\"TProtocolException\"" << endl
+          << indent() << "                             reason: @\"Required field '"
+          << (*f_iter)->get_name() << "' is not set.\"];" << endl << indent() << "}" << endl;
     }
   }
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1105,7 +1018,7 @@ void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out,
 void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ofstream& out,
                                                                              t_struct* tstruct,
                                                                              bool is_exception) {
-  (void) is_exception;
+  (void)is_exception;
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1128,8 +1041,8 @@ void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ofs
     indent(out) << "}" << endl << endl;
 
     // Simple setter
-    indent(out) << "- (void) set" << cap_name << ": (" << type_name(type) <<
-      ") " << field_name << " {" << endl;
+    indent(out) << "- (void) set" << cap_name << ": (" << type_name(type) << ") " << field_name
+                << " {" << endl;
     indent_up();
     if (!type_can_be_null(type)) {
       indent(out) << "__" << field_name << " = " << field_name << ";" << endl;
@@ -1167,15 +1080,12 @@ void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ofs
  *
  * @param tstruct The struct definition
  */
-void t_cocoa_generator::generate_cocoa_struct_description(ofstream& out,
-                                                          t_struct* tstruct) {
-  out <<
-    indent() << "- (NSString *) description {" << endl;
+void t_cocoa_generator::generate_cocoa_struct_description(ofstream& out, t_struct* tstruct) {
+  out << indent() << "- (NSString *) description {" << endl;
   indent_up();
 
-  out <<
-    indent() << "NSMutableString * ms = [NSMutableString stringWithString: @\"" <<
-    cocoa_prefix_ << tstruct->get_name() << "(\"];" << endl;
+  out << indent() << "NSMutableString * ms = [NSMutableString stringWithString: @\""
+      << cocoa_prefix_ << tstruct->get_name() << "(\"];" << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
@@ -1188,19 +1098,16 @@ void t_cocoa_generator::generate_cocoa_struct_description(ofstream& out,
       indent(out) << "[ms appendString: @\"," << (*f_iter)->get_name() << ":\"];" << endl;
     }
     t_type* ttype = (*f_iter)->get_type();
-    indent(out) << "[ms appendFormat: @\"" << format_string_for_type(ttype) << "\", __" <<
-      (*f_iter)->get_name() << "];" << endl;
+    indent(out) << "[ms appendFormat: @\"" << format_string_for_type(ttype) << "\", __"
+                << (*f_iter)->get_name() << "];" << endl;
   }
-  out <<
-    indent() << "[ms appendString: @\")\"];" << endl <<
-    indent() << "return [NSString stringWithString: ms];" << endl;
+  out << indent() << "[ms appendString: @\")\"];" << endl << indent()
+      << "return [NSString stringWithString: ms];" << endl;
 
   indent_down();
-  indent(out) << "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
-
 /**
  * Generates a thrift service.  In Objective-C this consists of a
  * protocol definition, a client interface and a client implementation.
@@ -1216,7 +1123,6 @@ void t_cocoa_generator::generate_service(t_service* tservice) {
   generate_cocoa_service_server_implementation(f_impl_, tservice);
 }
 
-
 /**
  * Generates structs for all the service return types
  *
@@ -1241,12 +1147,10 @@ string t_cocoa_generator::function_result_helper_struct_type(t_function* tfuncti
   }
 }
 
-
 string t_cocoa_generator::function_args_helper_struct_type(t_function* tfunction) {
   return tfunction->get_name() + "_args";
 }
 
-
 /**
  * Generates a struct and helpers for a function.
  *
@@ -1277,21 +1181,19 @@ void t_cocoa_generator::generate_function_helpers(t_function* tfunction) {
   generate_cocoa_struct_implementation(f_impl_, &result, false, true);
 }
 
-
 /**
  * Generates a service protocol definition.
  *
  * @param tservice The service to generate a protocol definition for
  */
-void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out,
-                                                        t_service* tservice) {
+void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out, t_service* tservice) {
   out << "@protocol " << cocoa_prefix_ << tservice->get_name() << " <NSObject>" << endl;
 
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    out << "- " << function_signature(*f_iter) << ";" <<
-      "  // throws ";
+    out << "- " << function_signature(*f_iter) << ";"
+        << "  // throws ";
     t_struct* xs = (*f_iter)->get_xceptions();
     const std::vector<t_field*>& xceptions = xs->get_members();
     vector<t_field*>::const_iterator x_iter;
@@ -1303,7 +1205,6 @@ void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out,
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Generates a service client interface definition.
  *
@@ -1311,8 +1212,8 @@ void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out,
  */
 void t_cocoa_generator::generate_cocoa_service_client_interface(ofstream& out,
                                                                 t_service* tservice) {
-  out << "@interface " << cocoa_prefix_ << tservice->get_name() << "Client : NSObject <" <<
-    cocoa_prefix_ << tservice->get_name() << "> ";
+  out << "@interface " << cocoa_prefix_ << tservice->get_name() << "Client : NSObject <"
+      << cocoa_prefix_ << tservice->get_name() << "> ";
 
   scope_up(out);
   out << indent() << "id <TProtocol> inProtocol;" << endl;
@@ -1320,33 +1221,35 @@ void t_cocoa_generator::generate_cocoa_service_client_interface(ofstream& out,
   scope_down(out);
 
   out << "- (id) initWithProtocol: (id <TProtocol>) protocol;" << endl;
-  out << "- (id) initWithInProtocol: (id <TProtocol>) inProtocol outProtocol: (id <TProtocol>) outProtocol;" << endl;
+  out << "- (id) initWithInProtocol: (id <TProtocol>) inProtocol outProtocol: (id <TProtocol>) "
+         "outProtocol;" << endl;
   out << "@end" << endl << endl;
 }
 
-
 /**
- * Generates a service server interface definition. In other words, the TProcess implementation for the
+ * Generates a service server interface definition. In other words, the TProcess implementation for
+ *the
  * service definition.
  *
  * @param tservice The service to generate a client interface definition for
  */
 void t_cocoa_generator::generate_cocoa_service_server_interface(ofstream& out,
                                                                 t_service* tservice) {
-  out << "@interface " << cocoa_prefix_ << tservice->get_name() << "Processor : NSObject <TProcessor> ";
+  out << "@interface " << cocoa_prefix_ << tservice->get_name()
+      << "Processor : NSObject <TProcessor> ";
 
   scope_up(out);
-  out << indent() << "id <" << cocoa_prefix_ << tservice->get_name() <<"> mService;" << endl;
+  out << indent() << "id <" << cocoa_prefix_ << tservice->get_name() << "> mService;" << endl;
   out << indent() << "NSDictionary * mMethodMap;" << endl;
   scope_down(out);
 
-  out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_ << tservice->get_name() << ">) service;" << endl;
-  out << "- (id<"<<cocoa_prefix_ << tservice->get_name() << ">) service;" << endl;
+  out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_
+      << tservice->get_name() << ">) service;" << endl;
+  out << "- (id<" << cocoa_prefix_ << tservice->get_name() << ">) service;" << endl;
 
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Generates a service client implementation.
  *
@@ -1363,7 +1266,8 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
   scope_down(out);
   out << endl;
 
-  out << "- (id) initWithInProtocol: (id <TProtocol>) anInProtocol outProtocol: (id <TProtocol>) anOutProtocol" << endl;
+  out << "- (id) initWithInProtocol: (id <TProtocol>) anInProtocol outProtocol: (id <TProtocol>) "
+         "anOutProtocol" << endl;
   scope_up(out);
   out << indent() << "self = [super init];" << endl;
   out << indent() << "inProtocol = [anInProtocol retain_stub];" << endl;
@@ -1394,18 +1298,15 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
     string argsname = (*f_iter)->get_name() + "_args";
 
     // Open function
-    indent(out) <<
-      "- " << function_signature(&send_function) << endl;
+    indent(out) << "- " << function_signature(&send_function) << endl;
     scope_up(out);
 
     // Serialize the request
-    out <<
-      indent() << "[outProtocol writeMessageBeginWithName: @\"" << funname << "\"" <<
-      ((*f_iter)->is_oneway() ? " type: TMessageType_ONEWAY" : " type: TMessageType_CALL") <<
-      " sequenceID: 0];" << endl;
+    out << indent() << "[outProtocol writeMessageBeginWithName: @\"" << funname << "\""
+        << ((*f_iter)->is_oneway() ? " type: TMessageType_ONEWAY" : " type: TMessageType_CALL")
+        << " sequenceID: 0];" << endl;
 
-    out <<
-      indent() << "[outProtocol writeStructBeginWithName: @\"" << argsname << "\"];" << endl;
+    out << indent() << "[outProtocol writeStructBeginWithName: @\"" << argsname << "\"];" << endl;
 
     // write out function parameters
     t_struct* arg_struct = (*f_iter)->get_arglist();
@@ -1417,29 +1318,25 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
         out << indent() << "if (" << fieldName << " != nil)";
         scope_up(out);
       }
-      out <<
-        indent() << "[outProtocol writeFieldBeginWithName: @\"" << fieldName << "\""
-        " type: " << type_to_enum((*fld_iter)->get_type()) <<
-        " fieldID: " << (*fld_iter)->get_key() << "];" << endl;
+      out << indent() << "[outProtocol writeFieldBeginWithName: @\"" << fieldName
+          << "\""
+             " type: " << type_to_enum((*fld_iter)->get_type())
+          << " fieldID: " << (*fld_iter)->get_key() << "];" << endl;
 
       generate_serialize_field(out, *fld_iter, fieldName);
 
-      out <<
-        indent() << "[outProtocol writeFieldEnd];" << endl;
+      out << indent() << "[outProtocol writeFieldEnd];" << endl;
 
       if (type_can_be_null((*fld_iter)->get_type())) {
         scope_down(out);
       }
     }
 
-    out <<
-      indent() << "[outProtocol writeFieldStop];" << endl;
-    out <<
-      indent() << "[outProtocol writeStructEnd];" << endl;
+    out << indent() << "[outProtocol writeFieldStop];" << endl;
+    out << indent() << "[outProtocol writeStructEnd];" << endl;
 
-    out <<
-      indent() << "[outProtocol writeMessageEnd];" << endl <<
-      indent() << "[[outProtocol transport] flush];" << endl;
+    out << indent() << "[outProtocol writeMessageEnd];" << endl << indent()
+        << "[[outProtocol transport] flush];" << endl;
 
     scope_down(out);
     out << endl;
@@ -1451,56 +1348,49 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
                                &noargs,
                                (*f_iter)->get_xceptions());
       // Open function
-      indent(out) <<
-        "- " << function_signature(&recv_function) << endl;
+      indent(out) << "- " << function_signature(&recv_function) << endl;
       scope_up(out);
 
       // TODO(mcslee): Message validation here, was the seqid etc ok?
 
       // check for an exception
-      out <<
-        indent() << "int msgType = 0;" << endl <<
-        indent() << "[inProtocol readMessageBeginReturningName: nil type: &msgType sequenceID: NULL];" << endl <<
-        indent() << "if (msgType == TMessageType_EXCEPTION) {" << endl <<
-        indent() << "  TApplicationException * x = [TApplicationException read: inProtocol];" << endl <<
-        indent() << "  [inProtocol readMessageEnd];" << endl <<
-        indent() << "  @throw x;" << endl <<
-        indent() << "}" << endl;
+      out << indent() << "int msgType = 0;" << endl << indent()
+          << "[inProtocol readMessageBeginReturningName: nil type: &msgType sequenceID: NULL];"
+          << endl << indent() << "if (msgType == TMessageType_EXCEPTION) {" << endl << indent()
+          << "  TApplicationException * x = [TApplicationException read: inProtocol];" << endl
+          << indent() << "  [inProtocol readMessageEnd];" << endl << indent() << "  @throw x;"
+          << endl << indent() << "}" << endl;
 
       // FIXME - could optimize here to reduce creation of temporary objects.
       string resultname = function_result_helper_struct_type(*f_iter);
-      out <<
-        indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_ <<
-        resultname << " alloc] init] autorelease_stub];" << endl;
+      out << indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_
+          << resultname << " alloc] init] autorelease_stub];" << endl;
       indent(out) << "[result read: inProtocol];" << endl;
       indent(out) << "[inProtocol readMessageEnd];" << endl;
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        out <<
-          indent() << "if ([result successIsSet]) {" << endl <<
-          indent() << "  return [result success];" << endl <<
-          indent() << "}" << endl;
+        out << indent() << "if ([result successIsSet]) {" << endl << indent()
+            << "  return [result success];" << endl << indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        out <<
-          indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl <<
-          indent() << "  @throw [result " << (*x_iter)->get_name() << "];" << endl <<
-          indent() << "}" << endl;
+        out << indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl
+            << indent() << "  @throw [result " << (*x_iter)->get_name() << "];" << endl << indent()
+            << "}" << endl;
       }
 
       // If you get here it's an exception, unless a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(out) <<
-          "return;" << endl;
+        indent(out) << "return;" << endl;
       } else {
-        out <<
-          indent() << "@throw [TApplicationException exceptionWithType: TApplicationException_MISSING_RESULT" << endl <<
-          indent() << "                                         reason: @\"" << (*f_iter)->get_name() << " failed: unknown result\"];" << endl;
+        out << indent() << "@throw [TApplicationException exceptionWithType: "
+                           "TApplicationException_MISSING_RESULT" << endl << indent()
+            << "                                         reason: @\"" << (*f_iter)->get_name()
+            << " failed: unknown result\"];" << endl;
       }
 
       // Close function
@@ -1509,11 +1399,9 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
     }
 
     // Open function
-    indent(out) <<
-      "- " << function_signature(*f_iter) << endl;
+    indent(out) << "- " << function_signature(*f_iter) << endl;
     scope_up(out);
-    indent(out) <<
-      "[self send_" << funname;
+    indent(out) << "[self send_" << funname;
 
     // Declare the function arguments
     bool first = true;
@@ -1534,8 +1422,7 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
       if (!(*f_iter)->get_returntype()->is_void()) {
         out << "return ";
       }
-      out <<
-        "[self recv_" << funname << "];" << endl;
+      out << "[self recv_" << funname << "];" << endl;
     }
     scope_down(out);
     out << endl;
@@ -1546,7 +1433,6 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Generates a service server implementation.  In other words the actual TProcessor implementation
  * for the service.
@@ -1560,7 +1446,8 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
 
   // initializer
   out << endl;
-  out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_ << tservice->get_name() << ">) service" << endl;
+  out << "- (id) initWith" << tservice->get_name() << ": (id <" << cocoa_prefix_
+      << tservice->get_name() << ">) service" << endl;
   scope_up(out);
   out << indent() << "self = [super init];" << endl;
   out << indent() << "if (!self) {" << endl;
@@ -1575,9 +1462,11 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     string funname = (*f_iter)->get_name();
     scope_up(out);
-    out << indent() << "SEL s = @selector(process_" << funname << "_withSequenceID:inProtocol:outProtocol:);" << endl;
+    out << indent() << "SEL s = @selector(process_" << funname
+        << "_withSequenceID:inProtocol:outProtocol:);" << endl;
     out << indent() << "NSMethodSignature * sig = [self methodSignatureForSelector: s];" << endl;
-    out << indent() << "NSInvocation * invocation = [NSInvocation invocationWithMethodSignature: sig];" << endl;
+    out << indent()
+        << "NSInvocation * invocation = [NSInvocation invocationWithMethodSignature: sig];" << endl;
     out << indent() << "[invocation setSelector: s];" << endl;
     out << indent() << "[invocation retainArguments];" << endl;
     out << indent() << "[mMethodMap setValue: invocation forKey: @\"" << funname << "\"];" << endl;
@@ -1589,7 +1478,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   // implementation of the 'service' method which returns the service associated with this
   // processor
   out << endl;
-  out << indent() << "- (id<"<<cocoa_prefix_ << tservice->get_name() << ">) service" << endl;
+  out << indent() << "- (id<" << cocoa_prefix_ << tservice->get_name() << ">) service" << endl;
   out << indent() << "{" << endl;
   out << indent() << "  return [[mService retain_stub] autorelease_stub];" << endl;
   out << indent() << "}" << endl;
@@ -1597,7 +1486,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   // implementation of the TProcess method, which dispatches the incoming call using the method map
   out << endl;
   out << indent() << "- (BOOL) processOnInputProtocol: (id <TProtocol>) inProtocol" << endl;
-  out << indent() << "                 outputProtocol: (id <TProtocol>) outProtocol" <<endl;
+  out << indent() << "                 outputProtocol: (id <TProtocol>) outProtocol" << endl;
   out << indent() << "{" << endl;
   out << indent() << "  NSString * messageName;" << endl;
   out << indent() << "  int messageType;" << endl;
@@ -1609,7 +1498,9 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   out << indent() << "  if (invocation == nil) {" << endl;
   out << indent() << "    [TProtocolUtil skipType: TType_STRUCT onProtocol: inProtocol];" << endl;
   out << indent() << "    [inProtocol readMessageEnd];" << endl;
-  out << indent() << "    TApplicationException * x = [TApplicationException exceptionWithType: TApplicationException_UNKNOWN_METHOD reason: [NSString stringWithFormat: @\"Invalid method name: '%@'\", messageName]];" << endl;
+  out << indent() << "    TApplicationException * x = [TApplicationException exceptionWithType: "
+                     "TApplicationException_UNKNOWN_METHOD reason: [NSString stringWithFormat: "
+                     "@\"Invalid method name: '%@'\", messageName]];" << endl;
   out << indent() << "    [outProtocol writeMessageBeginWithName: messageName" << endl;
   out << indent() << "                                      type: TMessageType_EXCEPTION" << endl;
   out << indent() << "                                sequenceID: seqID];" << endl;
@@ -1619,7 +1510,8 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   out << indent() << "    return YES;" << endl;
   out << indent() << "  }" << endl;
   out << indent() << "  // NSInvocation does not conform to NSCopying protocol" << endl;
-  out << indent() << "  NSInvocation * i = [NSInvocation invocationWithMethodSignature: [invocation methodSignature]];" << endl;
+  out << indent() << "  NSInvocation * i = [NSInvocation invocationWithMethodSignature: "
+                     "[invocation methodSignature]];" << endl;
   out << indent() << "  [i setSelector: [invocation selector]];" << endl;
   out << indent() << "  [i setArgument: &seqID atIndex: 2];" << endl;
   out << indent() << "  [i setArgument: &inProtocol atIndex: 3];" << endl;
@@ -1629,12 +1521,15 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   out << indent() << "  return YES;" << endl;
   out << indent() << "}" << endl;
 
-  // generate a process_XXXX method for each service function, which reads args, calls the service, and writes results
+  // generate a process_XXXX method for each service function, which reads args, calls the service,
+  // and writes results
   functions = tservice->get_functions();
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     out << endl;
     string funname = (*f_iter)->get_name();
-    out << indent() << "- (void) process_" << funname << "_withSequenceID: (int32_t) seqID inProtocol: (id<TProtocol>) inProtocol outProtocol: (id<TProtocol>) outProtocol" << endl;
+    out << indent() << "- (void) process_" << funname
+        << "_withSequenceID: (int32_t) seqID inProtocol: (id<TProtocol>) inProtocol outProtocol: "
+           "(id<TProtocol>) outProtocol" << endl;
     scope_up(out);
     string argstype = cocoa_prefix_ + function_args_helper_struct_type(*f_iter);
     out << indent() << argstype << " * args = [[" << argstype << " alloc] init];" << endl;
@@ -1643,8 +1538,8 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
 
     // prepare the result if not oneway
     if (!(*f_iter)->is_oneway()) {
-        string resulttype = cocoa_prefix_ + function_result_helper_struct_type(*f_iter);
-        out << indent() << resulttype << " * result = [[" << resulttype << " alloc] init];" << endl;
+      string resulttype = cocoa_prefix_ + function_result_helper_struct_type(*f_iter);
+      out << indent() << resulttype << " * result = [[" << resulttype << " alloc] init];" << endl;
     }
 
     // make the call to the actual service object
@@ -1675,13 +1570,13 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
 
     // write out the result if not oneway
     if (!(*f_iter)->is_oneway()) {
-        out << indent() << "[outProtocol writeMessageBeginWithName: @\"" << funname << "\"" << endl;
-        out << indent() << "                                  type: TMessageType_REPLY" << endl;
-        out << indent() << "                            sequenceID: seqID];" << endl;
-        out << indent() << "[result write: outProtocol];" << endl;
-        out << indent() << "[outProtocol writeMessageEnd];" << endl;
-        out << indent() << "[[outProtocol transport] flush];" << endl;
-        out << indent() << "[result release_stub];" << endl;
+      out << indent() << "[outProtocol writeMessageBeginWithName: @\"" << funname << "\"" << endl;
+      out << indent() << "                                  type: TMessageType_REPLY" << endl;
+      out << indent() << "                            sequenceID: seqID];" << endl;
+      out << indent() << "[result write: outProtocol];" << endl;
+      out << indent() << "[outProtocol writeMessageEnd];" << endl;
+      out << indent() << "[[outProtocol transport] flush];" << endl;
+      out << indent() << "[result release_stub];" << endl;
     }
     out << indent() << "[args release_stub];" << endl;
 
@@ -1703,7 +1598,6 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
   out << "@end" << endl << endl;
 }
 
-
 /**
  * Deserializes a field of any type.
  *
@@ -1716,26 +1610,21 @@ void t_cocoa_generator::generate_deserialize_field(ofstream& out,
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + tfield->get_name();
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                fieldName);
+    generate_deserialize_struct(out, (t_struct*)type, fieldName);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, fieldName);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      type_name(type) << " " << fieldName << " = [inProtocol ";
+    indent(out) << type_name(type) << " " << fieldName << " = [inProtocol ";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          tfield->get_name();
+        throw "compiler error: cannot serialize void field in a struct: " + tfield->get_name();
         break;
       case t_base_type::TYPE_STRING:
         if (((t_base_type*)type)->is_binary()) {
@@ -1763,16 +1652,17 @@ void t_cocoa_generator::generate_deserialize_field(ofstream& out,
         out << "readDouble];";
         break;
       default:
-        throw "compiler error: no Objective-C name for base type " + t_base_type::t_base_name(tbase);
+        throw "compiler error: no Objective-C name for base type "
+            + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "readI32];";
     }
-    out <<
-      endl;
+    out << endl;
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type_name(type).c_str());
+           tfield->get_name().c_str(),
+           type_name(type).c_str());
   }
 }
 
@@ -1782,8 +1672,8 @@ void t_cocoa_generator::generate_deserialize_field(ofstream& out,
 void t_cocoa_generator::generate_deserialize_struct(ofstream& out,
                                                     t_struct* tstruct,
                                                     string fieldName) {
-  indent(out) << type_name(tstruct) << fieldName << " = [[" <<
-    type_name(tstruct, true) << " alloc] init];" << endl;
+  indent(out) << type_name(tstruct) << fieldName << " = [[" << type_name(tstruct, true)
+              << " alloc] init];" << endl;
   indent(out) << "[" << fieldName << " read: inProtocol];" << endl;
 }
 
@@ -1798,21 +1688,20 @@ void t_cocoa_generator::generate_deserialize_container(ofstream& out,
 
   // Declare variables, read header
   if (ttype->is_map()) {
-    indent(out)
-      << "[inProtocol readMapBeginReturningKeyType: NULL valueType: NULL size: &" <<
-      size << "];" << endl;
-    indent(out) << "NSMutableDictionary * " << fieldName <<
-      " = [[NSMutableDictionary alloc] initWithCapacity: " << size << "];" << endl;
+    indent(out) << "[inProtocol readMapBeginReturningKeyType: NULL valueType: NULL size: &" << size
+                << "];" << endl;
+    indent(out) << "NSMutableDictionary * " << fieldName
+                << " = [[NSMutableDictionary alloc] initWithCapacity: " << size << "];" << endl;
   } else if (ttype->is_set()) {
-    indent(out)
-      << "[inProtocol readSetBeginReturningElementType: NULL size: &" << size << "];" << endl;
-    indent(out) << "NSMutableSet * " << fieldName <<
-      " = [[NSMutableSet alloc] initWithCapacity: " << size << "];" << endl;
+    indent(out) << "[inProtocol readSetBeginReturningElementType: NULL size: &" << size << "];"
+                << endl;
+    indent(out) << "NSMutableSet * " << fieldName
+                << " = [[NSMutableSet alloc] initWithCapacity: " << size << "];" << endl;
   } else if (ttype->is_list()) {
-    indent(out)
-      << "[inProtocol readListBeginReturningElementType: NULL size: &" << size << "];" << endl;
-    indent(out) << "NSMutableArray * " << fieldName <<
-      " = [[NSMutableArray alloc] initWithCapacity: " << size << "];" << endl;
+    indent(out) << "[inProtocol readListBeginReturningElementType: NULL size: &" << size << "];"
+                << endl;
+    indent(out) << "NSMutableArray * " << fieldName
+                << " = [[NSMutableArray alloc] initWithCapacity: " << size << "];" << endl;
   }
   // FIXME - the code above does not verify that the element types of
   // the containers being read match the element types of the
@@ -1820,22 +1709,21 @@ void t_cocoa_generator::generate_deserialize_container(ofstream& out,
 
   // For loop iterates over elements
   string i = tmp("_i");
-  indent(out) << "int " << i << ";" << endl <<
-    indent() << "for (" << i << " = 0; " <<
-    i << " < " << size << "; " <<
-    "++" << i << ")" << endl;
+  indent(out) << "int " << i << ";" << endl << indent() << "for (" << i << " = 0; " << i << " < "
+              << size << "; "
+              << "++" << i << ")" << endl;
 
-    scope_up(out);
+  scope_up(out);
 
-    if (ttype->is_map()) {
-      generate_deserialize_map_element(out, (t_map*)ttype, fieldName);
-    } else if (ttype->is_set()) {
-      generate_deserialize_set_element(out, (t_set*)ttype, fieldName);
-    } else if (ttype->is_list()) {
-      generate_deserialize_list_element(out, (t_list*)ttype, fieldName);
-    }
+  if (ttype->is_map()) {
+    generate_deserialize_map_element(out, (t_map*)ttype, fieldName);
+  } else if (ttype->is_set()) {
+    generate_deserialize_set_element(out, (t_set*)ttype, fieldName);
+  } else if (ttype->is_list()) {
+    generate_deserialize_list_element(out, (t_list*)ttype, fieldName);
+  }
 
-    scope_down(out);
+  scope_down(out);
 
   // Read container end
   if (ttype->is_map()) {
@@ -1845,18 +1733,14 @@ void t_cocoa_generator::generate_deserialize_container(ofstream& out,
   } else if (ttype->is_list()) {
     indent(out) << "[inProtocol readListEnd];" << endl;
   }
-
 }
 
-
 /**
  * Take a variable of a given type and wrap it in code to make it
  * suitable for putting into a container, if necessary.  Basically,
  * wrap scaler primitives in NSNumber objects.
  */
-string t_cocoa_generator::containerize(t_type * ttype,
-                                       string fieldName)
-{
+string t_cocoa_generator::containerize(t_type* ttype, string fieldName) {
   // FIXME - optimize here to avoid autorelease pool?
   ttype = get_true_type(ttype);
   if (ttype->is_enum()) {
@@ -1887,7 +1771,6 @@ string t_cocoa_generator::containerize(t_type * ttype,
   return fieldName;
 }
 
-
 /**
  * Generates code to deserialize a map element
  */
@@ -1904,9 +1787,8 @@ void t_cocoa_generator::generate_deserialize_map_element(ofstream& out,
   generate_deserialize_field(out, &fkey, key);
   generate_deserialize_field(out, &fval, val);
 
-  indent(out) <<
-    "[" << fieldName << " setObject: " << containerize(valType, val) <<
-    " forKey: " << containerize(keyType, key) << "];" << endl;
+  indent(out) << "[" << fieldName << " setObject: " << containerize(valType, val)
+              << " forKey: " << containerize(keyType, key) << "];" << endl;
 
   if (type_can_be_null(keyType)) {
     if (!(get_true_type(keyType)->is_string())) {
@@ -1933,8 +1815,7 @@ void t_cocoa_generator::generate_deserialize_set_element(ofstream& out,
 
   generate_deserialize_field(out, &felem, elem);
 
-  indent(out) <<
-    "[" << fieldName << " addObject: " << containerize(type, elem) << "];" << endl;
+  indent(out) << "[" << fieldName << " addObject: " << containerize(type, elem) << "];" << endl;
 
   if (type_can_be_null(type)) {
     // deserialized strings are autorelease, so don't release them
@@ -1956,8 +1837,7 @@ void t_cocoa_generator::generate_deserialize_list_element(ofstream& out,
 
   generate_deserialize_field(out, &felem, elem);
 
-  indent(out) <<
-    "[" << fieldName << " addObject: " << containerize(type, elem) << "];" << endl;
+  indent(out) << "[" << fieldName << " addObject: " << containerize(type, elem) << "];" << endl;
 
   if (type_can_be_null(type)) {
     if (!(get_true_type(type)->is_string())) {
@@ -1966,42 +1846,32 @@ void t_cocoa_generator::generate_deserialize_list_element(ofstream& out,
   }
 }
 
-
 /**
  * Serializes a field of any type.
  *
  * @param tfield The field to serialize
  * @param fieldName Name to of the variable holding the field
  */
-void t_cocoa_generator::generate_serialize_field(ofstream& out,
-                                                 t_field* tfield,
-                                                 string fieldName) {
+void t_cocoa_generator::generate_serialize_field(ofstream& out, t_field* tfield, string fieldName) {
   t_type* type = get_true_type(tfield->get_type());
 
   // Do nothing for void types
   if (type->is_void()) {
-    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
-      tfield->get_name();
+    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + tfield->get_name();
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_serialize_struct(out,
-                              (t_struct*)type,
-                              fieldName);
+    generate_serialize_struct(out, (t_struct*)type, fieldName);
   } else if (type->is_container()) {
-    generate_serialize_container(out,
-                                 type,
-                                 fieldName);
+    generate_serialize_container(out, type, fieldName);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      "[outProtocol ";
+    indent(out) << "[outProtocol ";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + fieldName;
+        throw "compiler error: cannot serialize void field in a struct: " + fieldName;
         break;
       case t_base_type::TYPE_STRING:
         if (((t_base_type*)type)->is_binary()) {
@@ -2029,7 +1899,8 @@ void t_cocoa_generator::generate_serialize_field(ofstream& out,
         out << "writeDouble: " << fieldName << "];";
         break;
       default:
-        throw "compiler error: no Objective-C name for base type " + t_base_type::t_base_name(tbase);
+        throw "compiler error: no Objective-C name for base type "
+            + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "writeI32: " << fieldName << "];";
@@ -2051,9 +1922,8 @@ void t_cocoa_generator::generate_serialize_field(ofstream& out,
 void t_cocoa_generator::generate_serialize_struct(ofstream& out,
                                                   t_struct* tstruct,
                                                   string fieldName) {
-  (void) tstruct;
-  out <<
-    indent() << "[" << fieldName << " write: outProtocol];" << endl;
+  (void)tstruct;
+  out << indent() << "[" << fieldName << " write: outProtocol];" << endl;
 }
 
 /**
@@ -2068,21 +1938,18 @@ void t_cocoa_generator::generate_serialize_container(ofstream& out,
   scope_up(out);
 
   if (ttype->is_map()) {
-    indent(out) <<
-      "[outProtocol writeMapBeginWithKeyType: " <<
-      type_to_enum(((t_map*)ttype)->get_key_type()) << " valueType: " <<
-      type_to_enum(((t_map*)ttype)->get_val_type()) << " size: [" <<
-      fieldName << " count]];" << endl;
+    indent(out) << "[outProtocol writeMapBeginWithKeyType: "
+                << type_to_enum(((t_map*)ttype)->get_key_type())
+                << " valueType: " << type_to_enum(((t_map*)ttype)->get_val_type()) << " size: ["
+                << fieldName << " count]];" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "[outProtocol writeSetBeginWithElementType: " <<
-      type_to_enum(((t_set*)ttype)->get_elem_type()) << " size: [" <<
-      fieldName << " count]];" << endl;
+    indent(out) << "[outProtocol writeSetBeginWithElementType: "
+                << type_to_enum(((t_set*)ttype)->get_elem_type()) << " size: [" << fieldName
+                << " count]];" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "[outProtocol writeListBeginWithElementType: " <<
-      type_to_enum(((t_list*)ttype)->get_elem_type()) << " size: [" <<
-      fieldName << " count]];" << endl;
+    indent(out) << "[outProtocol writeListBeginWithElementType: "
+                << type_to_enum(((t_list*)ttype)->get_elem_type()) << " size: [" << fieldName
+                << " count]];" << endl;
   }
 
   string iter = tmp("_iter");
@@ -2094,38 +1961,36 @@ void t_cocoa_generator::generate_serialize_container(ofstream& out,
     indent(out) << "while ((" << key << " = [" << iter << " nextObject]))" << endl;
   } else if (ttype->is_set()) {
     key = tmp("obj");
-    indent(out) << "NSEnumerator * " << iter << " = [" << fieldName << " objectEnumerator];" << endl;
+    indent(out) << "NSEnumerator * " << iter << " = [" << fieldName << " objectEnumerator];"
+                << endl;
     indent(out) << "id " << key << ";" << endl;
     indent(out) << "while ((" << key << " = [" << iter << " nextObject]))" << endl;
   } else if (ttype->is_list()) {
     key = tmp("idx");
     indent(out) << "int " << key << ";" << endl;
-    indent(out) <<
-      "for (" << key << " = 0; " << key << " < [" << fieldName << " count]; " << key << "++)" << endl;
+    indent(out) << "for (" << key << " = 0; " << key << " < [" << fieldName << " count]; " << key
+                << "++)" << endl;
   }
 
-    scope_up(out);
+  scope_up(out);
 
-    if (ttype->is_map()) {
-      generate_serialize_map_element(out, (t_map*)ttype, key, fieldName);
-    } else if (ttype->is_set()) {
-      generate_serialize_set_element(out, (t_set*)ttype, key);
-    } else if (ttype->is_list()) {
-      generate_serialize_list_element(out, (t_list*)ttype, key, fieldName);
-    }
+  if (ttype->is_map()) {
+    generate_serialize_map_element(out, (t_map*)ttype, key, fieldName);
+  } else if (ttype->is_set()) {
+    generate_serialize_set_element(out, (t_set*)ttype, key);
+  } else if (ttype->is_list()) {
+    generate_serialize_list_element(out, (t_list*)ttype, key, fieldName);
+  }
 
-    scope_down(out);
+  scope_down(out);
 
-    if (ttype->is_map()) {
-      indent(out) <<
-        "[outProtocol writeMapEnd];" << endl;
-    } else if (ttype->is_set()) {
-      indent(out) <<
-        "[outProtocol writeSetEnd];" << endl;
-    } else if (ttype->is_list()) {
-      indent(out) <<
-        "[outProtocol writeListEnd];" << endl;
-    }
+  if (ttype->is_map()) {
+    indent(out) << "[outProtocol writeMapEnd];" << endl;
+  } else if (ttype->is_set()) {
+    indent(out) << "[outProtocol writeSetEnd];" << endl;
+  } else if (ttype->is_list()) {
+    indent(out) << "[outProtocol writeListEnd];" << endl;
+  }
 
   scope_down(out);
 }
@@ -2134,10 +1999,8 @@ void t_cocoa_generator::generate_serialize_container(ofstream& out,
  * Given a field variable name, wrap it in code that converts it to a
  * primitive type, if necessary.
  */
-string t_cocoa_generator::decontainerize(t_field * tfield,
-                                         string fieldName)
-{
-  t_type * ttype = get_true_type(tfield->get_type());
+string t_cocoa_generator::decontainerize(t_field* tfield, string fieldName) {
+  t_type* ttype = get_true_type(tfield->get_type());
   if (ttype->is_enum()) {
     return "[" + fieldName + " intValue]";
   } else if (ttype->is_base_type()) {
@@ -2166,7 +2029,6 @@ string t_cocoa_generator::decontainerize(t_field * tfield,
   return fieldName;
 }
 
-
 /**
  * Serializes the members of a map.
  

<TRUNCATED>

[32/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_csharp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 0b9ae2a..a0cddbf 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -43,174 +43,203 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
-
-class t_csharp_generator : public t_oop_generator
-{
-  public:
-    t_csharp_generator(
-        t_program* program,
-        const std::map<std::string, std::string>& parsed_options,
-        const std::string& option_string)
-      : t_oop_generator(program)
-    {
-      (void) option_string;
-
-      std::map<std::string, std::string>::const_iterator iter;
-
-      iter = parsed_options.find("async");
-      async_ = (iter != parsed_options.end());
-      iter = parsed_options.find("asyncctp");
-      async_ctp_ = (iter != parsed_options.end());
-      if (async_ && async_ctp_) {
-        throw "argument error: Cannot specify both async and asyncctp; they are incompatible.";
-      }
-
-      iter = parsed_options.find("nullable");
-      nullable_ = (iter != parsed_options.end());
-
-      iter = parsed_options.find("hashcode");
-      hashcode_ = (iter != parsed_options.end());
-
-      iter = parsed_options.find("union");
-      union_ = (iter != parsed_options.end());
-
-      iter = parsed_options.find("serial");
-      serialize_ = (iter != parsed_options.end());
-      if (serialize_) {
-        wcf_namespace_ = iter->second;  // since there can be only one namespace
-      }
-
-      iter = parsed_options.find("wcf");
-      wcf_ = (iter != parsed_options.end());
-      if (wcf_) {
-        wcf_namespace_ = iter->second;
-      }
-
-      out_dir_base_ = "gen-csharp";
-    }
-    void init_generator();
-    void close_generator();
-
-    void generate_consts(std::vector<t_const*> consts);
-
-    void generate_typedef (t_typedef* ttypedef);
-    void generate_enum (t_enum* tenum);
-    void generate_struct (t_struct* tstruct);
-    void generate_union (t_struct* tunion);
-    void generate_xception (t_struct* txception);
-    void generate_service (t_service* tservice);
-    void generate_property(ofstream& out, t_field* tfield, bool isPublic, bool generateIsset);
-    void generate_csharp_property(ofstream& out, t_field* tfield, bool isPublic, bool includeIsset=true, std::string fieldPrefix = "");
-    bool print_const_value (std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false, bool needtype=false);
-    std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
-    void print_const_constructor(std::ofstream& out, std::vector<t_const*> consts);
-    void print_const_def_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
-
-    void generate_csharp_struct(t_struct* tstruct, bool is_exception);
-    void generate_csharp_union(t_struct* tunion);
-    void generate_csharp_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
-    void generate_csharp_union_definition(std::ofstream& out, t_struct* tunion);
-    void generate_csharp_union_class(std::ofstream& out, t_struct* tunion, t_field* tfield);
-    void generate_csharp_wcffault(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_reader(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_result_writer(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_writer(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_tostring(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_equals(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_struct_hashcode(std::ofstream& out, t_struct* tstruct);
-    void generate_csharp_union_reader(std::ofstream& out, t_struct* tunion);
-
-    void generate_function_helpers(t_function* tfunction);
-    void generate_service_interface (t_service* tservice);
-    void generate_service_helpers (t_service* tservice);
-    void generate_service_client (t_service* tservice);
-    void generate_service_server (t_service* tservice);
-    void generate_process_function (t_service* tservice, t_function* function);
-
-    void generate_deserialize_field (std::ofstream& out, t_field* tfield, std::string prefix="", bool is_propertyless=false);
-    void generate_deserialize_struct (std::ofstream& out, t_struct* tstruct, std::string prefix="");
-    void generate_deserialize_container (std::ofstream& out, t_type* ttype, std::string prefix="");
-    void generate_deserialize_set_element (std::ofstream& out, t_set* tset, std::string prefix="");
-    void generate_deserialize_map_element (std::ofstream& out, t_map* tmap, std::string prefix="");
-    void generate_deserialize_list_element (std::ofstream& out, t_list* list, std::string prefix="");
-    void generate_serialize_field (std::ofstream& out, t_field* tfield, std::string prefix="", bool is_element=false, bool is_propertyless=false);
-    void generate_serialize_struct (std::ofstream& out, t_struct* tstruct, std::string prefix="");
-    void generate_serialize_container (std::ofstream& out, t_type* ttype, std::string prefix="");
-    void generate_serialize_map_element (std::ofstream& out, t_map* tmap, std::string iter, std::string map);
-    void generate_serialize_set_element (std::ofstream& out, t_set* tmap, std::string iter);
-    void generate_serialize_list_element (std::ofstream& out, t_list* tlist, std::string iter);
-
-    void generate_csharp_doc (std::ofstream& out, t_field*    field);
-    void generate_csharp_doc (std::ofstream& out, t_doc*      tdoc);
-    void generate_csharp_doc (std::ofstream& out, t_function* tdoc);
-    void generate_csharp_docstring_comment (std::ofstream &out, string contents);
-
-    void start_csharp_namespace (std::ofstream& out);
-    void end_csharp_namespace (std::ofstream& out);
-
-    std::string csharp_type_usings();
-    std::string csharp_thrift_usings();
-
-    std::string type_name(t_type* ttype, bool in_countainer=false, bool in_init=false, bool in_param=false, bool is_required=false);
-    std::string base_type_name(t_base_type* tbase, bool in_container=false, bool in_param=false, bool is_required=false);
-    std::string declare_field(t_field* tfield, bool init=false, std::string prefix="");
-    std::string function_signature_async_begin(t_function* tfunction, std::string prefix = "");
-    std::string function_signature_async_end(t_function* tfunction, std::string prefix = "");
-    std::string function_signature_async(t_function* tfunction, std::string prefix = "");
-    std::string function_signature(t_function* tfunction, std::string prefix="");
-    std::string argument_list(t_struct* tstruct);
-    std::string type_to_enum(t_type* ttype);
-    std::string prop_name(t_field* tfield, bool suppress_mapping = false);
-    std::string get_enum_class_name(t_type* type);
-
-    bool field_has_default(t_field* tfield) {
-      return tfield->get_value() != NULL;
-    }
-
-    bool field_is_required(t_field* tfield) {
-      return tfield->get_req() == t_field::T_REQUIRED;
-    }
-
-    bool type_can_be_null(t_type* ttype) {
-      while (ttype->is_typedef()) {
-        ttype = ((t_typedef*)ttype)->get_type();
-      }
+static const string endl = "\n"; // avoid ostream << std::endl flushes
+
+class t_csharp_generator : public t_oop_generator {
+public:
+  t_csharp_generator(t_program* program,
+                     const std::map<std::string, std::string>& parsed_options,
+                     const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
+
+    std::map<std::string, std::string>::const_iterator iter;
+
+    iter = parsed_options.find("async");
+    async_ = (iter != parsed_options.end());
+    iter = parsed_options.find("asyncctp");
+    async_ctp_ = (iter != parsed_options.end());
+    if (async_ && async_ctp_) {
+      throw "argument error: Cannot specify both async and asyncctp; they are incompatible.";
+    }
+
+    iter = parsed_options.find("nullable");
+    nullable_ = (iter != parsed_options.end());
+
+    iter = parsed_options.find("hashcode");
+    hashcode_ = (iter != parsed_options.end());
+
+    iter = parsed_options.find("union");
+    union_ = (iter != parsed_options.end());
+
+    iter = parsed_options.find("serial");
+    serialize_ = (iter != parsed_options.end());
+    if (serialize_) {
+      wcf_namespace_ = iter->second; // since there can be only one namespace
+    }
+
+    iter = parsed_options.find("wcf");
+    wcf_ = (iter != parsed_options.end());
+    if (wcf_) {
+      wcf_namespace_ = iter->second;
+    }
+
+    out_dir_base_ = "gen-csharp";
+  }
+  void init_generator();
+  void close_generator();
+
+  void generate_consts(std::vector<t_const*> consts);
+
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_union(t_struct* tunion);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+  void generate_property(ofstream& out, t_field* tfield, bool isPublic, bool generateIsset);
+  void generate_csharp_property(ofstream& out,
+                                t_field* tfield,
+                                bool isPublic,
+                                bool includeIsset = true,
+                                std::string fieldPrefix = "");
+  bool print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool in_static,
+                         bool defval = false,
+                         bool needtype = false);
+  std::string render_const_value(std::ofstream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
+  void print_const_constructor(std::ofstream& out, std::vector<t_const*> consts);
+  void print_const_def_value(std::ofstream& out,
+                             std::string name,
+                             t_type* type,
+                             t_const_value* value);
+
+  void generate_csharp_struct(t_struct* tstruct, bool is_exception);
+  void generate_csharp_union(t_struct* tunion);
+  void generate_csharp_struct_definition(std::ofstream& out,
+                                         t_struct* tstruct,
+                                         bool is_xception = false,
+                                         bool in_class = false,
+                                         bool is_result = false);
+  void generate_csharp_union_definition(std::ofstream& out, t_struct* tunion);
+  void generate_csharp_union_class(std::ofstream& out, t_struct* tunion, t_field* tfield);
+  void generate_csharp_wcffault(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_reader(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_result_writer(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_writer(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_tostring(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_equals(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_struct_hashcode(std::ofstream& out, t_struct* tstruct);
+  void generate_csharp_union_reader(std::ofstream& out, t_struct* tunion);
+
+  void generate_function_helpers(t_function* tfunction);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* function);
+
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool is_propertyless = false);
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
+  void generate_deserialize_list_element(std::ofstream& out, t_list* list, std::string prefix = "");
+  void generate_serialize_field(std::ofstream& out,
+                                t_field* tfield,
+                                std::string prefix = "",
+                                bool is_element = false,
+                                bool is_propertyless = false);
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
+
+  void generate_csharp_doc(std::ofstream& out, t_field* field);
+  void generate_csharp_doc(std::ofstream& out, t_doc* tdoc);
+  void generate_csharp_doc(std::ofstream& out, t_function* tdoc);
+  void generate_csharp_docstring_comment(std::ofstream& out, string contents);
+
+  void start_csharp_namespace(std::ofstream& out);
+  void end_csharp_namespace(std::ofstream& out);
+
+  std::string csharp_type_usings();
+  std::string csharp_thrift_usings();
+
+  std::string type_name(t_type* ttype,
+                        bool in_countainer = false,
+                        bool in_init = false,
+                        bool in_param = false,
+                        bool is_required = false);
+  std::string base_type_name(t_base_type* tbase,
+                             bool in_container = false,
+                             bool in_param = false,
+                             bool is_required = false);
+  std::string declare_field(t_field* tfield, bool init = false, std::string prefix = "");
+  std::string function_signature_async_begin(t_function* tfunction, std::string prefix = "");
+  std::string function_signature_async_end(t_function* tfunction, std::string prefix = "");
+  std::string function_signature_async(t_function* tfunction, std::string prefix = "");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string argument_list(t_struct* tstruct);
+  std::string type_to_enum(t_type* ttype);
+  std::string prop_name(t_field* tfield, bool suppress_mapping = false);
+  std::string get_enum_class_name(t_type* type);
+
+  bool field_has_default(t_field* tfield) { return tfield->get_value() != NULL; }
+
+  bool field_is_required(t_field* tfield) { return tfield->get_req() == t_field::T_REQUIRED; }
+
+  bool type_can_be_null(t_type* ttype) {
+    while (ttype->is_typedef()) {
+      ttype = ((t_typedef*)ttype)->get_type();
+    }
 
-      return ttype->is_container() ||
-        ttype->is_struct() ||
-        ttype->is_xception() ||
-        ttype->is_string();
-    }
-
-  private:
-    std::string namespace_name_;
-    std::ofstream f_service_;
-    std::string namespace_dir_;
-    bool async_;
-    bool async_ctp_;
-    bool nullable_;
-    bool union_;
-    bool hashcode_;
-    bool serialize_;
-    bool wcf_;
-    std::string wcf_namespace_;
-
-    std::map<std::string, int> csharp_keywords;
-
-    void* member_mapping_scope;
-    std::map<std::string, std::string> member_name_mapping;
-
-    void init_keywords();
-    std::string normalize_name( std::string name);
-    std::string make_valid_csharp_identifier( std::string const & fromName);
-    void prepare_member_name_mapping( t_struct* tstruct);
-    void prepare_member_name_mapping( void* scope, const vector<t_field*>& members, const string & structname);
-    void cleanup_member_name_mapping( void* scope);
-    string get_mapped_member_name( string oldname);
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
+           || ttype->is_string();
+  }
+
+private:
+  std::string namespace_name_;
+  std::ofstream f_service_;
+  std::string namespace_dir_;
+  bool async_;
+  bool async_ctp_;
+  bool nullable_;
+  bool union_;
+  bool hashcode_;
+  bool serialize_;
+  bool wcf_;
+  std::string wcf_namespace_;
+
+  std::map<std::string, int> csharp_keywords;
+
+  void* member_mapping_scope;
+  std::map<std::string, std::string> member_name_mapping;
+
+  void init_keywords();
+  std::string normalize_name(std::string name);
+  std::string make_valid_csharp_identifier(std::string const& fromName);
+  void prepare_member_name_mapping(t_struct* tstruct);
+  void prepare_member_name_mapping(void* scope,
+                                   const vector<t_field*>& members,
+                                   const string& structname);
+  void cleanup_member_name_mapping(void* scope);
+  string get_mapped_member_name(string oldname);
 };
 
-
 void t_csharp_generator::init_generator() {
   MKDIR(get_out_dir().c_str());
   namespace_name_ = program_->get_namespace("csharp");
@@ -243,12 +272,12 @@ void t_csharp_generator::init_generator() {
   pverbose("- wcf ........ %s\n", (wcf_ ? "ON" : "off"));
 }
 
-std::string t_csharp_generator::normalize_name( std::string name) {
-  string tmp( name );
+std::string t_csharp_generator::normalize_name(std::string name) {
+  string tmp(name);
   std::transform(tmp.begin(), tmp.end(), tmp.begin(), static_cast<int (*)(int)>(std::tolower));
 
   // un-conflict keywords by prefixing with "@"
-  if ( csharp_keywords.find(tmp) != csharp_keywords.end()) {
+  if (csharp_keywords.find(tmp) != csharp_keywords.end()) {
     return "@" + name;
   }
 
@@ -261,113 +290,112 @@ void t_csharp_generator::init_keywords() {
 
   // C# keywords
   csharp_keywords["abstract"] = 1;
-  csharp_keywords["as"]= 1;
-  csharp_keywords["base"]= 1;
-  csharp_keywords["bool"]= 1;
-  csharp_keywords["break"]= 1;
-  csharp_keywords["byte"]= 1;
-  csharp_keywords["case"]= 1;
-  csharp_keywords["catch"]= 1;
-  csharp_keywords["char"]= 1;
-  csharp_keywords["checked"]= 1;
-  csharp_keywords["class"]= 1;
-  csharp_keywords["const"]= 1;
-  csharp_keywords["continue"]= 1;
-  csharp_keywords["decimal"]= 1;
-  csharp_keywords["default"]= 1;
-  csharp_keywords["delegate"]= 1;
-  csharp_keywords["do"]= 1;
-  csharp_keywords["double"]= 1;
-  csharp_keywords["else"]= 1;
-  csharp_keywords["enum"]= 1;
-  csharp_keywords["event"]= 1;
-  csharp_keywords["explicit"]= 1;
-  csharp_keywords["extern"]= 1;
-  csharp_keywords["false"]= 1;
-  csharp_keywords["finally"]= 1;
-  csharp_keywords["fixed"]= 1;
-  csharp_keywords["float"]= 1;
-  csharp_keywords["for"]= 1;
-  csharp_keywords["foreach"]= 1;
-  csharp_keywords["goto"]= 1;
-  csharp_keywords["if"]= 1;
-  csharp_keywords["implicit"]= 1;
-  csharp_keywords["in"]= 1;
-  csharp_keywords["int"]= 1;
-  csharp_keywords["interface"]= 1;
-  csharp_keywords["internal"]= 1;
-  csharp_keywords["is"]= 1;
-  csharp_keywords["lock"]= 1;
-  csharp_keywords["long"]= 1;
-  csharp_keywords["namespace"]= 1;
-  csharp_keywords["new"]= 1;
-  csharp_keywords["null"]= 1;
-  csharp_keywords["object"]= 1;
-  csharp_keywords["operator"]= 1;
-  csharp_keywords["out"]= 1;
-  csharp_keywords["override"]= 1;
-  csharp_keywords["params"]= 1;
-  csharp_keywords["private"]= 1;
-  csharp_keywords["protected"]= 1;
-  csharp_keywords["public"]= 1;
-  csharp_keywords["readonly"]= 1;
-  csharp_keywords["ref"]= 1;
-  csharp_keywords["return"]= 1;
-  csharp_keywords["sbyte"]= 1;
-  csharp_keywords["sealed"]= 1;
-  csharp_keywords["short"]= 1;
-  csharp_keywords["sizeof"]= 1;
-  csharp_keywords["stackalloc"]= 1;
-  csharp_keywords["static"]= 1;
-  csharp_keywords["string"]= 1;
-  csharp_keywords["struct"]= 1;
-  csharp_keywords["switch"]= 1;
-  csharp_keywords["this"]= 1;
-  csharp_keywords["throw"]= 1;
-  csharp_keywords["true"]= 1;
-  csharp_keywords["try"]= 1;
-  csharp_keywords["typeof"]= 1;
-  csharp_keywords["uint"]= 1;
-  csharp_keywords["ulong"]= 1;
-  csharp_keywords["unchecked"]= 1;
-  csharp_keywords["unsafe"]= 1;
-  csharp_keywords["ushort"]= 1;
-  csharp_keywords["using"]= 1;
-  csharp_keywords["virtual"]= 1;
-  csharp_keywords["void"]= 1;
-  csharp_keywords["volatile"]= 1;
-  csharp_keywords["while"]= 1;
+  csharp_keywords["as"] = 1;
+  csharp_keywords["base"] = 1;
+  csharp_keywords["bool"] = 1;
+  csharp_keywords["break"] = 1;
+  csharp_keywords["byte"] = 1;
+  csharp_keywords["case"] = 1;
+  csharp_keywords["catch"] = 1;
+  csharp_keywords["char"] = 1;
+  csharp_keywords["checked"] = 1;
+  csharp_keywords["class"] = 1;
+  csharp_keywords["const"] = 1;
+  csharp_keywords["continue"] = 1;
+  csharp_keywords["decimal"] = 1;
+  csharp_keywords["default"] = 1;
+  csharp_keywords["delegate"] = 1;
+  csharp_keywords["do"] = 1;
+  csharp_keywords["double"] = 1;
+  csharp_keywords["else"] = 1;
+  csharp_keywords["enum"] = 1;
+  csharp_keywords["event"] = 1;
+  csharp_keywords["explicit"] = 1;
+  csharp_keywords["extern"] = 1;
+  csharp_keywords["false"] = 1;
+  csharp_keywords["finally"] = 1;
+  csharp_keywords["fixed"] = 1;
+  csharp_keywords["float"] = 1;
+  csharp_keywords["for"] = 1;
+  csharp_keywords["foreach"] = 1;
+  csharp_keywords["goto"] = 1;
+  csharp_keywords["if"] = 1;
+  csharp_keywords["implicit"] = 1;
+  csharp_keywords["in"] = 1;
+  csharp_keywords["int"] = 1;
+  csharp_keywords["interface"] = 1;
+  csharp_keywords["internal"] = 1;
+  csharp_keywords["is"] = 1;
+  csharp_keywords["lock"] = 1;
+  csharp_keywords["long"] = 1;
+  csharp_keywords["namespace"] = 1;
+  csharp_keywords["new"] = 1;
+  csharp_keywords["null"] = 1;
+  csharp_keywords["object"] = 1;
+  csharp_keywords["operator"] = 1;
+  csharp_keywords["out"] = 1;
+  csharp_keywords["override"] = 1;
+  csharp_keywords["params"] = 1;
+  csharp_keywords["private"] = 1;
+  csharp_keywords["protected"] = 1;
+  csharp_keywords["public"] = 1;
+  csharp_keywords["readonly"] = 1;
+  csharp_keywords["ref"] = 1;
+  csharp_keywords["return"] = 1;
+  csharp_keywords["sbyte"] = 1;
+  csharp_keywords["sealed"] = 1;
+  csharp_keywords["short"] = 1;
+  csharp_keywords["sizeof"] = 1;
+  csharp_keywords["stackalloc"] = 1;
+  csharp_keywords["static"] = 1;
+  csharp_keywords["string"] = 1;
+  csharp_keywords["struct"] = 1;
+  csharp_keywords["switch"] = 1;
+  csharp_keywords["this"] = 1;
+  csharp_keywords["throw"] = 1;
+  csharp_keywords["true"] = 1;
+  csharp_keywords["try"] = 1;
+  csharp_keywords["typeof"] = 1;
+  csharp_keywords["uint"] = 1;
+  csharp_keywords["ulong"] = 1;
+  csharp_keywords["unchecked"] = 1;
+  csharp_keywords["unsafe"] = 1;
+  csharp_keywords["ushort"] = 1;
+  csharp_keywords["using"] = 1;
+  csharp_keywords["virtual"] = 1;
+  csharp_keywords["void"] = 1;
+  csharp_keywords["volatile"] = 1;
+  csharp_keywords["while"] = 1;
 
   // C# contextual keywords
-  csharp_keywords["add"]= 1;
-  csharp_keywords["alias"]= 1;
-  csharp_keywords["ascending"]= 1;
-  csharp_keywords["async"]= 1;
-  csharp_keywords["await"]= 1;
-  csharp_keywords["descending"]= 1;
-  csharp_keywords["dynamic"]= 1;
-  csharp_keywords["from"]= 1;
-  csharp_keywords["get"]= 1;
-  csharp_keywords["global"]= 1;
-  csharp_keywords["group"]= 1;
-  csharp_keywords["into"]= 1;
-  csharp_keywords["join"]= 1;
-  csharp_keywords["let"]= 1;
-  csharp_keywords["orderby"]= 1;
-  csharp_keywords["partial"]= 1;
-  csharp_keywords["remove"]= 1;
-  csharp_keywords["select"]= 1;
-  csharp_keywords["set"]= 1;
-  csharp_keywords["value"]= 1;
-  csharp_keywords["var"]= 1;
-  csharp_keywords["where"]= 1;
-  csharp_keywords["yield"]= 1;
+  csharp_keywords["add"] = 1;
+  csharp_keywords["alias"] = 1;
+  csharp_keywords["ascending"] = 1;
+  csharp_keywords["async"] = 1;
+  csharp_keywords["await"] = 1;
+  csharp_keywords["descending"] = 1;
+  csharp_keywords["dynamic"] = 1;
+  csharp_keywords["from"] = 1;
+  csharp_keywords["get"] = 1;
+  csharp_keywords["global"] = 1;
+  csharp_keywords["group"] = 1;
+  csharp_keywords["into"] = 1;
+  csharp_keywords["join"] = 1;
+  csharp_keywords["let"] = 1;
+  csharp_keywords["orderby"] = 1;
+  csharp_keywords["partial"] = 1;
+  csharp_keywords["remove"] = 1;
+  csharp_keywords["select"] = 1;
+  csharp_keywords["set"] = 1;
+  csharp_keywords["value"] = 1;
+  csharp_keywords["var"] = 1;
+  csharp_keywords["where"] = 1;
+  csharp_keywords["yield"] = 1;
 }
 
 void t_csharp_generator::start_csharp_namespace(ofstream& out) {
   if (!namespace_name_.empty()) {
-    out <<
-      "namespace " << namespace_name_ << "\n";
+    out << "namespace " << namespace_name_ << "\n";
     scope_up(out);
   }
 }
@@ -379,53 +407,43 @@ void t_csharp_generator::end_csharp_namespace(ofstream& out) {
 }
 
 string t_csharp_generator::csharp_type_usings() {
-  return string() +
-    "using System;\n" +
-    "using System.Collections;\n" +
-    "using System.Collections.Generic;\n" +
-    "using System.Text;\n" +
-    "using System.IO;\n" +
-    ((async_||async_ctp_) ? "using System.Threading.Tasks;\n" : "") +
-    "using Thrift;\n" +
-    "using Thrift.Collections;\n" +
-    ((serialize_||wcf_) ? "#if !SILVERLIGHT\n" : "") +
-    ((serialize_||wcf_) ? "using System.Xml.Serialization;\n" : "") +
-    ((serialize_||wcf_) ? "#endif\n" : "") +
-    (wcf_ ? "//using System.ServiceModel;\n" : "") +
-    "using System.Runtime.Serialization;\n";
+  return string() + "using System;\n" + "using System.Collections;\n"
+         + "using System.Collections.Generic;\n" + "using System.Text;\n" + "using System.IO;\n"
+         + ((async_ || async_ctp_) ? "using System.Threading.Tasks;\n" : "") + "using Thrift;\n"
+         + "using Thrift.Collections;\n" + ((serialize_ || wcf_) ? "#if !SILVERLIGHT\n" : "")
+         + ((serialize_ || wcf_) ? "using System.Xml.Serialization;\n" : "")
+         + ((serialize_ || wcf_) ? "#endif\n" : "") + (wcf_ ? "//using System.ServiceModel;\n" : "")
+         + "using System.Runtime.Serialization;\n";
 }
 
 string t_csharp_generator::csharp_thrift_usings() {
-  return string() +
-    "using Thrift.Protocol;\n" +
-    "using Thrift.Transport;\n";
+  return string() + "using Thrift.Protocol;\n" + "using Thrift.Transport;\n";
 }
 
-void t_csharp_generator::close_generator() { }
+void t_csharp_generator::close_generator() {
+}
 void t_csharp_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 void t_csharp_generator::generate_enum(t_enum* tenum) {
-  string f_enum_name = namespace_dir_+"/" + (tenum->get_name())+".cs";
+  string f_enum_name = namespace_dir_ + "/" + (tenum->get_name()) + ".cs";
   ofstream f_enum;
   f_enum.open(f_enum_name.c_str());
 
-  f_enum <<
-    autogen_comment() << endl;
+  f_enum << autogen_comment() << endl;
 
   start_csharp_namespace(f_enum);
 
   generate_csharp_doc(f_enum, tenum);
 
-  indent(f_enum) <<
-    "public enum " << tenum->get_name() << "\n";
+  indent(f_enum) << "public enum " << tenum->get_name() << "\n";
   scope_up(f_enum);
 
   vector<t_enum_value*> constants = tenum->get_constants();
   vector<t_enum_value*>::iterator c_iter;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
-        generate_csharp_doc(f_enum, *c_iter);
+    generate_csharp_doc(f_enum, *c_iter);
 
     int value = (*c_iter)->get_value();
     indent(f_enum) << (*c_iter)->get_name() << " = " << value << "," << endl;
@@ -439,28 +457,30 @@ void t_csharp_generator::generate_enum(t_enum* tenum) {
 }
 
 void t_csharp_generator::generate_consts(std::vector<t_const*> consts) {
-  if (consts.empty()){
+  if (consts.empty()) {
     return;
   }
-  string f_consts_name = namespace_dir_ + '/' + program_name_ +  ".Constants.cs";
+  string f_consts_name = namespace_dir_ + '/' + program_name_ + ".Constants.cs";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
-  f_consts <<
-    autogen_comment() <<
-    csharp_type_usings() << endl;
+  f_consts << autogen_comment() << csharp_type_usings() << endl;
 
   start_csharp_namespace(f_consts);
 
-  indent(f_consts) <<
-    "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << endl;
+  indent(f_consts) << "public static class " << make_valid_csharp_identifier(program_name_)
+                   << "Constants" << endl;
   scope_up(f_consts);
 
   vector<t_const*>::iterator c_iter;
   bool need_static_constructor = false;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     generate_csharp_doc(f_consts, (*c_iter));
-    if (print_const_value(f_consts, (*c_iter)->get_name(), (*c_iter)->get_type(), (*c_iter)->get_value(), false)) {
+    if (print_const_value(f_consts,
+                          (*c_iter)->get_name(),
+                          (*c_iter)->get_type(),
+                          (*c_iter)->get_value(),
+                          false)) {
       need_static_constructor = true;
     }
   }
@@ -474,8 +494,10 @@ void t_csharp_generator::generate_consts(std::vector<t_const*> consts) {
   f_consts.close();
 }
 
-void t_csharp_generator::print_const_def_value(std::ofstream& out, string name, t_type* type, t_const_value* value)
-{
+void t_csharp_generator::print_const_def_value(std::ofstream& out,
+                                               string name,
+                                               t_type* type,
+                                               t_const_value* value) {
   if (type->is_struct() || type->is_xception()) {
     const vector<t_field*>& fields = ((t_struct*)type)->get_members();
     vector<t_field*>::const_iterator f_iter;
@@ -503,7 +525,8 @@ void t_csharp_generator::print_const_def_value(std::ofstream& out, string name,
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string key = render_const_value(out, name, ktype, v_iter->first);
       string val = render_const_value(out, name, vtype, v_iter->second);
-      indent(out) << name << "[" << key << "]" << " = " << val << ";" << endl;
+      indent(out) << name << "[" << key << "]"
+                  << " = " << val << ";" << endl;
     }
   } else if (type->is_list() || type->is_set()) {
     t_type* etype;
@@ -523,7 +546,8 @@ void t_csharp_generator::print_const_def_value(std::ofstream& out, string name,
 }
 
 void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector<t_const*> consts) {
-  indent(out) << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << endl;
+  indent(out) << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()"
+              << endl;
   scope_up(out);
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -536,9 +560,15 @@ void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector
   scope_down(out);
 }
 
-
-//it seems like all that methods that call this are using in_static to be the opposite of what it would imply
-bool t_csharp_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval, bool needtype) {
+// it seems like all that methods that call this are using in_static to be the opposite of what it
+// would imply
+bool t_csharp_generator::print_const_value(std::ofstream& out,
+                                           string name,
+                                           t_type* type,
+                                           t_const_value* value,
+                                           bool in_static,
+                                           bool defval,
+                                           bool needtype) {
   indent(out);
   bool need_static_construction = !in_static;
   while (type->is_typedef()) {
@@ -546,16 +576,16 @@ bool t_csharp_generator::print_const_value(std::ofstream& out, string name, t_ty
   }
 
   if (!defval || needtype) {
-    out <<
-      (in_static ? "" : type->is_base_type() ? "public const " : "public static ") <<
-      type_name(type) << " ";
+    out << (in_static ? "" : type->is_base_type() ? "public const " : "public static ")
+        << type_name(type) << " ";
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
     out << name << " = " << v2 << ";" << endl;
     need_static_construction = false;
   } else if (type->is_enum()) {
-    out << name << " = " << type_name(type, false, true) << "." << value->get_identifier_name() << ";" << endl;
+    out << name << " = " << type_name(type, false, true) << "." << value->get_identifier_name()
+        << ";" << endl;
     need_static_construction = false;
   } else if (type->is_struct() || type->is_xception()) {
     out << name << " = new " << type_name(type) << "();" << endl;
@@ -572,34 +602,37 @@ bool t_csharp_generator::print_const_value(std::ofstream& out, string name, t_ty
   return need_static_construction;
 }
 
-std::string t_csharp_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+std::string t_csharp_generator::render_const_value(ofstream& out,
+                                                   string name,
+                                                   t_type* type,
+                                                   t_const_value* value) {
+  (void)name;
   std::ostringstream render;
 
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        render << '"' << get_escaped_string(value) << '"';
-        break;
-      case t_base_type::TYPE_BOOL:
-        render << ((value->get_integer() > 0) ? "true" : "false");
-        break;
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-      case t_base_type::TYPE_I64:
+    case t_base_type::TYPE_STRING:
+      render << '"' << get_escaped_string(value) << '"';
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() > 0) ? "true" : "false");
+      break;
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
         render << value->get_integer();
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        if (value->get_type() == t_const_value::CV_INTEGER) {
-          render << value->get_integer();
-        } else {
-          render << value->get_double();
-        }
-        break;
-      default:
-        throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
     render << type->get_name() << "." << value->get_identifier_name();
@@ -630,17 +663,18 @@ void t_csharp_generator::generate_csharp_struct(t_struct* tstruct, bool is_excep
 
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-    csharp_type_usings() <<
-    csharp_thrift_usings() << endl;
+  f_struct << autogen_comment() << csharp_type_usings() << csharp_thrift_usings() << endl;
 
   generate_csharp_struct_definition(f_struct, tstruct, is_exception);
 
   f_struct.close();
 }
 
-void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_struct* tstruct, bool is_exception, bool in_class, bool is_result) {
+void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
+                                                           t_struct* tstruct,
+                                                           bool is_exception,
+                                                           bool in_class,
+                                                           bool is_result) {
 
   if (!in_class) {
     start_csharp_namespace(out);
@@ -649,17 +683,20 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
   out << endl;
 
   generate_csharp_doc(out, tstruct);
-  prepare_member_name_mapping( tstruct);
+  prepare_member_name_mapping(tstruct);
 
   indent(out) << "#if !SILVERLIGHT" << endl;
   indent(out) << "[Serializable]" << endl;
   indent(out) << "#endif" << endl;
-  if ((serialize_||wcf_) &&!is_exception) {
-    indent(out) << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl; // do not make exception classes directly WCF serializable, we provide a seperate "fault" for that
+  if ((serialize_ || wcf_) && !is_exception) {
+    indent(out) << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]"
+                << endl; // do not make exception classes directly WCF serializable, we provide a
+                         // seperate "fault" for that
   }
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << normalize_name(tstruct->get_name()) << " : ";
+  indent(out) << "public " << (is_final ? "sealed " : "") << "partial class "
+              << normalize_name(tstruct->get_name()) << " : ";
 
   if (is_exception) {
     out << "TException, ";
@@ -673,7 +710,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  //make private members with public Properties
+  // make private members with public Properties
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     // if the field is requied, then we use auto-properties
     if (!field_is_required((*m_iter)) && (!nullable_ || field_has_default((*m_iter)))) {
@@ -700,23 +737,18 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
     }
   }
 
-  bool generate_isset =
-    (nullable_ && has_non_required_default_value_fields)
-    || (!nullable_ && has_non_required_fields);
+  bool generate_isset = (nullable_ && has_non_required_default_value_fields)
+                        || (!nullable_ && has_non_required_fields);
   if (generate_isset) {
-    out <<
-      endl;
-    if(serialize_||wcf_) {
-      out <<
-        indent() << "[XmlIgnore] // XmlSerializer" << endl <<
-        indent() << "[DataMember(Order = 1)]  // XmlObjectSerializer, DataContractJsonSerializer, etc." << endl;
-    }
-    out <<
-      indent() << "public Isset __isset;" << endl <<
-      indent() << "#if !SILVERLIGHT" << endl <<
-      indent() << "[Serializable]" << endl <<
-      indent() << "#endif" << endl;
-    if (serialize_||wcf_) {
+    out << endl;
+    if (serialize_ || wcf_) {
+      out << indent() << "[XmlIgnore] // XmlSerializer" << endl << indent()
+          << "[DataMember(Order = 1)]  // XmlObjectSerializer, DataContractJsonSerializer, etc."
+          << endl;
+    }
+    out << indent() << "public Isset __isset;" << endl << indent() << "#if !SILVERLIGHT" << endl
+        << indent() << "[Serializable]" << endl << indent() << "#endif" << endl;
+    if (serialize_ || wcf_) {
       indent(out) << "[DataContract]" << endl;
     }
     indent(out) << "public struct Isset {" << endl;
@@ -728,7 +760,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
       // if it is not required, if it has a default value, we need to generate Isset
       // if we are not nullable, then we generate Isset
       if (!is_required && (!nullable_ || has_default)) {
-        if(serialize_||wcf_) {
+        if (serialize_ || wcf_) {
           indent(out) << "[DataMember]" << endl;
         }
         indent(out) << "public bool " << normalize_name((*m_iter)->get_name()) << ";" << endl;
@@ -738,7 +770,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
     indent_down();
     indent(out) << "}" << endl << endl;
 
-    if(generate_isset && (serialize_||wcf_)) {
+    if (generate_isset && (serialize_ || wcf_)) {
       indent(out) << "#region XmlSerializer support" << endl << endl;
 
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -774,9 +806,15 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
       if (field_is_required((*m_iter))) {
         print_const_value(out, "this." + prop_name(*m_iter), t, (*m_iter)->get_value(), true, true);
       } else {
-        print_const_value(out, "this._" + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
+        print_const_value(out,
+                          "this._" + (*m_iter)->get_name(),
+                          t,
+                          (*m_iter)->get_value(),
+                          true,
+                          true);
         // Optionals with defaults are marked set
-        indent(out) << "this.__isset." << normalize_name((*m_iter)->get_name()) << " = true;" << endl;
+        indent(out) << "this.__isset." << normalize_name((*m_iter)->get_name()) << " = true;"
+                    << endl;
       }
     }
   }
@@ -801,7 +839,8 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if (field_is_required((*m_iter))) {
-        indent(out) << "this." << prop_name((*m_iter)) << " = " << (*m_iter)->get_name() << ";" << endl;
+        indent(out) << "this." << prop_name((*m_iter)) << " = " << (*m_iter)->get_name() << ";"
+                    << endl;
       }
     }
 
@@ -824,11 +863,11 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru
   out << endl;
 
   // generate a corresponding WCF fault to wrap the exception
-  if((serialize_||wcf_) && is_exception) {
+  if ((serialize_ || wcf_) && is_exception) {
     generate_csharp_wcffault(out, tstruct);
   }
 
-  cleanup_member_name_mapping( tstruct);
+  cleanup_member_name_mapping(tstruct);
   if (!in_class) {
     end_csharp_namespace(out);
   }
@@ -842,7 +881,8 @@ void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstru
   indent(out) << "[DataContract]" << endl;
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << tstruct->get_name() << "Fault" << endl;
+  indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << tstruct->get_name()
+              << "Fault" << endl;
 
   scope_up(out);
 
@@ -851,8 +891,7 @@ void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstru
 
   // make private members with public Properties
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) <<
-    "private " << declare_field(*m_iter, false, "_") << endl;
+    indent(out) << "private " << declare_field(*m_iter, false, "_") << endl;
   }
   out << endl;
 
@@ -865,8 +904,7 @@ void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstru
 }
 
 void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct* tstruct) {
-  indent(out) <<
-    "public void Read (TProtocol iprot)" << endl;
+  indent(out) << "public void Read (TProtocol iprot)" << endl;
   scope_up(out);
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -879,38 +917,28 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
     }
   }
 
-  indent(out) <<
-    "TField field;" << endl <<
-    indent() << "iprot.ReadStructBegin();" << endl;
+  indent(out) << "TField field;" << endl << indent() << "iprot.ReadStructBegin();" << endl;
 
-  indent(out) <<
-    "while (true)" << endl;
+  indent(out) << "while (true)" << endl;
   scope_up(out);
 
-  indent(out) <<
-    "field = iprot.ReadFieldBegin();" << endl;
+  indent(out) << "field = iprot.ReadFieldBegin();" << endl;
 
-  indent(out) <<
-    "if (field.Type == TType.Stop) { " << endl;
+  indent(out) << "if (field.Type == TType.Stop) { " << endl;
   indent_up();
-  indent(out) <<
-    "break;" << endl;
+  indent(out) << "break;" << endl;
   indent_down();
-  indent(out) <<
-    "}" << endl;
+  indent(out) << "}" << endl;
 
-  indent(out) <<
-    "switch (field.ID)" << endl;
+  indent(out) << "switch (field.ID)" << endl;
 
   scope_up(out);
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool is_required = field_is_required((*f_iter));
-    indent(out) <<
-      "case " << (*f_iter)->get_key() << ":" << endl;
+    indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
     indent_up();
-    indent(out) <<
-      "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent(out) << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
     indent_up();
 
     generate_deserialize_field(out, *f_iter);
@@ -919,16 +947,12 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
     }
 
     indent_down();
-    out <<
-      indent() << "} else { " << endl <<
-      indent() << "  TProtocolUtil.Skip(iprot, field.Type);" << endl <<
-      indent() << "}" << endl <<
-      indent() << "break;" << endl;
+    out << indent() << "} else { " << endl << indent() << "  TProtocolUtil.Skip(iprot, field.Type);"
+        << endl << indent() << "}" << endl << indent() << "break;" << endl;
     indent_down();
   }
 
-  indent(out) <<
-    "default: " << endl;
+  indent(out) << "default: " << endl;
   indent_up();
   indent(out) << "TProtocolUtil.Skip(iprot, field.Type);" << endl;
   indent(out) << "break;" << endl;
@@ -936,13 +960,11 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
 
   scope_down(out);
 
-  indent(out) <<
-    "iprot.ReadFieldEnd();" << endl;
+  indent(out) << "iprot.ReadFieldEnd();" << endl;
 
   scope_down(out);
 
-  indent(out) <<
-    "iprot.ReadStructEnd();" << endl;
+  indent(out) << "iprot.ReadStructEnd();" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (field_is_required((*f_iter))) {
@@ -956,22 +978,18 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
   indent_down();
 
   indent(out) << "}" << endl << endl;
-
 }
 
 void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct* tstruct) {
-  out <<
-    indent() << "public void Write(TProtocol oprot) {" << endl;
+  out << indent() << "public void Write(TProtocol oprot) {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
 
-  indent(out) <<
-    "TStruct struc = new TStruct(\"" << name << "\");" << endl;
-  indent(out) <<
-    "oprot.WriteStructBegin(struc);" << endl;
+  indent(out) << "TStruct struc = new TStruct(\"" << name << "\");" << endl;
+  indent(out) << "oprot.WriteStructBegin(struc);" << endl;
 
   if (fields.size() > 0) {
     indent(out) << "TField field = new TField();" << endl;
@@ -984,12 +1002,11 @@ void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct*
       } else if (!is_required) {
         bool null_allowed = type_can_be_null((*f_iter)->get_type());
         if (null_allowed) {
-          indent(out) <<
-            "if (" << prop_name((*f_iter)) << " != null && __isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
+          indent(out) << "if (" << prop_name((*f_iter)) << " != null && __isset."
+                      << normalize_name((*f_iter)->get_name()) << ") {" << endl;
           indent_up();
         } else {
-          indent(out) <<
-            "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
+          indent(out) << "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
           indent_up();
         }
       }
@@ -1017,18 +1034,15 @@ void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct*
 }
 
 void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_struct* tstruct) {
-  indent(out) <<
-    "public void Write(TProtocol oprot) {" << endl;
+  indent(out) << "public void Write(TProtocol oprot) {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
 
-  indent(out) <<
-    "TStruct struc = new TStruct(\"" << name << "\");" << endl;
-  indent(out) <<
-    "oprot.WriteStructBegin(struc);" << endl;
+  indent(out) << "TStruct struc = new TStruct(\"" << name << "\");" << endl;
+  indent(out) << "oprot.WriteStructBegin(struc);" << endl;
 
   if (fields.size() > 0) {
     indent(out) << "TField field = new TField();" << endl;
@@ -1050,24 +1064,18 @@ void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_s
 
       bool null_allowed = !nullable_ && type_can_be_null((*f_iter)->get_type());
       if (null_allowed) {
-        indent(out) <<
-          "if (" << prop_name(*f_iter) << " != null) {" << endl;
+        indent(out) << "if (" << prop_name(*f_iter) << " != null) {" << endl;
         indent_up();
       }
 
-      indent(out) <<
-        "field.Name = \"" << prop_name(*f_iter) << "\";" << endl;
-      indent(out) <<
-        "field.Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl;
-      indent(out) <<
-        "field.ID = " << (*f_iter)->get_key() << ";" << endl;
-      indent(out) <<
-        "oprot.WriteFieldBegin(field);" << endl;
+      indent(out) << "field.Name = \"" << prop_name(*f_iter) << "\";" << endl;
+      indent(out) << "field.Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl;
+      indent(out) << "field.ID = " << (*f_iter)->get_key() << ";" << endl;
+      indent(out) << "oprot.WriteFieldBegin(field);" << endl;
 
       generate_serialize_field(out, *f_iter);
 
-      indent(out) <<
-        "oprot.WriteFieldEnd();" << endl;
+      indent(out) << "oprot.WriteFieldEnd();" << endl;
 
       if (null_allowed) {
         indent_down();
@@ -1079,38 +1087,34 @@ void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_s
     }
   }
 
-  out <<
-    endl <<
-    indent() << "oprot.WriteFieldStop();" << endl <<
-    indent() << "oprot.WriteStructEnd();" << endl;
+  out << endl << indent() << "oprot.WriteFieldStop();" << endl << indent()
+      << "oprot.WriteStructEnd();" << endl;
 
   indent_down();
 
-  indent(out) <<
-    "}" << endl << endl;
+  indent(out) << "}" << endl << endl;
 }
 
 void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct* tstruct) {
-  indent(out) <<
-    "public override string ToString() {" << endl;
+  indent(out) << "public override string ToString() {" << endl;
   indent_up();
 
-  indent(out) <<
-    "StringBuilder __sb = new StringBuilder(\"" << tstruct->get_name() << "(\");" << endl;
+  indent(out) << "StringBuilder __sb = new StringBuilder(\"" << tstruct->get_name() << "(\");"
+              << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   bool useFirstFlag = false;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    if( ! field_is_required((*f_iter))) {
+    if (!field_is_required((*f_iter))) {
       indent(out) << "bool __first = true;" << endl;
       useFirstFlag = true;
     }
     break;
   }
 
-  bool had_required = false;  // set to true after first required field has been processed
+  bool had_required = false; // set to true after first required field has been processed
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool is_required = field_is_required((*f_iter));
@@ -1121,66 +1125,55 @@ void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct
     } else if (!is_required) {
       bool null_allowed = type_can_be_null((*f_iter)->get_type());
       if (null_allowed) {
-        indent(out) <<
-          "if (" << prop_name((*f_iter)) << " != null && __isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
+        indent(out) << "if (" << prop_name((*f_iter)) << " != null && __isset."
+                    << normalize_name((*f_iter)->get_name()) << ") {" << endl;
         indent_up();
       } else {
-        indent(out) <<
-          "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
+        indent(out) << "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
         indent_up();
       }
     }
 
-    if( useFirstFlag && (! had_required)) {
+    if (useFirstFlag && (!had_required)) {
       indent(out) << "if(!__first) { __sb.Append(\", \"); }" << endl;
-      if( ! is_required) {
+      if (!is_required) {
         indent(out) << "__first = false;" << endl;
       }
-      indent(out) <<
-        "__sb.Append(\"" << prop_name((*f_iter)) << ": \");" << endl;
+      indent(out) << "__sb.Append(\"" << prop_name((*f_iter)) << ": \");" << endl;
     } else {
-      indent(out) <<
-        "__sb.Append(\", " << prop_name((*f_iter)) << ": \");" << endl;
+      indent(out) << "__sb.Append(\", " << prop_name((*f_iter)) << ": \");" << endl;
     }
 
-
     t_type* ttype = (*f_iter)->get_type();
     if (ttype->is_xception() || ttype->is_struct()) {
-      indent(out) <<
-        "__sb.Append(" << prop_name((*f_iter)) << "== null ? \"<null>\" : "<< prop_name((*f_iter))  << ".ToString());" << endl;
+      indent(out) << "__sb.Append(" << prop_name((*f_iter))
+                  << "== null ? \"<null>\" : " << prop_name((*f_iter)) << ".ToString());" << endl;
     } else {
-      indent(out) <<
-        "__sb.Append(" << prop_name((*f_iter))  << ");" << endl;
+      indent(out) << "__sb.Append(" << prop_name((*f_iter)) << ");" << endl;
     }
 
     if (!is_required) {
       indent_down();
       indent(out) << "}" << endl;
     } else {
-      had_required = true;  // now __first must be false, so we don't need to check it anymore
+      had_required = true; // now __first must be false, so we don't need to check it anymore
     }
   }
 
-  indent(out) <<
-    "__sb.Append(\")\");" << endl;
-  indent(out) <<
-    "return __sb.ToString();" << endl;
+  indent(out) << "__sb.Append(\")\");" << endl;
+  indent(out) << "return __sb.ToString();" << endl;
 
   indent_down();
   indent(out) << "}" << endl << endl;
 }
 
-
 void t_csharp_generator::generate_csharp_union(t_struct* tunion) {
   string f_union_name = namespace_dir_ + "/" + (tunion->get_name()) + ".cs";
   ofstream f_union;
 
   f_union.open(f_union_name.c_str());
 
-  f_union <<
-    autogen_comment() <<
-    csharp_type_usings() <<
-    csharp_thrift_usings() << endl;
+  f_union << autogen_comment() << csharp_type_usings() << csharp_thrift_usings() << endl;
 
   generate_csharp_union_definition(f_union, tunion);
 
@@ -1191,7 +1184,8 @@ void t_csharp_generator::generate_csharp_union_definition(std::ofstream& out, t_
   // Let's define the class first
   start_csharp_namespace(out);
 
-  indent(out) << "public abstract partial class " << tunion->get_name() << " : TAbstractBase {" << endl;
+  indent(out) << "public abstract partial class " << tunion->get_name() << " : TAbstractBase {"
+              << endl;
 
   indent_up();
 
@@ -1214,7 +1208,8 @@ void t_csharp_generator::generate_csharp_union_definition(std::ofstream& out, t_
 
   indent(out) << "public override void Write(TProtocol protocol) {" << endl;
   indent_up();
-  indent(out) << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << endl;
+  indent(out) << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist "
+                 "an union type which is not set.\");" << endl;
   indent_down();
   indent(out) << "}" << endl << endl;
 
@@ -1236,12 +1231,16 @@ void t_csharp_generator::generate_csharp_union_definition(std::ofstream& out, t_
   end_csharp_namespace(out);
 }
 
-void t_csharp_generator::generate_csharp_union_class(std::ofstream& out, t_struct* tunion, t_field* tfield) {
-  indent(out) << "public class " << tfield->get_name() << " : " << tunion->get_name() << " {" << endl;
+void t_csharp_generator::generate_csharp_union_class(std::ofstream& out,
+                                                     t_struct* tunion,
+                                                     t_field* tfield) {
+  indent(out) << "public class " << tfield->get_name() << " : " << tunion->get_name() << " {"
+              << endl;
   indent_up();
   indent(out) << "private " << type_name(tfield->get_type()) << " _data;" << endl;
   indent(out) << "public override object Data { get { return _data; } }" << endl;
-  indent(out) << "public " << tfield->get_name() << "(" << type_name(tfield->get_type()) << " data) : base(true) {" << endl;
+  indent(out) << "public " << tfield->get_name() << "(" << type_name(tfield->get_type())
+              << " data) : base(true) {" << endl;
   indent_up();
   indent(out) << "this._data = data;" << endl;
   indent_down();
@@ -1269,7 +1268,6 @@ void t_csharp_generator::generate_csharp_union_class(std::ofstream& out, t_struc
   indent(out) << "}" << endl << endl;
 }
 
-
 void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct* tstruct) {
   indent(out) << "public override bool Equals(object that) {" << endl;
   indent_up();
@@ -1293,9 +1291,9 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
       indent(out) << "&& ";
     }
     if (!field_is_required((*f_iter)) && !(nullable_ && !field_has_default((*f_iter)))) {
-      out << "((__isset." << normalize_name((*f_iter)->get_name())
-          << " == other.__isset." << normalize_name((*f_iter)->get_name())
-          << ") && ((!__isset." << normalize_name((*f_iter)->get_name()) << ") || (";
+      out << "((__isset." << normalize_name((*f_iter)->get_name()) << " == other.__isset."
+          << normalize_name((*f_iter)->get_name()) << ") && ((!__isset."
+          << normalize_name((*f_iter)->get_name()) << ") || (";
     }
     t_type* ttype = (*f_iter)->get_type();
     if (ttype->is_container()) {
@@ -1334,20 +1332,16 @@ void t_csharp_generator::generate_csharp_struct_hashcode(ofstream& out, t_struct
     t_type* ttype = (*f_iter)->get_type();
     indent(out) << "hashcode = (hashcode * 397) ^ ";
     if (field_is_required((*f_iter))) {
-    out << "(";
-    } else if ( nullable_) {
+      out << "(";
+    } else if (nullable_) {
       out << "(" << prop_name((*f_iter)) << " == null ? 0 : ";
-    }else {
+    } else {
       out << "(!__isset." << normalize_name((*f_iter)->get_name()) << " ? 0 : ";
     }
     if (ttype->is_container()) {
-            out << "(TCollections.GetHashCode("
-                    << prop_name((*f_iter))
-                    << "))";
+      out << "(TCollections.GetHashCode(" << prop_name((*f_iter)) << "))";
     } else {
-                out << "("
-                        << prop_name((*f_iter))
-                        << ".GetHashCode())";
+      out << "(" << prop_name((*f_iter)) << ".GetHashCode())";
     }
     out << ");" << endl;
   }
@@ -1364,15 +1358,11 @@ void t_csharp_generator::generate_service(t_service* tservice) {
   string f_service_name = namespace_dir_ + "/" + service_name_ + ".cs";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    autogen_comment() <<
-    csharp_type_usings() <<
-    csharp_thrift_usings() << endl;
+  f_service_ << autogen_comment() << csharp_type_usings() << csharp_thrift_usings() << endl;
 
   start_csharp_namespace(f_service_);
 
-  indent(f_service_) <<
-    "public partial class " << normalize_name(service_name_) << " {" << endl;
+  indent(f_service_) << "public partial class " << normalize_name(service_name_) << " {" << endl;
   indent_up();
 
   generate_service_interface(tservice);
@@ -1382,8 +1372,7 @@ void t_csharp_generator::generate_service(t_service* tservice) {
 
   indent_down();
 
-  indent(f_service_) <<
-    "}" << endl;
+  indent(f_service_) << "}" << endl;
   end_csharp_namespace(f_service_);
   f_service_.close();
 }
@@ -1399,51 +1388,43 @@ void t_csharp_generator::generate_service_interface(t_service* tservice) {
   generate_csharp_doc(f_service_, tservice);
 
   if (wcf_) {
-          indent(f_service_) <<
-                "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl;
+    indent(f_service_) << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl;
   }
-  indent(f_service_) <<
-    "public interface Iface" << extends_iface << " {" << endl;
+  indent(f_service_) << "public interface Iface" << extends_iface << " {" << endl;
 
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
-  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
-  {
-        generate_csharp_doc(f_service_, *f_iter);
-
-        // if we're using WCF, add the corresponding attributes
-        if (wcf_) {
-                indent(f_service_) <<
-                        "[OperationContract]" << endl;
-
-                const std::vector<t_field*>& xceptions = (*f_iter)->get_xceptions()->get_members();
-                vector<t_field*>::const_iterator x_iter;
-                for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-                  indent(f_service_) << "[FaultContract(typeof(" + type_name((*x_iter)->get_type(), false, false) + "Fault))]" << endl;
-                }
-        }
+  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
+    generate_csharp_doc(f_service_, *f_iter);
+
+    // if we're using WCF, add the corresponding attributes
+    if (wcf_) {
+      indent(f_service_) << "[OperationContract]" << endl;
 
-    indent(f_service_) <<
-      function_signature(*f_iter) << ";" << endl;
-    if(!async_) {
+      const std::vector<t_field*>& xceptions = (*f_iter)->get_xceptions()->get_members();
+      vector<t_field*>::const_iterator x_iter;
+      for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
+        indent(f_service_) << "[FaultContract(typeof("
+                              + type_name((*x_iter)->get_type(), false, false) + "Fault))]" << endl;
+      }
+    }
+
+    indent(f_service_) << function_signature(*f_iter) << ";" << endl;
+    if (!async_) {
       indent(f_service_) << "#if SILVERLIGHT" << endl;
     }
-    indent(f_service_) <<
-      function_signature_async_begin(*f_iter, "Begin_") << ";" << endl;
-    indent(f_service_) <<
-      function_signature_async_end(*f_iter, "End_") << ";" << endl;
-    if(async_||async_ctp_) {
-      indent(f_service_) <<
-        function_signature_async(*f_iter) << ";" << endl;
+    indent(f_service_) << function_signature_async_begin(*f_iter, "Begin_") << ";" << endl;
+    indent(f_service_) << function_signature_async_end(*f_iter, "End_") << ";" << endl;
+    if (async_ || async_ctp_) {
+      indent(f_service_) << function_signature_async(*f_iter) << ";" << endl;
     }
     if (!async_) {
       indent(f_service_) << "#endif" << endl;
     }
   }
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl << endl;
+  f_service_ << indent() << "}" << endl << endl;
 }
 
 void t_csharp_generator::generate_service_helpers(t_service* tservice) {
@@ -1469,17 +1450,14 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
 
   generate_csharp_doc(f_service_, tservice);
 
-  indent(f_service_) <<
-    "public class Client : " << extends_client << "Iface {" << endl;
+  indent(f_service_) << "public class Client : " << extends_client << "Iface {" << endl;
   indent_up();
-  indent(f_service_) <<
-    "public Client(TProtocol prot) : this(prot, prot)" << endl;
+  indent(f_service_) << "public Client(TProtocol prot) : this(prot, prot)" << endl;
   scope_up(f_service_);
   scope_down(f_service_);
   f_service_ << endl;
 
-  indent(f_service_) <<
-    "public Client(TProtocol iprot, TProtocol oprot)";
+  indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)";
   if (!extends.empty()) {
     f_service_ << " : base(iprot, oprot)";
   }
@@ -1487,19 +1465,16 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
 
   scope_up(f_service_);
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "iprot_ = iprot;" << endl <<
-      indent() << "oprot_ = oprot;" << endl;
+    f_service_ << indent() << "iprot_ = iprot;" << endl << indent() << "oprot_ = oprot;" << endl;
   }
   scope_down(f_service_);
 
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected TProtocol iprot_;" << endl <<
-      indent() << "protected TProtocol oprot_;" << endl <<
-      indent() << "protected int seqid_;" << endl << endl;
+    f_service_ << indent() << "protected TProtocol iprot_;" << endl << indent()
+               << "protected TProtocol oprot_;" << endl << indent() << "protected int seqid_;"
+               << endl << endl;
 
     f_service_ << indent() << "public TProtocol InputProtocol" << endl;
     scope_up(f_service_);
@@ -1553,14 +1528,13 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
       indent(f_service_) << "#if SILVERLIGHT" << endl;
     }
     // Begin_
-    indent(f_service_) <<
-      "public " << function_signature_async_begin(*f_iter, "Begin_") << endl;
+    indent(f_service_) << "public " << function_signature_async_begin(*f_iter, "Begin_") << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return " << "send_" << funname << "(callback, state";
+    indent(f_service_) << "return "
+                       << "send_" << funname << "(callback, state";
 
     t_struct* arg_struct = (*f_iter)->get_arglist();
-    prepare_member_name_mapping( arg_struct);
+    prepare_member_name_mapping(arg_struct);
 
     const vector<t_field*>& fields = arg_struct->get_members();
     vector<t_field*>::const_iterator fld_iter;
@@ -1573,34 +1547,28 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
     f_service_ << endl;
 
     // End
-    indent(f_service_) <<
-      "public " << function_signature_async_end(*f_iter, "End_") << endl;
+    indent(f_service_) << "public " << function_signature_async_end(*f_iter, "End_") << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "oprot_.Transport.EndFlush(asyncResult);" << endl;
+    indent(f_service_) << "oprot_.Transport.EndFlush(asyncResult);" << endl;
     if (!(*f_iter)->is_oneway()) {
       f_service_ << indent();
       if (!(*f_iter)->get_returntype()->is_void()) {
         f_service_ << "return ";
       }
-      f_service_ <<
-        "recv_" << funname << "();" << endl;
+      f_service_ << "recv_" << funname << "();" << endl;
     }
     scope_down(f_service_);
     f_service_ << endl;
 
     // async
     bool first;
-    if( async_||async_ctp_) {
-      indent(f_service_) <<
-        "public async " << function_signature_async(*f_iter, "") << endl;
+    if (async_ || async_ctp_) {
+      indent(f_service_) << "public async " << function_signature_async(*f_iter, "") << endl;
       scope_up(f_service_);
 
       if (!(*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          type_name( (*f_iter)->get_returntype()) << " retval;" << endl;
-        indent(f_service_) <<
-          "retval = ";
+        indent(f_service_) << type_name((*f_iter)->get_returntype()) << " retval;" << endl;
+        indent(f_service_) << "retval = ";
       } else {
         indent(f_service_);
       }
@@ -1612,12 +1580,10 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
       scope_up(f_service_);
       indent(f_service_);
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          "return ";
+        f_service_ << "return ";
       }
-      f_service_ <<
-        funname << "(";
-          first = true;
+      f_service_ << funname << "(";
+      first = true;
       for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
         if (first) {
           first = false;
@@ -1628,13 +1594,11 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
       }
       f_service_ << ");" << endl;
       indent_down();
-      indent(f_service_) <<
-        "});" << endl;
+      indent(f_service_) << "});" << endl;
       if (!(*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "return retval;"  << endl;
+        indent(f_service_) << "return retval;" << endl;
       }
-          scope_down(f_service_);
+      scope_down(f_service_);
       f_service_ << endl;
     }
 
@@ -1644,14 +1608,12 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
 
     // "Normal" Synchronous invoke
     generate_csharp_doc(f_service_, *f_iter);
-    indent(f_service_) <<
-      "public " << function_signature(*f_iter) << endl;
+    indent(f_service_) << "public " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
 
     if (!async_) {
       indent(f_service_) << "#if !SILVERLIGHT" << endl;
-      indent(f_service_) <<
-        "send_" << funname << "(";
+      indent(f_service_) << "send_" << funname << "(";
 
       first = true;
       for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -1669,8 +1631,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
         if (!(*f_iter)->get_returntype()->is_void()) {
           f_service_ << "return ";
         }
-        f_service_ <<
-          "recv_" << funname << "();" << endl;
+        f_service_ << "recv_" << funname << "();" << endl;
       }
       f_service_ << endl;
 
@@ -1689,8 +1650,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void()) {
         f_service_ << "return ";
       }
-      f_service_ <<
-        "End_" << funname << "(asyncResult);" << endl;
+      f_service_ << "End_" << funname << "(asyncResult);" << endl;
     }
     f_service_ << endl;
 
@@ -1701,8 +1661,8 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
 
     // Send
     t_function send_function(g_type_void,
-        string("send_") + (*f_iter)->get_name(),
-        (*f_iter)->get_arglist());
+                             string("send_") + (*f_iter)->get_name(),
+                             (*f_iter)->get_arglist());
 
     string argsname = (*f_iter)->get_name() + "_args";
 
@@ -1717,20 +1677,19 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
     }
     scope_up(f_service_);
 
-    f_service_ <<
-      indent() << "oprot_.WriteMessageBegin(new TMessage(\"" << funname << "\", " <<
-      ((*f_iter)->is_oneway() ? "TMessageType.Oneway" : "TMessageType.Call") <<
-      ", seqid_));" << endl <<
-      indent() << argsname << " args = new " << argsname << "();" << endl;
+    f_service_ << indent() << "oprot_.WriteMessageBegin(new TMessage(\"" << funname << "\", "
+               << ((*f_iter)->is_oneway() ? "TMessageType.Oneway" : "TMessageType.Call")
+               << ", seqid_));" << endl << indent() << argsname << " args = new " << argsname
+               << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args." << prop_name(*fld_iter) << " = " << normalize_name((*fld_iter)->get_name()) << ";" << endl;
+      f_service_ << indent() << "args." << prop_name(*fld_iter) << " = "
+                 << normalize_name((*fld_iter)->get_name()) << ";" << endl;
     }
 
-    f_service_ <<
-      indent() << "args.Write(oprot_);" << endl <<
-      indent() << "oprot_.WriteMessageEnd();" << endl;;
+    f_service_ << indent() << "args.Write(oprot_);" << endl << indent()
+               << "oprot_.WriteMessageEnd();" << endl;
+    ;
 
     if (!async_) {
       indent(f_service_) << "#if SILVERLIGHT" << endl;
@@ -1742,7 +1701,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
       indent(f_service_) << "#endif" << endl;
     }
 
-    cleanup_member_name_mapping( arg_struct);
+    cleanup_member_name_mapping(arg_struct);
     scope_down(f_service_);
     f_service_ << endl;
 
@@ -1751,85 +1710,72 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
 
       t_struct noargs(program_);
       t_function recv_function((*f_iter)->get_returntype(),
-          string("recv_") + (*f_iter)->get_name(),
-          &noargs,
-          (*f_iter)->get_xceptions());
-      indent(f_service_) <<
-        "public " << function_signature(&recv_function) << endl;
+                               string("recv_") + (*f_iter)->get_name(),
+                               &noargs,
+                               (*f_iter)->get_xceptions());
+      indent(f_service_) << "public " << function_signature(&recv_function) << endl;
       scope_up(f_service_);
-      prepare_member_name_mapping( (*f_iter)->get_xceptions());
+      prepare_member_name_mapping((*f_iter)->get_xceptions());
 
-      f_service_ <<
-        indent() << "TMessage msg = iprot_.ReadMessageBegin();" << endl <<
-        indent() << "if (msg.Type == TMessageType.Exception) {" << endl;
+      f_service_ << indent() << "TMessage msg = iprot_.ReadMessageBegin();" << endl << indent()
+                 << "if (msg.Type == TMessageType.Exception) {" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "TApplicationException x = TApplicationException.Read(iprot_);" << endl <<
-        indent() << "iprot_.ReadMessageEnd();" << endl <<
-        indent() << "throw x;" << endl;
+      f_service_ << indent() << "TApplicationException x = TApplicationException.Read(iprot_);"
+                 << endl << indent() << "iprot_.ReadMessageEnd();" << endl << indent() << "throw x;"
+                 << endl;
       indent_down();
-      f_service_ <<
-        indent() << "}" << endl <<
-        indent() << resultname << " result = new " << resultname << "();" << endl <<
-        indent() << "result.Read(iprot_);" << endl <<
-        indent() << "iprot_.ReadMessageEnd();" << endl;
+      f_service_ << indent() << "}" << endl << indent() << resultname << " result = new "
+                 << resultname << "();" << endl << indent() << "result.Read(iprot_);" << endl
+                 << indent() << "iprot_.ReadMessageEnd();" << endl;
 
       if (!(*f_iter)->get_returntype()->is_void()) {
         if (nullable_) {
           if (type_can_be_null((*f_iter)->get_returntype())) {
-            f_service_ <<
-              indent() << "if (result.Success != null) {" << endl <<
-              indent() << "  return result.Success;" << endl <<
-              indent() << "}" << endl;
+            f_service_ << indent() << "if (result.Success != null) {" << endl << indent()
+                       << "  return result.Success;" << endl << indent() << "}" << endl;
           } else {
-            f_service_ <<
-              indent() << "if (result.Success.HasValue) {" << endl <<
-              indent() << "  return result.Success.Value;" << endl <<
-              indent() << "}" << endl;
+            f_service_ << indent() << "if (result.Success.HasValue) {" << endl << indent()
+                       << "  return result.Success.Value;" << endl << indent() << "}" << endl;
           }
         } else {
-          f_service_ <<
-            indent() << "if (result.__isset.success) {" << endl <<
-            indent() << "  return result.Success;" << endl <<
-            indent() << "}" << endl;
+          f_service_ << indent() << "if (result.__isset.success) {" << endl << indent()
+                     << "  return result.Success;" << endl << indent() << "}" << endl;
         }
       }
 
-      t_struct *xs = (*f_iter)->get_xceptions();
+      t_struct* xs = (*f_iter)->get_xceptions();
 
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
         if (nullable_) {
-          f_service_ <<
-            indent() << "if (result." << prop_name(*x_iter) << " != null) {" << endl <<
-            indent() << "  throw result." << prop_name(*x_iter) << ";" << endl <<
-            indent() << "}" << endl;
+          f_service_ << indent() << "if (result." << prop_name(*x_iter) << " != null) {" << endl
+                     << indent() << "  throw result." << prop_name(*x_iter) << ";" << endl
+                     << indent() << "}" << endl;
         } else {
-          f_service_ <<
-            indent() << "if (result.__isset." << normalize_name((*x_iter)->get_name()) << ") {" << endl <<
-            indent() << "  throw result." << prop_name(*x_iter) << ";" << endl <<
-            indent() << "}" << endl;
+          f_service_ << indent() << "if (result.__isset." << normalize_name((*x_iter)->get_name())
+                     << ") {" << endl << indent() << "  throw result." << prop_name(*x_iter) << ";"
+                     << endl << indent() << "}" << endl;
         }
       }
 
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "return;" << endl;
+        indent(f_service_) << "return;" << endl;
       } else {
-        f_service_ <<
-          indent() << "throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+        f_service_ << indent()
+                   << "throw new "
+                      "TApplicationException(TApplicationException.ExceptionType.MissingResult, \""
+                   << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
       }
 
-      cleanup_member_name_mapping( (*f_iter)->get_xceptions());
+      cleanup_member_name_mapping((*f_iter)->get_xceptions());
       scope_down(f_service_);
       f_service_ << endl;
     }
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl;
+  indent(f_service_) << "}" << endl;
 }
 
 void t_csharp_generator::generate_service_server(t_service* tservice) {
@@ -1843,98 +1789,84 @@ void t_csharp_generator::generate_service_server(t_service* tservice) {
     extends_processor = extends + ".Processor, ";
   }
 
-  indent(f_service_) <<
-    "public class Processor : " << extends_processor << "TProcessor {" << endl;
+  indent(f_service_) << "public class Processor : " << extends_processor << "TProcessor {" << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public Processor(Iface iface)" ;
+  indent(f_service_) << "public Processor(Iface iface)";
   if (!extends.empty()) {
     f_service_ << " : base(iface)";
   }
   f_service_ << endl;
   scope_up(f_service_);
-  f_service_ <<
-    indent() << "iface_ = iface;" << endl;
+  f_service_ << indent() << "iface_ = iface;" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "processMap_[\"" << (*f_iter)->get_name() << "\"] = " << (*f_iter)->get_name() << "_Process;" << endl;
+    f_service_ << indent() << "processMap_[\"" << (*f_iter)->get_name()
+               << "\"] = " << (*f_iter)->get_name() << "_Process;" << endl;
   }
 
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected delegate void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);" << endl;
+    f_service_
+        << indent()
+        << "protected delegate void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);"
+        << endl;
   }
 
-  f_service_ <<
-    indent() << "private Iface iface_;" << endl;
+  f_service_ << indent() << "private Iface iface_;" << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected Dictionary<string, ProcessFunction> processMap_ = new Dictionary<string, ProcessFunction>();" << endl;
+    f_service_ << indent() << "protected Dictionary<string, ProcessFunction> processMap_ = new "
+                              "Dictionary<string, ProcessFunction>();" << endl;
   }
 
   f_service_ << endl;
 
   if (extends.empty()) {
-    indent(f_service_) <<
-      "public bool Process(TProtocol iprot, TProtocol oprot)" << endl;
-  }
-  else
-  {
-    indent(f_service_) <<
-      "public new bool Process(TProtocol iprot, TProtocol oprot)" << endl;
+    indent(f_service_) << "public bool Process(TProtocol iprot, TProtocol oprot)" << endl;
+  } else {
+    indent(f_service_) << "public new bool Process(TProtocol iprot, TProtocol oprot)" << endl;
   }
   scope_up(f_service_);
 
-  f_service_ <<  indent() << "try" << endl;
+  f_service_ << indent() << "try" << endl;
   scope_up(f_service_);
 
-  f_service_ <<
-    indent() << "TMessage msg = iprot.ReadMessageBegin();" << endl;
-
-  f_service_ <<
-    indent() << "ProcessFunction fn;" << endl <<
-    indent() << "processMap_.TryGetValue(msg.Name, out fn);" << endl <<
-    indent() << "if (fn == null) {" << endl <<
-    indent() << "  TProtocolUtil.Skip(iprot, TType.Struct);" << endl <<
-    indent() << "  iprot.ReadMessageEnd();" << endl <<
-    indent() << "  TApplicationException x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + msg.Name + \"'\");" << endl <<
-    indent() << "  oprot.WriteMessageBegin(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID));" << endl <<
-    indent() << "  x.Write(oprot);" << endl <<
-    indent() << "  oprot.WriteMessageEnd();" << endl <<
-    indent() << "  oprot.Transport.Flush();" << endl <<
-    indent() << "  return true;" << endl <<
-    indent() << "}" << endl <<
-    indent() << "fn(msg.SeqID, iprot, oprot);" << endl;
+  f_service_ << indent() << "TMessage msg = iprot.ReadMessageBegin();" << endl;
+
+  f_service_
+      << indent() << "ProcessFunction fn;" << endl << indent()
+      << "processMap_.TryGetValue(msg.Name, out fn);" << endl << indent() << "if (fn == null) {"
+      << endl << indent() << "  TProtocolUtil.Skip(iprot, TType.Struct);" << endl << indent()
+      << "  iprot.ReadMessageEnd();" << endl << indent()
+      << "  TApplicationException x = new TApplicationException "
+         "(TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + "
+         "msg.Name + \"'\");" << endl << indent()
+      << "  oprot.WriteMessageBegin(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID));"
+      << endl << indent() << "  x.Write(oprot);" << endl << indent() << "  oprot.WriteMessageEnd();"
+      << endl << indent() << "  oprot.Transport.Flush();" << endl << indent() << "  return true;"
+      << endl << indent() << "}" << endl << indent() << "fn(msg.SeqID, iprot, oprot);" << endl;
 
   scope_down(f_service_);
 
-  f_service_ <<
-    indent() << "catch (IOException)" << endl;
+  f_service_ << indent() << "catch (IOException)" << endl;
   scope_up(f_service_);
-  f_service_ <<
-    indent() << "return false;" << endl;
+  f_service_ << indent() << "return false;" << endl;
   scope_down(f_service_);
 
-  f_service_ <<
-    indent() << "return true;" << endl;
+  f_service_ << indent() << "return true;" << endl;
 
   scope_down(f_service_);
   f_service_ << endl;
 
-  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
-  {
+  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     generate_process_function(tservice, *f_iter);
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl << endl;
+  indent(f_service_) << "}" << endl << endl;
 }
 
 void t_csharp_generator::generate_function_helpers(t_function* tfunction) {
@@ -1948,7 +1880,7 @@ void t_csharp_generator::generate_function_helpers(t_function* tfunction) {
     result.append(&success);
   }
 
-  t_struct *xs = tfunction->get_xceptions();
+  t_struct* xs = tfunction->get_xceptions();
   const vector<t_field*>& fields = xs->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1959,31 +1891,27 @@ void t_csharp_generator::generate_function_helpers(t_function* tfunction) {
 }
 
 void t_csharp_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
-  (void) tservice;
-  indent(f_service_) <<
-    "public void " << tfunction->get_name() << "_Process(int seqid, TProtocol iprot, TProtocol oprot)" << endl;
+  (void)tservice;
+  indent(f_service_) << "public void " << tfunction->get_name()
+                     << "_Process(int seqid, TProtocol iprot, TProtocol oprot)" << endl;
   scope_up(f_service_);
 
   string argsname = tfunction->get_name() + "_args";
   string resultname = tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << argsname << " args = new " << argsname << "();" << endl <<
-    indent() << "args.Read(iprot);" << endl <<
-    indent() << "iprot.ReadMessageEnd();" << endl;
+  f_service_ << indent() << argsname << " args = new " << argsname << "();" << endl << indent()
+             << "args.Read(iprot);" << endl << indent() << "iprot.ReadMessageEnd();" << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
   vector<t_field*>::const_iterator x_iter;
 
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << resultname << " result = new " << resultname << "();" << endl;
+    f_service_ << indent() << resultname << " result = new " << resultname << "();" << endl;
   }
 
   if (xceptions.size() > 0) {
-    f_service_ <<
-      indent() << "try {" << endl;
+    f_service_ << indent() << "try {" << endl;
     indent_up();
   }
 
@@ -1995,8 +1923,7 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << "result.Success = ";
   }
-  f_service_ <<
-    "iface_." << normalize_name(tfunction->get_name()) << "(";
+  f_service_ << "iface_." << normalize_name(tfunction->get_name()) << "(";
   bool first = true;
   prepare_member_name_mapping(arg_struct);
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -2016,36 +1943,35 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi
   if (!tfunction->is_oneway() && xceptions.size() > 0) {
     indent_down();
     f_service_ << indent() << "}";
-    prepare_member_name_mapping( xs);
+    prepare_member_name_mapping(xs);
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl;
+      f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " "
+                 << (*x_iter)->get_name() << ") {" << endl;
       if (!tfunction->is_oneway()) {
         indent_up();
-        f_service_ <<
-          indent() << "result." << prop_name(*x_iter) << " = " << (*x_iter)->get_name() << ";" << endl;
+        f_service_ << indent() << "result." << prop_name(*x_iter) << " = " << (*x_iter)->get_name()
+                   << ";" << endl;
         indent_down();
         f_service_ << indent() << "}";
       } else {
         f_service_ << "}";
       }
     }
-    cleanup_member_name_mapping( xs);
+    cleanup_member_name_mapping(xs);
     f_service_ << endl;
   }
 
   if (tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "return;" << endl;
+    f_service_ << indent() << "return;" << endl;
     scope_down(f_service_);
 
     return;
   }
 
-  f_service_ <<
-    indent() << "oprot.WriteMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.Reply, seqid)); " << endl <<
-    indent() << "result.Write(oprot);" << endl <<
-    indent() << "oprot.WriteMessageEnd();" << endl <<
-    indent() << "oprot.Transport.Flush();" << endl;
+  f_service_ << indent() << "oprot.WriteMessageBegin(new TMessage(\"" << tfunction->get_name()
+             << "\", TMessageType.Reply, seqid)); " << endl << indent() << "result.Write(oprot);"
+             << endl << indent() << "oprot.WriteMessageEnd();" << endl << indent()
+             << "oprot.Transport.Flush();" << endl;
 
   scope_down(f_service_);
 
@@ -2074,8 +2000,7 @@ void t_csharp_generator::generate_csharp_union_reader(std::ofstream& out, t_stru
   scope_up(out);
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)

<TRUNCATED>

[20/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_json_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_json_generator.cc b/compiler/cpp/src/generate/t_json_generator.cc
index 290ffaa..dee1de2 100644
--- a/compiler/cpp/src/generate/t_json_generator.cc
+++ b/compiler/cpp/src/generate/t_json_generator.cc
@@ -45,14 +45,12 @@ static const string quot = "\"";
 
 class t_json_generator : public t_generator {
 public:
-  t_json_generator(
-    t_program* program,
-    const std::map<std::string, std::string>& parsed_options,
-    const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+  t_json_generator(t_program* program,
+                   const std::map<std::string, std::string>& parsed_options,
+                   const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-json";
   }
 
@@ -69,8 +67,8 @@ public:
   void generate_enum(t_enum* tenum);
   void generate_program();
   void generate_consts(vector<t_const*>);
-  void generate_function(t_function * tfunc);
-  void generate_field(t_field * field);
+  void generate_function(t_function* tfunc);
+  void generate_field(t_field* field);
 
   void generate_service(t_service* tservice);
   void generate_struct(t_struct* tstruct);
@@ -100,7 +98,7 @@ void t_json_generator::init_generator() {
   string f_json_name = get_out_dir() + program_->get_name() + ".json";
   f_json_.open(f_json_name.c_str());
 
-  //Merge all included programs into this one so we can output one big file.
+  // Merge all included programs into this one so we can output one big file.
   merge_includes(program_);
 }
 
@@ -108,60 +106,81 @@ string t_json_generator::escapeJsonString(const string& input) {
   std::ostringstream ss;
   for (std::string::const_iterator iter = input.begin(); iter != input.end(); iter++) {
     switch (*iter) {
-    case '\\': ss << "\\\\"; break;
-    case '"': ss << "\\\""; break;
-    case '/': ss << "\\/"; break;
-    case '\b': ss << "\\b"; break;
-    case '\f': ss << "\\f"; break;
-    case '\n': ss << "\\n"; break;
-    case '\r': ss << "\\r"; break;
-    case '\t': ss << "\\t"; break;
-    default: ss << *iter; break;
+    case '\\':
+      ss << "\\\\";
+      break;
+    case '"':
+      ss << "\\\"";
+      break;
+    case '/':
+      ss << "\\/";
+      break;
+    case '\b':
+      ss << "\\b";
+      break;
+    case '\f':
+      ss << "\\f";
+      break;
+    case '\n':
+      ss << "\\n";
+      break;
+    case '\r':
+      ss << "\\r";
+      break;
+    case '\t':
+      ss << "\\t";
+      break;
+    default:
+      ss << *iter;
+      break;
     }
   }
   return ss.str();
 }
 
-void t_json_generator::start_object(){
+void t_json_generator::start_object() {
   f_json_ << "{";
   _commaNeeded.push(false);
 }
 
-void t_json_generator::start_array(){
+void t_json_generator::start_array() {
   f_json_ << "[";
   _commaNeeded.push(false);
 }
 
-void t_json_generator::write_comma_if_needed(){
-  if (_commaNeeded.top()) f_json_ << ",";
+void t_json_generator::write_comma_if_needed() {
+  if (_commaNeeded.top())
+    f_json_ << ",";
 }
 
-void t_json_generator::indicate_comma_needed(){
+void t_json_generator::indicate_comma_needed() {
   _commaNeeded.pop();
   _commaNeeded.push(true);
 }
 
-void t_json_generator::write_key(string key, string val){
+void t_json_generator::write_key(string key, string val) {
   write_comma_if_needed();
   f_json_ << quot << key << quot << ":" << quot << escapeJsonString(val) << quot;
   indicate_comma_needed();
 }
 
-void t_json_generator::write_key_int(string key, int val){
+void t_json_generator::write_key_int(string key, int val) {
   write_comma_if_needed();
   f_json_ << quot << key << quot << ":" << quot << val << quot;
   indicate_comma_needed();
 }
 
-void t_json_generator::end_object(bool newLine){
+void t_json_generator::end_object(bool newLine) {
   f_json_ << "}";
-  if (newLine) f_json_ << endl;
+  if (newLine)
+    f_json_ << endl;
   _commaNeeded.pop();
 }
 
-void t_json_generator::end_array(bool newLine){
+void t_json_generator::end_array(bool newLine) {
   f_json_ << "]";
-  if (newLine) f_json_ << endl;
+  if (newLine)
+    f_json_ << endl;
   _commaNeeded.pop();
 }
 
@@ -169,35 +188,35 @@ void t_json_generator::close_generator() {
   f_json_.close();
 }
 
-void t_json_generator::merge_includes(t_program * program) {
+void t_json_generator::merge_includes(t_program* program) {
   vector<t_program*> includes = program->get_includes();
   vector<t_program*>::iterator inc_iter;
-  for (inc_iter = includes.begin(); inc_iter != includes.end(); ++inc_iter){
+  for (inc_iter = includes.begin(); inc_iter != includes.end(); ++inc_iter) {
     t_program* include = *inc_iter;
-    //recurse in case we get crazy
+    // recurse in case we get crazy
     merge_includes(include);
-    //merge enums
+    // merge enums
     vector<t_enum*> enums = include->get_enums();
     vector<t_enum*>::iterator en_iter;
     for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) {
       program->add_enum(*en_iter);
     }
-    //merge typedefs
+    // merge typedefs
     vector<t_typedef*> typedefs = include->get_typedefs();
     vector<t_typedef*>::iterator td_iter;
     for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) {
       program->add_typedef(*td_iter);
     }
-    //merge structs
+    // merge structs
     vector<t_struct*> objects = include->get_objects();
     vector<t_struct*>::iterator o_iter;
     for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
       program->add_struct(*o_iter);
     }
-    //merge constants
+    // merge constants
     vector<t_const*> consts = include->get_consts();
     vector<t_const*>::iterator c_iter;
-    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter){
+    for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
       program->add_const(*c_iter);
     }
 
@@ -216,7 +235,8 @@ void t_json_generator::generate_program() {
   start_object();
 
   write_key("name", program_->get_name());
-  if (program_->has_doc()) write_key("doc", program_->get_doc());
+  if (program_->has_doc())
+    write_key("doc", program_->get_doc());
 
   // Generate enums
   vector<t_enum*> enums = program_->get_enums();
@@ -254,8 +274,7 @@ void t_json_generator::generate_program() {
     write_comma_if_needed();
     if ((*o_iter)->is_xception()) {
       generate_xception(*o_iter);
-    }
-    else {
+    } else {
       generate_struct(*o_iter);
     }
     indicate_comma_needed();
@@ -284,15 +303,16 @@ void t_json_generator::generate_program() {
   close_generator();
 }
 
-void t_json_generator::generate_typedef(t_typedef* ttypedef){
+void t_json_generator::generate_typedef(t_typedef* ttypedef) {
   start_object();
   write_key("name", ttypedef->get_name());
   write_key("type", get_type_name(ttypedef->get_true_type()));
-  if (ttypedef->has_doc()) write_key("doc", ttypedef->get_doc());
+  if (ttypedef->has_doc())
+    write_key("doc", ttypedef->get_doc());
   end_object(true);
 }
 
-void t_json_generator::generate_consts(vector<t_const*> consts){
+void t_json_generator::generate_consts(vector<t_const*> consts) {
   vector<t_const*>::iterator c_iter;
   f_json_ << ",\"constants\":";
   start_array();
@@ -304,7 +324,8 @@ void t_json_generator::generate_consts(vector<t_const*> consts){
     t_const* con = (*c_iter);
     write_key("name", con->get_name());
     write_key("type", get_type_name(con->get_type()));
-    if (con->has_doc()) write_key("doc", con->get_doc());
+    if (con->has_doc())
+      write_key("doc", con->get_doc());
     write_key("value", get_const_value(con->get_value()));
     end_object(true);
   }
@@ -314,7 +335,8 @@ void t_json_generator::generate_consts(vector<t_const*> consts){
 void t_json_generator::generate_enum(t_enum* tenum) {
   start_object();
   write_key("name", tenum->get_name());
-  if (tenum->has_doc()) write_key("doc", tenum->get_doc());
+  if (tenum->has_doc())
+    write_key("doc", tenum->get_doc());
   f_json_ << ",\"members\":";
   start_array();
   vector<t_enum_value*> values = tenum->get_constants();
@@ -325,7 +347,8 @@ void t_json_generator::generate_enum(t_enum* tenum) {
     start_object();
     write_key("name", val->get_name());
     write_key_int("value", val->get_value());
-    if (val->has_doc()) write_key("doc", val->get_doc());
+    if (val->has_doc())
+      write_key("doc", val->get_doc());
     end_object(false);
     indicate_comma_needed();
   }
@@ -333,11 +356,13 @@ void t_json_generator::generate_enum(t_enum* tenum) {
   end_object(true);
 }
 
-void t_json_generator::generate_struct(t_struct* tstruct){
+void t_json_generator::generate_struct(t_struct* tstruct) {
   start_object();
   write_key("name", tstruct->get_name());
-  if (tstruct->has_doc()) write_key("doc", tstruct->get_doc());
-  if (tstruct->is_xception()) write_key("isException", "true");
+  if (tstruct->has_doc())
+    write_key("doc", tstruct->get_doc());
+  if (tstruct->is_xception())
+    write_key("isException", "true");
   vector<t_field*> members = tstruct->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
   f_json_ << ",\"fields\":";
@@ -349,11 +374,13 @@ void t_json_generator::generate_struct(t_struct* tstruct){
   end_object(true);
 }
 
-void t_json_generator::generate_service(t_service* tservice){
+void t_json_generator::generate_service(t_service* tservice) {
   start_object();
   write_key("name", tservice->get_name());
-  if (tservice->get_extends()) write_key("extendsType", tservice->get_extends()->get_name());
-  if (tservice->has_doc()) write_key("doc", tservice->get_doc());
+  if (tservice->get_extends())
+    write_key("extendsType", tservice->get_extends()->get_name());
+  if (tservice->has_doc())
+    write_key("doc", tservice->get_doc());
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator fn_iter = functions.begin();
   f_json_ << ",\"functions\":";
@@ -368,12 +395,14 @@ void t_json_generator::generate_service(t_service* tservice){
   end_object(true);
 }
 
-void t_json_generator::generate_function(t_function* tfunc){
+void t_json_generator::generate_function(t_function* tfunc) {
   start_object();
   write_key("name", tfunc->get_name());
   write_key("returnType", get_type_name(tfunc->get_returntype()));
-  if (tfunc->is_oneway()) write_key("oneWay", "true");
-  if (tfunc->has_doc()) write_key("doc", tfunc->get_doc());
+  if (tfunc->is_oneway())
+    write_key("oneWay", "true");
+  if (tfunc->has_doc())
+    write_key("doc", tfunc->get_doc());
   vector<t_field*> members = tfunc->get_arglist()->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
   f_json_ << ",\"arguments\":";
@@ -394,20 +423,21 @@ void t_json_generator::generate_function(t_function* tfunc){
   end_object(false);
 }
 
-void t_json_generator::generate_field(t_field * field){
+void t_json_generator::generate_field(t_field* field) {
   write_comma_if_needed();
   start_object();
   write_key_int("index", field->get_key());
   write_key("name", field->get_name());
   write_key("type", get_type_name(field->get_type()));
-  if (field->has_doc()) write_key("doc", field->get_doc());
+  if (field->has_doc())
+    write_key("doc", field->get_doc());
   switch (field->get_req()) {
-        case t_field::T_REQUIRED:
-            write_key("required", "true");
-            break;
-        default:
-            write_key("required", "false");
-            break;
+  case t_field::T_REQUIRED:
+    write_key("required", "true");
+    break;
+  default:
+    write_key("required", "false");
+    break;
   }
   if (field->get_value())
     write_key("default", get_const_value(field->get_value()));
@@ -415,7 +445,7 @@ void t_json_generator::generate_field(t_field * field){
   end_object(false);
   indicate_comma_needed();
 }
-string t_json_generator::get_const_value(t_const_value* tvalue){
+string t_json_generator::get_const_value(t_const_value* tvalue) {
 
   switch (tvalue->get_type()) {
   case t_const_value::CV_INTEGER:
@@ -424,14 +454,15 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
     return tvalue->get_string();
   case t_const_value::CV_STRING:
     return tvalue->get_string();
-  case t_const_value::CV_LIST:
-  {
+  case t_const_value::CV_LIST: {
     string list = "[";
-    vector<t_const_value*> list_elems = tvalue->get_list();;
+    vector<t_const_value*> list_elems = tvalue->get_list();
+    ;
     vector<t_const_value*>::iterator list_iter;
     bool first = true;
     for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
-      if (!first)list += ",";
+      if (!first)
+        list += ",";
       first = false;
       list += get_const_value(*list_iter);
     }
@@ -445,7 +476,8 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
     string map = "[";
     bool first = true;
     for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
-      if (!first) map += ",";
+      if (!first)
+        map += ",";
       first = false;
       map += get_const_value(map_iter->first) + ":";
       map += get_const_value(map_iter->second);
@@ -454,20 +486,17 @@ string t_json_generator::get_const_value(t_const_value* tvalue){
   }
   return "UNKNOWN";
 }
-string t_json_generator::get_type_name(t_type* ttype){
+string t_json_generator::get_type_name(t_type* ttype) {
   if (ttype->is_container()) {
     if (ttype->is_list()) {
       return "list<" + get_type_name(((t_list*)ttype)->get_elem_type()) + ">";
-    }
-    else if (ttype->is_set()) {
+    } else if (ttype->is_set()) {
       return "set<" + get_type_name(((t_set*)ttype)->get_elem_type()) + ">";
+    } else if (ttype->is_map()) {
+      return "map<" + get_type_name(((t_map*)ttype)->get_key_type()) + +","
+             + get_type_name(((t_map*)ttype)->get_val_type()) + ">";
     }
-    else if (ttype->is_map()) {
-      return "map<" + get_type_name(((t_map*)ttype)->get_key_type()) +
-        +"," + get_type_name(((t_map*)ttype)->get_val_type()) + ">";
-    }
-  }
-  else if (ttype->is_base_type()) {
+  } else if (ttype->is_base_type()) {
     return (((t_base_type*)ttype)->is_binary() ? "binary" : ttype->get_name());
   }
   return ttype->get_name();

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_lua_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_lua_generator.cc b/compiler/cpp/src/generate/t_lua_generator.cc
index 7303c21..5703ecb 100644
--- a/compiler/cpp/src/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/generate/t_lua_generator.cc
@@ -26,21 +26,19 @@ using std::string;
 using std::vector;
 using std::map;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * LUA code generator.
  *
  */
 class t_lua_generator : public t_oop_generator {
- public:
-  t_lua_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_lua_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("omit_requires");
@@ -58,17 +56,16 @@ class t_lua_generator : public t_oop_generator {
   /**
    * Program-level generation functions
    */
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
- private:
-
+private:
   /**
    * True iff we should generate lua require statements.
    */
@@ -77,81 +74,71 @@ class t_lua_generator : public t_oop_generator {
   /**
    * Struct-level generation functions
    */
-  void generate_lua_struct_definition(
-    std::ofstream& out, t_struct* tstruct, bool is_xception=false);
+  void generate_lua_struct_definition(std::ofstream& out,
+                                      t_struct* tstruct,
+                                      bool is_xception = false);
   void generate_lua_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_lua_struct_writer(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
-  void generate_service_client    (std::ofstream& out, t_service* tservice);
-  void generate_service_interface (std::ofstream& out, t_service* tservice);
-  void generate_service_processor (std::ofstream& out, t_service* tservice);
-  void generate_process_function  (std::ofstream& out, t_service* tservice,
-                                   t_function* tfunction);
-  void generate_service_helpers   (ofstream &out, t_service* tservice);
-  void generate_function_helpers  (ofstream &out, t_function* tfunction);
+  void generate_service_client(std::ofstream& out, t_service* tservice);
+  void generate_service_interface(std::ofstream& out, t_service* tservice);
+  void generate_service_processor(std::ofstream& out, t_service* tservice);
+  void generate_process_function(std::ofstream& out, t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(ofstream& out, t_service* tservice);
+  void generate_function_helpers(ofstream& out, t_function* tfunction);
 
   /**
    * Deserialization (Read)
    */
-  void generate_deserialize_field(
-    std::ofstream &out, t_field *tfield, std::string prefix="");
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_deserialize_struct(
-    std::ofstream &out, t_struct *tstruct, std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container(
-    std::ofstream &out, t_type *ttype, std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element(
-    std::ofstream &out, t_set *tset, std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element(
-    std::ofstream &out, t_map *tmap, std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element(
-    std::ofstream &out, t_list *tlist, std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
   /**
    * Serialization (Write)
    */
-  void generate_serialize_field(
-    std::ofstream &out, t_field *tfield, std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct(
-    std::ofstream &out, t_struct *tstruct, std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container(
-    std::ofstream &out, t_type *ttype, std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element(
-    std::ofstream &out, t_map *tmap, std::string kiter, std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element(
-    std::ofstream &out, t_set *tmap, std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element(
-    std::ofstream &out, t_list *tlist, std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
   /**
    * Helper rendering functions
    */
   std::string lua_includes();
-  std::string function_signature(t_function* tfunction, std::string prefix="");
-  std::string argument_list(t_struct* tstruct, std::string prefix="");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string argument_list(t_struct* tstruct, std::string prefix = "");
   std::string type_to_enum(t_type* ttype);
   static std::string get_namespace(const t_program* program);
 
   std::string autogen_comment() {
-    return
-      std::string("--\n") +
-      "-- Autogenerated by Thrift\n" +
-      "--\n" +
-      "-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-      "-- @""generated\n" +
-      "--\n";
+    return std::string("--\n") + "-- Autogenerated by Thrift\n" + "--\n"
+           + "-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "-- @"
+                                                                                       "generated\n"
+           + "--\n";
   }
 
   /**
@@ -162,7 +149,6 @@ class t_lua_generator : public t_oop_generator {
   std::ofstream f_service_;
 };
 
-
 /**
  * Init and close methods
  */
@@ -196,10 +182,8 @@ void t_lua_generator::close_generator() {
  * Generate a typedef (essentially a constant)
  */
 void t_lua_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_
-    << endl << endl << indent()
-    << ttypedef->get_symbolic() << " = "
-    << ttypedef->get_type()->get_name();
+  f_types_ << endl << endl << indent() << ttypedef->get_symbolic() << " = "
+           << ttypedef->get_type()->get_name();
 }
 
 /**
@@ -238,8 +222,7 @@ void t_lua_generator::generate_const(t_const* tconst) {
 /**
  * Prints the value of a constant with the given type.
  */
-string t_lua_generator::render_const_value(
-  t_type* type, t_const_value* value) {
+string t_lua_generator::render_const_value(t_type* type, t_const_value* value) {
   std::ostringstream out;
 
   type = get_true_type(type);
@@ -268,8 +251,7 @@ string t_lua_generator::render_const_value(
       }
       break;
     default:
-      throw "compiler error: no const of base type "
-        + t_base_type::t_base_name(tbase);
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
     out << value->get_integer();
@@ -289,8 +271,7 @@ string t_lua_generator::render_const_value(
         }
       }
       if (field_type == NULL) {
-        throw "type error: " + type->get_name() + " has no field "
-          + v_iter->first->get_string();
+        throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
       }
 
       indent(out);
@@ -315,9 +296,8 @@ string t_lua_generator::render_const_value(
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end();) {
-      indent(out)
-        << "[" << render_const_value(ktype, v_iter->first) << "] = "
-        << render_const_value(vtype, v_iter->second);
+      indent(out) << "[" << render_const_value(ktype, v_iter->first)
+                  << "] = " << render_const_value(vtype, v_iter->second);
       ++v_iter;
       if (v_iter != val.end()) {
         out << ",";
@@ -371,16 +351,15 @@ void t_lua_generator::generate_xception(t_struct* txception) {
 /**
  * Generate a thrift struct or exception (lua table)
  */
-void t_lua_generator::generate_lua_struct_definition(ofstream &out,
-                                                     t_struct *tstruct,
+void t_lua_generator::generate_lua_struct_definition(ofstream& out,
+                                                     t_struct* tstruct,
                                                      bool is_exception) {
   vector<t_field*>::const_iterator m_iter;
   const vector<t_field*>& members = tstruct->get_members();
 
   indent(out) << endl << endl << tstruct->get_name();
   if (is_exception) {
-    out << " = TException:new{" << endl <<
-      indent() << "  __type = '" << tstruct->get_name() << "'";
+    out << " = TException:new{" << endl << indent() << "  __type = '" << tstruct->get_name() << "'";
     if (members.size() > 0) {
       out << ",";
     }
@@ -408,56 +387,51 @@ void t_lua_generator::generate_lua_struct_definition(ofstream &out,
 /**
  * Generate a struct/exception reader
  */
-void t_lua_generator::generate_lua_struct_reader(ofstream& out,
-                                                  t_struct* tstruct) {
+void t_lua_generator::generate_lua_struct_reader(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // function
-  indent(out) << endl << endl
-    << "function " << tstruct->get_name() << ":read(iprot)" << endl;
+  indent(out) << endl << endl << "function " << tstruct->get_name() << ":read(iprot)" << endl;
   indent_up();
 
   indent(out) << "iprot:readStructBegin()" << endl;
 
   // while: Read in fields
   indent(out) << "while true do" << endl;
-    indent_up();
+  indent_up();
 
-    // if: Check what to read
-    indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl;
-    indent(out) << "if ftype == TType.STOP then" << endl;
-      indent_up();
-      indent(out) << "break" << endl;
+  // if: Check what to read
+  indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl;
+  indent(out) << "if ftype == TType.STOP then" << endl;
+  indent_up();
+  indent(out) << "break" << endl;
 
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent_down();
-        indent(out)
-          << "elseif fid == " << (*f_iter)->get_key() << " then" << endl;
-          indent_up();
-          indent(out)
-            << "if ftype == " << type_to_enum((*f_iter)->get_type())
-            << " then" << endl;
-            indent_up();
-
-            // Read field contents
-            generate_deserialize_field(out, *f_iter, "self.");
-
-            indent_down();
-          indent(out) << "else" << endl;
-          indent(out) << "  iprot:skip(ftype)" << endl;
-          indent(out) << "end" << endl;
-      }
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent_down();
+    indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << endl;
+    indent_up();
+    indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
+    indent_up();
+
+    // Read field contents
+    generate_deserialize_field(out, *f_iter, "self.");
 
-    // end if
     indent_down();
     indent(out) << "else" << endl;
     indent(out) << "  iprot:skip(ftype)" << endl;
     indent(out) << "end" << endl;
-    indent(out) << "iprot:readFieldEnd()" << endl;
+  }
+
+  // end if
+  indent_down();
+  indent(out) << "else" << endl;
+  indent(out) << "  iprot:skip(ftype)" << endl;
+  indent(out) << "end" << endl;
+  indent(out) << "iprot:readFieldEnd()" << endl;
 
   // end while
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
   indent(out) << "iprot:readStructEnd()" << endl;
 
@@ -470,36 +444,31 @@ void t_lua_generator::generate_lua_struct_reader(ofstream& out,
 /**
  * Generate a struct/exception writer
  */
-void t_lua_generator::generate_lua_struct_writer(ofstream& out,
-                                                  t_struct* tstruct) {
+void t_lua_generator::generate_lua_struct_writer(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // function
-  indent(out) << endl << endl
-    << "function " << tstruct->get_name() << ":write(oprot)" << endl;
+  indent(out) << endl << endl << "function " << tstruct->get_name() << ":write(oprot)" << endl;
   indent_up();
 
-    indent(out)
-      << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl;
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      indent(out) << "if self." << (*f_iter)->get_name() << " then" << endl;
-      indent_up();
-        indent(out)
-          << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', "
-          << type_to_enum((*f_iter)->get_type()) << ", "
-          << (*f_iter)->get_key() << ")" << endl;
+  indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "if self." << (*f_iter)->get_name() << " then" << endl;
+    indent_up();
+    indent(out) << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', "
+                << type_to_enum((*f_iter)->get_type()) << ", " << (*f_iter)->get_key() << ")"
+                << endl;
 
-        // Write field contents
-        generate_serialize_field(out, *f_iter, "self.");
+    // Write field contents
+    generate_serialize_field(out, *f_iter, "self.");
 
-        indent(out)
-          << "oprot:writeFieldEnd()" << endl;
-      indent_down();
-      indent(out) << "end" << endl;
-    }
-    indent(out) << "oprot:writeFieldStop()" << endl;
-    indent(out) << "oprot:writeStructEnd()" << endl;
+    indent(out) << "oprot:writeFieldEnd()" << endl;
+    indent_down();
+    indent(out) << "end" << endl;
+  }
+  indent(out) << "oprot:writeFieldStop()" << endl;
+  indent(out) << "oprot:writeStructEnd()" << endl;
 
   // end function
   indent_down();
@@ -525,9 +494,8 @@ void t_lua_generator::generate_service(t_service* tservice) {
     f_service_ << endl << "require '" << cur_ns << "ttypes'" << endl;
 
     if (tservice->get_extends() != NULL) {
-      f_service_
-        << "require '" << get_namespace(tservice->get_extends()->get_program())
-        << tservice->get_extends()->get_name() << "'" << endl;
+      f_service_ << "require '" << get_namespace(tservice->get_extends()->get_program())
+                 << tservice->get_extends()->get_name() << "'" << endl;
     }
   }
 
@@ -542,8 +510,7 @@ void t_lua_generator::generate_service(t_service* tservice) {
   f_service_.close();
 }
 
-void t_lua_generator::generate_service_interface(ofstream &out,
-                                                 t_service* tservice) {
+void t_lua_generator::generate_service_interface(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Iface";
   t_service* extends_s = tservice->get_extends();
 
@@ -554,13 +521,10 @@ void t_lua_generator::generate_service_interface(ofstream &out,
   } else {
     out << "__TObject:new{" << endl;
   }
-  out
-    << "  __type = '" << classname << "'" << endl
-    << "}" << endl << endl;
+  out << "  __type = '" << classname << "'" << endl << "}" << endl << endl;
 }
 
-void t_lua_generator::generate_service_client(ofstream &out,
-                                              t_service* tservice) {
+void t_lua_generator::generate_service_client(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Client";
   t_service* extends_s = tservice->get_extends();
 
@@ -571,10 +535,7 @@ void t_lua_generator::generate_service_client(ofstream &out,
   } else {
     out << "__TClient";
   }
-  out
-    <<", {" << endl
-    << "  __type = '" << classname << "'" << endl
-    << "})" << endl;
+  out << ", {" << endl << "  __type = '" << classname << "'" << endl << "})" << endl;
 
   // Send/Recv functions
   vector<t_function*> functions = tservice->get_functions();
@@ -585,141 +546,113 @@ void t_lua_generator::generate_service_client(ofstream &out,
 
     // Wrapper function
     indent(out) << endl << "function " << classname << ":" << sig << endl;
-      indent_up();
+    indent_up();
 
-      indent(out) << "self:send_" << sig << endl << indent();
-      if (!(*f_iter)->is_oneway()) {
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          out << "return ";
-        }
-        out << "self:recv_" << sig << endl;
+    indent(out) << "self:send_" << sig << endl << indent();
+    if (!(*f_iter)->is_oneway()) {
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        out << "return ";
       }
+      out << "self:recv_" << sig << endl;
+    }
 
-      indent_down();
+    indent_down();
     indent(out) << "end" << endl;
 
     // Send function
     indent(out) << endl << "function " << classname << ":send_" << sig << endl;
-      indent_up();
+    indent_up();
 
-      indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', "
-                  << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
-                  << ", self._seqid)" << endl;
-      indent(out) << "local args = " << funcname << "_args:new{}" << endl;
-
-      // Set the args
-      const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
-      vector<t_field*>::const_iterator fld_iter;
-      for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
-        std::string argname = (*fld_iter)->get_name();
-        indent(out) << "args." << argname << " = " << argname << endl;
-      }
+    indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', "
+                << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
+                << ", self._seqid)" << endl;
+    indent(out) << "local args = " << funcname << "_args:new{}" << endl;
+
+    // Set the args
+    const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
+    vector<t_field*>::const_iterator fld_iter;
+    for (fld_iter = args.begin(); fld_iter != args.end(); ++fld_iter) {
+      std::string argname = (*fld_iter)->get_name();
+      indent(out) << "args." << argname << " = " << argname << endl;
+    }
 
-      indent(out) << "args:write(self.oprot)" << endl;
-      indent(out) << "self.oprot:writeMessageEnd()" << endl;
-      indent(out) << "self.oprot.trans:flush()" << endl;
+    indent(out) << "args:write(self.oprot)" << endl;
+    indent(out) << "self.oprot:writeMessageEnd()" << endl;
+    indent(out) << "self.oprot.trans:flush()" << endl;
 
-      indent_down();
+    indent_down();
     indent(out) << "end" << endl;
 
     // Recv function
     if (!(*f_iter)->is_oneway()) {
-      indent(out)
-        << endl << "function " << classname << ":recv_" << sig << endl;
-        indent_up();
-
-        out <<
-          indent() << "local fname, mtype, rseqid = self.iprot:"
-                   << "readMessageBegin()"<< endl <<
-          indent() << "if mtype == TMessageType.EXCEPTION then" << endl <<
-          indent() << "  local x = TApplicationException:new{}" << endl <<
-          indent() << "  x:read(self.iprot)" << endl <<
-          indent() << "  self.iprot:readMessageEnd()" << endl <<
-          indent() << "  error(x)" << endl <<
-          indent() << "end" << endl <<
-          indent() << "local result = " << funcname << "_result:new{}"
-                   << endl <<
-          indent() << "result:read(self.iprot)" << endl <<
-          indent() << "self.iprot:readMessageEnd()" << endl;
-
-        // Return the result if it's not a void function
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          out <<
-            indent() << "if result.success then" << endl <<
-            indent() << "  return result.success" << endl;
-
-          // Throw custom exceptions
-          const std::vector<t_field*>& xf =
-            (*f_iter)->get_xceptions()->get_members();
-          vector<t_field*>::const_iterator x_iter;
-          for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
-            out <<
-              indent() << "elseif result." << (*x_iter)->get_name() << " then"
-                       << endl <<
-              indent() << "  error(result." << (*x_iter)->get_name() << ")"
-                       << endl;
-          }
-
-          out <<
-            indent() << "end" << endl <<
-            indent() << "error(TApplicationException:new{errorCode = "
-                     << "TApplicationException.MISSING_RESULT})" << endl;
+      indent(out) << endl << "function " << classname << ":recv_" << sig << endl;
+      indent_up();
+
+      out << indent() << "local fname, mtype, rseqid = self.iprot:"
+          << "readMessageBegin()" << endl << indent() << "if mtype == TMessageType.EXCEPTION then"
+          << endl << indent() << "  local x = TApplicationException:new{}" << endl << indent()
+          << "  x:read(self.iprot)" << endl << indent() << "  self.iprot:readMessageEnd()" << endl
+          << indent() << "  error(x)" << endl << indent() << "end" << endl << indent()
+          << "local result = " << funcname << "_result:new{}" << endl << indent()
+          << "result:read(self.iprot)" << endl << indent() << "self.iprot:readMessageEnd()" << endl;
+
+      // Return the result if it's not a void function
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        out << indent() << "if result.success then" << endl << indent() << "  return result.success"
+            << endl;
+
+        // Throw custom exceptions
+        const std::vector<t_field*>& xf = (*f_iter)->get_xceptions()->get_members();
+        vector<t_field*>::const_iterator x_iter;
+        for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
+          out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << endl
+              << indent() << "  error(result." << (*x_iter)->get_name() << ")" << endl;
         }
 
-        indent_down();
+        out << indent() << "end" << endl << indent()
+            << "error(TApplicationException:new{errorCode = "
+            << "TApplicationException.MISSING_RESULT})" << endl;
+      }
+
+      indent_down();
       indent(out) << "end" << endl;
     }
   }
 }
 
-void t_lua_generator::generate_service_processor(ofstream &out,
-                                                 t_service* tservice) {
+void t_lua_generator::generate_service_processor(ofstream& out, t_service* tservice) {
   string classname = tservice->get_name() + "Processor";
   t_service* extends_s = tservice->get_extends();
 
   // Define processor table
-  out << endl
-    << classname << " = __TObject.new(";
+  out << endl << classname << " = __TObject.new(";
   if (extends_s != NULL) {
     out << extends_s << "Processor" << endl;
   } else {
     out << "__TProcessor" << endl;
   }
-  out
-    << ", {" << endl
-    << " __type = '" << classname << "'" << endl
-    << "})" << endl;
+  out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl;
 
   // Process function
-  indent(out) << endl << "function " << classname
-    << ":process(iprot, oprot, server_ctx)" << endl;
-    indent_up();
+  indent(out) << endl << "function " << classname << ":process(iprot, oprot, server_ctx)" << endl;
+  indent_up();
 
-    indent(out)
-      << "local name, mtype, seqid = iprot:readMessageBegin()" << endl;
-    indent(out)
-      << "local func_name = 'process_' .. name" << endl;
-    indent(out)
-      << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then";
-    indent_up();
-      out << endl <<
-        indent() << "iprot:skip(TType.STRUCT)" << endl <<
-        indent() << "iprot:readMessageEnd()" << endl <<
-        indent() << "x = TApplicationException:new{" << endl <<
-        indent() << "  errorCode = TApplicationException.UNKNOWN_METHOD" << endl
-     << indent() << "}" << endl <<
-        indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
-                 << "seqid)" << endl <<
-        indent() << "x:write(oprot)" << endl <<
-        indent() << "oprot:writeMessageEnd()" << endl <<
-        indent() << "oprot.trans:flush()" << endl;
-    indent_down();
-    indent(out) << "else" << endl <<
-       indent() << "  self[func_name](self, seqid, iprot, oprot, server_ctx)"
-                << endl
-    << indent() << "end" << endl;
+  indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << endl;
+  indent(out) << "local func_name = 'process_' .. name" << endl;
+  indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then";
+  indent_up();
+  out << endl << indent() << "iprot:skip(TType.STRUCT)" << endl << indent()
+      << "iprot:readMessageEnd()" << endl << indent() << "x = TApplicationException:new{" << endl
+      << indent() << "  errorCode = TApplicationException.UNKNOWN_METHOD" << endl << indent() << "}"
+      << endl << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
+      << "seqid)" << endl << indent() << "x:write(oprot)" << endl << indent()
+      << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
+  indent_down();
+  indent(out) << "else" << endl << indent()
+              << "  self[func_name](self, seqid, iprot, oprot, server_ctx)" << endl << indent()
+              << "end" << endl;
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 
   // Generate the process subfunctions
@@ -730,7 +663,7 @@ void t_lua_generator::generate_service_processor(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_process_function(ofstream &out,
+void t_lua_generator::generate_process_function(ofstream& out,
                                                 t_service* tservice,
                                                 t_function* tfunction) {
   string classname = tservice->get_name() + "Processor";
@@ -739,62 +672,49 @@ void t_lua_generator::generate_process_function(ofstream &out,
   string fn_name = tfunction->get_name();
 
   indent(out) << endl << "function " << classname << ":process_" << fn_name
-    << "(seqid, iprot, oprot, server_ctx)" << endl;
-    indent_up();
+              << "(seqid, iprot, oprot, server_ctx)" << endl;
+  indent_up();
 
-    // Read the request
-    out <<
-      indent() << "local args = " << argsname << ":new{}" << endl <<
-      indent() << "local reply_type = TMessageType.REPLY" << endl <<
-      indent() << "args:read(iprot)" << endl <<
-      indent() << "iprot:readMessageEnd()" << endl <<
-      indent() << "local result = " << resultname << ":new{}" << endl <<
-      indent() << "local status, res = pcall(self.handler." << fn_name
-               << ", self.handler";
-
-    // Print arguments
-    t_struct *args = tfunction->get_arglist();
-    if (args->get_members().size() > 0) {
-      out << ", " << argument_list(args, "args.");
-    }
+  // Read the request
+  out << indent() << "local args = " << argsname << ":new{}" << endl << indent()
+      << "local reply_type = TMessageType.REPLY" << endl << indent() << "args:read(iprot)" << endl
+      << indent() << "iprot:readMessageEnd()" << endl << indent() << "local result = " << resultname
+      << ":new{}" << endl << indent() << "local status, res = pcall(self.handler." << fn_name
+      << ", self.handler";
+
+  // Print arguments
+  t_struct* args = tfunction->get_arglist();
+  if (args->get_members().size() > 0) {
+    out << ", " << argument_list(args, "args.");
+  }
 
-    // Check for errors
-    out << ")" << endl <<
-      indent() << "if not status then" << endl <<
-      indent() << "  reply_type = TMessageType.EXCEPTION" << endl <<
-      indent() << "  result = TApplicationException:new{message = res}"
-               << endl;
-
-    // Handle custom exceptions
-    const std::vector<t_field*>& xf = tfunction->get_xceptions()->get_members();
-    if (xf.size() > 0) {
-      vector<t_field*>::const_iterator x_iter;
-      for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
-        out <<
-          indent() << "elseif ttype(res) == '"
-                   << (*x_iter)->get_type()->get_name() << "' then" << endl <<
-          indent() << "  result." << (*x_iter)->get_name() << " = res" << endl;
-      }
+  // Check for errors
+  out << ")" << endl << indent() << "if not status then" << endl << indent()
+      << "  reply_type = TMessageType.EXCEPTION" << endl << indent()
+      << "  result = TApplicationException:new{message = res}" << endl;
+
+  // Handle custom exceptions
+  const std::vector<t_field*>& xf = tfunction->get_xceptions()->get_members();
+  if (xf.size() > 0) {
+    vector<t_field*>::const_iterator x_iter;
+    for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
+      out << indent() << "elseif ttype(res) == '" << (*x_iter)->get_type()->get_name() << "' then"
+          << endl << indent() << "  result." << (*x_iter)->get_name() << " = res" << endl;
     }
+  }
 
-    // Set the result and write the reply
-    out <<
-      indent() << "else" << endl <<
-      indent() << "  result.success = res" << endl <<
-      indent() << "end" << endl <<
-      indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
-               << "seqid)" << endl <<
-      indent() << "result:write(oprot)" << endl <<
-      indent() << "oprot:writeMessageEnd()" << endl <<
-      indent() << "oprot.trans:flush()" << endl;
+  // Set the result and write the reply
+  out << indent() << "else" << endl << indent() << "  result.success = res" << endl << indent()
+      << "end" << endl << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
+      << "seqid)" << endl << indent() << "result:write(oprot)" << endl << indent()
+      << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 }
 
 // Service helpers
-void t_lua_generator::generate_service_helpers(ofstream &out,
-                                               t_service* tservice) {
+void t_lua_generator::generate_service_helpers(ofstream& out, t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
@@ -806,8 +726,7 @@ void t_lua_generator::generate_service_helpers(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_function_helpers(ofstream &out,
-                                                t_function *tfunction) {
+void t_lua_generator::generate_function_helpers(ofstream& out, t_function* tfunction) {
   if (!tfunction->is_oneway()) {
     t_struct result(program_, tfunction->get_name() + "_result");
     t_field success(tfunction->get_returntype(), "success", 0);
@@ -828,14 +747,11 @@ void t_lua_generator::generate_function_helpers(ofstream &out,
 /**
  * Deserialize (Read)
  */
-void t_lua_generator::generate_deserialize_field(ofstream &out,
-                                                 t_field* tfield,
-                                                 string prefix) {
+void t_lua_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = prefix + tfield->get_name();
@@ -845,15 +761,13 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      name << " = iprot:";
+    indent(out) << name << " = iprot:";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "readString()";
@@ -877,8 +791,7 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
         out << "readDouble()";
         break;
       default:
-        throw "compiler error: no PHP name for base type " +
-          t_base_type::t_base_name(tbase);
+        throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "readI32()";
@@ -887,21 +800,17 @@ void t_lua_generator::generate_deserialize_field(ofstream &out,
 
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type->get_name().c_str());
+           tfield->get_name().c_str(),
+           type->get_name().c_str());
   }
 }
 
-void t_lua_generator::generate_deserialize_struct(ofstream &out,
-                                                  t_struct* tstruct,
-                                                  string prefix) {
-  indent(out)
-    << prefix << " = " << tstruct->get_name() << ":new{}" << endl
-    << indent() << prefix << ":read(iprot)" << endl;
+void t_lua_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  indent(out) << prefix << " = " << tstruct->get_name() << ":new{}" << endl << indent() << prefix
+              << ":read(iprot)" << endl;
 }
 
-void t_lua_generator::generate_deserialize_container(ofstream &out,
-                                                     t_type* ttype,
-                                                     string prefix) {
+void t_lua_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
   string size = tmp("_size");
   string ktype = tmp("_ktype");
   string vtype = tmp("_vtype");
@@ -915,29 +824,27 @@ void t_lua_generator::generate_deserialize_container(ofstream &out,
   // Declare variables, read header
   indent(out) << prefix << " = {}" << endl;
   if (ttype->is_map()) {
-    indent(out) << "local " << ktype << ", " << vtype << ", " << size
-                << " = iprot:readMapBegin() " << endl;
+    indent(out) << "local " << ktype << ", " << vtype << ", " << size << " = iprot:readMapBegin() "
+                << endl;
   } else if (ttype->is_set()) {
-    indent(out) << "local " << etype << ", " << size
-                << " = iprot:readSetBegin()" << endl;
+    indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << endl;
   } else if (ttype->is_list()) {
-    indent(out) << "local " << etype << ", " << size
-                << " = iprot:readListBegin()" << endl;
+    indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << endl;
   }
 
   // Deserialize
   indent(out) << "for _i=1," << size << " do" << endl;
-    indent_up();
+  indent_up();
 
-    if (ttype->is_map()) {
-      generate_deserialize_map_element(out, (t_map*)ttype, prefix);
-    } else if (ttype->is_set()) {
-      generate_deserialize_set_element(out, (t_set*)ttype, prefix);
-    } else if (ttype->is_list()) {
-      generate_deserialize_list_element(out, (t_list*)ttype, prefix);
-    }
+  if (ttype->is_map()) {
+    generate_deserialize_map_element(out, (t_map*)ttype, prefix);
+  } else if (ttype->is_set()) {
+    generate_deserialize_set_element(out, (t_set*)ttype, prefix);
+  } else if (ttype->is_list()) {
+    generate_deserialize_list_element(out, (t_list*)ttype, prefix);
+  }
 
-    indent_down();
+  indent_down();
   indent(out) << "end" << endl;
 
   // Read container end
@@ -950,9 +857,7 @@ void t_lua_generator::generate_deserialize_container(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_deserialize_map_element(ofstream &out,
-                                                       t_map* tmap,
-                                                       string prefix) {
+void t_lua_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
   // A map is represented by a table indexable by any lua type
   string key = tmp("_key");
   string val = tmp("_val");
@@ -965,20 +870,17 @@ void t_lua_generator::generate_deserialize_map_element(ofstream &out,
   indent(out) << prefix << "[" << key << "] = " << val << endl;
 }
 
-void t_lua_generator::generate_deserialize_set_element(ofstream &out,
-                                                       t_set* tset,
-                                                       string prefix) {
+void t_lua_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
   // A set is represented by a table indexed by the value
   string elem = tmp("_elem");
   t_field felem(tset->get_elem_type(), elem);
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-    prefix << "[" << elem << "] = " << elem << endl;
+  indent(out) << prefix << "[" << elem << "] = " << elem << endl;
 }
 
-void t_lua_generator::generate_deserialize_list_element(ofstream &out,
+void t_lua_generator::generate_deserialize_list_element(ofstream& out,
                                                         t_list* tlist,
                                                         string prefix) {
   // A list is represented by a table indexed by integer values
@@ -994,9 +896,7 @@ void t_lua_generator::generate_deserialize_list_element(ofstream &out,
 /**
  * Serialize (Write)
  */
-void t_lua_generator::generate_serialize_field(ofstream &out,
-                                               t_field* tfield,
-                                               string prefix) {
+void t_lua_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
   string name = prefix + tfield->get_name();
 
@@ -1016,8 +916,7 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "writeString(" << name << ")";
@@ -1041,8 +940,7 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
         out << "writeDouble(" << name << ")";
         break;
       default:
-        throw "compiler error: no PHP name for base type " +
-          t_base_type::t_base_name(tbase);
+        throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       out << "writeI32(" << name << ")";
@@ -1055,61 +953,48 @@ void t_lua_generator::generate_serialize_field(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_serialize_struct(ofstream &out,
-                                                t_struct* tstruct,
-                                                string prefix) {
-  (void) tstruct;
+void t_lua_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  (void)tstruct;
   indent(out) << prefix << ":write(oprot)" << endl;
 }
 
-void t_lua_generator::generate_serialize_container(ofstream &out,
-                                                   t_type* ttype,
-                                                   string prefix) {
+void t_lua_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   // Begin writing
   if (ttype->is_map()) {
-    indent(out) <<
-      "oprot:writeMapBegin(" <<
-      type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
-      type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
+                << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
+                << "string.len(" << prefix << "))" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "oprot:writeSetBegin(" <<
-      type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
+                << "string.len(" << prefix << "))" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "oprot:writeListBegin(" <<
-      type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
-      "string.len(" << prefix << "))" << endl;
+    indent(out) << "oprot:writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
+                << ", "
+                << "string.len(" << prefix << "))" << endl;
   }
 
   // Serialize
   if (ttype->is_map()) {
     string kiter = tmp("kiter");
     string viter = tmp("viter");
-    indent(out)
-      << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do"
-      << endl;
-      indent_up();
-      generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
-      indent_down();
+    indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
+    indent_down();
     indent(out) << "end" << endl;
   } else if (ttype->is_set()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "for " << iter << ",_ in pairs(" << prefix << ") do" << endl;
-      indent_up();
-      generate_serialize_set_element(out, (t_set*)ttype, iter);
-      indent_down();
+    indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_set_element(out, (t_set*)ttype, iter);
+    indent_down();
     indent(out) << "end" << endl;
   } else if (ttype->is_list()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "for _," << iter << " in ipairs(" << prefix << ") do" << endl;
-      indent_up();
-      generate_serialize_list_element(out, (t_list*)ttype, iter);
-      indent_down();
+    indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << endl;
+    indent_up();
+    generate_serialize_list_element(out, (t_list*)ttype, iter);
+    indent_down();
     indent(out) << "end" << endl;
   }
 
@@ -1123,7 +1008,7 @@ void t_lua_generator::generate_serialize_container(ofstream &out,
   }
 }
 
-void t_lua_generator::generate_serialize_map_element(ofstream &out,
+void t_lua_generator::generate_serialize_map_element(ofstream& out,
                                                      t_map* tmap,
                                                      string kiter,
                                                      string viter) {
@@ -1134,16 +1019,12 @@ void t_lua_generator::generate_serialize_map_element(ofstream &out,
   generate_serialize_field(out, &vfield, "");
 }
 
-void t_lua_generator::generate_serialize_set_element(ofstream &out,
-                                                     t_set* tset,
-                                                     string iter) {
+void t_lua_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
   t_field efield(tset->get_elem_type(), iter);
   generate_serialize_field(out, &efield, "");
 }
 
-void t_lua_generator::generate_serialize_list_element(ofstream &out,
-                                                      t_list* tlist,
-                                                      string iter) {
+void t_lua_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
   t_field efield(tlist->get_elem_type(), iter);
   generate_serialize_field(out, &efield, "");
 }
@@ -1167,11 +1048,9 @@ string t_lua_generator::get_namespace(const t_program* program) {
   return real_module + "_";
 }
 
-string t_lua_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
-  (void) prefix;
-  std::string ret = tfunction->get_name() + "(" +
-    argument_list(tfunction->get_arglist()) + ")";
+string t_lua_generator::function_signature(t_function* tfunction, string prefix) {
+  (void)prefix;
+  std::string ret = tfunction->get_name() + "(" + argument_list(tfunction->get_arglist()) + ")";
   return ret;
 }
 
@@ -1195,22 +1074,22 @@ string t_lua_generator::type_to_enum(t_type* type) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_VOID:
-        throw "NO T_VOID CONSTRUCT";
-      case t_base_type::TYPE_STRING:
-        return "TType.STRING";
-      case t_base_type::TYPE_BOOL:
-        return "TType.BOOL";
-      case t_base_type::TYPE_BYTE:
-        return "TType.BYTE";
-      case t_base_type::TYPE_I16:
-        return "TType.I16";
-      case t_base_type::TYPE_I32:
-        return "TType.I32";
-      case t_base_type::TYPE_I64:
-        return "TType.I64";
-      case t_base_type::TYPE_DOUBLE:
-        return "TType.DOUBLE";
+    case t_base_type::TYPE_VOID:
+      throw "NO T_VOID CONSTRUCT";
+    case t_base_type::TYPE_STRING:
+      return "TType.STRING";
+    case t_base_type::TYPE_BOOL:
+      return "TType.BOOL";
+    case t_base_type::TYPE_BYTE:
+      return "TType.BYTE";
+    case t_base_type::TYPE_I16:
+      return "TType.I16";
+    case t_base_type::TYPE_I32:
+      return "TType.I32";
+    case t_base_type::TYPE_I64:
+      return "TType.I64";
+    case t_base_type::TYPE_DOUBLE:
+      return "TType.DOUBLE";
     }
   } else if (type->is_enum()) {
     return "TType.I32";


[10/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TDenseProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TDenseProtocol.h b/lib/cpp/src/thrift/protocol/TDenseProtocol.h
index 4808d79..e7f2cd2 100644
--- a/lib/cpp/src/thrift/protocol/TDenseProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TDenseProtocol.h
@@ -22,7 +22,9 @@
 
 #include <thrift/protocol/TBinaryProtocol.h>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 /**
  * !!!WARNING!!!
@@ -56,14 +58,13 @@ namespace apache { namespace thrift { namespace protocol {
  * methods within our versions.
  *
  */
-class TDenseProtocol
-  : public TVirtualProtocol<TDenseProtocol, TBinaryProtocol> {
- protected:
+class TDenseProtocol : public TVirtualProtocol<TDenseProtocol, TBinaryProtocol> {
+protected:
   static const int32_t VERSION_MASK = ((int32_t)0xffff0000);
   // VERSION_1 (0x80010000)  is taken by TBinaryProtocol.
   static const int32_t VERSION_2 = ((int32_t)0x80020000);
 
- public:
+public:
   typedef apache::thrift::reflection::local::TypeSpec TypeSpec;
   static const int FP_PREFIX_LEN;
 
@@ -71,20 +72,13 @@ class TDenseProtocol
    * @param tran       The transport to use.
    * @param type_spec  The TypeSpec of the structures using this protocol.
    */
-  TDenseProtocol(boost::shared_ptr<TTransport> trans,
-                 TypeSpec* type_spec = NULL) :
-    TVirtualProtocol<TDenseProtocol, TBinaryProtocol>(trans),
-    type_spec_(type_spec),
-    standalone_(true)
-  {}
-
-  void setTypeSpec(TypeSpec* type_spec) {
-    type_spec_ = type_spec;
-  }
-  TypeSpec* getTypeSpec() {
-    return type_spec_;
-  }
+  TDenseProtocol(boost::shared_ptr<TTransport> trans, TypeSpec* type_spec = NULL)
+    : TVirtualProtocol<TDenseProtocol, TBinaryProtocol>(trans),
+      type_spec_(type_spec),
+      standalone_(true) {}
 
+  void setTypeSpec(TypeSpec* type_spec) { type_spec_ = type_spec; }
+  TypeSpec* getTypeSpec() { return type_spec_; }
 
   /*
    * Writing functions.
@@ -96,22 +90,17 @@ class TDenseProtocol
 
   uint32_t writeMessageEnd();
 
-
   uint32_t writeStructBegin(const char* name);
 
   uint32_t writeStructEnd();
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId);
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
 
   uint32_t writeFieldEnd();
 
   uint32_t writeFieldStop();
 
-  uint32_t writeMapBegin(const TType keyType,
-                         const TType valType,
-                         const uint32_t size);
+  uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
 
   uint32_t writeMapEnd();
 
@@ -139,7 +128,6 @@ class TDenseProtocol
 
   uint32_t writeBinary(const std::string& str);
 
-
   /*
    * Helper writing functions (don't do state transitions).
    */
@@ -147,18 +135,13 @@ class TDenseProtocol
 
   inline uint32_t subWriteString(const std::string& str);
 
-  uint32_t subWriteBool(const bool value) {
-    return TBinaryProtocol::writeBool(value);
-  }
-
+  uint32_t subWriteBool(const bool value) { return TBinaryProtocol::writeBool(value); }
 
   /*
    * Reading functions
    */
 
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid);
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
 
   uint32_t readMessageEnd();
 
@@ -166,25 +149,19 @@ class TDenseProtocol
 
   uint32_t readStructEnd();
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId);
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
 
   uint32_t readFieldEnd();
 
-  uint32_t readMapBegin(TType& keyType,
-                        TType& valType,
-                        uint32_t& size);
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
 
   uint32_t readMapEnd();
 
-  uint32_t readListBegin(TType& elemType,
-                         uint32_t& size);
+  uint32_t readListBegin(TType& elemType, uint32_t& size);
 
   uint32_t readListEnd();
 
-  uint32_t readSetBegin(TType& elemType,
-                        uint32_t& size);
+  uint32_t readSetBegin(TType& elemType, uint32_t& size);
 
   uint32_t readSetEnd();
 
@@ -213,13 +190,9 @@ class TDenseProtocol
 
   inline uint32_t subReadString(std::string& str);
 
-  uint32_t subReadBool(bool& value) {
-    return TBinaryProtocol::readBool(value);
-  }
-
-
- private:
+  uint32_t subReadBool(bool& value) { return TBinaryProtocol::readBool(value); }
 
+private:
   // Implementation functions, documented in the .cpp.
   inline void checkTType(const TType ttype);
   inline void stateTransition();
@@ -240,15 +213,16 @@ class TDenseProtocol
   // for standalone protocol objects.
   TypeSpec* type_spec_;
 
-  std::vector<TypeSpec*> ts_stack_;   // TypeSpec stack.
-  std::vector<int>       idx_stack_;  // InDeX stack.
-  std::vector<bool>      mkv_stack_;  // Map Key/Vlue stack.
-                                      // True = key, False = value.
+  std::vector<TypeSpec*> ts_stack_; // TypeSpec stack.
+  std::vector<int> idx_stack_;      // InDeX stack.
+  std::vector<bool> mkv_stack_;     // Map Key/Vlue stack.
+                                    // True = key, False = value.
 
   // True iff this is a standalone instance (no RPC).
   bool standalone_;
 };
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #endif // #ifndef _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
index a0cc8e2..ca450f4 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
@@ -26,8 +26,9 @@
 
 using namespace apache::thrift::transport;
 
-namespace apache { namespace thrift { namespace protocol {
-
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 // Static data
 
@@ -63,7 +64,7 @@ static const std::string kTypeNameMap("map");
 static const std::string kTypeNameList("lst");
 static const std::string kTypeNameSet("set");
 
-static const std::string &getTypeNameForTypeID(TType typeID) {
+static const std::string& getTypeNameForTypeID(TType typeID) {
   switch (typeID) {
   case T_BOOL:
     return kTypeNameBool;
@@ -88,12 +89,11 @@ static const std::string &getTypeNameForTypeID(TType typeID) {
   case T_LIST:
     return kTypeNameList;
   default:
-    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
-                             "Unrecognized type");
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, "Unrecognized type");
   }
 }
 
-static TType getTypeIDForTypeName(const std::string &name) {
+static TType getTypeIDForTypeName(const std::string& name) {
   TType result = T_STOP; // Sentinel value
   if (name.length() > 1) {
     switch (name[0]) {
@@ -128,8 +128,7 @@ static TType getTypeIDForTypeName(const std::string &name) {
     case 's':
       if (name[1] == 't') {
         result = T_STRING;
-      }
-      else if (name[1] == 'e') {
+      } else if (name[1] == 'e') {
         result = T_SET;
       }
       break;
@@ -139,25 +138,67 @@ static TType getTypeIDForTypeName(const std::string &name) {
     }
   }
   if (result == T_STOP) {
-    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
-                             "Unrecognized type");
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, "Unrecognized type");
   }
   return result;
 }
 
-
 // This table describes the handling for the first 0x30 characters
 //  0 : escape using "\u00xx" notation
 //  1 : just output index
 // <other> : escape using "\<other>" notation
 static const uint8_t kJSONCharTable[0x30] = {
-//  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
-    0,  0,  0,  0,  0,  0,  0,  0,'b','t','n',  0,'f','r',  0,  0, // 0
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, // 1
-    1,  1,'"',  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, // 2
+    //  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    'b',
+    't',
+    'n',
+    0,
+    'f',
+    'r',
+    0,
+    0, // 0
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0, // 1
+    1,
+    1,
+    '"',
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1,
+    1, // 2
 };
 
-
 // This string's characters must match up with the elements in kEscapeCharVals.
 // I don't have '/' on this list even though it appears on www.json.org --
 // it is not in the RFC
@@ -166,23 +207,26 @@ const static std::string kEscapeChars("\"\\bfnrt");
 // The elements of this array must match up with the sequence of characters in
 // kEscapeChars
 const static uint8_t kEscapeCharVals[7] = {
-  '"', '\\', '\b', '\f', '\n', '\r', '\t',
+    '"',
+    '\\',
+    '\b',
+    '\f',
+    '\n',
+    '\r',
+    '\t',
 };
 
-
 // Static helper functions
 
 // Read 1 character from the transport trans and verify that it is the
 // expected character ch.
 // Throw a protocol exception if it is not.
-static uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader &reader,
-                               uint8_t ch) {
+static uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader& reader, uint8_t ch) {
   uint8_t ch2 = reader.read();
   if (ch2 != ch) {
     throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "Expected \'" + std::string((char *)&ch, 1) +
-                             "\'; got \'" + std::string((char *)&ch2, 1) +
-                             "\'.");
+                             "Expected \'" + std::string((char*)&ch, 1) + "\'; got \'"
+                             + std::string((char*)&ch2, 1) + "\'.");
   }
   return 1;
 }
@@ -192,14 +236,12 @@ static uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader &reader,
 static uint8_t hexVal(uint8_t ch) {
   if ((ch >= '0') && (ch <= '9')) {
     return ch - '0';
-  }
-  else if ((ch >= 'a') && (ch <= 'f')) {
+  } else if ((ch >= 'a') && (ch <= 'f')) {
     return ch - 'a' + 10;
-  }
-  else {
+  } else {
     throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "Expected hex val ([0-9a-f]); got \'"
-                               + std::string((char *)&ch, 1) + "\'.");
+                             "Expected hex val ([0-9a-f]); got \'" + std::string((char*)&ch, 1)
+                             + "\'.");
   }
 }
 
@@ -209,8 +251,7 @@ static uint8_t hexChar(uint8_t val) {
   val &= 0x0F;
   if (val < 10) {
     return val + '0';
-  }
-  else {
+  } else {
     return val - 10 + 'a';
   }
 }
@@ -238,32 +279,30 @@ static bool isJSONNumeric(uint8_t ch) {
   return false;
 }
 
-
 /**
  * Class to serve as base JSON context and as base class for other context
  * implementations
  */
 class TJSONContext {
 
- public:
-
-  TJSONContext() {};
+public:
+  TJSONContext(){};
 
-  virtual ~TJSONContext() {};
+  virtual ~TJSONContext(){};
 
   /**
    * Write context data to the transport. Default is to do nothing.
    */
-  virtual uint32_t write(TTransport &trans) {
-    (void) trans;
+  virtual uint32_t write(TTransport& trans) {
+    (void)trans;
     return 0;
   };
 
   /**
    * Read context data from the transport. Default is to do nothing.
    */
-  virtual uint32_t read(TJSONProtocol::LookaheadReader &reader) {
-    (void) reader;
+  virtual uint32_t read(TJSONProtocol::LookaheadReader& reader) {
+    (void)reader;
     return 0;
   };
 
@@ -271,41 +310,33 @@ class TJSONContext {
    * Return true if numbers need to be escaped as strings in this context.
    * Default behavior is to return false.
    */
-  virtual bool escapeNum() {
-    return false;
-  }
+  virtual bool escapeNum() { return false; }
 };
 
 // Context class for object member key-value pairs
 class JSONPairContext : public TJSONContext {
 
 public:
+  JSONPairContext() : first_(true), colon_(true) {}
 
-  JSONPairContext() :
-    first_(true),
-    colon_(true) {
-  }
-
-  uint32_t write(TTransport &trans) {
+  uint32_t write(TTransport& trans) {
     if (first_) {
       first_ = false;
       colon_ = true;
       return 0;
-    }
-    else {
+    } else {
       trans.write(colon_ ? &kJSONPairSeparator : &kJSONElemSeparator, 1);
       colon_ = !colon_;
       return 1;
     }
   }
 
-  uint32_t read(TJSONProtocol::LookaheadReader &reader) {
+  uint32_t read(TJSONProtocol::LookaheadReader& reader) {
     if (first_) {
       first_ = false;
       colon_ = true;
       return 0;
-    }
-    else {
+    } else {
       uint8_t ch = (colon_ ? kJSONPairSeparator : kJSONElemSeparator);
       colon_ = !colon_;
       return readSyntaxChar(reader, ch);
@@ -313,59 +344,51 @@ public:
   }
 
   // Numbers must be turned into strings if they are the key part of a pair
-  virtual bool escapeNum() {
-    return colon_;
-  }
-
-  private:
+  virtual bool escapeNum() { return colon_; }
 
-    bool first_;
-    bool colon_;
+private:
+  bool first_;
+  bool colon_;
 };
 
 // Context class for lists
 class JSONListContext : public TJSONContext {
 
 public:
+  JSONListContext() : first_(true) {}
 
-  JSONListContext() :
-    first_(true) {
-  }
-
-  uint32_t write(TTransport &trans) {
+  uint32_t write(TTransport& trans) {
     if (first_) {
       first_ = false;
       return 0;
-    }
-    else {
+    } else {
       trans.write(&kJSONElemSeparator, 1);
       return 1;
     }
   }
 
-  uint32_t read(TJSONProtocol::LookaheadReader &reader) {
+  uint32_t read(TJSONProtocol::LookaheadReader& reader) {
     if (first_) {
       first_ = false;
       return 0;
-    }
-    else {
+    } else {
       return readSyntaxChar(reader, kJSONElemSeparator);
     }
   }
 
-  private:
-    bool first_;
+private:
+  bool first_;
 };
 
-
-TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) :
-  TVirtualProtocol<TJSONProtocol>(ptrans),
-  trans_(ptrans.get()),
-  context_(new TJSONContext()),
-  reader_(*ptrans) {
+TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans)
+  : TVirtualProtocol<TJSONProtocol>(ptrans),
+    trans_(ptrans.get()),
+    context_(new TJSONContext()),
+    reader_(*ptrans) {
 }
 
-TJSONProtocol::~TJSONProtocol() {}
+TJSONProtocol::~TJSONProtocol() {
+}
 
 void TJSONProtocol::pushContext(boost::shared_ptr<TJSONContext> c) {
   contexts_.push(context_);
@@ -379,7 +402,7 @@ void TJSONProtocol::popContext() {
 
 // Write the character ch as a JSON escape sequence ("\u00xx")
 uint32_t TJSONProtocol::writeJSONEscapeChar(uint8_t ch) {
-  trans_->write((const uint8_t *)kJSONEscapePrefix.c_str(),
+  trans_->write((const uint8_t*)kJSONEscapePrefix.c_str(),
                 static_cast<uint32_t>(kJSONEscapePrefix.length()));
   uint8_t outCh = hexChar(ch >> 4);
   trans_->write(&outCh, 1);
@@ -395,25 +418,21 @@ uint32_t TJSONProtocol::writeJSONChar(uint8_t ch) {
       trans_->write(&kJSONBackslash, 1);
       trans_->write(&kJSONBackslash, 1);
       return 2;
-    }
-    else {
+    } else {
       trans_->write(&ch, 1);
       return 1;
     }
-  }
-  else {
+  } else {
     uint8_t outCh = kJSONCharTable[ch];
     // Check if regular character, backslash escaped, or JSON escaped
     if (outCh == 1) {
       trans_->write(&ch, 1);
       return 1;
-    }
-    else if (outCh > 1) {
+    } else if (outCh > 1) {
       trans_->write(&kJSONBackslash, 1);
       trans_->write(&outCh, 1);
       return 2;
-    }
-    else {
+    } else {
       return writeJSONEscapeChar(ch);
     }
   }
@@ -421,7 +440,7 @@ uint32_t TJSONProtocol::writeJSONChar(uint8_t ch) {
 
 // Write out the contents of the string str as a JSON string, escaping
 // characters as appropriate.
-uint32_t TJSONProtocol::writeJSONString(const std::string &str) {
+uint32_t TJSONProtocol::writeJSONString(const std::string& str) {
   uint32_t result = context_->write(*trans_);
   result += 2; // For quotes
   trans_->write(&kJSONStringDelimiter, 1);
@@ -436,13 +455,13 @@ uint32_t TJSONProtocol::writeJSONString(const std::string &str) {
 
 // Write out the contents of the string as JSON string, base64-encoding
 // the string's contents, and escaping as appropriate
-uint32_t TJSONProtocol::writeJSONBase64(const std::string &str) {
+uint32_t TJSONProtocol::writeJSONBase64(const std::string& str) {
   uint32_t result = context_->write(*trans_);
   result += 2; // For quotes
   trans_->write(&kJSONStringDelimiter, 1);
   uint8_t b[4];
-  const uint8_t *bytes = (const uint8_t *)str.c_str();
-  if(str.length() > (std::numeric_limits<uint32_t>::max)())
+  const uint8_t* bytes = (const uint8_t*)str.c_str();
+  if (str.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   uint32_t len = static_cast<uint32_t>(str.length());
   while (len >= 3) {
@@ -451,7 +470,7 @@ uint32_t TJSONProtocol::writeJSONBase64(const std::string &str) {
     trans_->write(b, 4);
     result += 4;
     bytes += 3;
-    len -=3;
+    len -= 3;
   }
   if (len) { // Handle remainder
     base64_encode(bytes, len, b);
@@ -473,9 +492,9 @@ uint32_t TJSONProtocol::writeJSONInteger(NumberType num) {
     trans_->write(&kJSONStringDelimiter, 1);
     result += 1;
   }
-  if(val.length() > (std::numeric_limits<uint32_t>::max)())
+  if (val.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
-  trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length()));
+  trans_->write((const uint8_t*)val.c_str(), static_cast<uint32_t>(val.length()));
   result += static_cast<uint32_t>(val.length());
   if (escapeNum) {
     trans_->write(&kJSONStringDelimiter, 1);
@@ -516,9 +535,9 @@ uint32_t TJSONProtocol::writeJSONDouble(double num) {
     trans_->write(&kJSONStringDelimiter, 1);
     result += 1;
   }
-  if(val.length() > (std::numeric_limits<uint32_t>::max)())
+  if (val.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
-  trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length()));
+  trans_->write((const uint8_t*)val.c_str(), static_cast<uint32_t>(val.length()));
   result += static_cast<uint32_t>(val.length());
   if (escapeNum) {
     trans_->write(&kJSONStringDelimiter, 1);
@@ -569,7 +588,7 @@ uint32_t TJSONProtocol::writeMessageEnd() {
 }
 
 uint32_t TJSONProtocol::writeStructBegin(const char* name) {
-  (void) name;
+  (void)name;
   return writeJSONObjectStart();
 }
 
@@ -580,7 +599,7 @@ uint32_t TJSONProtocol::writeStructEnd() {
 uint32_t TJSONProtocol::writeFieldBegin(const char* name,
                                         const TType fieldType,
                                         const int16_t fieldId) {
-  (void) name;
+  (void)name;
   uint32_t result = writeJSONInteger(fieldId);
   result += writeJSONObjectStart();
   result += writeJSONString(getTypeNameForTypeID(fieldType));
@@ -610,8 +629,7 @@ uint32_t TJSONProtocol::writeMapEnd() {
   return writeJSONObjectEnd() + writeJSONArrayEnd();
 }
 
-uint32_t TJSONProtocol::writeListBegin(const TType elemType,
-                                       const uint32_t size) {
+uint32_t TJSONProtocol::writeListBegin(const TType elemType, const uint32_t size) {
   uint32_t result = writeJSONArrayStart();
   result += writeJSONString(getTypeNameForTypeID(elemType));
   result += writeJSONInteger((int64_t)size);
@@ -622,8 +640,7 @@ uint32_t TJSONProtocol::writeListEnd() {
   return writeJSONArrayEnd();
 }
 
-uint32_t TJSONProtocol::writeSetBegin(const TType elemType,
-                                      const uint32_t size) {
+uint32_t TJSONProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
   uint32_t result = writeJSONArrayStart();
   result += writeJSONString(getTypeNameForTypeID(elemType));
   result += writeJSONInteger((int64_t)size);
@@ -668,9 +685,9 @@ uint32_t TJSONProtocol::writeBinary(const std::string& str) {
   return writeJSONBase64(str);
 }
 
-  /**
-   * Reading functions
-   */
+/**
+ * Reading functions
+ */
 
 // Reads 1 byte and verifies that it matches ch.
 uint32_t TJSONProtocol::readJSONSyntaxChar(uint8_t ch) {
@@ -679,7 +696,7 @@ uint32_t TJSONProtocol::readJSONSyntaxChar(uint8_t ch) {
 
 // Decodes the four hex parts of a JSON escaped string character and returns
 // the character via out. The first two characters must be "00".
-uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t *out) {
+uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t* out) {
   uint8_t b[2];
   readJSONSyntaxChar(kJSONZeroChar);
   readJSONSyntaxChar(kJSONZeroChar);
@@ -690,7 +707,7 @@ uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t *out) {
 }
 
 // Decodes a JSON string, including unescaping, and returns the string via str
-uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
+uint32_t TJSONProtocol::readJSONString(std::string& str, bool skipContext) {
   uint32_t result = (skipContext ? 0 : context_->read(reader_));
   result += readJSONSyntaxChar(kJSONStringDelimiter);
   uint8_t ch;
@@ -706,13 +723,12 @@ uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
       ++result;
       if (ch == kJSONEscapeChar) {
         result += readJSONEscapeChar(&ch);
-      }
-      else {
+      } else {
         size_t pos = kEscapeChars.find(ch);
         if (pos == std::string::npos) {
           throw TProtocolException(TProtocolException::INVALID_DATA,
-                                   "Expected control char, got '" +
-                                   std::string((const char *)&ch, 1)  + "'.");
+                                   "Expected control char, got '" + std::string((const char*)&ch, 1)
+                                   + "'.");
         }
         ch = kEscapeCharVals[pos];
       }
@@ -723,17 +739,17 @@ uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
 }
 
 // Reads a block of base64 characters, decoding it, and returns via str
-uint32_t TJSONProtocol::readJSONBase64(std::string &str) {
+uint32_t TJSONProtocol::readJSONBase64(std::string& str) {
   std::string tmp;
   uint32_t result = readJSONString(tmp);
-  uint8_t *b = (uint8_t *)tmp.c_str();
-  if(tmp.length() > (std::numeric_limits<uint32_t>::max)())
+  uint8_t* b = (uint8_t*)tmp.c_str();
+  if (tmp.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   uint32_t len = static_cast<uint32_t>(tmp.length());
   str.clear();
   while (len >= 4) {
     base64_decode(b, 4);
-    str.append((const char *)b, 3);
+    str.append((const char*)b, 3);
     b += 4;
     len -= 4;
   }
@@ -741,14 +757,14 @@ uint32_t TJSONProtocol::readJSONBase64(std::string &str) {
   // base64 but legal for skip of regular string type)
   if (len > 1) {
     base64_decode(b, len);
-    str.append((const char *)b, len - 1);
+    str.append((const char*)b, len - 1);
   }
   return result;
 }
 
 // Reads a sequence of characters, stopping at the first one that is not
 // a valid JSON numeric character.
-uint32_t TJSONProtocol::readJSONNumericChars(std::string &str) {
+uint32_t TJSONProtocol::readJSONNumericChars(std::string& str) {
   uint32_t result = 0;
   str.clear();
   while (true) {
@@ -766,7 +782,7 @@ uint32_t TJSONProtocol::readJSONNumericChars(std::string &str) {
 // Reads a sequence of characters and assembles them into a number,
 // returning them via num
 template <typename NumberType>
-uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
+uint32_t TJSONProtocol::readJSONInteger(NumberType& num) {
   uint32_t result = context_->read(reader_);
   if (context_->escapeNum()) {
     result += readJSONSyntaxChar(kJSONStringDelimiter);
@@ -775,11 +791,9 @@ uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
   result += readJSONNumericChars(str);
   try {
     num = boost::lexical_cast<NumberType>(str);
-  }
-  catch (boost::bad_lexical_cast e) {
+  } catch (boost::bad_lexical_cast e) {
     throw new TProtocolException(TProtocolException::INVALID_DATA,
-                                 "Expected numeric value; got \"" + str +
-                                  "\"");
+                                 "Expected numeric value; got \"" + str + "\"");
   }
   if (context_->escapeNum()) {
     result += readJSONSyntaxChar(kJSONStringDelimiter);
@@ -788,22 +802,19 @@ uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
 }
 
 // Reads a JSON number or string and interprets it as a double.
-uint32_t TJSONProtocol::readJSONDouble(double &num) {
+uint32_t TJSONProtocol::readJSONDouble(double& num) {
   uint32_t result = context_->read(reader_);
   std::string str;
   if (reader_.peek() == kJSONStringDelimiter) {
     result += readJSONString(str, true);
     // Check for NaN, Infinity and -Infinity
     if (str == kThriftNan) {
-      num = HUGE_VAL/HUGE_VAL; // generates NaN
-    }
-    else if (str == kThriftInfinity) {
+      num = HUGE_VAL / HUGE_VAL; // generates NaN
+    } else if (str == kThriftInfinity) {
       num = HUGE_VAL;
-    }
-    else if (str == kThriftNegativeInfinity) {
+    } else if (str == kThriftNegativeInfinity) {
       num = -HUGE_VAL;
-    }
-    else {
+    } else {
       if (!context_->escapeNum()) {
         // Throw exception -- we should not be in a string in this case
         throw new TProtocolException(TProtocolException::INVALID_DATA,
@@ -811,15 +822,12 @@ uint32_t TJSONProtocol::readJSONDouble(double &num) {
       }
       try {
         num = boost::lexical_cast<double>(str);
-      }
-      catch (boost::bad_lexical_cast e) {
+      } catch (boost::bad_lexical_cast e) {
         throw new TProtocolException(TProtocolException::INVALID_DATA,
-                                     "Expected numeric value; got \"" + str +
-                                     "\"");
+                                     "Expected numeric value; got \"" + str + "\"");
       }
     }
-  }
-  else {
+  } else {
     if (context_->escapeNum()) {
       // This will throw - we should have had a quote if escapeNum == true
       readJSONSyntaxChar(kJSONStringDelimiter);
@@ -827,11 +835,9 @@ uint32_t TJSONProtocol::readJSONDouble(double &num) {
     result += readJSONNumericChars(str);
     try {
       num = boost::lexical_cast<double>(str);
-    }
-    catch (boost::bad_lexical_cast e) {
+    } catch (boost::bad_lexical_cast e) {
       throw new TProtocolException(TProtocolException::INVALID_DATA,
-                                   "Expected numeric value; got \"" + str +
-                                   "\"");
+                                   "Expected numeric value; got \"" + str + "\"");
     }
   }
   return result;
@@ -870,14 +876,13 @@ uint32_t TJSONProtocol::readMessageBegin(std::string& name,
   uint64_t tmpVal = 0;
   result += readJSONInteger(tmpVal);
   if (tmpVal != kThriftVersion1) {
-    throw TProtocolException(TProtocolException::BAD_VERSION,
-                             "Message contained bad version.");
+    throw TProtocolException(TProtocolException::BAD_VERSION, "Message contained bad version.");
   }
   result += readJSONString(name);
   result += readJSONInteger(tmpVal);
   messageType = (TMessageType)tmpVal;
   result += readJSONInteger(tmpVal);
-  if(tmpVal > static_cast<uint64_t>((std::numeric_limits<int32_t>::max)()))
+  if (tmpVal > static_cast<uint64_t>((std::numeric_limits<int32_t>::max)()))
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   seqid = static_cast<int32_t>(tmpVal);
   return result;
@@ -888,7 +893,7 @@ uint32_t TJSONProtocol::readMessageEnd() {
 }
 
 uint32_t TJSONProtocol::readStructBegin(std::string& name) {
-  (void) name;
+  (void)name;
   return readJSONObjectStart();
 }
 
@@ -896,21 +901,18 @@ uint32_t TJSONProtocol::readStructEnd() {
   return readJSONObjectEnd();
 }
 
-uint32_t TJSONProtocol::readFieldBegin(std::string& name,
-                                       TType& fieldType,
-                                       int16_t& fieldId) {
-  (void) name;
+uint32_t TJSONProtocol::readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
+  (void)name;
   uint32_t result = 0;
   // Check if we hit the end of the list
   uint8_t ch = reader_.peek();
   if (ch == kJSONObjectEnd) {
     fieldType = apache::thrift::protocol::T_STOP;
-  }
-  else {
+  } else {
     uint64_t tmpVal = 0;
     std::string tmpStr;
     result += readJSONInteger(tmpVal);
-    if(tmpVal > static_cast<uint32_t>((std::numeric_limits<int16_t>::max)()))
+    if (tmpVal > static_cast<uint32_t>((std::numeric_limits<int16_t>::max)()))
       throw TProtocolException(TProtocolException::SIZE_LIMIT);
     fieldId = static_cast<int16_t>(tmpVal);
     result += readJSONObjectStart();
@@ -924,9 +926,7 @@ uint32_t TJSONProtocol::readFieldEnd() {
   return readJSONObjectEnd();
 }
 
-uint32_t TJSONProtocol::readMapBegin(TType& keyType,
-                                     TType& valType,
-                                     uint32_t& size) {
+uint32_t TJSONProtocol::readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
   uint64_t tmpVal = 0;
   std::string tmpStr;
   uint32_t result = readJSONArrayStart();
@@ -935,7 +935,7 @@ uint32_t TJSONProtocol::readMapBegin(TType& keyType,
   result += readJSONString(tmpStr);
   valType = getTypeIDForTypeName(tmpStr);
   result += readJSONInteger(tmpVal);
-  if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+  if (tmpVal > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   size = static_cast<uint32_t>(tmpVal);
   result += readJSONObjectStart();
@@ -946,15 +946,14 @@ uint32_t TJSONProtocol::readMapEnd() {
   return readJSONObjectEnd() + readJSONArrayEnd();
 }
 
-uint32_t TJSONProtocol::readListBegin(TType& elemType,
-                                      uint32_t& size) {
+uint32_t TJSONProtocol::readListBegin(TType& elemType, uint32_t& size) {
   uint64_t tmpVal = 0;
   std::string tmpStr;
   uint32_t result = readJSONArrayStart();
   result += readJSONString(tmpStr);
   elemType = getTypeIDForTypeName(tmpStr);
   result += readJSONInteger(tmpVal);
-  if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+  if (tmpVal > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   size = static_cast<uint32_t>(tmpVal);
   return result;
@@ -964,15 +963,14 @@ uint32_t TJSONProtocol::readListEnd() {
   return readJSONArrayEnd();
 }
 
-uint32_t TJSONProtocol::readSetBegin(TType& elemType,
-                                     uint32_t& size) {
+uint32_t TJSONProtocol::readSetBegin(TType& elemType, uint32_t& size) {
   uint64_t tmpVal = 0;
   std::string tmpStr;
   uint32_t result = readJSONArrayStart();
   result += readJSONString(tmpStr);
   elemType = getTypeIDForTypeName(tmpStr);
   result += readJSONInteger(tmpVal);
-  if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+  if (tmpVal > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   size = static_cast<uint32_t>(tmpVal);
   return result;
@@ -989,8 +987,8 @@ uint32_t TJSONProtocol::readBool(bool& value) {
 // readByte() must be handled properly becuase boost::lexical cast sees int8_t
 // as a text type instead of an integer type
 uint32_t TJSONProtocol::readByte(int8_t& byte) {
-  int16_t tmp = (int16_t) byte;
-  uint32_t result =  readJSONInteger(tmp);
+  int16_t tmp = (int16_t)byte;
+  uint32_t result = readJSONInteger(tmp);
   assert(tmp < 256);
   byte = (int8_t)tmp;
   return result;
@@ -1012,12 +1010,13 @@ uint32_t TJSONProtocol::readDouble(double& dub) {
   return readJSONDouble(dub);
 }
 
-uint32_t TJSONProtocol::readString(std::string &str) {
+uint32_t TJSONProtocol::readString(std::string& str) {
   return readJSONString(str);
 }
 
-uint32_t TJSONProtocol::readBinary(std::string &str) {
+uint32_t TJSONProtocol::readBinary(std::string& str) {
   return readJSONBase64(str);
 }
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TJSONProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
index edfc744..b19c35d 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
@@ -24,7 +24,9 @@
 
 #include <stack>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 // Forward declaration
 class TJSONContext;
@@ -88,14 +90,12 @@ class TJSONContext;
  *
  */
 class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
- public:
-
+public:
   TJSONProtocol(boost::shared_ptr<TTransport> ptrans);
 
   ~TJSONProtocol();
 
- private:
-
+private:
   void pushContext(boost::shared_ptr<TJSONContext> c);
 
   void popContext();
@@ -104,16 +104,16 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t writeJSONChar(uint8_t ch);
 
-  uint32_t writeJSONString(const std::string &str);
+  uint32_t writeJSONString(const std::string& str);
 
-  uint32_t writeJSONBase64(const std::string &str);
+  uint32_t writeJSONBase64(const std::string& str);
 
   template <typename NumberType>
   uint32_t writeJSONInteger(NumberType num);
 
   uint32_t writeJSONDouble(double num);
 
-  uint32_t writeJSONObjectStart() ;
+  uint32_t writeJSONObjectStart();
 
   uint32_t writeJSONObjectEnd();
 
@@ -123,18 +123,18 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t readJSONSyntaxChar(uint8_t ch);
 
-  uint32_t readJSONEscapeChar(uint8_t *out);
+  uint32_t readJSONEscapeChar(uint8_t* out);
 
-  uint32_t readJSONString(std::string &str, bool skipContext = false);
+  uint32_t readJSONString(std::string& str, bool skipContext = false);
 
-  uint32_t readJSONBase64(std::string &str);
+  uint32_t readJSONBase64(std::string& str);
 
-  uint32_t readJSONNumericChars(std::string &str);
+  uint32_t readJSONNumericChars(std::string& str);
 
   template <typename NumberType>
-  uint32_t readJSONInteger(NumberType &num);
+  uint32_t readJSONInteger(NumberType& num);
 
-  uint32_t readJSONDouble(double &num);
+  uint32_t readJSONDouble(double& num);
 
   uint32_t readJSONObjectStart();
 
@@ -144,8 +144,7 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t readJSONArrayEnd();
 
- public:
-
+public:
   /**
    * Writing functions.
    */
@@ -160,27 +159,21 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t writeStructEnd();
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId);
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
 
   uint32_t writeFieldEnd();
 
   uint32_t writeFieldStop();
 
-  uint32_t writeMapBegin(const TType keyType,
-                         const TType valType,
-                         const uint32_t size);
+  uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
 
   uint32_t writeMapEnd();
 
-  uint32_t writeListBegin(const TType elemType,
-                          const uint32_t size);
+  uint32_t writeListBegin(const TType elemType, const uint32_t size);
 
   uint32_t writeListEnd();
 
-  uint32_t writeSetBegin(const TType elemType,
-                         const uint32_t size);
+  uint32_t writeSetBegin(const TType elemType, const uint32_t size);
 
   uint32_t writeSetEnd();
 
@@ -204,9 +197,7 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
    * Reading functions
    */
 
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid);
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
 
   uint32_t readMessageEnd();
 
@@ -214,25 +205,19 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t readStructEnd();
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId);
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
 
   uint32_t readFieldEnd();
 
-  uint32_t readMapBegin(TType& keyType,
-                        TType& valType,
-                        uint32_t& size);
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
 
   uint32_t readMapEnd();
 
-  uint32_t readListBegin(TType& elemType,
-                         uint32_t& size);
+  uint32_t readListBegin(TType& elemType, uint32_t& size);
 
   uint32_t readListEnd();
 
-  uint32_t readSetBegin(TType& elemType,
-                        uint32_t& size);
+  uint32_t readSetBegin(TType& elemType, uint32_t& size);
 
   uint32_t readSetEnd();
 
@@ -257,18 +242,13 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   class LookaheadReader {
 
-   public:
-
-    LookaheadReader(TTransport &trans) :
-      trans_(&trans),
-      hasData_(false) {
-    }
+  public:
+    LookaheadReader(TTransport& trans) : trans_(&trans), hasData_(false) {}
 
     uint8_t read() {
       if (hasData_) {
         hasData_ = false;
-      }
-      else {
+      } else {
         trans_->readAll(&data_, 1);
       }
       return data_;
@@ -282,13 +262,13 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
       return data_;
     }
 
-   private:
-    TTransport *trans_;
+  private:
+    TTransport* trans_;
     bool hasData_;
     uint8_t data_;
   };
 
- private:
+private:
   TTransport* trans_;
 
   std::stack<boost::shared_ptr<TJSONContext> > contexts_;
@@ -300,7 +280,7 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
  * Constructs input and output protocol objects given transports.
  */
 class TJSONProtocolFactory : public TProtocolFactory {
- public:
+public:
   TJSONProtocolFactory() {}
 
   virtual ~TJSONProtocolFactory() {}
@@ -309,17 +289,18 @@ class TJSONProtocolFactory : public TProtocolFactory {
     return boost::shared_ptr<TProtocol>(new TJSONProtocol(trans));
   }
 };
-
-}}} // apache::thrift::protocol
-
+}
+}
+} // apache::thrift::protocol
 
 // TODO(dreiss): Move part of ThriftJSONString into a .cpp file and remove this.
 #include <thrift/transport/TBufferTransports.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
-template<typename ThriftStruct>
-  std::string ThriftJSONString(const ThriftStruct& ts) {
+template <typename ThriftStruct>
+std::string ThriftJSONString(const ThriftStruct& ts) {
   using namespace apache::thrift::transport;
   using namespace apache::thrift::protocol;
   TMemoryBuffer* buffer = new TMemoryBuffer;
@@ -333,7 +314,7 @@ template<typename ThriftStruct>
   buffer->getBuffer(&buf, &size);
   return std::string((char*)buf, (unsigned int)size);
 }
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // #define _THRIFT_PROTOCOL_TJSONPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
index 756b9b9..f0dc69e 100644
--- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
@@ -21,27 +21,20 @@
 #include <thrift/processor/TMultiplexedProcessor.h>
 #include <thrift/protocol/TProtocolDecorator.h>
 
-namespace apache
-{
-    namespace thrift
-    {
-        namespace protocol
-        {
-            uint32_t TMultiplexedProtocol::writeMessageBegin_virt(
-                const std::string& _name,
-                const TMessageType _type,
-                const int32_t _seqid)
-            {
-                if( _type == T_CALL || _type == T_ONEWAY )
-                {
-                    return TProtocolDecorator::writeMessageBegin_virt( serviceName + separator + _name, _type, _seqid );
-                }
-                else
-                {
-                    return TProtocolDecorator::writeMessageBegin_virt(_name, _type, _seqid);
-                }
-            }
-        }
-    }
+namespace apache {
+namespace thrift {
+namespace protocol {
+uint32_t TMultiplexedProtocol::writeMessageBegin_virt(const std::string& _name,
+                                                      const TMessageType _type,
+                                                      const int32_t _seqid) {
+  if (_type == T_CALL || _type == T_ONEWAY) {
+    return TProtocolDecorator::writeMessageBegin_virt(serviceName + separator + _name,
+                                                      _type,
+                                                      _seqid);
+  } else {
+    return TProtocolDecorator::writeMessageBegin_virt(_name, _type, _seqid);
+  }
+}
+}
+}
 }
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
index e93f371..0244fbe 100644
--- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
@@ -22,82 +22,74 @@
 
 #include <thrift/protocol/TProtocolDecorator.h>
 
-namespace apache
-{
-    namespace thrift
-    {
-        namespace protocol
-        {
-            using boost::shared_ptr;
+namespace apache {
+namespace thrift {
+namespace protocol {
+using boost::shared_ptr;
 
-            /**
-             * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator
-             * that allows a Thrift client to communicate with a multiplexing Thrift server,
-             * by prepending the service name to the function name during function calls.
-             *
-             * \note THIS IS NOT USED BY SERVERS.  On the server, use
-             * {@link apache::thrift::TMultiplexedProcessor TMultiplexedProcessor} to handle requests
-             * from a multiplexing client.
-             *
-             * This example uses a single socket transport to invoke two services:
-             *
-             * <blockquote><code>
-             *     shared_ptr<TSocket> transport(new TSocket("localhost", 9090));
-             *     transport->open();
-             *
-             *     shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
-             *
-             *     shared_ptr<TMultiplexedProtocol> mp1(new TMultiplexedProtocol(protocol, "Calculator"));
-             *     shared_ptr<CalculatorClient> service1(new CalculatorClient(mp1));
-             *
-             *     shared_ptr<TMultiplexedProtocol> mp2(new TMultiplexedProtocol(protocol, "WeatherReport"));
-             *     shared_ptr<WeatherReportClient> service2(new WeatherReportClient(mp2));
-             *
-             *     service1->add(2,2);
-             *     int temp = service2->getTemperature();
-             * </code></blockquote>
-             *
-             * @see apache::thrift::protocol::TProtocolDecorator
-             */
-             class TMultiplexedProtocol : public TProtocolDecorator
-            {
-            public:
-                /**
-                 * Wrap the specified protocol, allowing it to be used to communicate with a
-                 * multiplexing server.  The <code>serviceName</code> is required as it is
-                 * prepended to the message header so that the multiplexing server can broker
-                 * the function call to the proper service.
-                 *
-                 * \param _protocol    Your communication protocol of choice, e.g. <code>TBinaryProtocol</code>.
-                 * \param _serviceName The service name of the service communicating via this protocol.
-                 */
-                 TMultiplexedProtocol( shared_ptr<TProtocol> _protocol, const std::string& _serviceName )
-                    : TProtocolDecorator(_protocol),
-                      serviceName(_serviceName),
-                      separator(":")
-                { }
-                virtual ~TMultiplexedProtocol() {}
+/**
+ * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator
+ * that allows a Thrift client to communicate with a multiplexing Thrift server,
+ * by prepending the service name to the function name during function calls.
+ *
+ * \note THIS IS NOT USED BY SERVERS.  On the server, use
+ * {@link apache::thrift::TMultiplexedProcessor TMultiplexedProcessor} to handle requests
+ * from a multiplexing client.
+ *
+ * This example uses a single socket transport to invoke two services:
+ *
+ * <blockquote><code>
+ *     shared_ptr<TSocket> transport(new TSocket("localhost", 9090));
+ *     transport->open();
+ *
+ *     shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
+ *
+ *     shared_ptr<TMultiplexedProtocol> mp1(new TMultiplexedProtocol(protocol, "Calculator"));
+ *     shared_ptr<CalculatorClient> service1(new CalculatorClient(mp1));
+ *
+ *     shared_ptr<TMultiplexedProtocol> mp2(new TMultiplexedProtocol(protocol, "WeatherReport"));
+ *     shared_ptr<WeatherReportClient> service2(new WeatherReportClient(mp2));
+ *
+ *     service1->add(2,2);
+ *     int temp = service2->getTemperature();
+ * </code></blockquote>
+ *
+ * @see apache::thrift::protocol::TProtocolDecorator
+ */
+class TMultiplexedProtocol : public TProtocolDecorator {
+public:
+  /**
+   * Wrap the specified protocol, allowing it to be used to communicate with a
+   * multiplexing server.  The <code>serviceName</code> is required as it is
+   * prepended to the message header so that the multiplexing server can broker
+   * the function call to the proper service.
+   *
+   * \param _protocol    Your communication protocol of choice, e.g. <code>TBinaryProtocol</code>.
+   * \param _serviceName The service name of the service communicating via this protocol.
+   */
+  TMultiplexedProtocol(shared_ptr<TProtocol> _protocol, const std::string& _serviceName)
+    : TProtocolDecorator(_protocol), serviceName(_serviceName), separator(":") {}
+  virtual ~TMultiplexedProtocol() {}
 
-                /**
-                 * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
-                 *
-                 * \param [in] _name   The name of the method to be called in the service.
-                 * \param [in] _type   The type of message
-                 * \param [in] _name   The sequential id of the message
-                 *
-                 * \throws TException  Passed through from wrapped <code>TProtocol</code> instance.
-                 */
-                uint32_t writeMessageBegin_virt(
-                    const std::string& _name,
-                    const TMessageType _type,
-                    const int32_t _seqid);
-            private:
-                const std::string serviceName;
-                const std::string separator;
-            };
+  /**
+   * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
+   *
+   * \param [in] _name   The name of the method to be called in the service.
+   * \param [in] _type   The type of message
+   * \param [in] _name   The sequential id of the message
+   *
+   * \throws TException  Passed through from wrapped <code>TProtocol</code> instance.
+   */
+  uint32_t writeMessageBegin_virt(const std::string& _name,
+                                  const TMessageType _type,
+                                  const int32_t _seqid);
 
-        }
-    }
+private:
+  const std::string serviceName;
+  const std::string separator;
+};
+}
+}
 }
 
 #endif // THRIFT_TMULTIPLEXEDPROTOCOL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h
index d4c343d..0c76cc0 100644
--- a/lib/cpp/src/thrift/protocol/TProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TProtocol.h
@@ -34,7 +34,6 @@
 #include <map>
 #include <vector>
 
-
 // Use this to get around strict aliasing rules.
 // For example, uint64_t i = bitwise_cast<uint64_t>(returns_double());
 // The most obvious implementation is to just cast a pointer,
@@ -136,7 +135,9 @@ static inline To bitwise_cast(From from) {
 # error "Can't define htonll or ntohll!"
 #endif
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 using apache::thrift::transport::TTransport;
 
@@ -186,98 +187,91 @@ enum TMessageType {
 template <class Protocol_>
 uint32_t skip(Protocol_& prot, TType type) {
   switch (type) {
-  case T_BOOL:
-    {
-      bool boolv;
-      return prot.readBool(boolv);
-    }
-  case T_BYTE:
-    {
-      int8_t bytev;
-      return prot.readByte(bytev);
-    }
-  case T_I16:
-    {
-      int16_t i16;
-      return prot.readI16(i16);
-    }
-  case T_I32:
-    {
-      int32_t i32;
-      return prot.readI32(i32);
-    }
-  case T_I64:
-    {
-      int64_t i64;
-      return prot.readI64(i64);
-    }
-  case T_DOUBLE:
-    {
-      double dub;
-      return prot.readDouble(dub);
-    }
-  case T_STRING:
-    {
-      std::string str;
-      return prot.readBinary(str);
-    }
-  case T_STRUCT:
-    {
-      uint32_t result = 0;
-      std::string name;
-      int16_t fid;
-      TType ftype;
-      result += prot.readStructBegin(name);
-      while (true) {
-        result += prot.readFieldBegin(name, ftype, fid);
-        if (ftype == T_STOP) {
-          break;
-        }
-        result += skip(prot, ftype);
-        result += prot.readFieldEnd();
+  case T_BOOL: {
+    bool boolv;
+    return prot.readBool(boolv);
+  }
+  case T_BYTE: {
+    int8_t bytev;
+    return prot.readByte(bytev);
+  }
+  case T_I16: {
+    int16_t i16;
+    return prot.readI16(i16);
+  }
+  case T_I32: {
+    int32_t i32;
+    return prot.readI32(i32);
+  }
+  case T_I64: {
+    int64_t i64;
+    return prot.readI64(i64);
+  }
+  case T_DOUBLE: {
+    double dub;
+    return prot.readDouble(dub);
+  }
+  case T_STRING: {
+    std::string str;
+    return prot.readBinary(str);
+  }
+  case T_STRUCT: {
+    uint32_t result = 0;
+    std::string name;
+    int16_t fid;
+    TType ftype;
+    result += prot.readStructBegin(name);
+    while (true) {
+      result += prot.readFieldBegin(name, ftype, fid);
+      if (ftype == T_STOP) {
+        break;
       }
-      result += prot.readStructEnd();
-      return result;
+      result += skip(prot, ftype);
+      result += prot.readFieldEnd();
     }
-  case T_MAP:
-    {
-      uint32_t result = 0;
-      TType keyType;
-      TType valType;
-      uint32_t i, size;
-      result += prot.readMapBegin(keyType, valType, size);
-      for (i = 0; i < size; i++) {
-        result += skip(prot, keyType);
-        result += skip(prot, valType);
-      }
-      result += prot.readMapEnd();
-      return result;
+    result += prot.readStructEnd();
+    return result;
+  }
+  case T_MAP: {
+    uint32_t result = 0;
+    TType keyType;
+    TType valType;
+    uint32_t i, size;
+    result += prot.readMapBegin(keyType, valType, size);
+    for (i = 0; i < size; i++) {
+      result += skip(prot, keyType);
+      result += skip(prot, valType);
     }
-  case T_SET:
-    {
-      uint32_t result = 0;
-      TType elemType;
-      uint32_t i, size;
-      result += prot.readSetBegin(elemType, size);
-      for (i = 0; i < size; i++) {
-        result += skip(prot, elemType);
-      }
-      result += prot.readSetEnd();
-      return result;
+    result += prot.readMapEnd();
+    return result;
+  }
+  case T_SET: {
+    uint32_t result = 0;
+    TType elemType;
+    uint32_t i, size;
+    result += prot.readSetBegin(elemType, size);
+    for (i = 0; i < size; i++) {
+      result += skip(prot, elemType);
     }
-  case T_LIST:
-    {
-      uint32_t result = 0;
-      TType elemType;
-      uint32_t i, size;
-      result += prot.readListBegin(elemType, size);
-      for (i = 0; i < size; i++) {
-        result += skip(prot, elemType);
-      }
-      result += prot.readListEnd();
-      return result;
+    result += prot.readSetEnd();
+    return result;
+  }
+  case T_LIST: {
+    uint32_t result = 0;
+    TType elemType;
+    uint32_t i, size;
+    result += prot.readListBegin(elemType, size);
+    for (i = 0; i < size; i++) {
+      result += skip(prot, elemType);
     }
-  case T_STOP: case T_VOID: case T_U64: case T_UTF8: case T_UTF16:
+    result += prot.readListEnd();
+    return result;
+  }
+  case T_STOP:
+  case T_VOID:
+  case T_U64:
+  case T_UTF8:
+  case T_UTF16:
     break;
   }
   return 0;
@@ -300,7 +294,7 @@ static const uint32_t DEFAULT_RECURSION_LIMIT = 64;
  *
  */
 class TProtocol {
- public:
+public:
   virtual ~TProtocol() {}
 
   /**
@@ -313,7 +307,6 @@ class TProtocol {
 
   virtual uint32_t writeMessageEnd_virt() = 0;
 
-
   virtual uint32_t writeStructBegin_virt(const char* name) = 0;
 
   virtual uint32_t writeStructEnd_virt() = 0;
@@ -326,19 +319,16 @@ class TProtocol {
 
   virtual uint32_t writeFieldStop_virt() = 0;
 
-  virtual uint32_t writeMapBegin_virt(const TType keyType,
-                                      const TType valType,
-                                      const uint32_t size) = 0;
+  virtual uint32_t writeMapBegin_virt(const TType keyType, const TType valType, const uint32_t size)
+      = 0;
 
   virtual uint32_t writeMapEnd_virt() = 0;
 
-  virtual uint32_t writeListBegin_virt(const TType elemType,
-                                       const uint32_t size) = 0;
+  virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) = 0;
 
   virtual uint32_t writeListEnd_virt() = 0;
 
-  virtual uint32_t writeSetBegin_virt(const TType elemType,
-                                      const uint32_t size) = 0;
+  virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) = 0;
 
   virtual uint32_t writeSetEnd_virt() = 0;
 
@@ -370,7 +360,6 @@ class TProtocol {
     return writeMessageEnd_virt();
   }
 
-
   uint32_t writeStructBegin(const char* name) {
     T_VIRTUAL_CALL();
     return writeStructBegin_virt(name);
@@ -381,9 +370,7 @@ class TProtocol {
     return writeStructEnd_virt();
   }
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId) {
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId) {
     T_VIRTUAL_CALL();
     return writeFieldBegin_virt(name, fieldType, fieldId);
   }
@@ -398,9 +385,7 @@ class TProtocol {
     return writeFieldStop_virt();
   }
 
-  uint32_t writeMapBegin(const TType keyType,
-                         const TType valType,
-                         const uint32_t size) {
+  uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size) {
     T_VIRTUAL_CALL();
     return writeMapBegin_virt(keyType, valType, size);
   }
@@ -485,24 +470,19 @@ class TProtocol {
   virtual uint32_t readStructEnd_virt() = 0;
 
   virtual uint32_t readFieldBegin_virt(std::string& name,
-                                       TType& fieldType,
-                                       int16_t& fieldId) = 0;
+  virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) = 0;
 
   virtual uint32_t readFieldEnd_virt() = 0;
 
-  virtual uint32_t readMapBegin_virt(TType& keyType,
-                                     TType& valType,
-                                     uint32_t& size) = 0;
+  virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) = 0;
 
   virtual uint32_t readMapEnd_virt() = 0;
 
-  virtual uint32_t readListBegin_virt(TType& elemType,
-                                      uint32_t& size) = 0;
+  virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) = 0;
 
   virtual uint32_t readListEnd_virt() = 0;
 
-  virtual uint32_t readSetBegin_virt(TType& elemType,
-                                     uint32_t& size) = 0;
+  virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) = 0;
 
   virtual uint32_t readSetEnd_virt() = 0;
 
@@ -524,9 +504,7 @@ class TProtocol {
 
   virtual uint32_t readBinary_virt(std::string& str) = 0;
 
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid) {
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
     T_VIRTUAL_CALL();
     return readMessageBegin_virt(name, messageType, seqid);
   }
@@ -546,9 +524,7 @@ class TProtocol {
     return readStructEnd_virt();
   }
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId) {
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
     T_VIRTUAL_CALL();
     return readFieldBegin_virt(name, fieldType, fieldId);
   }
@@ -645,22 +621,14 @@ class TProtocol {
     T_VIRTUAL_CALL();
     return skip_virt(type);
   }
-  virtual uint32_t skip_virt(TType type) {
-    return ::apache::thrift::protocol::skip(*this, type);
-  }
+  virtual uint32_t skip_virt(TType type) { return ::apache::thrift::protocol::skip(*this, type); }
 
-  inline boost::shared_ptr<TTransport> getTransport() {
-    return ptrans_;
-  }
+  inline boost::shared_ptr<TTransport> getTransport() { return ptrans_; }
 
   // TODO: remove these two calls, they are for backwards
   // compatibility
-  inline boost::shared_ptr<TTransport> getInputTransport() {
-    return ptrans_;
-  }
-  inline boost::shared_ptr<TTransport> getOutputTransport() {
-    return ptrans_;
-  }
+  inline boost::shared_ptr<TTransport> getInputTransport() { return ptrans_; }
+  inline boost::shared_ptr<TTransport> getOutputTransport() { return ptrans_; }
 
   void incrementRecursionDepth() {
     if (recursion_limit_ < ++recursion_depth_) {
@@ -668,19 +636,15 @@ class TProtocol {
     }
   }
 
-  void decrementRecursionDepth() {
-    --recursion_depth_;
-  }
+  void decrementRecursionDepth() { --recursion_depth_; }
 
- protected:
+protected:
   TProtocol(boost::shared_ptr<TTransport> ptrans)
-    : ptrans_(ptrans)
-    , recursion_depth_(0)
-    , recursion_limit_(DEFAULT_RECURSION_LIMIT) {}
+    : ptrans_(ptrans), recursion_depth_(0), recursion_limit_(DEFAULT_RECURSION_LIMIT) {}
 
   boost::shared_ptr<TTransport> ptrans_;
 
- private:
+private:
   TProtocol() {}
   uint32_t recursion_depth_;
   uint32_t recursion_limit_;
@@ -690,7 +654,7 @@ class TProtocol {
  * Constructs input and output protocol objects given transports.
  */
 class TProtocolFactory {
- public:
+public:
   TProtocolFactory() {}
 
   virtual ~TProtocolFactory() {}
@@ -704,9 +668,9 @@ class TProtocolFactory {
  * This class does nothing, and should never be instantiated.
  * It is used only by the generator code.
  */
-class TDummyProtocol : public TProtocol {
-};
-
-}}} // apache::thrift::protocol
+class TDummyProtocol : public TProtocol {};
+}
+}
+} // apache::thrift::protocol
 
 #endif // #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
index 570e977..446a81f 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
@@ -23,111 +23,129 @@
 #include <thrift/protocol/TProtocol.h>
 #include <boost/shared_ptr.hpp>
 
-namespace apache
-{
-    namespace thrift
-    {
-        namespace protocol
-        {
-            using boost::shared_ptr;
-
-            /**
-             * <code>TProtocolDecorator</code> forwards all requests to an enclosed
-             * <code>TProtocol</code> instance, providing a way to author concise
-             * concrete decorator subclasses.
-             *
-             * <p>See p.175 of Design Patterns (by Gamma et al.)</p>
-             *
-             * @see apache::thrift::protocol::TMultiplexedProtocol
-             */
-            class TProtocolDecorator : public TProtocol
-            {
-            public:
-                virtual ~TProtocolDecorator() {}
-
-                // Desc: Initializes the protocol decorator object.
-                TProtocolDecorator( shared_ptr<TProtocol> proto )
-                    : TProtocol(proto->getTransport()), protocol(proto)
-                {
-                }
-
-                virtual uint32_t writeMessageBegin_virt(
-                    const std::string& name,
-                    const TMessageType messageType,
-                    const int32_t seqid)
-                {
-                    return protocol->writeMessageBegin(name, messageType, seqid);
-                }
-                virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
-                virtual uint32_t writeStructBegin_virt(const char* name) { return protocol->writeStructBegin(name); }
-                virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
-
-                virtual uint32_t writeFieldBegin_virt(const char* name,
-                    const TType fieldType,
-                    const int16_t fieldId) { return protocol->writeFieldBegin(name,fieldType,fieldId); }
-
-                virtual uint32_t writeFieldEnd_virt()  { return protocol->writeFieldEnd(); }
-                virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
-
-                virtual uint32_t writeMapBegin_virt(const TType keyType,
-                    const TType valType,
-                    const uint32_t size) { return protocol->writeMapBegin(keyType,valType,size); }
-
-                virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
-
-                virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeListBegin(elemType,size); }
-                virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
-
-                virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeSetBegin(elemType,size); }
-                virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
-
-                virtual uint32_t writeBool_virt(const bool value)  { return protocol->writeBool(value); }
-                virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
-                virtual uint32_t writeI16_virt(const int16_t i16)  { return protocol->writeI16(i16); }
-                virtual uint32_t writeI32_virt(const int32_t i32)  { return protocol->writeI32(i32); }
-                virtual uint32_t writeI64_virt(const int64_t i64)  { return protocol->writeI64(i64); }
-
-                virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
-                virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
-                virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
-
-                virtual uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, int32_t& seqid) { return protocol->readMessageBegin(name,messageType,seqid); }
-                virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
-
-                virtual uint32_t readStructBegin_virt(std::string& name) { return protocol->readStructBegin(name); }
-                virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
-
-                virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) { return protocol->readFieldBegin(name, fieldType, fieldId); }
-                virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
-
-                virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) { return protocol->readMapBegin(keyType,valType,size); }
-                virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
-
-                virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) { return protocol->readListBegin(elemType,size); }
-                virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
-
-                virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) { return protocol->readSetBegin(elemType,size); }
-                virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
-
-                virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
-                virtual uint32_t readBool_virt(std::vector<bool>::reference value) { return protocol->readBool(value); }
-
-                virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
-
-                virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
-                virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
-                virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
-
-                virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
-
-                virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
-                virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
-
-            private:
-                shared_ptr<TProtocol> protocol;
-            };
-        }
-    }
+namespace apache {
+namespace thrift {
+namespace protocol {
+using boost::shared_ptr;
+
+/**
+ * <code>TProtocolDecorator</code> forwards all requests to an enclosed
+ * <code>TProtocol</code> instance, providing a way to author concise
+ * concrete decorator subclasses.
+ *
+ * <p>See p.175 of Design Patterns (by Gamma et al.)</p>
+ *
+ * @see apache::thrift::protocol::TMultiplexedProtocol
+ */
+class TProtocolDecorator : public TProtocol {
+public:
+  virtual ~TProtocolDecorator() {}
+
+  // Desc: Initializes the protocol decorator object.
+  TProtocolDecorator(shared_ptr<TProtocol> proto)
+    : TProtocol(proto->getTransport()), protocol(proto) {}
+
+  virtual uint32_t writeMessageBegin_virt(const std::string& name,
+                                          const TMessageType messageType,
+                                          const int32_t seqid) {
+    return protocol->writeMessageBegin(name, messageType, seqid);
+  }
+  virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
+  virtual uint32_t writeStructBegin_virt(const char* name) {
+    return protocol->writeStructBegin(name);
+  }
+  virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
+
+  virtual uint32_t writeFieldBegin_virt(const char* name,
+                                        const TType fieldType,
+                                        const int16_t fieldId) {
+    return protocol->writeFieldBegin(name, fieldType, fieldId);
+  }
+
+  virtual uint32_t writeFieldEnd_virt() { return protocol->writeFieldEnd(); }
+  virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
+
+  virtual uint32_t writeMapBegin_virt(const TType keyType,
+                                      const TType valType,
+                                      const uint32_t size) {
+    return protocol->writeMapBegin(keyType, valType, size);
+  }
+
+  virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
+
+  virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
+    return protocol->writeListBegin(elemType, size);
+  }
+  virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
+
+  virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
+    return protocol->writeSetBegin(elemType, size);
+  }
+  virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
+
+  virtual uint32_t writeBool_virt(const bool value) { return protocol->writeBool(value); }
+  virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
+  virtual uint32_t writeI16_virt(const int16_t i16) { return protocol->writeI16(i16); }
+  virtual uint32_t writeI32_virt(const int32_t i32) { return protocol->writeI32(i32); }
+  virtual uint32_t writeI64_virt(const int64_t i64) { return protocol->writeI64(i64); }
+
+  virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
+  virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
+  virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
+
+  virtual uint32_t readMessageBegin_virt(std::string& name,
+                                         TMessageType& messageType,
+                                         int32_t& seqid) {
+    return protocol->readMessageBegin(name, messageType, seqid);
+  }
+  virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
+
+  virtual uint32_t readStructBegin_virt(std::string& name) {
+    return protocol->readStructBegin(name);
+  }
+  virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
+
+  virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+    return protocol->readFieldBegin(name, fieldType, fieldId);
+  }
+  virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
+
+  virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
+    return protocol->readMapBegin(keyType, valType, size);
+  }
+  virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
+
+  virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
+    return protocol->readListBegin(elemType, size);
+  }
+  virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
+
+  virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
+    return protocol->readSetBegin(elemType, size);
+  }
+  virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
+
+  virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
+  virtual uint32_t readBool_virt(std::vector<bool>::reference value) {
+    return protocol->readBool(value);
+  }
+
+  virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
+
+  virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
+  virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
+  virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
+
+  virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
+
+  virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
+  virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
+
+private:
+  shared_ptr<TProtocol> protocol;
+};
+}
+}
 }
 
 #endif // THRIFT_TPROTOCOLDECORATOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolException.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TProtocolException.h b/lib/cpp/src/thrift/protocol/TProtocolException.h
index 4ddb81e..18a8ed0 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolException.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolException.h
@@ -22,7 +22,9 @@
 
 #include <string>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 /**
  * Class to encapsulate all the possible types of protocol errors that may
@@ -33,36 +35,29 @@ namespace apache { namespace thrift { namespace protocol {
  *
  */
 class TProtocolException : public apache::thrift::TException {
- public:
-
+public:
   /**
    * Error codes for the various types of exceptions.
    */
-  enum TProtocolExceptionType
-  { UNKNOWN = 0
-  , INVALID_DATA = 1
-  , NEGATIVE_SIZE = 2
-  , SIZE_LIMIT = 3
-  , BAD_VERSION = 4
-  , NOT_IMPLEMENTED = 5
-  , DEPTH_LIMIT = 6
+  enum TProtocolExceptionType {
+    UNKNOWN = 0,
+    INVALID_DATA = 1,
+    NEGATIVE_SIZE = 2,
+    SIZE_LIMIT = 3,
+    BAD_VERSION = 4,
+    NOT_IMPLEMENTED = 5,
+    DEPTH_LIMIT = 6
   };
 
-  TProtocolException() :
-    apache::thrift::TException(),
-    type_(UNKNOWN) {}
+  TProtocolException() : apache::thrift::TException(), type_(UNKNOWN) {}
 
-  TProtocolException(TProtocolExceptionType type) :
-    apache::thrift::TException(),
-    type_(type) {}
+  TProtocolException(TProtocolExceptionType type) : apache::thrift::TException(), type_(type) {}
 
-  TProtocolException(const std::string& message) :
-    apache::thrift::TException(message),
-    type_(UNKNOWN) {}
+  TProtocolException(const std::string& message)
+    : apache::thrift::TException(message), type_(UNKNOWN) {}
 
-  TProtocolException(TProtocolExceptionType type, const std::string& message) :
-    apache::thrift::TException(message),
-    type_(type) {}
+  TProtocolException(TProtocolExceptionType type, const std::string& message)
+    : apache::thrift::TException(message), type_(type) {}
 
   virtual ~TProtocolException() throw() {}
 
@@ -72,34 +67,39 @@ class TProtocolException : public apache::thrift::TException {
    *
    * @return Error code
    */
-  TProtocolExceptionType getType() {
-    return type_;
-  }
+  TProtocolExceptionType getType() { return type_; }
 
   virtual const char* what() const throw() {
     if (message_.empty()) {
       switch (type_) {
-        case UNKNOWN         : return "TProtocolException: Unknown protocol exception";
-        case INVALID_DATA    : return "TProtocolException: Invalid data";
-        case NEGATIVE_SIZE   : return "TProtocolException: Negative size";
-        case SIZE_LIMIT      : return "TProtocolException: Exceeded size limit";
-        case BAD_VERSION     : return "TProtocolException: Invalid version";
-        case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
-        default              : return "TProtocolException: (Invalid exception type)";
+      case UNKNOWN:
+        return "TProtocolException: Unknown protocol exception";
+      case INVALID_DATA:
+        return "TProtocolException: Invalid data";
+      case NEGATIVE_SIZE:
+        return "TProtocolException: Negative size";
+      case SIZE_LIMIT:
+        return "TProtocolException: Exceeded size limit";
+      case BAD_VERSION:
+        return "TProtocolException: Invalid version";
+      case NOT_IMPLEMENTED:
+        return "TProtocolException: Not implemented";
+      default:
+        return "TProtocolException: (Invalid exception type)";
       }
     } else {
       return message_.c_str();
     }
   }
 
- protected:
+protected:
   /**
    * Error code
    */
   TProtocolExceptionType type_;
-
 };
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #endif // #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolTap.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TProtocolTap.h b/lib/cpp/src/thrift/protocol/TProtocolTap.h
index f493f88..3e56393 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolTap.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolTap.h
@@ -22,7 +22,9 @@
 
 #include <thrift/protocol/TVirtualProtocol.h>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 using apache::thrift::transport::TTransport;
 
@@ -33,17 +35,11 @@ using apache::thrift::transport::TTransport;
  *
  */
 class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
- public:
-   TProtocolTap(boost::shared_ptr<TProtocol> source,
-                boost::shared_ptr<TProtocol> sink)
-     : TVirtualProtocol<TProtocolTap>(source->getTransport())
-     , source_(source)
-     , sink_(sink)
-  {}
-
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid) {
+public:
+  TProtocolTap(boost::shared_ptr<TProtocol> source, boost::shared_ptr<TProtocol> sink)
+    : TVirtualProtocol<TProtocolTap>(source->getTransport()), source_(source), sink_(sink) {}
+
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
     uint32_t rv = source_->readMessageBegin(name, messageType, seqid);
     sink_->writeMessageBegin(name, messageType, seqid);
     return rv;
@@ -67,9 +63,7 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId) {
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
     uint32_t rv = source_->readFieldBegin(name, fieldType, fieldId);
     if (fieldType == T_STOP) {
       sink_->writeFieldStop();
@@ -79,22 +73,18 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-
   uint32_t readFieldEnd() {
     uint32_t rv = source_->readFieldEnd();
     sink_->writeFieldEnd();
     return rv;
   }
 
-  uint32_t readMapBegin(TType& keyType,
-                        TType& valType,
-                        uint32_t& size) {
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
     uint32_t rv = source_->readMapBegin(keyType, valType, size);
     sink_->writeMapBegin(keyType, valType, size);
     return rv;
   }
 
-
   uint32_t readMapEnd() {
     uint32_t rv = source_->readMapEnd();
     sink_->writeMapEnd();
@@ -107,7 +97,6 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-
   uint32_t readListEnd() {
     uint32_t rv = source_->readListEnd();
     sink_->writeListEnd();
@@ -120,7 +109,6 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-
   uint32_t readSetEnd() {
     uint32_t rv = source_->readSetEnd();
     sink_->writeSetEnd();
@@ -178,11 +166,12 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
- private:
+private:
   boost::shared_ptr<TProtocol> source_;
   boost::shared_ptr<TProtocol> sink_;
 };
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #endif // #define _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ 1


[22/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_javame_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_javame_generator.cc b/compiler/cpp/src/generate/t_javame_generator.cc
index eb934ac..b4a13fc 100644
--- a/compiler/cpp/src/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/generate/t_javame_generator.cc
@@ -37,22 +37,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Java code generator.
  *
  */
 class t_javame_generator : public t_oop_generator {
- public:
-  t_javame_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_javame_generator(t_program* program,
+                     const std::map<std::string, std::string>& parsed_options,
+                     const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
     out_dir_base_ = "gen-javame";
   }
@@ -70,15 +68,23 @@ class t_javame_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_union   (t_struct*   tunion);
-  void generate_xception(t_struct*   txception);
-  void generate_service (t_service*  tservice);
-
-  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
-  std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_union(t_struct* tunion);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  void print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool in_static,
+                         bool defval = false);
+  std::string render_const_value(std::ofstream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
 
   /**
    * Service-level generation functions
@@ -86,7 +92,11 @@ class t_javame_generator : public t_oop_generator {
 
   void generate_java_struct(t_struct* tstruct, bool is_exception);
 
-  void generate_java_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
+  void generate_java_struct_definition(std::ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_xception = false,
+                                       bool in_class = false,
+                                       bool is_result = false);
   void generate_java_struct_equality(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_compare_to(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_reader(std::ofstream& out, t_struct* tstruct);
@@ -97,8 +107,14 @@ class t_javame_generator : public t_oop_generator {
   void generate_java_struct_clear(std::ofstream& out, t_struct* tstruct);
   void generate_field_value_meta_data(std::ofstream& out, t_type* type);
   std::string get_java_type_string(t_type* type);
-  void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
-  void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
+  void generate_reflection_setters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
+  void generate_reflection_getters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
   void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
   void generate_java_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
 
@@ -109,12 +125,12 @@ class t_javame_generator : public t_oop_generator {
   void generate_isset_set(ofstream& out, t_field* field);
   std::string isset_field_id(t_field* field);
 
-  void generate_primitive_service_interface (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_primitive_service_interface(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   void generate_java_union(t_struct* tstruct);
   void generate_union_constructor(ofstream& out, t_struct* tstruct);
@@ -134,69 +150,52 @@ class t_javame_generator : public t_oop_generator {
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter,
-                                          std::string map);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map);
 
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_java_doc                 (std::ofstream& out,
-                                          t_field*    field);
+  void generate_java_doc(std::ofstream& out, t_field* field);
 
-  void generate_java_doc                 (std::ofstream& out,
-                                          t_doc*      tdoc);
+  void generate_java_doc(std::ofstream& out, t_doc* tdoc);
 
-  void generate_java_doc                 (std::ofstream& out,
-                                          t_function* tdoc);
+  void generate_java_doc(std::ofstream& out, t_function* tdoc);
 
-  void generate_java_docstring_comment   (std::ofstream &out,
-                                          string contents);
+  void generate_java_docstring_comment(std::ofstream& out, string contents);
 
-  void generate_deep_copy_container(std::ofstream& out, std::string source_name_p1, std::string source_name_p2, std::string result_name, t_type* type);
-  void generate_deep_copy_non_container(std::ofstream& out, std::string source_name, std::string dest_name, t_type* type);
+  void generate_deep_copy_container(std::ofstream& out,
+                                    std::string source_name_p1,
+                                    std::string source_name_p2,
+                                    std::string result_name,
+                                    t_type* type);
+  void generate_deep_copy_non_container(std::ofstream& out,
+                                        std::string source_name,
+                                        std::string dest_name,
+                                        t_type* type);
 
   bool has_bit_vector(t_struct* tstruct);
 
@@ -207,10 +206,13 @@ class t_javame_generator : public t_oop_generator {
   std::string java_package();
   std::string java_type_imports();
   std::string java_thrift_imports();
-  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false);
-  std::string base_type_name(t_base_type* tbase, bool in_container=false);
-  std::string declare_field(t_field* tfield, bool init=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string type_name(t_type* ttype,
+                        bool in_container = false,
+                        bool in_init = false,
+                        bool skip_generic = false);
+  std::string base_type_name(t_base_type* tbase, bool in_container = false);
+  std::string declare_field(t_field* tfield, bool init = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
   std::string argument_list(t_struct* tstruct, bool include_types = true);
   std::string type_to_enum(t_type* ttype);
   std::string get_enum_class_name(t_type* type);
@@ -221,18 +223,13 @@ class t_javame_generator : public t_oop_generator {
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return
-      ttype->is_container() ||
-      ttype->is_struct() ||
-      ttype->is_xception() ||
-      ttype->is_string() ||
-      ttype->is_enum();
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception() || ttype->is_string()
+           || ttype->is_enum();
   }
 
   std::string constant_name(std::string name);
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -240,10 +237,8 @@ class t_javame_generator : public t_oop_generator {
   std::string package_name_;
   std::ofstream f_service_;
   std::string package_dir_;
-
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -261,7 +256,7 @@ void t_javame_generator::init_generator() {
   while ((loc = dir.find(".")) != string::npos) {
     subdir = subdir + "/" + dir.substr(0, loc);
     MKDIR(subdir.c_str());
-    dir = dir.substr(loc+1);
+    dir = dir.substr(loc + 1);
   }
   if (dir.size() > 0) {
     subdir = subdir + "/" + dir;
@@ -289,11 +284,8 @@ string t_javame_generator::java_package() {
  * @return List of imports for Java types that are used in here
  */
 string t_javame_generator::java_type_imports() {
-  return
-    string() +
-    "import java.util.Hashtable;\n" +
-    "import java.util.Vector;\n" +
-    "import java.util.Enumeration;\n\n";
+  return string() + "import java.util.Hashtable;\n" + "import java.util.Vector;\n"
+         + "import java.util.Enumeration;\n\n";
 }
 
 /**
@@ -302,18 +294,15 @@ string t_javame_generator::java_type_imports() {
  * @return List of imports necessary for thrift
  */
 string t_javame_generator::java_thrift_imports() {
-  return
-    string() +
-    "import org.apache.thrift.*;\n" +
-    "import org.apache.thrift.meta_data.*;\n" +
-    "import org.apache.thrift.transport.*;\n" +
-    "import org.apache.thrift.protocol.*;\n\n";
+  return string() + "import org.apache.thrift.*;\n" + "import org.apache.thrift.meta_data.*;\n"
+         + "import org.apache.thrift.transport.*;\n" + "import org.apache.thrift.protocol.*;\n\n";
 }
 
 /**
  * Nothing in Java
  */
-void t_javame_generator::close_generator() {}
+void t_javame_generator::close_generator() {
+}
 
 /**
  * Generates a typedef. This is not done in Java, since it does
@@ -323,7 +312,7 @@ void t_javame_generator::close_generator() {}
  * @param ttypedef The type definition
  */
 void t_javame_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -333,18 +322,15 @@ void t_javame_generator::generate_typedef(t_typedef* ttypedef) {
  */
 void t_javame_generator::generate_enum(t_enum* tenum) {
   // Make output file
-  string f_enum_name = package_dir_+"/"+(tenum->get_name())+".java";
+  string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".java";
   ofstream f_enum;
   f_enum.open(f_enum_name.c_str());
 
   // Comment and package it
-  f_enum <<
-    autogen_comment() <<
-    java_package();
+  f_enum << autogen_comment() << java_package();
 
   generate_java_doc(f_enum, tenum);
-  indent(f_enum) <<
-    "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
+  indent(f_enum) << "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
   scope_up(f_enum);
   f_enum << endl;
 
@@ -353,9 +339,8 @@ void t_javame_generator::generate_enum(t_enum* tenum) {
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     generate_java_doc(f_enum, *c_iter);
-    indent(f_enum) << "public static final " << tenum->get_name() <<
-      " " << (*c_iter)->get_name() << " = new " << tenum->get_name() <<
-      "(" << value << ");" << endl;
+    indent(f_enum) << "public static final " << tenum->get_name() << " " << (*c_iter)->get_name()
+                   << " = new " << tenum->get_name() << "(" << value << ");" << endl;
   }
   f_enum << endl;
 
@@ -363,21 +348,23 @@ void t_javame_generator::generate_enum(t_enum* tenum) {
   indent(f_enum) << "private final int value;" << endl << endl;
 
   indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl;
-  indent(f_enum) << "  this.value = value;" <<endl;
+  indent(f_enum) << "  this.value = value;" << endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL." << endl;
+  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL."
+                 << endl;
   indent(f_enum) << " */" << endl;
   indent(f_enum) << "public int getValue() {" << endl;
-  indent(f_enum) << "  return value;" <<endl;
+  indent(f_enum) << "  return value;" << endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL." << endl;
+  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL."
+                 << endl;
   indent(f_enum) << " * @return null if the value is not found." << endl;
   indent(f_enum) << " */" << endl;
-  indent(f_enum) << "public static "+ tenum->get_name() + " findByValue(int value) { " << endl;
+  indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl;
 
   indent_up();
 
@@ -414,19 +401,14 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
     return;
   }
 
-  string f_consts_name = package_dir_+ "/" + program_name_ +  "Constants.java";
+  string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.java";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
   // Print header
-  f_consts <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports();
-
-  f_consts <<
-    "public class " << program_name_ << "Constants {" << endl <<
-    endl;
+  f_consts << autogen_comment() << java_package() << java_type_imports();
+
+  f_consts << "public class " << program_name_ << "Constants {" << endl << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -437,25 +419,26 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
                       false);
   }
   indent_down();
-  indent(f_consts) <<
-    "}" << endl;
+  indent(f_consts) << "}" << endl;
   f_consts.close();
 }
 
-
 /**
  * Prints the value of a constant with the given type. Note that type checking
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-void t_javame_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
+void t_javame_generator::print_const_value(std::ofstream& out,
+                                           string name,
+                                           t_type* type,
+                                           t_const_value* value,
+                                           bool in_static,
+                                           bool defval) {
   type = get_true_type(type);
 
   indent(out);
   if (!defval) {
-    out <<
-      (in_static ? "" : "public static final ") <<
-      type_name(type) << " ";
+    out << (in_static ? "" : "public static final ") << type_name(type) << " ";
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
@@ -505,8 +488,8 @@ void t_javame_generator::print_const_value(std::ofstream& out, string name, t_ty
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string key = render_const_value(out, name, ktype, v_iter->first);
       string val = render_const_value(out, name, vtype, v_iter->second);
-      indent(out) << name << ".put(" << box_type(ktype, key) << ", " <<
-	box_type(vtype, val) << ");" << endl;
+      indent(out) << name << ".put(" << box_type(ktype, key) << ", " << box_type(vtype, val) << ");"
+                  << endl;
     }
     if (!in_static) {
       indent_down();
@@ -530,11 +513,10 @@ void t_javame_generator::print_const_value(std::ofstream& out, string name, t_ty
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string val = render_const_value(out, name, etype, *v_iter);
       if (type->is_list()) {
-	indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl;
+        indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl;
       } else {
-	indent(out) << name << ".put(" <<
-	  box_type(etype, val) << ", " <<
-	  box_type(etype, val) << ");" << endl;
+        indent(out) << name << ".put(" << box_type(etype, val) << ", " << box_type(etype, val)
+                    << ");" << endl;
       }
     }
     if (!in_static) {
@@ -547,8 +529,11 @@ void t_javame_generator::print_const_value(std::ofstream& out, string name, t_ty
   }
 }
 
-string t_javame_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+string t_javame_generator::render_const_value(ofstream& out,
+                                              string name,
+                                              t_type* type,
+                                              t_const_value* value) {
+  (void)name;
   type = get_true_type(type);
   std::ostringstream render;
 
@@ -639,28 +624,20 @@ void t_javame_generator::generate_xception(t_struct* txception) {
   generate_java_struct(txception, true);
 }
 
-
 /**
  * Java struct definition.
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct(t_struct* tstruct,
-                                            bool is_exception) {
+void t_javame_generator::generate_java_struct(t_struct* tstruct, bool is_exception) {
   // Make output file
-  string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".java";
+  string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_thrift_imports();
+  f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
 
-  generate_java_struct_definition(f_struct,
-                                  tstruct,
-                                  is_exception);
+  generate_java_struct_definition(f_struct, tstruct, is_exception);
   f_struct.close();
 }
 
@@ -671,23 +648,18 @@ void t_javame_generator::generate_java_struct(t_struct* tstruct,
  */
 void t_javame_generator::generate_java_union(t_struct* tstruct) {
   // Make output file
-  string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".java";
+  string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_thrift_imports();
+  f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
 
   generate_java_doc(f_struct, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(f_struct) <<
-    "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
-	      << " extends TUnion ";
+  indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
+                   << " extends TUnion ";
 
   scope_up(f_struct);
 
@@ -730,7 +702,8 @@ void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tst
   indent(out) << "  super(setField, value);" << endl;
   indent(out) << "}" << endl << endl;
 
-  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" << endl;
+  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {"
+              << endl;
   indent(out) << "  super(other);" << endl;
   indent(out) << "}" << endl;
 
@@ -742,7 +715,8 @@ void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tst
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type()) << " value) {" << endl;
+    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "("
+                << type_name((*m_iter)->get_type()) << " value) {" << endl;
     indent(out) << "  " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
     indent(out) << "  x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl;
     indent(out) << "  return x;" << endl;
@@ -765,19 +739,24 @@ void t_javame_generator::generate_union_getters_and_setters(ofstream& out, t_str
     t_field* field = (*m_iter);
 
     generate_java_doc(out, field);
-    indent(out) << "public " << type_name(field->get_type()) << " get" << get_cap_name(field->get_name()) << "() {" << endl;
-    indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" << endl;
-    indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();" << endl;
+    indent(out) << "public " << type_name(field->get_type()) << " get"
+                << get_cap_name(field->get_name()) << "() {" << endl;
+    indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
+                << endl;
+    indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();"
+                << endl;
     indent(out) << "  } else {" << endl;
     indent(out) << "    throw new RuntimeException(\"Cannot get field '" << field->get_name()
-      << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" << endl;
+                << "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
+                << endl;
     indent(out) << "  }" << endl;
     indent(out) << "}" << endl;
 
     out << endl;
 
     generate_java_doc(out, field);
-    indent(out) << "public void set" << get_cap_name(field->get_name()) << "(" << type_name(field->get_type()) << " value) {" << endl;
+    indent(out) << "public void set" << get_cap_name(field->get_name()) << "("
+                << type_name(field->get_type()) << " value) {" << endl;
     if (type_can_be_null(field->get_type())) {
       indent(out) << "  if (value == null) throw new NullPointerException();" << endl;
     }
@@ -801,7 +780,9 @@ void t_javame_generator::generate_union_abstract_methods(ofstream& out, t_struct
 }
 
 void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
-  indent(out) << "protected void checkType(_Fields setField, Object value) throws ClassCastException {" << endl;
+  indent(out)
+      << "protected void checkType(_Fields setField, Object value) throws ClassCastException {"
+      << endl;
   indent_up();
 
   indent(out) << "switch (setField) {" << endl;
@@ -814,12 +795,13 @@ void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
     t_field* field = (*m_iter);
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
-    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true) << ") {" << endl;
+    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true)
+                << ") {" << endl;
     indent(out) << "    break;" << endl;
     indent(out) << "  }" << endl;
     indent(out) << "  throw new ClassCastException(\"Was expecting value of type "
-      << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
-      << "', but got \" + value.getClass().getSimpleName());" << endl;
+                << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
+                << "', but got \" + value.getClass().getSimpleName());" << endl;
     // do the real check here
   }
 
@@ -834,7 +816,8 @@ void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
 }
 
 void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
-  indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {" << endl;
+  indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {"
+              << endl;
 
   indent_up();
 
@@ -852,9 +835,11 @@ void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {" << endl;
+    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {"
+                << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
+                << endl;
     generate_deserialize_field(out, field, "");
     indent(out) << "return " << field->get_name() << ";" << endl;
     indent_down();
@@ -866,7 +851,8 @@ void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any of the case statements!\");" << endl;
+  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any "
+                 "of the case statements!\");" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -899,23 +885,22 @@ void t_javame_generator::generate_write_value(ofstream& out, t_struct* tstruct)
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name()
-      << " = (" <<  type_name(field->get_type(), true, false) << ")value_;" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
+                << type_name(field->get_type(), true, false) << ")value_;" << endl;
     generate_serialize_field(out, field, "");
     indent(out) << "return;" << endl;
     indent_down();
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField_);" << endl;
+  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + "
+                 "setField_);" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
 
   indent_down();
 
-
-
   indent(out) << "}" << endl;
 }
 
@@ -946,7 +931,7 @@ void t_javame_generator::generate_get_field_desc(ofstream& out, t_struct* tstruc
 }
 
 void t_javame_generator::generate_get_struct_desc(ofstream& out, t_struct* tstruct) {
-  (void) tstruct;
+  (void)tstruct;
   indent(out) << "protected TStruct getStructDesc() {" << endl;
   indent(out) << "  return STRUCT_DESC;" << endl;
   indent(out) << "}" << endl;
@@ -965,14 +950,17 @@ void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tst
   out << endl;
 
   indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << endl;
-  indent(out) << "  return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());" << endl;
+  indent(out) << "  return other != null && getSetField() == other.getSetField() && "
+                 "getFieldValue().equals(other.getFieldValue());" << endl;
   indent(out) << "}" << endl;
   out << endl;
 
   indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
-  indent(out) << "  int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());" << endl;
+  indent(out) << "  int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());"
+              << endl;
   indent(out) << "  if (lastComparison == 0) {" << endl;
-  indent(out) << "    return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" << endl;
+  indent(out) << "    return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());"
+              << endl;
   indent(out) << "  }" << endl;
   indent(out) << "  return lastComparison;" << endl;
   indent(out) << "}" << endl;
@@ -980,9 +968,11 @@ void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tst
 }
 
 void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct) {
-  (void) tstruct;
+  (void)tstruct;
   indent(out) << "/**" << endl;
-  indent(out) << " * If you'd like this to perform more respectably, use the hashcode generator option." << endl;
+  indent(out)
+      << " * If you'd like this to perform more respectably, use the hashcode generator option."
+      << endl;
   indent(out) << " */" << endl;
   indent(out) << "public int hashCode() {" << endl;
   indent(out) << "  return 0;" << endl;
@@ -999,18 +989,17 @@ void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruc
  * @param in_class     If inside a class, needs to be static class
  * @param is_result    If this is a result it needs a different writer
  */
-void t_javame_generator::generate_java_struct_definition(ofstream &out,
-                                                       t_struct* tstruct,
-                                                       bool is_exception,
-                                                       bool in_class,
-                                                       bool is_result) {
+void t_javame_generator::generate_java_struct_definition(ofstream& out,
+                                                         t_struct* tstruct,
+                                                         bool is_exception,
+                                                         bool in_class,
+                                                         bool is_result) {
   generate_java_doc(out, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(out) <<
-    "public " << (is_final ? "final " : "") <<
-     (in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
+  indent(out) << "public " << (is_final ? "final " : "") << (in_class ? "static " : "") << "class "
+              << tstruct->get_name() << " ";
 
   if (is_exception) {
     out << "extends Exception ";
@@ -1045,8 +1034,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
     int i = 0;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if (!type_can_be_null((*m_iter)->get_type())) {
-        indent(out) << "private static final int " << isset_field_id(*m_iter)
-          << " = " << i << ";" <<  endl;
+        indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";"
+                    << endl;
         i++;
       }
     }
@@ -1061,13 +1050,17 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
   bool all_optional_members = true;
 
   // Default constructor
-  indent(out) <<
-    "public " << tstruct->get_name() << "() {" << endl;
+  indent(out) << "public " << tstruct->get_name() << "() {" << endl;
   indent_up();
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* t = get_true_type((*m_iter)->get_type());
     if ((*m_iter)->get_value() != NULL) {
-      print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
+      print_const_value(out,
+                        "this." + (*m_iter)->get_name(),
+                        t,
+                        (*m_iter)->get_value(),
+                        true,
+                        true);
     }
     if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
       all_optional_members = false;
@@ -1078,8 +1071,7 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
 
   if (!members.empty() && !all_optional_members) {
     // Full constructor for all fields
-    indent(out) <<
-      "public " << tstruct->get_name() << "(" << endl;
+    indent(out) << "public " << tstruct->get_name() << "(" << endl;
     indent_up();
     bool first = true;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1088,8 +1080,7 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
           out << "," << endl;
         }
         first = false;
-        indent(out) << type_name((*m_iter)->get_type()) << " " <<
-          (*m_iter)->get_name();
+        indent(out) << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name();
       }
     }
     out << ")" << endl;
@@ -1099,8 +1090,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
     indent(out) << "this();" << endl;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
-        indent(out) << "this." << (*m_iter)->get_name() << " = " <<
-          (*m_iter)->get_name() << ";" << endl;
+        indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << ";"
+                    << endl;
         generate_isset_set(out, (*m_iter));
       }
     }
@@ -1112,11 +1103,13 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
   indent(out) << "/**" << endl;
   indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
   indent(out) << " */" << endl;
-  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {" << endl;
+  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {"
+              << endl;
   indent_up();
 
   if (has_bit_vector(tstruct)) {
-    indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, other.__isset_vector.length);" << endl;
+    indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, "
+                   "other.__isset_vector.length);" << endl;
   }
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1178,25 +1171,19 @@ void t_javame_generator::generate_java_struct_definition(ofstream &out,
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_equality(ofstream& out,
-                                                     t_struct* tstruct) {
+void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct* tstruct) {
   out << indent() << "public boolean equals(Object that) {" << endl;
   indent_up();
-  out <<
-    indent() << "if (that == null)" << endl <<
-    indent() << "  return false;" << endl <<
-    indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl <<
-    indent() << "  return this.equals((" << tstruct->get_name() << ")that);" << endl <<
-    indent() << "return false;" << endl;
+  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl
+      << indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl << indent()
+      << "  return this.equals((" << tstruct->get_name() << ")that);" << endl << indent()
+      << "return false;" << endl;
   scope_down(out);
   out << endl;
 
-  out <<
-    indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
+  out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
   indent_up();
-  out <<
-    indent() << "if (that == null)" << endl <<
-    indent() << "  return false;" << endl;
+  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl;
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
@@ -1219,31 +1206,24 @@ void t_javame_generator::generate_java_struct_equality(ofstream& out,
       that_present += " && that." + generate_isset_check(*m_iter);
     }
 
-    out <<
-      indent() << "boolean this_present_" << name << " = "
-               << this_present << ";" << endl <<
-      indent() << "boolean that_present_" << name << " = "
-               << that_present << ";" << endl <<
-      indent() << "if (" << "this_present_" << name
-               << " || that_present_" << name << ") {" << endl;
+    out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl
+        << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl
+        << indent() << "if ("
+        << "this_present_" << name << " || that_present_" << name << ") {" << endl;
     indent_up();
-    out <<
-      indent() << "if (!(" << "this_present_" << name
-               << " && that_present_" << name << "))" << endl <<
-      indent() << "  return false;" << endl;
+    out << indent() << "if (!("
+        << "this_present_" << name << " && that_present_" << name << "))" << endl << indent()
+        << "  return false;" << endl;
 
     if (t->is_base_type() && ((t_base_type*)t)->is_binary()) {
-      unequal = "TBaseHelper.compareTo(this." + name + ", that." +
-	name + ") != 0";
+      unequal = "TBaseHelper.compareTo(this." + name + ", that." + name + ") != 0";
     } else if (can_be_null) {
       unequal = "!this." + name + ".equals(that." + name + ")";
     } else {
       unequal = "this." + name + " != that." + name;
     }
 
-    out <<
-      indent() << "if (" << unequal << ")" << endl <<
-      indent() << "  return false;" << endl;
+    out << indent() << "if (" << unequal << ")" << endl << indent() << "  return false;" << endl;
 
     scope_down(out);
   }
@@ -1265,7 +1245,8 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
   indent_up();
 
   indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << endl;
-  indent(out) << "  return getClass().getName().compareTo(otherObject.getClass().getName());" << endl;
+  indent(out) << "  return getClass().getName().compareTo(otherObject.getClass().getName());"
+              << endl;
   indent(out) << "}" << endl;
   out << endl;
   indent(out) << type_name(tstruct) << " other = (" << type_name(tstruct) << ")otherObject;";
@@ -1277,16 +1258,19 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_field* field = *m_iter;
-    indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field) << ", other." << generate_isset_check(field) << ");" << endl;
+    indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field)
+                << ", other." << generate_isset_check(field) << ");" << endl;
     indent(out) << "if (lastComparison != 0) {" << endl;
     indent(out) << "  return lastComparison;" << endl;
     indent(out) << "}" << endl;
 
     indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
     if (field->get_type()->is_struct() || field->get_type()->is_xception()) {
-      indent(out) << "  lastComparison = this." << field->get_name() << ".compareTo(other." << field->get_name() << ");" << endl;
+      indent(out) << "  lastComparison = this." << field->get_name() << ".compareTo(other."
+                  << field->get_name() << ");" << endl;
     } else {
-      indent(out) << "  lastComparison = TBaseHelper.compareTo(this." << field->get_name() << ", other." << field->get_name() << ");" << endl;
+      indent(out) << "  lastComparison = TBaseHelper.compareTo(this." << field->get_name()
+                  << ", other." << field->get_name() << ");" << endl;
     }
 
     indent(out) << "  if (lastComparison != 0) {" << endl;
@@ -1306,93 +1290,75 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public void read(TProtocol iprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_reader(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public void read(TProtocol iprot) throws TException {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables and read struct header
-  out <<
-    indent() << "TField field;" << endl <<
-    indent() << "iprot.readStructBegin();" << endl;
+  out << indent() << "TField field;" << endl << indent() << "iprot.readStructBegin();" << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
-    scope_up(out);
+  indent(out) << "while (true)" << endl;
+  scope_up(out);
 
-    // Read beginning field marker
-    indent(out) <<
-      "field = iprot.readFieldBegin();" << endl;
+  // Read beginning field marker
+  indent(out) << "field = iprot.readFieldBegin();" << endl;
 
-    // Check for field STOP marker and break
-    indent(out) <<
-      "if (field.type == TType.STOP) { " << endl;
-    indent_up();
-    indent(out) <<
-      "break;" << endl;
-    indent_down();
-    indent(out) <<
-      "}" << endl;
+  // Check for field STOP marker and break
+  indent(out) << "if (field.type == TType.STOP) { " << endl;
+  indent_up();
+  indent(out) << "break;" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    // Switch statement on the field we are reading
-    indent(out) << "switch (field.id) {" << endl;
+  // Switch statement on the field we are reading
+  indent(out) << "switch (field.id) {" << endl;
 
-    indent_up();
+  indent_up();
 
-    // Generate deserialization code for known cases
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      indent(out) <<
-        "case " << (*f_iter)->get_key() << ": // " << constant_name((*f_iter)->get_name()) << endl;
-      indent_up();
-      indent(out) <<
-        "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-      indent_up();
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "case " << (*f_iter)->get_key() << ": // "
+                << constant_name((*f_iter)->get_name()) << endl;
+    indent_up();
+    indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent_up();
 
-      generate_deserialize_field(out, *f_iter, "this.");
-      generate_isset_set(out, *f_iter);
-      indent_down();
-      out <<
-        indent() << "} else { " << endl <<
-        indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl <<
-        indent() << "}" << endl <<
-        indent() << "break;" << endl;
-      indent_down();
-    }
+    generate_deserialize_field(out, *f_iter, "this.");
+    generate_isset_set(out, *f_iter);
+    indent_down();
+    out << indent() << "} else { " << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
+        << endl << indent() << "}" << endl << indent() << "break;" << endl;
+    indent_down();
+  }
 
-    indent(out) << "default:" << endl;
-    indent(out) << "  TProtocolUtil.skip(iprot, field.type);" << endl;
+  indent(out) << "default:" << endl;
+  indent(out) << "  TProtocolUtil.skip(iprot, field.type);" << endl;
 
-    indent_down();
-    indent(out) << "}" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    // Read field end marker
-    indent(out) <<
-      "iprot.readFieldEnd();" << endl;
+  // Read field end marker
+  indent(out) << "iprot.readFieldEnd();" << endl;
 
-    indent_down();
-    indent(out) << "}" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    out <<
-      indent() << "iprot.readStructEnd();" << endl;
+  out << indent() << "iprot.readStructEnd();" << endl;
 
-    // performs various checks (e.g. check that all required fields are set)
-    indent(out) << "validate();" << endl;
+  // performs various checks (e.g. check that all required fields are set)
+  indent(out) << "validate();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 // generates java method to perform various checks
 // (e.g. check that all required fields are set)
-void t_javame_generator::generate_java_validator(ofstream& out,
-                                                   t_struct* tstruct){
+void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruct) {
   indent(out) << "public void validate() throws TException {" << endl;
   indent_up();
 
@@ -1402,10 +1368,9 @@ void t_javame_generator::generate_java_validator(ofstream& out,
   out << indent() << "// check for required fields" << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
-      out <<
-        indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
-        indent() << "  throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl <<
-        indent() << "}" << endl << endl;
+      out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << indent()
+          << "  throw new TProtocolException(\"Required field '" << (*f_iter)->get_name()
+          << "' is unset! Struct:\" + toString());" << endl << indent() << "}" << endl << endl;
     }
   }
 
@@ -1418,10 +1383,8 @@ void t_javame_generator::generate_java_validator(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1436,8 +1399,7 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out <<
-        indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+      out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
       indent_up();
     }
     bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL;
@@ -1446,14 +1408,14 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out,
       indent_up();
     }
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     if (optional) {
       indent_down();
@@ -1465,14 +1427,11 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out,
     }
   }
   // Write the struct map
-  out <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
+      << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1483,10 +1442,8 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_result_writer(ofstream& out,
-                                                          t_struct* tstruct) {
-  out <<
-    indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_result_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1499,9 +1456,7 @@ void t_javame_generator::generate_java_struct_result_writer(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out <<
-        endl <<
-        indent() << "if ";
+      out << endl << indent() << "if ";
     } else {
       out << " else if ";
     }
@@ -1510,38 +1465,38 @@ void t_javame_generator::generate_java_struct_result_writer(ofstream& out,
 
     indent_up();
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}";
   }
   // Write the struct map
-  out <<
-    endl <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
+      << "oprot.writeStructEnd();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
-void t_javame_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
+void t_javame_generator::generate_reflection_getters(ostringstream& out,
+                                                     t_type* type,
+                                                     string field_name,
+                                                     string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
 
   if (type->is_base_type() && !type->is_string()) {
     t_base_type* base_type = (t_base_type*)type;
 
-    indent(out) << "return new " << type_name(type, true, false) << "(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
+    indent(out) << "return new " << type_name(type, true, false) << "("
+                << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
   } else {
     indent(out) << "return get" << cap_name << "();" << endl << endl;
   }
@@ -1549,7 +1504,10 @@ void t_javame_generator::generate_reflection_getters(ostringstream& out, t_type*
   indent_down();
 }
 
-void t_javame_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
+void t_javame_generator::generate_reflection_setters(ostringstream& out,
+                                                     t_type* type,
+                                                     string field_name,
+                                                     string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
@@ -1562,8 +1520,9 @@ void t_javame_generator::generate_reflection_setters(ostringstream& out, t_type*
   indent_down();
 }
 
-void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
-  (void) out;
+void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& out,
+                                                                t_struct* tstruct) {
+  (void)out;
   std::ostringstream getter_stream;
   std::ostringstream setter_stream;
 
@@ -1581,7 +1540,6 @@ void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& o
     generate_reflection_getters(getter_stream, type, field_name, cap_name);
     indent_down();
   }
-
 }
 
 /**
@@ -1590,8 +1548,7 @@ void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& o
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
-                                                      t_struct* tstruct) {
+void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1606,8 +1563,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
       out << get_cap_name("size() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? 0 : " <<
-        "this." << field_name << ".size();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? 0 : "
+                  << "this." << field_name << ".size();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
     }
@@ -1626,8 +1583,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
       out << get_cap_name("Enumeration() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? null : " <<
-        "this." << field_name << ".elements();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? null : "
+                  << "this." << field_name << ".elements();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
 
@@ -1639,17 +1596,16 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) <<
-        "();" << endl;
+      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
+                  << endl;
       indent_down();
       indent(out) << "}" << endl;
       if (type->is_set()) {
-	indent(out) << "this." << field_name << ".put(" <<
-	  box_type(element_type, "elem") << ", " <<
-	  box_type(element_type, "elem") << ");" << endl;
+        indent(out) << "this." << field_name << ".put(" << box_type(element_type, "elem") << ", "
+                    << box_type(element_type, "elem") << ");" << endl;
       } else {
-	indent(out) << "this." << field_name << ".addElement(" <<
-	  box_type(element_type, "elem") << ");" << endl;
+        indent(out) << "this." << field_name << ".addElement(" << box_type(element_type, "elem")
+                    << ");" << endl;
       }
       indent_down();
       indent(out) << "}" << endl << endl;
@@ -1660,15 +1616,14 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
       t_type* val_type = ((t_map*)type)->get_val_type();
 
       indent(out);
-      out << "public void putTo"
-	  << cap_name << "(" << type_name(key_type, true) << " key, "
-	  << type_name(val_type, true) << " val) {" << endl;
+      out << "public void putTo" << cap_name << "(" << type_name(key_type, true) << " key, "
+          << type_name(val_type, true) << " val) {" << endl;
 
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " <<
-        type_name(type, false, true) << "();" << endl;
+      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
+                  << endl;
       indent_down();
       indent(out) << "}" << endl;
       indent(out) << "this." << field_name << ".put(key, val);" << endl;
@@ -1679,8 +1634,7 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
     // Simple getter
     generate_java_doc(out, field);
     indent(out) << "public " << type_name(type);
-    if (type->is_base_type() &&
-        ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
+    if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
       out << " is";
     } else {
       out << " get";
@@ -1697,8 +1651,7 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
     out << "void";
     out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << endl;
     indent_up();
-    indent(out) << "this." << field_name << " = " << field_name << ";" <<
-      endl;
+    indent(out) << "this." << field_name << " = " << field_name << ";" << endl;
     generate_isset_set(out, field);
 
     indent_down();
@@ -1716,7 +1669,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
     indent(out) << "}" << endl << endl;
 
     // isSet method
-    indent(out) << "/** Returns true if field " << field_name << " is set (has been assigned a value) and false otherwise */" << endl;
+    indent(out) << "/** Returns true if field " << field_name
+                << " is set (has been assigned a value) and false otherwise */" << endl;
     indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl;
     indent_up();
     if (type_can_be_null(type)) {
@@ -1727,7 +1681,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
     indent_down();
     indent(out) << "}" << endl << endl;
 
-    indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" << endl;
+    indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {"
+                << endl;
     indent_up();
     if (type_can_be_null(type)) {
       indent(out) << "if (!value) {" << endl;
@@ -1746,13 +1701,12 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_tostring(ofstream& out,
-                                                     t_struct* tstruct) {
+void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct* tstruct) {
   out << indent() << "public String toString() {" << endl;
   indent_up();
 
-  out <<
-    indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");" << endl;
+  out << indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");"
+      << endl;
   out << indent() << "boolean first = true;" << endl << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1760,7 +1714,7 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out,
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
       indent_up();
     }
@@ -1791,19 +1745,16 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out,
     }
     indent(out) << "first = false;" << endl;
 
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent_down();
       indent(out) << "}" << endl;
     }
     first = false;
   }
-  out <<
-    indent() << "sb.append(\")\");" << endl <<
-    indent() << "return sb.toString();" << endl;
+  out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl;
 
   indent_down();
-  indent(out) << "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1811,7 +1762,7 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out,
  * (e.g. for the type struct it returns "TType.STRUCT")
  */
 std::string t_javame_generator::get_java_type_string(t_type* type) {
-  if (type->is_list()){
+  if (type->is_list()) {
     return "TType.LIST";
   } else if (type->is_map()) {
     return "TType.MAP";
@@ -1825,37 +1776,58 @@ std::string t_javame_generator::get_java_type_string(t_type* type) {
     return get_java_type_string(((t_typedef*)type)->get_type());
   } else if (type->is_base_type()) {
     switch (((t_base_type*)type)->get_base()) {
-      case t_base_type::TYPE_VOID   : return      "TType.VOID"; break;
-      case t_base_type::TYPE_STRING : return    "TType.STRING"; break;
-      case t_base_type::TYPE_BOOL   : return      "TType.BOOL"; break;
-      case t_base_type::TYPE_BYTE   : return      "TType.BYTE"; break;
-      case t_base_type::TYPE_I16    : return       "TType.I16"; break;
-      case t_base_type::TYPE_I32    : return       "TType.I32"; break;
-      case t_base_type::TYPE_I64    : return       "TType.I64"; break;
-      case t_base_type::TYPE_DOUBLE : return    "TType.DOUBLE"; break;
-      default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_javame_generator::get_java_type_string!"); break; // This should never happen!
+    case t_base_type::TYPE_VOID:
+      return "TType.VOID";
+      break;
+    case t_base_type::TYPE_STRING:
+      return "TType.STRING";
+      break;
+    case t_base_type::TYPE_BOOL:
+      return "TType.BOOL";
+      break;
+    case t_base_type::TYPE_BYTE:
+      return "TType.BYTE";
+      break;
+    case t_base_type::TYPE_I16:
+      return "TType.I16";
+      break;
+    case t_base_type::TYPE_I32:
+      return "TType.I32";
+      break;
+    case t_base_type::TYPE_I64:
+      return "TType.I64";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      return "TType.DOUBLE";
+      break;
+    default:
+      throw std::runtime_error("Unknown thrift type \"" + type->get_name()
+                               + "\" passed to t_javame_generator::get_java_type_string!");
+      break; // This should never happen!
     }
   } else {
-    throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_javame_generator::get_java_type_string!"); // This should never happen!
+    throw std::runtime_error(
+        "Unknown thrift type \"" + type->get_name()
+        + "\" passed to t_javame_generator::get_java_type_string!"); // This should never happen!
   }
 }
 
-void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type){
+void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
   out << endl;
   indent_up();
   indent_up();
-  if (type->is_struct()){
+  if (type->is_struct()) {
     indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type) << ".class";
-  } else if (type->is_container()){
-    if (type->is_list()){
+  } else if (type->is_container()) {
+    if (type->is_list()) {
       indent(out) << "new ListMetaData(TType.LIST, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else if (type->is_set()){
+    } else if (type->is_set()) {
       indent(out) << "new SetMetaData(TType.SET, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else{ // map
+    } else { // map
       indent(out) << "new MapMetaData(TType.MAP, ";
       t_type* key_type = ((t_map*)type)->get_key_type();
       t_type* val_type = ((t_map*)type)->get_val_type();
@@ -1876,7 +1848,6 @@ void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_ty
   indent_down();
 }
 
-
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1887,18 +1858,12 @@ void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_ty
  */
 void t_javame_generator::generate_service(t_service* tservice) {
   // Make output file
-  string f_service_name = package_dir_+"/"+service_name_+".java";
+  string f_service_name = package_dir_ + "/" + service_name_ + ".java";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_thrift_imports();
+  f_service_ << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
 
-  f_service_ <<
-    "public class " << service_name_ << " {" << endl <<
-    endl;
+  f_service_ << "public class " << service_name_ << " {" << endl << endl;
   indent_up();
 
   // Generate the three main parts of the service
@@ -1908,8 +1873,7 @@ void t_javame_generator::generate_service(t_service* tservice) {
   generate_service_helpers(tservice);
 
   indent_down();
-  f_service_ <<
-    "}" << endl;
+  f_service_ << "}" << endl;
   f_service_.close();
 }
 
@@ -1919,8 +1883,8 @@ void t_javame_generator::generate_service(t_service* tservice) {
  * @param tservice The service to generate a header definition for
  */
 void t_javame_generator::generate_primitive_service_interface(t_service* tservice) {
-  f_service_ << indent() << "public interface Iface extends " <<
-    service_name_ << "Iface { }" << endl << endl;
+  f_service_ << indent() << "public interface Iface extends " << service_name_ << "Iface { }"
+             << endl << endl;
 
   string f_interface_name = package_dir_ + "/" + service_name_ + "Iface.java";
   std::ofstream f_iface;
@@ -1931,14 +1895,10 @@ void t_javame_generator::generate_primitive_service_interface(t_service* tservic
     extends_iface = " extends " + type_name(tservice->get_extends()) + "Iface";
   }
 
-  f_iface <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_thrift_imports();
+  f_iface << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
   generate_java_doc(f_iface, tservice);
-  f_iface <<
-    "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl << endl;
+  f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl
+          << endl;
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1962,8 +1922,7 @@ void t_javame_generator::generate_service_interface(t_service* tservice) {
   }
 
   generate_java_doc(f_service_, tservice);
-  f_service_ << indent() << "public interface Iface" << extends_iface <<
-    " {" << endl << endl;
+  f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl;
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
@@ -2003,56 +1962,42 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     extends_client = " extends " + extends + ".Client";
   }
 
-  indent(f_service_) <<
-    "public static class Client" << extends_client << " implements TServiceClient, Iface {" << endl;
+  indent(f_service_) << "public static class Client" << extends_client
+                     << " implements TServiceClient, Iface {" << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public Client(TProtocol prot)" << endl;
+  indent(f_service_) << "public Client(TProtocol prot)" << endl;
   scope_up(f_service_);
-  indent(f_service_) <<
-    "this(prot, prot);" << endl;
+  indent(f_service_) << "this(prot, prot);" << endl;
   scope_down(f_service_);
   f_service_ << endl;
 
-  indent(f_service_) <<
-    "public Client(TProtocol iprot, TProtocol oprot)" << endl;
+  indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << endl;
   scope_up(f_service_);
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "iprot_ = iprot;" << endl <<
-      indent() << "oprot_ = oprot;" << endl;
+    f_service_ << indent() << "iprot_ = iprot;" << endl << indent() << "oprot_ = oprot;" << endl;
   } else {
-    f_service_ <<
-      indent() << "super(iprot, oprot);" << endl;
+    f_service_ << indent() << "super(iprot, oprot);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected TProtocol iprot_;"  << endl <<
-      indent() << "protected TProtocol oprot_;"  << endl <<
-      endl <<
-      indent() << "protected int seqid_;" << endl <<
-      endl;
-
-    indent(f_service_) <<
-      "public TProtocol getInputProtocol()" << endl;
+    f_service_ << indent() << "protected TProtocol iprot_;" << endl << indent()
+               << "protected TProtocol oprot_;" << endl << endl << indent()
+               << "protected int seqid_;" << endl << endl;
+
+    indent(f_service_) << "public TProtocol getInputProtocol()" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.iprot_;" << endl;
+    indent(f_service_) << "return this.iprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
 
-    indent(f_service_) <<
-      "public TProtocol getOutputProtocol()" << endl;
+    indent(f_service_) << "public TProtocol getOutputProtocol()" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.oprot_;" << endl;
+    indent(f_service_) << "return this.oprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
-
   }
 
   // Generate client method implementations
@@ -2062,11 +2007,9 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    indent(f_service_) <<
-      "public " << function_signature(*f_iter) << endl;
+    indent(f_service_) << "public " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "send_" << funname << "(";
+    indent(f_service_) << "send_" << funname << "(";
 
     // Get the struct of function call params
     t_struct* arg_struct = (*f_iter)->get_arglist();
@@ -2090,8 +2033,7 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void()) {
         f_service_ << "return ";
       }
-      f_service_ <<
-        "recv_" << funname << "();" << endl;
+      f_service_ << "recv_" << funname << "();" << endl;
     }
     scope_down(f_service_);
     f_service_ << endl;
@@ -2103,26 +2045,23 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     string argsname = (*f_iter)->get_name() + "_args";
 
     // Open function
-    indent(f_service_) <<
-      "public " << function_signature(&send_function) << endl;
+    indent(f_service_) << "public " << function_signature(&send_function) << endl;
     scope_up(f_service_);
 
     // Serialize the request
-    f_service_ <<
-      indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", " <<
-      ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") <<
-      ", ++seqid_));" << endl <<
-      indent() << argsname << " args = new " << argsname << "();" << endl;
+    f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", "
+               << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
+               << ", ++seqid_));" << endl << indent() << argsname << " args = new " << argsname
+               << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" << (*fld_iter)->get_name() << ");" << endl;
+      f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "("
+                 << (*fld_iter)->get_name() << ");" << endl;
     }
 
-    f_service_ <<
-      indent() << "args.write(oprot_);" << endl <<
-      indent() << "oprot_.writeMessageEnd();" << endl <<
-      indent() << "oprot_.getTransport().flush();" << endl;
+    f_service_ << indent() << "args.write(oprot_);" << endl << indent()
+               << "oprot_.writeMessageEnd();" << endl << indent()
+               << "oprot_.getTransport().flush();" << endl;
 
     scope_down(f_service_);
     f_service_ << endl;
@@ -2136,49 +2075,43 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
                                &noargs,
                                (*f_iter)->get_xceptions());
       // Open function
-      indent(f_service_) <<
-        "public " << function_signature(&recv_function) << endl;
+      indent(f_service_) << "public " << function_signature(&recv_function) << endl;
       scope_up(f_service_);
 
-      f_service_ <<
-        indent() << "TMessage msg = iprot_.readMessageBegin();" << endl <<
-        indent() << "if (msg.type == TMessageType.EXCEPTION) {" << endl <<
-        indent() << "  TApplicationException x = TApplicationException.read(iprot_);" << endl <<
-        indent() << "  iprot_.readMessageEnd();" << endl <<
-        indent() << "  throw x;" << endl <<
-        indent() << "}" << endl <<
-        indent() << "if (msg.seqid != seqid_) {" << endl <<
-        indent() << "  throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \"" << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl <<
-        indent() << "}" << endl <<
-        indent() << resultname << " result = new " << resultname << "();" << endl <<
-        indent() << "result.read(iprot_);" << endl <<
-        indent() << "iprot_.readMessageEnd();" << endl;
+      f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << endl << indent()
+                 << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent()
+                 << "  TApplicationException x = TApplicationException.read(iprot_);" << endl
+                 << indent() << "  iprot_.readMessageEnd();" << endl << indent() << "  throw x;"
+                 << endl << indent() << "}" << endl << indent() << "if (msg.seqid != seqid_) {"
+                 << endl << indent()
+                 << "  throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \""
+                 << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl
+                 << indent() << "}" << endl << indent() << resultname << " result = new "
+                 << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl
+                 << indent() << "iprot_.readMessageEnd();" << endl;
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
-          indent() << "  return result.success;" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
+                   << indent() << "  return result.success;" << endl << indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
-          indent() << "  throw result." << (*x_iter)->get_name() << ";" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl
+                   << indent() << "  throw result." << (*x_iter)->get_name() << ";" << endl
+                   << indent() << "}" << endl;
       }
 
       // If you get here it's an exception, unless a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "return;" << endl;
+        indent(f_service_) << "return;" << endl;
       } else {
-        f_service_ <<
-          indent() << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+        f_service_ << indent()
+                   << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \""
+                   << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
       }
 
       // Close function
@@ -2188,8 +2121,7 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl;
+  indent(f_service_) << "}" << endl;
 }
 
 /**
@@ -2211,72 +2143,64 @@ void t_javame_generator::generate_service_server(t_service* tservice) {
   }
 
   // Generate the header portion
-  indent(f_service_) <<
-    "public static class Processor" << extends_processor << " implements TProcessor {" << endl;
+  indent(f_service_) << "public static class Processor" << extends_processor
+                     << " implements TProcessor {" << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public Processor(Iface iface)" << endl;
+  indent(f_service_) << "public Processor(Iface iface)" << endl;
   scope_up(f_service_);
   if (!extends.empty()) {
-    f_service_ <<
-      indent() << "super(iface);" << endl;
+    f_service_ << indent() << "super(iface);" << endl;
   }
-  f_service_ <<
-    indent() << "iface_ = iface;" << endl;
+  f_service_ << indent() << "iface_ = iface;" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new " << (*f_iter)->get_name() << "());" << endl;
+    f_service_ << indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new "
+               << (*f_iter)->get_name() << "());" << endl;
   }
 
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected static interface ProcessFunction {" << endl <<
-      indent() << "  public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" << endl <<
-      indent() << "}" << endl <<
-      endl;
+    f_service_
+        << indent() << "protected static interface ProcessFunction {" << endl << indent()
+        << "  public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;"
+        << endl << indent() << "}" << endl << endl;
   }
 
-  f_service_ <<
-    indent() << "private Iface iface_;" << endl;
+  f_service_ << indent() << "private Iface iface_;" << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl;
+    f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl;
   }
 
   f_service_ << endl;
 
   // Generate the server implementation
-  indent(f_service_) <<
-    "public boolean process(TProtocol iprot, TProtocol oprot) throws TException" << endl;
+  indent(f_service_) << "public boolean process(TProtocol iprot, TProtocol oprot) throws TException"
+                     << endl;
   scope_up(f_service_);
 
-  f_service_ <<
-    indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
+  f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
 
   // TODO(mcslee): validate message, was the seqid etc. legit?
 
-  f_service_ <<
-    indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl <<
-    indent() << "if (fn == null) {" << endl <<
-    indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl <<
-    indent() << "  iprot.readMessageEnd();" << endl <<
-    indent() << "  TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl <<
-    indent() << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl <<
-    indent() << "  x.write(oprot);" << endl <<
-    indent() << "  oprot.writeMessageEnd();" << endl <<
-    indent() << "  oprot.getTransport().flush();" << endl <<
-    indent() << "  return true;" << endl <<
-    indent() << "}" << endl <<
-    indent() << "fn.process(msg.seqid, iprot, oprot);" << endl;
-
-  f_service_ <<
-    indent() << "return true;" << endl;
+  f_service_
+      << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl
+      << indent() << "if (fn == null) {" << endl << indent()
+      << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl << indent()
+      << "  iprot.readMessageEnd();" << endl << indent()
+      << "  TApplicationException x = new "
+         "TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: "
+         "'\"+msg.name+\"'\");" << endl << indent()
+      << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
+      << endl << indent() << "  x.write(oprot);" << endl << indent() << "  oprot.writeMessageEnd();"
+      << endl << indent() << "  oprot.getTransport().flush();" << endl << indent()
+      << "  return true;" << endl << indent() << "}" << endl << indent()
+      << "fn.process(msg.seqid, iprot, oprot);" << endl;
+
+  f_service_ << indent() << "return true;" << endl;
 
   scope_down(f_service_);
   f_service_ << endl;
@@ -2287,9 +2211,7 @@ void t_javame_generator::generate_service_server(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl <<
-    endl;
+  indent(f_service_) << "}" << endl << endl;
 }
 
 /**
@@ -2323,44 +2245,40 @@ void t_javame_generator::generate_function_helpers(t_function* tfunction) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_javame_generator::generate_process_function(t_service* tservice,
-                                                 t_function* tfunction) {
-  (void) tservice;
+void t_javame_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open class
-  indent(f_service_) <<
-    "private class " << tfunction->get_name() << " implements ProcessFunction {" << endl;
+  indent(f_service_) << "private class " << tfunction->get_name() << " implements ProcessFunction {"
+                     << endl;
   indent_up();
 
   // Open function
-  indent(f_service_) <<
-    "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException" << endl;
+  indent(f_service_)
+      << "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException"
+      << endl;
   scope_up(f_service_);
 
   string argsname = tfunction->get_name() + "_args";
   string resultname = tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << argsname << " args = new " << argsname << "();" << endl <<
-    indent() << "try {" << endl;
+  f_service_ << indent() << argsname << " args = new " << argsname << "();" << endl << indent()
+             << "try {" << endl;
   indent_up();
-  f_service_ <<
-    indent() << "args.read(iprot);" << endl;
+  f_service_ << indent() << "args.read(iprot);" << endl;
   indent_down();
-  f_service_ <<
-    indent() << "} catch (TProtocolException e) {" << endl;
+  f_service_ << indent() << "} catch (TProtocolException e) {" << endl;
   indent_up();
-  f_service_ <<
-    indent() << "iprot.readMessageEnd();" << endl <<
-    indent() << "TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());" << endl <<
-    indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl <<
-    indent() << "x.write(oprot);" << endl <<
-    indent() << "oprot.writeMessageEnd();" << endl <<
-    indent() << "oprot.getTransport().flush();" << endl <<
-    indent() << "return;" << endl;
+  f_service_ << indent() << "iprot.readMessageEnd();" << endl << indent()
+             << "TApplicationException x = new "
+                "TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());"
+             << endl << indent() << "oprot.writeMessageBegin(new TMessage(\""
+             << tfunction->get_name() << "\", TMessageType.

<TRUNCATED>

[19/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_ocaml_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_ocaml_generator.cc b/compiler/cpp/src/generate/t_ocaml_generator.cc
index 6607f6e..75bc12d 100644
--- a/compiler/cpp/src/generate/t_ocaml_generator.cc
+++ b/compiler/cpp/src/generate/t_ocaml_generator.cc
@@ -38,22 +38,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * OCaml code generator.
  *
  */
 class t_ocaml_generator : public t_oop_generator {
- public:
-  t_ocaml_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_ocaml_generator(t_program* program,
+                    const std::map<std::string, std::string>& parsed_options,
+                    const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-ocaml";
   }
 
@@ -67,92 +65,77 @@ class t_ocaml_generator : public t_oop_generator {
   /**
    * Program-level generation functions
    */
-  void generate_program  ();
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_program();
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_const_value(t_type* type, t_const_value* value);
-  bool struct_member_persistent(t_field *tmember);
-  bool struct_member_omitable(t_field *tmember);
-  bool struct_member_default_cheaply_comparable(t_field *tmember);
-  std::string struct_member_copy_of(t_type *type, string what);
+  bool struct_member_persistent(t_field* tmember);
+  bool struct_member_omitable(t_field* tmember);
+  bool struct_member_default_cheaply_comparable(t_field* tmember);
+  std::string struct_member_copy_of(t_type* type, string what);
 
   /**
    * Struct generation code
    */
 
   void generate_ocaml_struct(t_struct* tstruct, bool is_exception);
-  void generate_ocaml_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false);
+  void generate_ocaml_struct_definition(std::ofstream& out,
+                                        t_struct* tstruct,
+                                        bool is_xception = false);
   void generate_ocaml_struct_member(std::ofstream& out, string tname, t_field* tmember);
   void generate_ocaml_struct_sig(std::ofstream& out, t_struct* tstruct, bool is_exception);
   void generate_ocaml_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_ocaml_struct_writer(std::ofstream& out, t_struct* tstruct);
   void generate_ocaml_function_helpers(t_function* tfunction);
-  void generate_ocaml_method_copy(std::ofstream& out, const vector<t_field *>& members);
-  void generate_ocaml_member_copy(std::ofstream& out, t_field *member);
+  void generate_ocaml_method_copy(std::ofstream& out, const vector<t_field*>& members);
+  void generate_ocaml_member_copy(std::ofstream& out, t_field* member);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service*  tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix);
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix);
 
-  void generate_deserialize_struct       (std::ofstream &out,
-                                          t_struct*   tstruct);
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct);
 
-  void generate_deserialize_container    (std::ofstream &out,
-                                          t_type*     ttype);
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype);
 
-  void generate_deserialize_set_element  (std::ofstream &out,
-                                          t_set*      tset);
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset);
 
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
+  void generate_deserialize_type(std::ofstream& out, t_type* type);
 
-  void generate_deserialize_list_element (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
-  void generate_deserialize_type          (std::ofstream &out,
-                                           t_type* type);
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string name = "");
 
-  void generate_serialize_field          (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string name= "");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_map_element    (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_set_element    (std::ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
-
-  void generate_serialize_list_element   (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
   /**
    * Helper rendering functions
@@ -161,15 +144,13 @@ class t_ocaml_generator : public t_oop_generator {
   std::string ocaml_autogen_comment();
   std::string ocaml_imports();
   std::string type_name(t_type* ttype);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
-  std::string function_type(t_function* tfunc, bool method=false, bool options = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string function_type(t_function* tfunc, bool method = false, bool options = false);
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
   std::string render_ocaml_type(t_type* type);
 
-
- private:
-
+private:
   /**
    * File streams
    */
@@ -180,10 +161,8 @@ class t_ocaml_generator : public t_oop_generator {
 
   std::ofstream f_types_i_;
   std::ofstream f_service_i_;
-
 };
 
-
 /*
  * This is necessary because we want typedefs to appear later,
  * after all the types have been declared.
@@ -236,7 +215,6 @@ void t_ocaml_generator::generate_program() {
   close_generator();
 }
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -248,38 +226,27 @@ void t_ocaml_generator::init_generator() {
   MKDIR(get_out_dir().c_str());
 
   // Make output file
-  string f_types_name = get_out_dir()+program_name_+"_types.ml";
+  string f_types_name = get_out_dir() + program_name_ + "_types.ml";
   f_types_.open(f_types_name.c_str());
-  string f_types_i_name = get_out_dir()+program_name_+"_types.mli";
+  string f_types_i_name = get_out_dir() + program_name_ + "_types.mli";
   f_types_i_.open(f_types_i_name.c_str());
 
-  string f_consts_name = get_out_dir()+program_name_+"_consts.ml";
+  string f_consts_name = get_out_dir() + program_name_ + "_consts.ml";
   f_consts_.open(f_consts_name.c_str());
 
   // Print header
-  f_types_ <<
-    ocaml_autogen_comment() << endl <<
-    ocaml_imports() << endl;
-  f_types_i_ <<
-    ocaml_autogen_comment() << endl <<
-    ocaml_imports() << endl;
-  f_consts_ <<
-    ocaml_autogen_comment() << endl <<
-    ocaml_imports() << endl <<
-    "open " << capitalize(program_name_)<<"_types"<< endl;
+  f_types_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
+  f_types_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
+  f_consts_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl << "open "
+            << capitalize(program_name_) << "_types" << endl;
 }
 
-
 /**
  * Autogen'd comment
  */
 string t_ocaml_generator::ocaml_autogen_comment() {
-  return
-    std::string("(*\n") +
-    " Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "\n" +
-    " DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING\n" +
-    "*)\n";
+  return std::string("(*\n") + " Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" + "\n"
+         + " DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING\n" + "*)\n";
 }
 
 /**
@@ -303,10 +270,10 @@ void t_ocaml_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_ocaml_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_ <<
-    indent() << "type "<< decapitalize(ttypedef->get_symbolic()) << " = " << render_ocaml_type(ttypedef->get_type()) << endl << endl;
-  f_types_i_ <<
-    indent() << "type "<< decapitalize(ttypedef->get_symbolic()) << " = " << render_ocaml_type(ttypedef->get_type()) << endl << endl;
+  f_types_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = "
+           << render_ocaml_type(ttypedef->get_type()) << endl << endl;
+  f_types_i_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = "
+             << render_ocaml_type(ttypedef->get_type()) << endl << endl;
 }
 
 /**
@@ -316,8 +283,10 @@ void t_ocaml_generator::generate_typedef(t_typedef* ttypedef) {
  * @param tenum The enumeration
  */
 void t_ocaml_generator::generate_enum(t_enum* tenum) {
-  indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << endl << "struct" << endl;
-  indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << endl << "sig" << endl;
+  indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << endl << "struct"
+                   << endl;
+  indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << endl << "sig"
+                     << endl;
   indent_up();
   indent(f_types_) << "type t = " << endl;
   indent(f_types_i_) << "type t = " << endl;
@@ -344,7 +313,7 @@ void t_ocaml_generator::generate_enum(t_enum* tenum) {
   indent(f_types_) << "let of_i = function" << endl;
   indent(f_types_i_) << "val of_i : Int32.t -> t" << endl;
   indent_up();
-  for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
+  for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     string name = capitalize((*c_iter)->get_name());
     indent(f_types_) << "| " << value << "l -> " << name << endl;
@@ -440,7 +409,7 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value)
       }
       string fname = v_iter->first->get_string();
       out << indent();
-      out << ct <<"#set_" << fname << " ";
+      out << ct << "#set_" << fname << " ";
       out << render_const_value(field_type, v_iter->second);
       out << ";" << endl;
     }
@@ -519,82 +488,81 @@ void t_ocaml_generator::generate_xception(t_struct* txception) {
 /**
  * Generates an OCaml struct
  */
-void t_ocaml_generator::generate_ocaml_struct(t_struct* tstruct,
-                                              bool is_exception) {
+void t_ocaml_generator::generate_ocaml_struct(t_struct* tstruct, bool is_exception) {
   generate_ocaml_struct_definition(f_types_, tstruct, is_exception);
-  generate_ocaml_struct_sig(f_types_i_,tstruct,is_exception);
+  generate_ocaml_struct_sig(f_types_i_, tstruct, is_exception);
 }
 
-void t_ocaml_generator::generate_ocaml_method_copy(ofstream& out,
-                                                   const vector<t_field *>& members) {
-    vector<t_field*>::const_iterator m_iter;
+void t_ocaml_generator::generate_ocaml_method_copy(ofstream& out, const vector<t_field*>& members) {
+  vector<t_field*>::const_iterator m_iter;
 
-    /* Create a copy of the current object */
-    indent(out) << "method copy =" << endl;
-    indent_up(); indent_up();
-    indent(out) << "let _new = Oo.copy self in" << endl;
-    for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
-        generate_ocaml_member_copy(out, *m_iter);
+  /* Create a copy of the current object */
+  indent(out) << "method copy =" << endl;
+  indent_up();
+  indent_up();
+  indent(out) << "let _new = Oo.copy self in" << endl;
+  for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
+    generate_ocaml_member_copy(out, *m_iter);
 
-    indent_down();
-    indent(out) << "_new" << endl;
-    indent_down();
+  indent_down();
+  indent(out) << "_new" << endl;
+  indent_down();
 }
 
-string t_ocaml_generator::struct_member_copy_of(t_type *type, string what) {
-    if (type->is_struct() || type->is_xception()) {
-        return what + string ("#copy");
-    } if (type->is_map()) {
-        string copy_of_k = struct_member_copy_of(((t_map *)type)->get_key_type(), "k");
-        string copy_of_v = struct_member_copy_of(((t_map *)type)->get_val_type(), "v");
-
-        if(copy_of_k == "k" && copy_of_v == "v") {
-                return string ("(Hashtbl.copy ") + what + string(")");
-        } else {
-                return string ("((fun oh -> let nh = Hashtbl.create (Hashtbl.length oh) in Hashtbl.iter (fun k v -> Hashtbl.add nh ")
-                    + copy_of_k + string(" ") + copy_of_v
-                    + string(") oh; nh) ")
-                    + what + ")";
-        }
-    } if (type->is_set()) {
-        string copy_of = struct_member_copy_of(((t_set *)type)->get_elem_type(), "k");
-
-        if(copy_of == "k") {
-                return string ("(Hashtbl.copy ") + what + string(")");
-        } else {
-                return string ("((fun oh -> let nh = Hashtbl.create (Hashtbl.length oh) in Hashtbl.iter (fun k v -> Hashtbl.add nh ")
-                    + copy_of + string(" true")
-                    + string(") oh; nh) ")
-                    + what + ")";
-        }
-    } if (type->is_list()) {
-        string copy_of = struct_member_copy_of(((t_list *)type)->get_elem_type(), "x");
-        if(copy_of != "x") {
-            return string("(List.map (fun x -> ")
-                + copy_of + string (") ")
-                + what + string(")");
-        } else {
-            return what;
-        }
+string t_ocaml_generator::struct_member_copy_of(t_type* type, string what) {
+  if (type->is_struct() || type->is_xception()) {
+    return what + string("#copy");
+  }
+  if (type->is_map()) {
+    string copy_of_k = struct_member_copy_of(((t_map*)type)->get_key_type(), "k");
+    string copy_of_v = struct_member_copy_of(((t_map*)type)->get_val_type(), "v");
+
+    if (copy_of_k == "k" && copy_of_v == "v") {
+      return string("(Hashtbl.copy ") + what + string(")");
+    } else {
+      return string(
+                 "((fun oh -> let nh = Hashtbl.create (Hashtbl.length oh) in Hashtbl.iter (fun k v "
+                 "-> Hashtbl.add nh ") + copy_of_k + string(" ") + copy_of_v + string(") oh; nh) ")
+             + what + ")";
+    }
+  }
+  if (type->is_set()) {
+    string copy_of = struct_member_copy_of(((t_set*)type)->get_elem_type(), "k");
+
+    if (copy_of == "k") {
+      return string("(Hashtbl.copy ") + what + string(")");
+    } else {
+      return string(
+                 "((fun oh -> let nh = Hashtbl.create (Hashtbl.length oh) in Hashtbl.iter (fun k v "
+                 "-> Hashtbl.add nh ") + copy_of + string(" true") + string(") oh; nh) ") + what
+             + ")";
     }
-    return what;
+  }
+  if (type->is_list()) {
+    string copy_of = struct_member_copy_of(((t_list*)type)->get_elem_type(), "x");
+    if (copy_of != "x") {
+      return string("(List.map (fun x -> ") + copy_of + string(") ") + what + string(")");
+    } else {
+      return what;
+    }
+  }
+  return what;
 }
 
-void t_ocaml_generator::generate_ocaml_member_copy(ofstream& out,
-                                                   t_field *tmember) {
-    string mname = decapitalize(tmember->get_name());
-    t_type* type = get_true_type(tmember->get_type());
-
-    string grab_field = string("self#grab_") + mname;
-    string copy_of = struct_member_copy_of(type, grab_field);
-    if(copy_of != grab_field) {
-        indent(out);
-        if(!struct_member_persistent(tmember)) {
-                out << "if _" << mname << " <> None then" << endl;
-                indent(out) << "  ";
-        }
-        out << "_new#set_" << mname << " " << copy_of << ";" << endl;
+void t_ocaml_generator::generate_ocaml_member_copy(ofstream& out, t_field* tmember) {
+  string mname = decapitalize(tmember->get_name());
+  t_type* type = get_true_type(tmember->get_type());
+
+  string grab_field = string("self#grab_") + mname;
+  string copy_of = struct_member_copy_of(type, grab_field);
+  if (copy_of != grab_field) {
+    indent(out);
+    if (!struct_member_persistent(tmember)) {
+      out << "if _" << mname << " <> None then" << endl;
+      indent(out) << "  ";
     }
+    out << "_new#set_" << mname << " " << copy_of << ";" << endl;
+  }
 }
 
 /**
@@ -624,8 +592,8 @@ void t_ocaml_generator::generate_ocaml_struct_definition(ofstream& out,
   indent_down();
   indent(out) << "end" << endl;
 
-  if(is_exception){
-    indent(out) << "exception " << capitalize(tname) <<" of " << tname << endl;
+  if (is_exception) {
+    indent(out) << "exception " << capitalize(tname) << " of " << tname << endl;
   }
 
   generate_ocaml_struct_reader(out, tstruct);
@@ -644,39 +612,41 @@ void t_ocaml_generator::generate_ocaml_struct_member(ofstream& out,
   string mname = decapitalize(tmember->get_name());
 
   indent(out) << "val mutable _" << mname << " : " << render_ocaml_type(tmember->get_type());
-  t_const_value *val = tmember->get_value();
-  if(val) {
-    if(struct_member_persistent(tmember))
-        out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+  t_const_value* val = tmember->get_value();
+  if (val) {
+    if (struct_member_persistent(tmember))
+      out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
     else
-        out << " option = Some " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+      out << " option = Some " << render_const_value(tmember->get_type(), tmember->get_value())
+          << endl;
   } else {
     // assert(!struct_member_persistent(tmember))
     out << " option = None" << endl;
   }
 
-  if(struct_member_persistent(tmember)) {
-        indent(out) << "method get_" << mname << " = Some _" << mname << endl;
-        indent(out) << "method grab_" << mname << " = _" << mname << endl;
-        indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << endl;
+  if (struct_member_persistent(tmember)) {
+    indent(out) << "method get_" << mname << " = Some _" << mname << endl;
+    indent(out) << "method grab_" << mname << " = _" << mname << endl;
+    indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << endl;
   } else {
-        indent(out) << "method get_" << mname << " = _" << mname << endl;
-        indent(out) << "method grab_" << mname << " = match _"<<mname<<" with None->raise (Field_empty \""<<tname<<"."<<mname<<"\") | Some " << x <<" -> " << x << endl;
-        indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- Some " << x << endl;
-        indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << endl;
+    indent(out) << "method get_" << mname << " = _" << mname << endl;
+    indent(out) << "method grab_" << mname << " = match _" << mname
+                << " with None->raise (Field_empty \"" << tname << "." << mname << "\") | Some "
+                << x << " -> " << x << endl;
+    indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- Some " << x
+                << endl;
+    indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << endl;
   }
 
   indent(out) << "method reset_" << mname << " = _" << mname << " <- ";
-  if(val) {
-    if(struct_member_persistent(tmember))
-        out << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+  if (val) {
+    if (struct_member_persistent(tmember))
+      out << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
     else
-        out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+      out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
   } else {
     out << "None" << endl;
   }
-
-
 }
 
 /**
@@ -684,8 +654,8 @@ void t_ocaml_generator::generate_ocaml_struct_member(ofstream& out,
  *
  * @param tmember Member definition
  */
-bool t_ocaml_generator::struct_member_persistent(t_field *tmember) {
-  t_const_value *val = tmember->get_value();
+bool t_ocaml_generator::struct_member_persistent(t_field* tmember) {
+  t_const_value* val = tmember->get_value();
   return (val ? true : false);
 }
 
@@ -694,7 +664,7 @@ bool t_ocaml_generator::struct_member_persistent(t_field *tmember) {
  *
  * @param tmember Member definition
  */
-bool t_ocaml_generator::struct_member_omitable(t_field *tmember) {
+bool t_ocaml_generator::struct_member_omitable(t_field* tmember) {
   return (tmember->get_req() != t_field::T_REQUIRED);
 }
 
@@ -704,29 +674,29 @@ bool t_ocaml_generator::struct_member_omitable(t_field *tmember) {
  *
  * @param tmember Member definition
  */
-bool t_ocaml_generator::struct_member_default_cheaply_comparable(t_field *tmember) {
+bool t_ocaml_generator::struct_member_default_cheaply_comparable(t_field* tmember) {
   t_type* type = get_true_type(tmember->get_type());
-  t_const_value *val = tmember->get_value();
-  if(!val) {
+  t_const_value* val = tmember->get_value();
+  if (!val) {
     return false;
-  } else if(type->is_base_type()) {
+  } else if (type->is_base_type()) {
     // Base types are generally cheaply compared for structural equivalence.
-    switch(((t_base_type*)type)->get_base()) {
+    switch (((t_base_type*)type)->get_base()) {
     case t_base_type::TYPE_DOUBLE:
-        if(val->get_double() == 0.0)
-                return true;
-        else
-                return false;
-    default:
+      if (val->get_double() == 0.0)
         return true;
+      else
+        return false;
+    default:
+      return true;
     }
-  } else if(type->is_list()) {
+  } else if (type->is_list()) {
     // Empty lists are cheaply compared for structural equivalence.
     // Is empty list?
-    if(val->get_list().size() == 0)
-        return true;
+    if (val->get_list().size() == 0)
+      return true;
     else
-        return false;
+      return false;
   } else {
     return false;
   }
@@ -756,7 +726,7 @@ void t_ocaml_generator::generate_ocaml_struct_sig(ofstream& out,
       indent(out) << "method get_" << mname << " : " << type << " option" << endl;
       indent(out) << "method grab_" << mname << " : " << type << endl;
       indent(out) << "method set_" << mname << " : " << type << " -> unit" << endl;
-      if(!struct_member_persistent(*m_iter))
+      if (!struct_member_persistent(*m_iter))
         indent(out) << "method unset_" << mname << " : unit" << endl;
       indent(out) << "method reset_" << mname << " : unit" << endl;
     }
@@ -766,8 +736,8 @@ void t_ocaml_generator::generate_ocaml_struct_sig(ofstream& out,
   indent_down();
   indent(out) << "end" << endl;
 
-  if(is_exception){
-    indent(out) << "exception " << capitalize(tname) <<" of " << tname << endl;
+  if (is_exception) {
+    indent(out) << "exception " << capitalize(tname) << " of " << tname << endl;
   }
 
   indent(out) << "val read_" << tname << " : Protocol.t -> " << tname << endl;
@@ -783,96 +753,83 @@ void t_ocaml_generator::generate_ocaml_struct_reader(ofstream& out, t_struct* ts
   string str = tmp("_str");
   string t = tmp("_t");
   string id = tmp("_id");
-  indent(out) <<
-    "let rec read_" << sname << " (iprot : Protocol.t) =" << endl;
+  indent(out) << "let rec read_" << sname << " (iprot : Protocol.t) =" << endl;
   indent_up();
   indent(out) << "let " << str << " = new " << sname << " in" << endl;
   indent_up();
-  indent(out) <<
-    "ignore(iprot#readStructBegin);" << endl;
+  indent(out) << "ignore(iprot#readStructBegin);" << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "(try while true do" << endl;
+  indent(out) << "(try while true do" << endl;
   indent_up();
   indent_up();
 
   // Read beginning field marker
-  indent(out) <<
-    "let (_," << t <<","<<id<<") = iprot#readFieldBegin in" << endl;
+  indent(out) << "let (_," << t << "," << id << ") = iprot#readFieldBegin in" << endl;
 
   // Check for field STOP marker and break
-  indent(out) <<
-    "if " << t <<" = Protocol.T_STOP then" << endl;
+  indent(out) << "if " << t << " = Protocol.T_STOP then" << endl;
   indent_up();
-  indent(out) <<
-      "raise Break" << endl;
-    indent_down();
-    indent(out) << "else ();" << endl;
+  indent(out) << "raise Break" << endl;
+  indent_down();
+  indent(out) << "else ();" << endl;
 
-    indent(out) << "(match " << id<<" with " << endl;
+  indent(out) << "(match " << id << " with " << endl;
+  indent_up();
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "| " << (*f_iter)->get_key() << " -> (";
+    out << "if " << t << " = " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
     indent_up();
-    // Generate deserialization code for known cases
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      indent(out) << "| " << (*f_iter)->get_key() << " -> (";
-      out << "if " << t <<" = " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
-      indent_up();
-      indent_up();
-      generate_deserialize_field(out, *f_iter,str);
-      indent_down();
-      out <<
-        indent() << "else" << endl <<
-        indent() << "  iprot#skip "<< t << ")" << endl;
-      indent_down();
-    }
-
-    // In the default case we skip the field
-    out <<
-      indent() << "| _ -> " << "iprot#skip "<<t<<");" << endl;
-    indent_down();
-    // Read field end marker
-    indent(out) << "iprot#readFieldEnd;" << endl;
+    indent_up();
+    generate_deserialize_field(out, *f_iter, str);
     indent_down();
-    indent(out) << "done; ()" << endl;
+    out << indent() << "else" << endl << indent() << "  iprot#skip " << t << ")" << endl;
     indent_down();
-    indent(out) << "with Break -> ());" << endl;
+  }
 
-    indent(out) <<
-      "iprot#readStructEnd;" << endl;
+  // In the default case we skip the field
+  out << indent() << "| _ -> "
+      << "iprot#skip " << t << ");" << endl;
+  indent_down();
+  // Read field end marker
+  indent(out) << "iprot#readFieldEnd;" << endl;
+  indent_down();
+  indent(out) << "done; ()" << endl;
+  indent_down();
+  indent(out) << "with Break -> ());" << endl;
 
-    indent(out) << str << endl << endl;
-    indent_down();
-    indent_down();
+  indent(out) << "iprot#readStructEnd;" << endl;
+
+  indent(out) << str << endl << endl;
+  indent_down();
+  indent_down();
 }
 
-void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out,
-                                               t_struct* tstruct) {
+void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out, t_struct* tstruct) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
   string str = tmp("_str");
   string f = tmp("_f");
 
-  indent(out) <<
-    "method write (oprot : Protocol.t) =" << endl;
+  indent(out) << "method write (oprot : Protocol.t) =" << endl;
   indent_up();
-  indent(out) <<
-    "oprot#writeStructBegin \""<<name<<"\";" << endl;
+  indent(out) << "oprot#writeStructBegin \"" << name << "\";" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    t_field *tmember = (*f_iter);
-    string mname = "_"+decapitalize(tmember->get_name());
+    t_field* tmember = (*f_iter);
+    string mname = "_" + decapitalize(tmember->get_name());
     string _v;
 
-    if(struct_member_persistent(tmember)) {
+    if (struct_member_persistent(tmember)) {
 
-      if(struct_member_omitable(tmember)
-        && struct_member_default_cheaply_comparable(tmember)) {
+      if (struct_member_omitable(tmember) && struct_member_default_cheaply_comparable(tmember)) {
         _v = "_v";
         // Avoid redundant encoding of members having default values.
         indent(out) << "(match " << mname << " with "
-            << render_const_value(tmember->get_type(), tmember->get_value())
-            << " -> () | " << _v << " -> " << endl;
+                    << render_const_value(tmember->get_type(), tmember->get_value()) << " -> () | "
+                    << _v << " -> " << endl;
       } else {
         _v = mname;
         indent(out) << "(" << endl;
@@ -882,20 +839,19 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out,
 
       indent(out) << "(match " << mname << " with ";
 
-      if(struct_member_omitable(tmember)) {
+      if (struct_member_omitable(tmember)) {
         out << "None -> ()";
 
-        if(struct_member_default_cheaply_comparable(tmember)) {
+        if (struct_member_default_cheaply_comparable(tmember)) {
           // Avoid redundant encoding of members having default values.
-          out << " | Some "
-              << render_const_value(tmember->get_type(), tmember->get_value())
+          out << " | Some " << render_const_value(tmember->get_type(), tmember->get_value())
               << " -> ()";
         }
         out << " | Some _v -> " << endl;
       } else {
         out << endl;
-        indent(out) << "| None -> raise (Field_empty \""
-                    << type_name(tstruct) << "." << mname << "\")" << endl;
+        indent(out) << "| None -> raise (Field_empty \"" << type_name(tstruct) << "." << mname
+                    << "\")" << endl;
         indent(out) << "| Some _v -> " << endl;
       }
 
@@ -903,9 +859,8 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out,
     }
     indent_up();
     // Write field header
-    indent(out) << "oprot#writeFieldBegin(\""<< tmember->get_name()<<"\","
-                << type_to_enum(tmember->get_type()) << ","
-                << tmember->get_key()<<");" << endl;
+    indent(out) << "oprot#writeFieldBegin(\"" << tmember->get_name() << "\","
+                << type_to_enum(tmember->get_type()) << "," << tmember->get_key() << ");" << endl;
 
     // Write field contents
     generate_serialize_field(out, tmember, _v);
@@ -918,9 +873,7 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out,
   }
 
   // Write the struct map
-  out <<
-    indent() << "oprot#writeFieldStop;" << endl <<
-    indent() << "oprot#writeStructEnd" << endl;
+  out << indent() << "oprot#writeFieldStop;" << endl << indent() << "oprot#writeStructEnd" << endl;
 
   indent_down();
 }
@@ -931,17 +884,13 @@ void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out,
  * @param tservice The service definition
  */
 void t_ocaml_generator::generate_service(t_service* tservice) {
-  string f_service_name = get_out_dir()+capitalize(service_name_)+".ml";
+  string f_service_name = get_out_dir() + capitalize(service_name_) + ".ml";
   f_service_.open(f_service_name.c_str());
-  string f_service_i_name = get_out_dir()+capitalize(service_name_)+".mli";
+  string f_service_i_name = get_out_dir() + capitalize(service_name_) + ".mli";
   f_service_i_.open(f_service_i_name.c_str());
 
-  f_service_ <<
-    ocaml_autogen_comment() << endl <<
-    ocaml_imports() << endl;
-  f_service_i_ <<
-    ocaml_autogen_comment() << endl <<
-    ocaml_imports() << endl;
+  f_service_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
+  f_service_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
 
   /* if (tservice->get_extends() != NULL) {
     f_service_ <<
@@ -950,13 +899,9 @@ void t_ocaml_generator::generate_service(t_service* tservice) {
       "open " << capitalize(tservice->get_extends()->get_name()) << endl;
   }
   */
-  f_service_ <<
-     "open " << capitalize(program_name_) << "_types" << endl <<
-    endl;
+  f_service_ << "open " << capitalize(program_name_) << "_types" << endl << endl;
 
-  f_service_i_ <<
-     "open " << capitalize(program_name_) << "_types" << endl <<
-    endl;
+  f_service_i_ << "open " << capitalize(program_name_) << "_types" << endl << endl;
 
   // Generate the three main parts of the service
   generate_service_helpers(tservice);
@@ -964,7 +909,6 @@ void t_ocaml_generator::generate_service(t_service* tservice) {
   generate_service_client(tservice);
   generate_service_server(tservice);
 
-
   // Close service file
   f_service_.close();
   f_service_i_.close();
@@ -979,8 +923,7 @@ void t_ocaml_generator::generate_service_helpers(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
-  indent(f_service_) <<
-    "(* HELPER FUNCTIONS AND STRUCTURES *)" << endl << endl;
+  indent(f_service_) << "(* HELPER FUNCTIONS AND STRUCTURES *)" << endl << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_struct* ts = (*f_iter)->get_arglist();
@@ -1016,10 +959,8 @@ void t_ocaml_generator::generate_ocaml_function_helpers(t_function* tfunction) {
  * @param tservice The service to generate a header definition for
  */
 void t_ocaml_generator::generate_service_interface(t_service* tservice) {
-  f_service_ <<
-    indent() << "class virtual iface =" << endl << "object (self)" << endl;
-  f_service_i_ <<
-    indent() << "class virtual iface :" << endl << "object" << endl;
+  f_service_ << indent() << "class virtual iface =" << endl << "object (self)" << endl;
+  f_service_i_ << indent() << "class virtual iface :" << endl << "object" << endl;
 
   indent_up();
 
@@ -1032,11 +973,11 @@ void t_ocaml_generator::generate_service_interface(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    string ft = function_type(*f_iter,true,true);
-    f_service_ <<
-      indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : " << ft  << endl;
-    f_service_i_ <<
-      indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : " << ft << endl;
+    string ft = function_type(*f_iter, true, true);
+    f_service_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : "
+               << ft << endl;
+    f_service_i_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : "
+                 << ft << endl;
   }
   indent_down();
   indent(f_service_) << "end" << endl << endl;
@@ -1044,20 +985,19 @@ void t_ocaml_generator::generate_service_interface(t_service* tservice) {
 }
 
 /**
- * Generates a service client definition. Note that in OCaml, the client doesn't implement iface. This is because
+ * Generates a service client definition. Note that in OCaml, the client doesn't implement iface.
+ *This is because
  * The client does not (and should not have to) deal with arguments being None.
  *
  * @param tservice The service to generate a server for.
  */
 void t_ocaml_generator::generate_service_client(t_service* tservice) {
   string extends = "";
-  indent(f_service_) <<
-    "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << endl << "object (self)" << endl;
-  indent(f_service_i_) <<
-    "class client : Protocol.t -> Protocol.t -> " << endl << "object" << endl;
+  indent(f_service_) << "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << endl
+                     << "object (self)" << endl;
+  indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << endl << "object" << endl;
   indent_up();
 
-
   if (tservice->get_extends() != NULL) {
     extends = type_name(tservice->get_extends());
     indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << endl;
@@ -1065,7 +1005,6 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) {
   }
   indent(f_service_) << "val mutable seqid = 0" << endl;
 
-
   // Generate client method implementations
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::const_iterator f_iter;
@@ -1076,14 +1015,11 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    indent(f_service_) <<
-      "method " << function_signature(*f_iter) << " = " << endl;
-    indent(f_service_i_) <<
-      "method " << decapitalize((*f_iter)->get_name()) << " : " << function_type(*f_iter,true,false) << endl;
+    indent(f_service_) << "method " << function_signature(*f_iter) << " = " << endl;
+    indent(f_service_i_) << "method " << decapitalize((*f_iter)->get_name()) << " : "
+                         << function_type(*f_iter, true, false) << endl;
     indent_up();
-    indent(f_service_) <<
-      "self#send_" << funname;
-
+    indent(f_service_) << "self#send_" << funname;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
       f_service_ << " " << decapitalize((*fld_iter)->get_name());
@@ -1092,37 +1028,31 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) {
 
     if (!(*f_iter)->is_oneway()) {
       f_service_ << indent();
-      f_service_ <<
-        "self#recv_" << funname << endl;
+      f_service_ << "self#recv_" << funname << endl;
     }
     indent_down();
 
-    indent(f_service_) <<
-      "method private send_" << function_signature(*f_iter) << " = " << endl;
+    indent(f_service_) << "method private send_" << function_signature(*f_iter) << " = " << endl;
     indent_up();
 
     std::string argsname = decapitalize((*f_iter)->get_name() + "_args");
 
     // Serialize the request header
-    f_service_ <<
-      indent() << "oprot#writeMessageBegin (\"" << (*f_iter)->get_name() << "\", "
-               << ((*f_iter)->is_oneway() ? "Protocol.ONEWAY" : "Protocol.CALL")
-               << ", seqid);" << endl;
+    f_service_ << indent() << "oprot#writeMessageBegin (\"" << (*f_iter)->get_name() << "\", "
+               << ((*f_iter)->is_oneway() ? "Protocol.ONEWAY" : "Protocol.CALL") << ", seqid);"
+               << endl;
 
-    f_service_ <<
-      indent() << "let args = new " << argsname << " in" << endl;
+    f_service_ << indent() << "let args = new " << argsname << " in" << endl;
     indent_up();
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args#set_" << (*fld_iter)->get_name() << " " << (*fld_iter)->get_name() << ";" << endl;
+      f_service_ << indent() << "args#set_" << (*fld_iter)->get_name() << " "
+                 << (*fld_iter)->get_name() << ";" << endl;
     }
 
     // Write to the stream
-    f_service_ <<
-      indent() << "args#write oprot;" << endl <<
-      indent() << "oprot#writeMessageEnd;" << endl <<
-      indent() << "oprot#getTransport#flush" << endl;
+    f_service_ << indent() << "args#write oprot;" << endl << indent() << "oprot#writeMessageEnd;"
+               << endl << indent() << "oprot#getTransport#flush" << endl;
 
     indent_down();
     indent_down();
@@ -1135,25 +1065,21 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) {
                                string("recv_") + (*f_iter)->get_name(),
                                &noargs);
       // Open function
-      f_service_ <<
-        indent() << "method private " << function_signature(&recv_function) << " =" << endl;
+      f_service_ << indent() << "method private " << function_signature(&recv_function) << " ="
+                 << endl;
       indent_up();
 
       // TODO(mcslee): Validate message reply here, seq ids etc.
 
-      f_service_ <<
-        indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << endl;
+      f_service_ << indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "(if mtype = Protocol.EXCEPTION then" << endl <<
-        indent() << "  let x = Application_Exn.read iprot in" << endl;
+      f_service_ << indent() << "(if mtype = Protocol.EXCEPTION then" << endl << indent()
+                 << "  let x = Application_Exn.read iprot in" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "  (iprot#readMessageEnd;" <<
-        indent() << "   raise (Application_Exn.E x))" << endl;
+      f_service_ << indent() << "  (iprot#readMessageEnd;" << indent()
+                 << "   raise (Application_Exn.E x))" << endl;
       indent_down();
-      f_service_ <<
-        indent() << "else ());" << endl;
+      f_service_ << indent() << "else ());" << endl;
       string res = "_";
 
       t_struct* xs = (*f_iter)->get_xceptions();
@@ -1162,34 +1088,32 @@ void t_ocaml_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void() || xceptions.size() > 0) {
         res = "result";
       }
-      f_service_ <<
-        indent() << "let "<<res<<" = read_" << resultname << " iprot in" << endl;
+      f_service_ << indent() << "let " << res << " = read_" << resultname << " iprot in" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "iprot#readMessageEnd;" << endl;
+      f_service_ << indent() << "iprot#readMessageEnd;" << endl;
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "match result#get_success with Some v -> v | None -> (" << endl;
+        f_service_ << indent() << "match result#get_success with Some v -> v | None -> (" << endl;
         indent_up();
       }
 
-
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "(match result#get_" << (*x_iter)->get_name() << " with None -> () | Some _v ->" << endl;
-        indent(f_service_) << "  raise (" << capitalize(type_name((*x_iter)->get_type())) << " _v));" << endl;
+        f_service_ << indent() << "(match result#get_" << (*x_iter)->get_name()
+                   << " with None -> () | Some _v ->" << endl;
+        indent(f_service_) << "  raise (" << capitalize(type_name((*x_iter)->get_type()))
+                           << " _v));" << endl;
       }
 
       // Careful, only return _result if not a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "()" << endl;
+        indent(f_service_) << "()" << endl;
       } else {
-        f_service_ <<
-          indent() << "raise (Application_Exn.E (Application_Exn.create Application_Exn.MISSING_RESULT \"" << (*f_iter)->get_name() << " failed: unknown result\")))" << endl;
+        f_service_
+            << indent()
+            << "raise (Application_Exn.E (Application_Exn.create Application_Exn.MISSING_RESULT \""
+            << (*f_iter)->get_name() << " failed: unknown result\")))" << endl;
         indent_down();
       }
 
@@ -1215,62 +1139,51 @@ void t_ocaml_generator::generate_service_server(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
-
   // Generate the header portion
-  indent(f_service_) <<
-    "class processor (handler : iface) =" << endl << indent() << "object (self)" << endl;
-  indent(f_service_i_) <<
-    "class processor : iface ->" << endl << indent() << "object" << endl;
+  indent(f_service_) << "class processor (handler : iface) =" << endl << indent() << "object (self)"
+                     << endl;
+  indent(f_service_i_) << "class processor : iface ->" << endl << indent() << "object" << endl;
   indent_up();
 
-  f_service_ <<
-     indent() << "inherit Processor.t" << endl <<
-    endl;
-  f_service_i_ <<
-     indent() << "inherit Processor.t" << endl <<
-    endl;
+  f_service_ << indent() << "inherit Processor.t" << endl << endl;
+  f_service_i_ << indent() << "inherit Processor.t" << endl << endl;
   string extends = "";
 
   if (tservice->get_extends() != NULL) {
     extends = type_name(tservice->get_extends());
-    indent(f_service_) << "inherit " + extends + ".processor (handler :> " + extends + ".iface)" << endl;
+    indent(f_service_) << "inherit " + extends + ".processor (handler :> " + extends + ".iface)"
+                       << endl;
     indent(f_service_i_) << "inherit " + extends + ".processor" << endl;
   }
 
   if (extends.empty()) {
     indent(f_service_) << "val processMap = Hashtbl.create " << functions.size() << endl;
   }
-  indent(f_service_i_) << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << endl;
+  indent(f_service_i_)
+      << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << endl;
 
   // Generate the server implementation
-  indent(f_service_) <<
-    "method process iprot oprot =" << endl;
-  indent(f_service_i_) <<
-    "method process : Protocol.t -> Protocol.t -> bool" << endl;
+  indent(f_service_) << "method process iprot oprot =" << endl;
+  indent(f_service_i_) << "method process : Protocol.t -> Protocol.t -> bool" << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "let (name, typ, seqid)  = iprot#readMessageBegin in" << endl;
+  f_service_ << indent() << "let (name, typ, seqid)  = iprot#readMessageBegin in" << endl;
   indent_up();
   // TODO(mcslee): validate message
 
   // HOT: dictionary function lookup
-  f_service_ <<
-    indent() << "if Hashtbl.mem processMap name then" << endl <<
-    indent() << "  (Hashtbl.find processMap name) (seqid, iprot, oprot)" << endl <<
-    indent() << "else (" << endl <<
-    indent() << "  iprot#skip(Protocol.T_STRUCT);" << endl <<
-    indent() << "  iprot#readMessageEnd;" << endl <<
-    indent() << "  let x = Application_Exn.create Application_Exn.UNKNOWN_METHOD (\"Unknown function \"^name) in" << endl <<
-    indent() << "    oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << endl <<
-    indent() << "    x#write oprot;" << endl <<
-    indent() << "    oprot#writeMessageEnd;" << endl <<
-    indent() << "    oprot#getTransport#flush" << endl <<
-    indent() << ");" << endl;
+  f_service_ << indent() << "if Hashtbl.mem processMap name then" << endl << indent()
+             << "  (Hashtbl.find processMap name) (seqid, iprot, oprot)" << endl << indent()
+             << "else (" << endl << indent() << "  iprot#skip(Protocol.T_STRUCT);" << endl
+             << indent() << "  iprot#readMessageEnd;" << endl << indent()
+             << "  let x = Application_Exn.create Application_Exn.UNKNOWN_METHOD (\"Unknown "
+                "function \"^name) in" << endl << indent()
+             << "    oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << endl << indent()
+             << "    x#write oprot;" << endl << indent() << "    oprot#writeMessageEnd;" << endl
+             << indent() << "    oprot#getTransport#flush" << endl << indent() << ");" << endl;
 
   // Read end of args field, the T_STOP, and the struct close
-  f_service_ <<
-    indent() << "true" << endl;
+  f_service_ << indent() << "true" << endl;
   indent_down();
   indent_down();
   // Generate the process subfunctions
@@ -1281,8 +1194,8 @@ void t_ocaml_generator::generate_service_server(t_service* tservice) {
   indent(f_service_) << "initializer" << endl;
   indent_up();
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "Hashtbl.add processMap \"" << (*f_iter)->get_name() << "\" self#process_" << (*f_iter)->get_name() << ";" << endl;
+    f_service_ << indent() << "Hashtbl.add processMap \"" << (*f_iter)->get_name()
+               << "\" self#process_" << (*f_iter)->get_name() << ";" << endl;
   }
   indent_down();
 
@@ -1296,13 +1209,11 @@ void t_ocaml_generator::generate_service_server(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_ocaml_generator::generate_process_function(t_service* tservice,
-                                               t_function* tfunction) {
-  (void) tservice;
+void t_ocaml_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open function
-  indent(f_service_) <<
-    "method private process_" << tfunction->get_name() <<
-    " (seqid, iprot, oprot) =" << endl;
+  indent(f_service_) << "method private process_" << tfunction->get_name()
+                     << " (seqid, iprot, oprot) =" << endl;
   indent_up();
 
   string argsname = decapitalize(tfunction->get_name()) + "_args";
@@ -1314,15 +1225,13 @@ void t_ocaml_generator::generate_process_function(t_service* tservice,
   vector<t_field*>::const_iterator f_iter;
 
   string args = "args";
-  if(fields.size() == 0){
-    args="_";
+  if (fields.size() == 0) {
+    args = "_";
   }
 
-  f_service_ <<
-    indent() << "let "<<args<<" = read_" << argsname << " iprot in" << endl;
+  f_service_ << indent() << "let " << args << " = read_" << argsname << " iprot in" << endl;
   indent_up();
-  f_service_ <<
-    indent() << "iprot#readMessageEnd;" << endl;
+  f_service_ << indent() << "iprot#readMessageEnd;" << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1330,45 +1239,38 @@ void t_ocaml_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "let result = new " << resultname << " in" << endl;
+    f_service_ << indent() << "let result = new " << resultname << " in" << endl;
     indent_up();
   }
 
   // Try block for a function with exceptions
   if (xceptions.size() > 0) {
-    f_service_ <<
-      indent() << "(try" << endl;
+    f_service_ << indent() << "(try" << endl;
     indent_up();
   }
 
-
-
-
   f_service_ << indent();
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << "result#set_success ";
   }
-  f_service_ <<
-    "(handler#" << tfunction->get_name();
+  f_service_ << "(handler#" << tfunction->get_name();
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    f_service_ <<  " args#get_" << (*f_iter)->get_name();
+    f_service_ << " args#get_" << (*f_iter)->get_name();
   }
   f_service_ << ");" << endl;
 
-
   if (xceptions.size() > 0) {
     indent_down();
-    indent(f_service_) << "with" <<endl;
+    indent(f_service_) << "with" << endl;
     indent_up();
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_ <<
-        indent() << "| " << capitalize(type_name((*x_iter)->get_type())) << " " << (*x_iter)->get_name() << " -> " << endl;
+      f_service_ << indent() << "| " << capitalize(type_name((*x_iter)->get_type())) << " "
+                 << (*x_iter)->get_name() << " -> " << endl;
       indent_up();
       indent_up();
-      if(!tfunction->is_oneway()){
-           f_service_ <<
-             indent() << "result#set_" << (*x_iter)->get_name() << " " << (*x_iter)->get_name() << endl;
+      if (!tfunction->is_oneway()) {
+        f_service_ << indent() << "result#set_" << (*x_iter)->get_name() << " "
+                   << (*x_iter)->get_name() << endl;
       } else {
         indent(f_service_) << "()";
       }
@@ -1379,22 +1281,18 @@ void t_ocaml_generator::generate_process_function(t_service* tservice,
     f_service_ << indent() << ");" << endl;
   }
 
-
-
   // Shortcut out here for oneway functions
   if (tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "()" << endl;
+    f_service_ << indent() << "()" << endl;
     indent_down();
     indent_down();
     return;
   }
 
-  f_service_ <<
-    indent() << "oprot#writeMessageBegin (\"" << tfunction->get_name() << "\", Protocol.REPLY, seqid);" << endl <<
-    indent() << "result#write oprot;" << endl <<
-    indent() << "oprot#writeMessageEnd;" << endl <<
-    indent() << "oprot#getTransport#flush" << endl;
+  f_service_ << indent() << "oprot#writeMessageBegin (\"" << tfunction->get_name()
+             << "\", Protocol.REPLY, seqid);" << endl << indent() << "result#write oprot;" << endl
+             << indent() << "oprot#writeMessageEnd;" << endl << indent()
+             << "oprot#getTransport#flush" << endl;
 
   // Close function
   indent_down();
@@ -1405,34 +1303,27 @@ void t_ocaml_generator::generate_process_function(t_service* tservice,
 /**
  * Deserializes a field of any type.
  */
-void t_ocaml_generator::generate_deserialize_field(ofstream &out,
-                                                   t_field* tfield,
-                                                   string prefix){
+void t_ocaml_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = tfield->get_type();
 
-
   string name = decapitalize(tfield->get_name());
-  indent(out) << prefix << "#set_"<<name << " ";
-  generate_deserialize_type(out,type);
+  indent(out) << prefix << "#set_" << name << " ";
+  generate_deserialize_type(out, type);
   out << endl;
 }
 
-
 /**
  * Deserializes a field of any type.
  */
-void t_ocaml_generator::generate_deserialize_type(ofstream &out,
-                                                   t_type* type){
+void t_ocaml_generator::generate_deserialize_type(ofstream& out, t_type* type) {
   type = get_true_type(type);
 
   if (type->is_void()) {
     throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE";
   }
 
-
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type);
+    generate_deserialize_struct(out, (t_struct*)type);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type);
   } else if (type->is_base_type()) {
@@ -1468,35 +1359,30 @@ void t_ocaml_generator::generate_deserialize_type(ofstream &out,
     }
   } else if (type->is_enum()) {
     string ename = capitalize(type->get_name());
-    out << "(" <<ename << ".of_i iprot#readI32)";
+    out << "(" << ename << ".of_i iprot#readI32)";
   } else {
-    printf("DO NOT KNOW HOW TO DESERIALIZE TYPE '%s'\n",
-           type->get_name().c_str());
+    printf("DO NOT KNOW HOW TO DESERIALIZE TYPE '%s'\n", type->get_name().c_str());
   }
 }
 
-
 /**
  * Generates an unserializer for a struct, calling read()
  */
-void t_ocaml_generator::generate_deserialize_struct(ofstream &out,
-                                                  t_struct* tstruct) {
+void t_ocaml_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct) {
   string prefix = "";
   t_program* program = tstruct->get_program();
   if (program != NULL && program != program_) {
-     prefix = capitalize(program->get_name()) + "_types.";
+    prefix = capitalize(program->get_name()) + "_types.";
   }
   string name = decapitalize(tstruct->get_name());
   out << "(" << prefix << "read_" << name << " iprot)";
-
 }
 
 /**
  * Serialize a container by writing out the header followed by
  * data and then a footer.
  */
-void t_ocaml_generator::generate_deserialize_container(ofstream &out,
-                                                    t_type* ttype) {
+void t_ocaml_generator::generate_deserialize_container(ofstream& out, t_type* ttype) {
   string size = tmp("_size");
   string ktype = tmp("_ktype");
   string vtype = tmp("_vtype");
@@ -1512,99 +1398,88 @@ void t_ocaml_generator::generate_deserialize_container(ofstream &out,
   indent_up();
   // Declare variables, read header
   if (ttype->is_map()) {
-    indent(out) << "(let ("<<ktype<<","<<vtype<<","<<size<<") = iprot#readMapBegin in" << endl;
-    indent(out) << "let "<<con<<" = Hashtbl.create "<<size<<" in" << endl;
+    indent(out) << "(let (" << ktype << "," << vtype << "," << size << ") = iprot#readMapBegin in"
+                << endl;
+    indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl;
     indent_up();
-    indent(out) << "for i = 1 to "<<size<<" do" <<endl;
+    indent(out) << "for i = 1 to " << size << " do" << endl;
     indent_up();
     indent(out) << "let _k = ";
-    generate_deserialize_type(out,((t_map*)ttype)->get_key_type());
+    generate_deserialize_type(out, ((t_map*)ttype)->get_key_type());
     out << " in" << endl;
     indent(out) << "let _v = ";
-    generate_deserialize_type(out,((t_map*)ttype)->get_val_type());
+    generate_deserialize_type(out, ((t_map*)ttype)->get_val_type());
     out << " in" << endl;
     indent_up();
-    indent(out) << "Hashtbl.add "<<con<< " _k _v" << endl;
+    indent(out) << "Hashtbl.add " << con << " _k _v" << endl;
     indent_down();
     indent_down();
-    indent(out) << "done; iprot#readMapEnd; "<<con<<")";
+    indent(out) << "done; iprot#readMapEnd; " << con << ")";
     indent_down();
   } else if (ttype->is_set()) {
-    indent(out) << "(let ("<<etype<<","<<size<<") = iprot#readSetBegin in" << endl;
-    indent(out) << "let "<<con<<" = Hashtbl.create "<<size<<" in" << endl;
+    indent(out) << "(let (" << etype << "," << size << ") = iprot#readSetBegin in" << endl;
+    indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl;
     indent_up();
-    indent(out) << "for i = 1 to "<<size<<" do" <<endl;
+    indent(out) << "for i = 1 to " << size << " do" << endl;
     indent_up();
-    indent(out) << "Hashtbl.add "<<con<<" ";
-    generate_deserialize_type(out,((t_set*)ttype)->get_elem_type());
+    indent(out) << "Hashtbl.add " << con << " ";
+    generate_deserialize_type(out, ((t_set*)ttype)->get_elem_type());
     out << " true" << endl;
     indent_down();
-    indent(out) << "done; iprot#readSetEnd; "<<con<<")";
+    indent(out) << "done; iprot#readSetEnd; " << con << ")";
     indent_down();
   } else if (ttype->is_list()) {
-    indent(out) << "(let ("<<etype<<","<<size<<") = iprot#readListBegin in" << endl;
+    indent(out) << "(let (" << etype << "," << size << ") = iprot#readListBegin in" << endl;
     indent_up();
-    indent(out) << "let "<<con<<" = (Array.to_list (Array.init "<<size<<" (fun _ -> ";
-    generate_deserialize_type(out,((t_list*)ttype)->get_elem_type());
+    indent(out) << "let " << con << " = (Array.to_list (Array.init " << size << " (fun _ -> ";
+    generate_deserialize_type(out, ((t_list*)ttype)->get_elem_type());
     out << "))) in" << endl;
     indent_up();
-    indent(out) << "iprot#readListEnd; "<<con<<")";
+    indent(out) << "iprot#readListEnd; " << con << ")";
     indent_down();
     indent_down();
   }
   indent_down();
 }
 
-
-
 /**
  * Serializes a field of any type.
  *
  * @param tfield The field to serialize
  * @param prefix Name to prepend to field name
  */
-void t_ocaml_generator::generate_serialize_field(ofstream &out,
-                                                 t_field* tfield,
-                                                 string name) {
+void t_ocaml_generator::generate_serialize_field(ofstream& out, t_field* tfield, string name) {
   t_type* type = get_true_type(tfield->get_type());
 
   // Do nothing for void types
   if (type->is_void()) {
-    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
-      tfield->get_name();
+    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + tfield->get_name();
   }
 
-  if(name.length() == 0){
+  if (name.length() == 0) {
     name = decapitalize(tfield->get_name());
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_serialize_struct(out,
-                              (t_struct*)type,
-                              name);
+    generate_serialize_struct(out, (t_struct*)type, name);
   } else if (type->is_container()) {
-    generate_serialize_container(out,
-                                 type,
-                                 name);
+    generate_serialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
 
-
-    indent(out) <<
-      "oprot#";
+    indent(out) << "oprot#";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "writeString(" << name << ")";
         break;
       case t_base_type::TYPE_BOOL:
         out << "writeBool(" << name << ")";
-       break;
+        break;
       case t_base_type::TYPE_BYTE:
         out << "writeByte(" << name << ")";
         break;
@@ -1625,7 +1500,7 @@ void t_ocaml_generator::generate_serialize_field(ofstream &out,
       }
     } else if (type->is_enum()) {
       string ename = capitalize(type->get_name());
-      out << "writeI32("<<ename<<".to_i " << name << ")";
+      out << "writeI32(" << ename << ".to_i " << name << ")";
     }
 
   } else {
@@ -1642,63 +1517,55 @@ void t_ocaml_generator::generate_serialize_field(ofstream &out,
  * @param tstruct The struct to serialize
  * @param prefix  String prefix to attach to all fields
  */
-void t_ocaml_generator::generate_serialize_struct(ofstream &out,
-                                               t_struct* tstruct,
-                                               string prefix) {
-  (void) tstruct;
+void t_ocaml_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  (void)tstruct;
   indent(out) << prefix << "#write(oprot)";
 }
 
-void t_ocaml_generator::generate_serialize_container(ofstream &out,
-                                                  t_type* ttype,
-                                                  string prefix) {
+void t_ocaml_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   if (ttype->is_map()) {
-    indent(out) << "oprot#writeMapBegin("<< type_to_enum(((t_map*)ttype)->get_key_type()) << ",";
+    indent(out) << "oprot#writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ",";
     out << type_to_enum(((t_map*)ttype)->get_val_type()) << ",";
     out << "Hashtbl.length " << prefix << ");" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "oprot#writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ",";
+    indent(out) << "oprot#writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ",";
     out << "Hashtbl.length " << prefix << ");" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "oprot#writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ",";
+    indent(out) << "oprot#writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
+                << ",";
     out << "List.length " << prefix << ");" << endl;
   }
 
   if (ttype->is_map()) {
     string kiter = tmp("_kiter");
     string viter = tmp("_viter");
-    indent(out) << "Hashtbl.iter (fun "<<kiter<<" -> fun " << viter << " -> " << endl;
+    indent(out) << "Hashtbl.iter (fun " << kiter << " -> fun " << viter << " -> " << endl;
     indent_up();
     generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
     indent_down();
     indent(out) << ") " << prefix << ";" << endl;
   } else if (ttype->is_set()) {
     string iter = tmp("_iter");
-    indent(out) << "Hashtbl.iter (fun "<<iter<<" -> fun _ -> ";
+    indent(out) << "Hashtbl.iter (fun " << iter << " -> fun _ -> ";
     indent_up();
     generate_serialize_set_element(out, (t_set*)ttype, iter);
     indent_down();
     indent(out) << ") " << prefix << ";" << endl;
   } else if (ttype->is_list()) {
     string iter = tmp("_iter");
-    indent(out) << "List.iter (fun "<<iter<<" -> ";
+    indent(out) << "List.iter (fun " << iter << " -> ";
     indent_up();
     generate_serialize_list_element(out, (t_list*)ttype, iter);
     indent_down();
-    indent(out) << ") " << prefix << ";" <<  endl;
+    indent(out) << ") " << prefix << ";" << endl;
   }
 
   if (ttype->is_map()) {
-    indent(out) <<
-      "oprot#writeMapEnd";
+    indent(out) << "oprot#writeMapEnd";
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "oprot#writeSetEnd";
+    indent(out) << "oprot#writeSetEnd";
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "oprot#writeListEnd";
+    indent(out) << "oprot#writeListEnd";
   }
 }
 
@@ -1706,10 +1573,10 @@ void t_ocaml_generator::generate_serialize_container(ofstream &out,
  * Serializes the members of a map.
  *
  */
-void t_ocaml_generator::generate_serialize_map_element(ofstream &out,
-                                                     t_map* tmap,
-                                                     string kiter,
-                                                     string viter) {
+void t_ocaml_generator::generate_serialize_map_element(ofstream& out,
+                                                       t_map* tmap,
+                                                       string kiter,
+                                                       string viter) {
   t_field kfield(tmap->get_key_type(), kiter);
   generate_serialize_field(out, &kfield);
 
@@ -1720,9 +1587,7 @@ void t_ocaml_generator::generate_serialize_map_element(ofstream &out,
 /**
  * Serializes the members of a set.
  */
-void t_ocaml_generator::generate_serialize_set_element(ofstream &out,
-                                                     t_set* tset,
-                                                     string iter) {
+void t_ocaml_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
   t_field efield(tset->get_elem_type(), iter);
   generate_serialize_field(out, &efield);
 }
@@ -1730,40 +1595,34 @@ void t_ocaml_generator::generate_serialize_set_element(ofstream &out,
 /**
  * Serializes the members of a list.
  */
-void t_ocaml_generator::generate_serialize_list_element(ofstream &out,
-                                                      t_list* tlist,
-                                                      string iter) {
+void t_ocaml_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
   t_field efield(tlist->get_elem_type(), iter);
   generate_serialize_field(out, &efield);
 }
 
-
-
 /**
  * Renders a function signature of the form 'name args'
  *
  * @param tfunction Function definition
  * @return String of rendered function definition
  */
-string t_ocaml_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
-  return
-    prefix + decapitalize(tfunction->get_name()) +
-    " " +  argument_list(tfunction->get_arglist());
+string t_ocaml_generator::function_signature(t_function* tfunction, string prefix) {
+  return prefix + decapitalize(tfunction->get_name()) + " "
+         + argument_list(tfunction->get_arglist());
 }
 
-string t_ocaml_generator::function_type(t_function* tfunc, bool method, bool options){
-  string result="";
+string t_ocaml_generator::function_type(t_function* tfunc, bool method, bool options) {
+  string result = "";
 
   const vector<t_field*>& fields = tfunc->get_arglist()->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     result += render_ocaml_type((*f_iter)->get_type());
-    if(options)
+    if (options)
       result += " option";
     result += " -> ";
   }
-  if(fields.empty() && !method){
+  if (fields.empty() && !method) {
     result += "unit -> ";
   }
   result += render_ocaml_type(tfunc->get_returntype());
@@ -1800,7 +1659,7 @@ string t_ocaml_generator::type_name(t_type* ttype) {
   }
 
   string name = ttype->get_name();
-  if(ttype->is_service()){
+  if (ttype->is_service()) {
     name = capitalize(name);
   } else {
     name = decapitalize(name);
@@ -1876,24 +1735,22 @@ string t_ocaml_generator::render_ocaml_type(t_type* type) {
       return "float";
     }
   } else if (type->is_enum()) {
-    return capitalize(((t_enum*)type)->get_name())+".t";
+    return capitalize(((t_enum*)type)->get_name()) + ".t";
   } else if (type->is_struct() || type->is_xception()) {
     return type_name((t_struct*)type);
   } else if (type->is_map()) {
     t_type* ktype = ((t_map*)type)->get_key_type();
     t_type* vtype = ((t_map*)type)->get_val_type();
-    return "("+render_ocaml_type(ktype)+","+render_ocaml_type(vtype)+") Hashtbl.t";
+    return "(" + render_ocaml_type(ktype) + "," + render_ocaml_type(vtype) + ") Hashtbl.t";
   } else if (type->is_set()) {
     t_type* etype = ((t_set*)type)->get_elem_type();
-    return "("+render_ocaml_type(etype)+",bool) Hashtbl.t";
+    return "(" + render_ocaml_type(etype) + ",bool) Hashtbl.t";
   } else if (type->is_list()) {
     t_type* etype = ((t_list*)type)->get_elem_type();
-    return render_ocaml_type(etype)+" list";
+    return render_ocaml_type(etype) + " list";
   }
 
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 THRIFT_REGISTER_GENERATOR(ocaml, "OCaml", "")
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_oop_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_oop_generator.h b/compiler/cpp/src/generate/t_oop_generator.h
index 8d27f38..925d108 100644
--- a/compiler/cpp/src/generate/t_oop_generator.h
+++ b/compiler/cpp/src/generate/t_oop_generator.h
@@ -35,9 +35,8 @@
  *
  */
 class t_oop_generator : public t_generator {
- public:
-  t_oop_generator(t_program* program) :
-    t_generator(program) {}
+public:
+  t_oop_generator(t_program* program) : t_generator(program) {}
 
   /**
    * Scoping, using curly braces!
@@ -54,7 +53,7 @@ class t_oop_generator : public t_generator {
   }
 
   std::string upcase_string(std::string original) {
-    std::transform(original.begin(), original.end(), original.begin(), (int(*)(int)) toupper);
+    std::transform(original.begin(), original.end(), original.begin(), (int (*)(int))toupper);
     return original;
   }
 
@@ -65,18 +64,13 @@ class t_oop_generator : public t_generator {
    * @return C-style comment mentioning that this file is autogenerated.
    */
   virtual std::string autogen_comment() {
-    return
-      std::string("/**\n") +
-      " * " + autogen_summary() + "\n" +
-      " *\n" +
-      " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-      " *  @generated\n" +
-      " */\n";
+    return std::string("/**\n") + " * " + autogen_summary() + "\n" + " *\n"
+           + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+           + " *  @generated\n" + " */\n";
   }
 
   virtual std::string autogen_summary() {
-    return
-      std::string("Autogenerated by Thrift Compiler (") + THRIFT_VERSION + ")";
+    return std::string("Autogenerated by Thrift Compiler (") + THRIFT_VERSION + ")";
   }
 
   virtual std::string get_enum_class_name(t_type* type) {
@@ -88,17 +82,14 @@ class t_oop_generator : public t_generator {
     return package + type->get_name();
   }
 
-  virtual void generate_java_docstring_comment(std::ofstream &out, std::string contents) {
-    generate_docstring_comment(out,
-                               "/**\n",
-                               " * ", contents,
-                               " */\n");
+  virtual void generate_java_docstring_comment(std::ofstream& out, std::string contents) {
+    generate_docstring_comment(out, "/**\n", " * ", contents, " */\n");
   }
 
-  virtual void generate_java_doc(std::ofstream &out,
-                                           t_field* field) {
+  virtual void generate_java_doc(std::ofstream& out, t_field* field) {
     if (field->get_type()->is_enum()) {
-      std::string combined_message = field->get_doc() + "\n@see " + get_enum_class_name(field->get_type());
+      std::string combined_message = field->get_doc() + "\n@see "
+                                     + get_enum_class_name(field->get_type());
       generate_java_docstring_comment(out, combined_message);
     } else {
       generate_java_doc(out, (t_doc*)field);
@@ -108,8 +99,7 @@ class t_oop_generator : public t_generator {
   /**
    * Emits a JavaDoc comment if the provided object has a doc in Thrift
    */
-  virtual void generate_java_doc(std::ofstream &out,
-                                           t_doc* tdoc) {
+  virtual void generate_java_doc(std::ofstream& out, t_doc* tdoc) {
     if (tdoc->has_doc()) {
       generate_java_docstring_comment(out, tdoc->get_doc());
     }
@@ -118,8 +108,7 @@ class t_oop_generator : public t_generator {
   /**
    * Emits a JavaDoc comment if the provided function object has a doc in Thrift
    */
-  virtual void generate_java_doc(std::ofstream &out,
-                                           t_function* tfunction) {
+  virtual void generate_java_doc(std::ofstream& out, t_function* tfunction) {
     if (tfunction->has_doc()) {
       std::stringstream ss;
       ss << tfunction->get_doc();
@@ -132,13 +121,9 @@ class t_oop_generator : public t_generator {
           ss << " " << p->get_doc();
         }
       }
-      generate_docstring_comment(out,
-                                 "/**\n",
-                                 " * ", ss.str(),
-                                 " */\n");
+      generate_docstring_comment(out, "/**\n", " * ", ss.str(), " */\n");
     }
   }
 };
 
 #endif
-


[24/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_html_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_html_generator.cc b/compiler/cpp/src/generate/t_html_generator.cc
index a79ed50..f5185ea 100644
--- a/compiler/cpp/src/generate/t_html_generator.cc
+++ b/compiler/cpp/src/generate/t_html_generator.cc
@@ -38,7 +38,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN };
 
@@ -48,15 +48,13 @@ enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN };
  * mostly copy/pasting/tweaking from mcslee's work.
  */
 class t_html_generator : public t_generator {
- public:
-  t_html_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_html_generator(t_program* program,
+                   const std::map<std::string, std::string>& parsed_options,
+                   const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-html";
     input_type_ = INPUT_UNKNOWN;
 
@@ -64,15 +62,14 @@ class t_html_generator : public t_generator {
     iter = parsed_options.find("standalone");
     standalone_ = (iter != parsed_options.end());
 
-	iter = parsed_options.find("noescape");
-	unsafe_ = (iter != parsed_options.end());
-
+    iter = parsed_options.find("noescape");
+    unsafe_ = (iter != parsed_options.end());
 
     escape_.clear();
-    escape_['&']  = "&amp;";
-    escape_['<']  = "&lt;";
-    escape_['>']  = "&gt;";
-    escape_['"']  = "&quot;";
+    escape_['&'] = "&amp;";
+    escape_['<'] = "&lt;";
+    escape_['>'] = "&gt;";
+    escape_['"'] = "&quot;";
     escape_['\''] = "&apos;";
 
     init_allowed__markup();
@@ -81,65 +78,62 @@ class t_html_generator : public t_generator {
   void generate_program();
   void generate_program_toc();
   void generate_program_toc_row(t_program* tprog);
-  void generate_program_toc_rows(t_program* tprog,
-         std::vector<t_program*>& finished);
+  void generate_program_toc_rows(t_program* tprog, std::vector<t_program*>& finished);
   void generate_index();
-  std::string escape_html(std::string const & str);
-  std::string escape_html_tags(std::string const & str);
+  std::string escape_html(std::string const& str);
+  std::string escape_html_tags(std::string const& str);
   void generate_css();
-  void generate_css_content(std::ofstream & f_target);
+  void generate_css_content(std::ofstream& f_target);
   void generate_style_tag();
-  std::string make_file_link( std::string name);
-  bool is_utf8_sequence(std::string const & str, size_t firstpos);
-  void detect_input_encoding(std::string const & str, size_t firstpos);
+  std::string make_file_link(std::string name);
+  bool is_utf8_sequence(std::string const& str, size_t firstpos);
+  void detect_input_encoding(std::string const& str, size_t firstpos);
   void init_allowed__markup();
 
   /**
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_const   (t_const*    tconst);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_service (t_service*  tservice);
-  void generate_xception(t_struct*   txception);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_service(t_service* tservice);
+  void generate_xception(t_struct* txception);
 
-  void print_doc        (t_doc* tdoc);
-  int  print_type       (t_type* ttype);
+  void print_doc(t_doc* tdoc);
+  int print_type(t_type* ttype);
   void print_const_value(t_type* type, t_const_value* tvalue);
   void print_fn_args_doc(t_function* tfunction);
 
- private:
+private:
   std::ofstream f_out_;
-  std::string  current_file_;
+  std::string current_file_;
   input_type input_type_;
   std::map<std::string, int> allowed_markup;
   bool standalone_;
   bool unsafe_;
 };
 
-
 /**
  * Emits the Table of Contents links at the top of the module's page
  */
 void t_html_generator::generate_program_toc() {
-  f_out_ << "<table class=\"table-bordered table-striped table-condensed\"><thead><th>Module</th><th>Services</th>"
-   << "<th>Data types</th><th>Constants</th></thead>" << endl;
+  f_out_ << "<table class=\"table-bordered table-striped "
+            "table-condensed\"><thead><th>Module</th><th>Services</th>"
+         << "<th>Data types</th><th>Constants</th></thead>" << endl;
   generate_program_toc_row(program_);
   f_out_ << "</table>" << endl;
 }
 
-
 /**
  * Recurses through from the provided program and generates a ToC row
  * for each discovered program exactly once by maintaining the list of
  * completed rows in 'finished'
  */
 void t_html_generator::generate_program_toc_rows(t_program* tprog,
-         std::vector<t_program*>& finished) {
-  for (vector<t_program*>::iterator iter = finished.begin();
-       iter != finished.end(); iter++) {
+                                                 std::vector<t_program*>& finished) {
+  for (vector<t_program*>::iterator iter = finished.begin(); iter != finished.end(); iter++) {
     if (tprog->get_path() == (*iter)->get_path()) {
       return;
     }
@@ -147,8 +141,7 @@ void t_html_generator::generate_program_toc_rows(t_program* tprog,
   finished.push_back(tprog);
   generate_program_toc_row(tprog);
   vector<t_program*> includes = tprog->get_includes();
-  for (vector<t_program*>::iterator iter = includes.begin();
-       iter != includes.end(); iter++) {
+  for (vector<t_program*>::iterator iter = includes.begin(); iter != includes.end(); iter++) {
     generate_program_toc_rows(*iter, finished);
   }
 }
@@ -165,26 +158,26 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) {
     for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
       string name = get_service_name(*sv_iter);
       f_out_ << "<a href=\"" << make_file_link(fname) << "#Svc_" << name << "\">" << name
-        << "</a><br/>" << endl;
+             << "</a><br/>" << endl;
       f_out_ << "<ul>" << endl;
-      map<string,string> fn_html;
+      map<string, string> fn_html;
       vector<t_function*> functions = (*sv_iter)->get_functions();
       vector<t_function*>::iterator fn_iter;
       for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) {
         string fn_name = (*fn_iter)->get_name();
-        string html = "<li><a href=\"" + make_file_link(fname) + "#Fn_" + name + "_" +
-          fn_name + "\">" + fn_name + "</a></li>";
-        fn_html.insert(pair<string,string>(fn_name, html));
+        string html = "<li><a href=\"" + make_file_link(fname) + "#Fn_" + name + "_" + fn_name
+                      + "\">" + fn_name + "</a></li>";
+        fn_html.insert(pair<string, string>(fn_name, html));
       }
-      for (map<string,string>::iterator html_iter = fn_html.begin();
-        html_iter != fn_html.end(); html_iter++) {
+      for (map<string, string>::iterator html_iter = fn_html.begin(); html_iter != fn_html.end();
+           html_iter++) {
         f_out_ << html_iter->second << endl;
       }
       f_out_ << "</ul>" << endl;
     }
   }
   f_out_ << "</td>" << endl << "<td>";
-  map<string,string> data_types;
+  map<string, string> data_types;
   if (!tprog->get_enums().empty()) {
     vector<t_enum*> enums = tprog->get_enums();
     vector<t_enum*>::iterator en_iter;
@@ -192,9 +185,8 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) {
       string name = (*en_iter)->get_name();
       // f_out_ << "<a href=\"" << make_file_link(fname) << "#Enum_" << name << "\">" << name
       // <<  "</a><br/>" << endl;
-      string html = "<a href=\"" + make_file_link(fname) + "#Enum_" + name + "\">" + name +
-        "</a>";
-      data_types.insert(pair<string,string>(name, html));
+      string html = "<a href=\"" + make_file_link(fname) + "#Enum_" + name + "\">" + name + "</a>";
+      data_types.insert(pair<string, string>(name, html));
     }
   }
   if (!tprog->get_typedefs().empty()) {
@@ -204,9 +196,9 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) {
       string name = (*td_iter)->get_symbolic();
       // f_out_ << "<a href=\"" << make_file_link(fname) << "#Typedef_" << name << "\">" << name
       // << "</a><br/>" << endl;
-      string html = "<a href=\"" + make_file_link(fname) + "#Typedef_" + name + "\">" + name +
-        "</a>";
-      data_types.insert(pair<string,string>(name, html));
+      string html = "<a href=\"" + make_file_link(fname) + "#Typedef_" + name + "\">" + name
+                    + "</a>";
+      data_types.insert(pair<string, string>(name, html));
     }
   }
   if (!tprog->get_objects().empty()) {
@@ -214,30 +206,30 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) {
     vector<t_struct*>::iterator o_iter;
     for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
       string name = (*o_iter)->get_name();
-      //f_out_ << "<a href=\"" << make_file_link(fname) << "#Struct_" << name << "\">" << name
+      // f_out_ << "<a href=\"" << make_file_link(fname) << "#Struct_" << name << "\">" << name
       //<< "</a><br/>" << endl;
-      string html = "<a href=\"" + make_file_link(fname) + "#Struct_" + name + "\">" + name +
-        "</a>";
-      data_types.insert(pair<string,string>(name, html));
+      string html = "<a href=\"" + make_file_link(fname) + "#Struct_" + name + "\">" + name
+                    + "</a>";
+      data_types.insert(pair<string, string>(name, html));
     }
   }
-  for (map<string,string>::iterator dt_iter = data_types.begin();
-       dt_iter != data_types.end(); dt_iter++) {
+  for (map<string, string>::iterator dt_iter = data_types.begin(); dt_iter != data_types.end();
+       dt_iter++) {
     f_out_ << dt_iter->second << "<br/>" << endl;
   }
   f_out_ << "</td>" << endl << "<td>";
   if (!tprog->get_consts().empty()) {
-    map<string,string> const_html;
+    map<string, string> const_html;
     vector<t_const*> consts = tprog->get_consts();
     vector<t_const*>::iterator con_iter;
     for (con_iter = consts.begin(); con_iter != consts.end(); ++con_iter) {
       string name = (*con_iter)->get_name();
-      string html ="<code><a href=\"" + make_file_link(fname) + "#Const_" + name +
-        "\">" + name + "</a></code>";
-      const_html.insert(pair<string,string>(name, html));
+      string html = "<code><a href=\"" + make_file_link(fname) + "#Const_" + name + "\">" + name
+                    + "</a></code>";
+      const_html.insert(pair<string, string>(name, html));
     }
-    for (map<string,string>::iterator con_iter = const_html.begin();
-   con_iter != const_html.end(); con_iter++) {
+    for (map<string, string>::iterator con_iter = const_html.begin(); con_iter != const_html.end();
+         con_iter++) {
       f_out_ << con_iter->second << "<br/>" << endl;
     }
   }
@@ -251,7 +243,7 @@ void t_html_generator::generate_program_toc_row(t_program* tprog) {
 void t_html_generator::generate_program() {
   // Make output directory
   MKDIR(get_out_dir().c_str());
-  current_file_ =  program_->get_name() + ".html";
+  current_file_ = program_->get_name() + ".html";
   string fname = get_out_dir() + current_file_;
   f_out_.open(fname.c_str());
   f_out_ << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" << endl;
@@ -260,11 +252,9 @@ void t_html_generator::generate_program() {
   f_out_ << "<head>" << endl;
   f_out_ << "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />" << endl;
   generate_style_tag();
-  f_out_ << "<title>Thrift module: " << program_->get_name()
-   << "</title></head><body>" << endl
-   << "<div class=\"container-fluid\">" << endl
-   << "<h1>Thrift module: "
-   << program_->get_name() << "</h1>" << endl;
+  f_out_ << "<title>Thrift module: " << program_->get_name() << "</title></head><body>" << endl
+         << "<div class=\"container-fluid\">" << endl
+         << "<h1>Thrift module: " << program_->get_name() << "</h1>" << endl;
 
   print_doc(program_);
 
@@ -331,7 +321,6 @@ void t_html_generator::generate_program() {
   generate_css();
 }
 
-
 /**
  * Emits the index.html file for the recursive set of Thrift programs
  */
@@ -341,11 +330,11 @@ void t_html_generator::generate_index() {
   f_out_.open(index_fname.c_str());
   f_out_ << "<html><head>" << endl;
   generate_style_tag();
-  f_out_ << "<title>All Thrift declarations</title></head><body>"
-   << endl << "<div class=\"container-fluid\">"
-   << endl << "<h1>All Thrift declarations</h1>" << endl;
-  f_out_ << "<table class=\"table-bordered table-striped table-condensed\"><thead><th>Module</th><th>Services</th><th>Data types</th>"
-   << "<th>Constants</th></thead>" << endl;
+  f_out_ << "<title>All Thrift declarations</title></head><body>" << endl
+         << "<div class=\"container-fluid\">" << endl << "<h1>All Thrift declarations</h1>" << endl;
+  f_out_ << "<table class=\"table-bordered table-striped "
+            "table-condensed\"><thead><th>Module</th><th>Services</th><th>Data types</th>"
+         << "<th>Constants</th></thead>" << endl;
   vector<t_program*> programs;
   generate_program_toc_rows(program_, programs);
   f_out_ << "</table>" << endl;
@@ -354,38 +343,40 @@ void t_html_generator::generate_index() {
 }
 
 void t_html_generator::generate_css() {
-  if( ! standalone_) {
+  if (!standalone_) {
     current_file_ = "style.css";
     string css_fname = get_out_dir() + current_file_;
     f_out_.open(css_fname.c_str());
-    generate_css_content( f_out_);
+    generate_css_content(f_out_);
     f_out_.close();
   }
 }
 
-
-void t_html_generator::generate_css_content(std::ofstream & f_target) {
+void t_html_generator::generate_css_content(std::ofstream& f_target) {
   f_target << BOOTSTRAP_CSS() << endl;
   f_target << "/* Auto-generated CSS for generated Thrift docs */" << endl;
   f_target << "h3, h4 { margin-bottom: 6px; }" << endl;
-  f_target << "div.definition { border: 1px solid #CCC; margin-bottom: 10px; padding: 10px; }" << endl;
+  f_target << "div.definition { border: 1px solid #CCC; margin-bottom: 10px; padding: 10px; }"
+           << endl;
   f_target << "div.extends { margin: -0.5em 0 1em 5em }" << endl;
   f_target << "td { vertical-align: top; }" << endl;
   f_target << "table { empty-cells: show; }" << endl;
   f_target << "code { line-height: 20px; }" << endl;
-  f_target << ".table-bordered th, .table-bordered td { border-bottom: 1px solid #DDDDDD; }" << endl;
+  f_target << ".table-bordered th, .table-bordered td { border-bottom: 1px solid #DDDDDD; }"
+           << endl;
 }
 
 /**
  * Generates the CSS tag.
- * Depending on "standalone", either a CSS file link (default), or the entire CSS is embedded inline.
+ * Depending on "standalone", either a CSS file link (default), or the entire CSS is embedded
+ * inline.
  */
 void t_html_generator::generate_style_tag() {
-  if( ! standalone_) {
+  if (!standalone_) {
     f_out_ << "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>" << endl;
   } else {
     f_out_ << "<style type=\"text/css\"/><!--" << endl;
-    generate_css_content( f_out_);
+    generate_css_content(f_out_);
     f_out_ << "--></style>" << endl;
   }
 }
@@ -394,8 +385,8 @@ void t_html_generator::generate_style_tag() {
  * Returns the target file for a <a href> link
  * The returned string is empty, whenever filename refers to the current file.
  */
-std::string t_html_generator::make_file_link( std::string filename) {
-  return (current_file_.compare(filename) != 0)  ?  filename  :  "";
+std::string t_html_generator::make_file_link(std::string filename) {
+  return (current_file_.compare(filename) != 0) ? filename : "";
 }
 
 /**
@@ -404,7 +395,7 @@ std::string t_html_generator::make_file_link( std::string filename) {
  */
 void t_html_generator::print_doc(t_doc* tdoc) {
   if (tdoc->has_doc()) {
-	if (unsafe_) {
+    if (unsafe_) {
       f_out_ << tdoc->get_doc() << "<br/>";
     } else {
       f_out_ << escape_html(tdoc->get_doc()) << "<br/>";
@@ -412,33 +403,32 @@ void t_html_generator::print_doc(t_doc* tdoc) {
   }
 }
 
-bool t_html_generator::is_utf8_sequence(std::string const & str, size_t firstpos) {
+bool t_html_generator::is_utf8_sequence(std::string const& str, size_t firstpos) {
   // leading char determines the length of the sequence
   unsigned char c = str.at(firstpos);
   int count = 0;
-  if(        (c & 0xE0) == 0xC0) {
+  if ((c & 0xE0) == 0xC0) {
     count = 1;
-  } else if( (c & 0xF0) == 0xE0) {
+  } else if ((c & 0xF0) == 0xE0) {
     count = 2;
-  } else if( (c & 0xF8) == 0xF0) {
+  } else if ((c & 0xF8) == 0xF0) {
     count = 3;
-  } else if( (c & 0xFC) == 0xF8) {
+  } else if ((c & 0xFC) == 0xF8) {
     count = 4;
-  } else if( (c & 0xFE) == 0xFC) {
+  } else if ((c & 0xFE) == 0xFC) {
     count = 5;
   } else {
-    //pdebug("UTF-8 test: char '%c' (%d) is not a valid UTF-8 leading byte", c, int(c));
-    return false;  // no UTF-8
+    // pdebug("UTF-8 test: char '%c' (%d) is not a valid UTF-8 leading byte", c, int(c));
+    return false; // no UTF-8
   }
 
   // following chars
   size_t pos = firstpos + 1;
-  while( (pos < str.length()) && (0 < count))
-  {
+  while ((pos < str.length()) && (0 < count)) {
     c = str.at(pos);
-    if( (c & 0xC0) !=  0x80) {
-      //pdebug("UTF-8 test: char '%c' (%d) is not a valid UTF-8 following byte", c, int(c));
-      return false;  // no UTF-8
+    if ((c & 0xC0) != 0x80) {
+      // pdebug("UTF-8 test: char '%c' (%d) is not a valid UTF-8 following byte", c, int(c));
+      return false; // no UTF-8
     }
     --count;
     ++pos;
@@ -448,16 +438,15 @@ bool t_html_generator::is_utf8_sequence(std::string const & str, size_t firstpos
   return (0 == count);
 }
 
-void t_html_generator::detect_input_encoding(std::string const & str, size_t firstpos) {
-  if( is_utf8_sequence(str,firstpos))
-  {
-    pdebug( "Input seems to be already UTF-8 encoded");
+void t_html_generator::detect_input_encoding(std::string const& str, size_t firstpos) {
+  if (is_utf8_sequence(str, firstpos)) {
+    pdebug("Input seems to be already UTF-8 encoded");
     input_type_ = INPUT_UTF8;
     return;
   }
 
   // fallback
-  pwarning( 1, "Input is not UTF-8, treating as plain ANSI");
+  pwarning(1, "Input is not UTF-8, treating as plain ANSI");
   input_type_ = INPUT_PLAIN;
 }
 
@@ -520,53 +509,53 @@ void t_html_generator::init_allowed__markup() {
   allowed_markup["/h6"] = 1;
 }
 
-std::string t_html_generator::escape_html_tags(std::string const & str) {
+std::string t_html_generator::escape_html_tags(std::string const& str) {
   std::ostringstream result;
 
   unsigned char c = '?';
   size_t lastpos;
   size_t firstpos = 0;
-  while( firstpos < str.length()) {
+  while (firstpos < str.length()) {
 
     // look for non-ASCII char
     lastpos = firstpos;
-    while( lastpos < str.length()) {
+    while (lastpos < str.length()) {
       c = str.at(lastpos);
-      if( ('<' == c) || ('>' == c)) {
+      if (('<' == c) || ('>' == c)) {
         break;
       }
       ++lastpos;
     }
 
     // copy what we got so far
-    if( lastpos > firstpos) {
-      result << str.substr( firstpos, lastpos-firstpos);
+    if (lastpos > firstpos) {
+      result << str.substr(firstpos, lastpos - firstpos);
       firstpos = lastpos;
     }
 
     // reached the end?
-    if( firstpos >= str.length()) {
+    if (firstpos >= str.length()) {
       break;
     }
 
     // tag end without corresponding begin
     ++firstpos;
-    if( '>' == c) {
+    if ('>' == c) {
       result << "&gt;";
       continue;
     }
 
     // extract the tag
     std::ostringstream tagstream;
-    while( firstpos < str.length()) {
+    while (firstpos < str.length()) {
       c = str.at(firstpos);
       ++firstpos;
-      if('<'==c) {
+      if ('<' == c) {
         tagstream << "&lt;"; // nested begin?
-      } else if('>'==c) {
+      } else if ('>' == c) {
         break;
       } else {
-        tagstream << c;  // not very efficient, but tags should be quite short
+        tagstream << c; // not very efficient, but tags should be quite short
       }
     }
 
@@ -574,13 +563,13 @@ std::string t_html_generator::escape_html_tags(std::string const & str) {
     string tag_content = tagstream.str();
     string tag_key = tag_content;
     size_t first_white = tag_key.find_first_of(" \t\f\v\n\r");
-    if( first_white != string::npos) {
+    if (first_white != string::npos) {
       tag_key.erase(first_white);
     }
-    for (std::string::size_type i=0; i<tag_key.length(); ++i) {
+    for (std::string::size_type i = 0; i < tag_key.length(); ++i) {
       tag_key[i] = tolower(tag_key[i]);
     }
-    if( allowed_markup.find(tag_key) != allowed_markup.end()) {
+    if (allowed_markup.find(tag_key) != allowed_markup.end()) {
       result << "<" << tag_content << ">";
     } else {
       result << "&lt;" << tagstream.str() << "&gt;";
@@ -591,10 +580,10 @@ std::string t_html_generator::escape_html_tags(std::string const & str) {
   return result.str();
 }
 
-std::string t_html_generator::escape_html(std::string const & str) {
+std::string t_html_generator::escape_html(std::string const& str) {
   // the generated HTML header says it is UTF-8 encoded
   // if UTF-8 input has been detected before, we don't need to change anything
-  if( input_type_ == INPUT_UTF8) {
+  if (input_type_ == INPUT_UTF8) {
     return escape_html_tags(str);
   }
 
@@ -604,70 +593,68 @@ std::string t_html_generator::escape_html(std::string const & str) {
   unsigned int ic = 0;
   size_t lastpos;
   size_t firstpos = 0;
-  while( firstpos < str.length()) {
+  while (firstpos < str.length()) {
 
     // look for non-ASCII char
     lastpos = firstpos;
-    while( lastpos < str.length()) {
+    while (lastpos < str.length()) {
       c = str.at(lastpos);
       ic = c;
-      if( (32 > ic) || (127 < ic)) {
+      if ((32 > ic) || (127 < ic)) {
         break;
       }
       ++lastpos;
     }
 
     // copy what we got so far
-    if( lastpos > firstpos) {
-      result << str.substr( firstpos, lastpos-firstpos);
+    if (lastpos > firstpos) {
+      result << str.substr(firstpos, lastpos - firstpos);
       firstpos = lastpos;
     }
 
     // reached the end?
-    if( firstpos >= str.length()) {
+    if (firstpos >= str.length()) {
       break;
     }
 
     // some control code?
-    if(ic <= 31)
-    {
-      switch( c)
-      {
-        case '\r' :
-        case '\n' :
-        case '\t' :
-          result << c;
-          break;
-        default: // silently consume all other ctrl chars
-          break;
+    if (ic <= 31) {
+      switch (c) {
+      case '\r':
+      case '\n':
+      case '\t':
+        result << c;
+        break;
+      default: // silently consume all other ctrl chars
+        break;
       }
       ++firstpos;
       continue;
     }
 
     // reached the end?
-    if( firstpos >= str.length()) {
+    if (firstpos >= str.length()) {
       break;
     }
 
     // try to detect input encoding
-    if( input_type_ == INPUT_UNKNOWN) {
-      detect_input_encoding(str,firstpos);
-      if( input_type_ == INPUT_UTF8) {
+    if (input_type_ == INPUT_UNKNOWN) {
+      detect_input_encoding(str, firstpos);
+      if (input_type_ == INPUT_UTF8) {
         lastpos = str.length();
-        result << str.substr( firstpos, lastpos-firstpos);
+        result << str.substr(firstpos, lastpos - firstpos);
         break;
       }
     }
 
     // convert the character to something useful based on the detected encoding
-    switch( input_type_) {
-      case INPUT_PLAIN:
-        result << "&#" << ic << ";";
-        ++firstpos;
-        break;
-      default:
-        throw "Unexpected or unrecognized input encoding";
+    switch (input_type_) {
+    case INPUT_PLAIN:
+      result << "&#" << ic << ";";
+      ++firstpos;
+      break;
+    default:
+      throw "Unexpected or unrecognized input encoding";
     }
   }
 
@@ -702,7 +689,7 @@ int t_html_generator::print_type(t_type* ttype) {
   } else {
     string prog_name = ttype->get_program()->get_name();
     string type_name = ttype->get_name();
-    f_out_ << "<a href=\"" << make_file_link(prog_name+".html") << "#";
+    f_out_ << "<a href=\"" << make_file_link(prog_name + ".html") << "#";
     if (ttype->is_typedef()) {
       f_out_ << "Typedef_";
     } else if (ttype->is_struct() || ttype->is_xception()) {
@@ -732,8 +719,9 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
   // if tvalue is an indentifier, the constant content is already shown elsewhere
   if (tvalue->get_type() == t_const_value::CV_IDENTIFIER) {
     string fname = program_->get_name() + ".html";
-    string name = escape_html( tvalue->get_identifier());
-    f_out_ << "<code><a href=\"" + make_file_link(fname) + "#Const_" + name +"\">" + name + "</a></code>";
+    string name = escape_html(tvalue->get_identifier());
+    f_out_ << "<code><a href=\"" + make_file_link(fname) + "#Const_" + name + "\">" + name
+              + "</a></code>";
     return;
   }
 
@@ -746,37 +734,38 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
   if (truetype->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)truetype)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        f_out_ << '"' << escape_html( get_escaped_string(tvalue)) << '"';
-        break;
-      case t_base_type::TYPE_BOOL:
-        f_out_ << ((tvalue->get_integer() != 0) ? "true" : "false");
-        break;
-      case t_base_type::TYPE_BYTE:
-        f_out_ << tvalue->get_integer();
-        break;
-      case t_base_type::TYPE_I16:
-        f_out_ << tvalue->get_integer();
-        break;
-      case t_base_type::TYPE_I32:
-        f_out_ << tvalue->get_integer();
-        break;
-      case t_base_type::TYPE_I64:
+    case t_base_type::TYPE_STRING:
+      f_out_ << '"' << escape_html(get_escaped_string(tvalue)) << '"';
+      break;
+    case t_base_type::TYPE_BOOL:
+      f_out_ << ((tvalue->get_integer() != 0) ? "true" : "false");
+      break;
+    case t_base_type::TYPE_BYTE:
+      f_out_ << tvalue->get_integer();
+      break;
+    case t_base_type::TYPE_I16:
+      f_out_ << tvalue->get_integer();
+      break;
+    case t_base_type::TYPE_I32:
+      f_out_ << tvalue->get_integer();
+      break;
+    case t_base_type::TYPE_I64:
+      f_out_ << tvalue->get_integer();
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (tvalue->get_type() == t_const_value::CV_INTEGER) {
         f_out_ << tvalue->get_integer();
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        if (tvalue->get_type() == t_const_value::CV_INTEGER) {
-          f_out_ << tvalue->get_integer();
-        } else {
-          f_out_ << tvalue->get_double();
-        }
-        break;
-      default:
-          f_out_ << "UNKNOWN BASE TYPE";
-          break;
+      } else {
+        f_out_ << tvalue->get_double();
+      }
+      break;
+    default:
+      f_out_ << "UNKNOWN BASE TYPE";
+      break;
     }
   } else if (truetype->is_enum()) {
-    f_out_ << escape_html(truetype->get_name()) << "." << escape_html(tvalue->get_identifier_name());
+    f_out_ << escape_html(truetype->get_name()) << "."
+           << escape_html(tvalue->get_identifier_name());
   } else if (truetype->is_struct() || truetype->is_xception()) {
     f_out_ << "{ ";
     const vector<t_field*>& fields = ((t_struct*)truetype)->get_members();
@@ -791,14 +780,15 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
         }
       }
       if (field_type == NULL) {
-        throw "type error: " + truetype->get_name() + " has no field " + v_iter->first->get_string();
+        throw "type error: " + truetype->get_name() + " has no field "
+            + v_iter->first->get_string();
       }
       if (!first) {
         f_out_ << ", ";
       }
       first = false;
-      f_out_ << escape_html( v_iter->first->get_string()) << " = ";
-      print_const_value( field_type, v_iter->second);
+      f_out_ << escape_html(v_iter->first->get_string()) << " = ";
+      print_const_value(field_type, v_iter->second);
     }
     f_out_ << " }";
   } else if (truetype->is_map()) {
@@ -810,33 +800,35 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
         f_out_ << ", ";
       }
       first = false;
-      print_const_value( ((t_map*)truetype)->get_key_type(), map_iter->first);
+      print_const_value(((t_map*)truetype)->get_key_type(), map_iter->first);
       f_out_ << " = ";
-      print_const_value( ((t_map*)truetype)->get_val_type(), map_iter->second);
+      print_const_value(((t_map*)truetype)->get_val_type(), map_iter->second);
     }
     f_out_ << " }";
   } else if (truetype->is_list()) {
     f_out_ << "{ ";
-    vector<t_const_value*> list_elems = tvalue->get_list();;
+    vector<t_const_value*> list_elems = tvalue->get_list();
+    ;
     vector<t_const_value*>::iterator list_iter;
     for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
       if (!first) {
         f_out_ << ", ";
       }
       first = false;
-      print_const_value( ((t_list*)truetype)->get_elem_type(), *list_iter);
+      print_const_value(((t_list*)truetype)->get_elem_type(), *list_iter);
     }
     f_out_ << " }";
   } else if (truetype->is_set()) {
     f_out_ << "{ ";
-    vector<t_const_value*> list_elems = tvalue->get_list();;
+    vector<t_const_value*> list_elems = tvalue->get_list();
+    ;
     vector<t_const_value*>::iterator list_iter;
     for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
       if (!first) {
         f_out_ << ", ";
       }
       first = false;
-      print_const_value( ((t_set*)truetype)->get_elem_type(), *list_iter);
+      print_const_value(((t_set*)truetype)->get_elem_type(), *list_iter);
     }
     f_out_ << " }";
   } else {
@@ -845,27 +837,28 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
 }
 
 /**
- * Prints out documentation for arguments/exceptions of a function, if any documentation has been supplied.
+ * Prints out documentation for arguments/exceptions of a function, if any documentation has been
+ * supplied.
  */
 void t_html_generator::print_fn_args_doc(t_function* tfunction) {
   bool has_docs = false;
   vector<t_field*> args = tfunction->get_arglist()->get_members();
   vector<t_field*>::iterator arg_iter = args.begin();
   if (arg_iter != args.end()) {
-    for ( ; arg_iter != args.end(); arg_iter++) {
+    for (; arg_iter != args.end(); arg_iter++) {
       if ((*arg_iter)->has_doc() && !(*arg_iter)->get_doc().empty())
         has_docs = true;
     }
     if (has_docs) {
       arg_iter = args.begin();
       f_out_ << "<br/><h4 id=\"Parameters_" << service_name_ << "_" << tfunction->get_name()
-        << "\">Parameters</h4>" << endl;
+             << "\">Parameters</h4>" << endl;
       f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
       f_out_ << "<thead><th>Name</th><th>Description</th></thead>";
-      for ( ; arg_iter != args.end(); arg_iter++) {
+      for (; arg_iter != args.end(); arg_iter++) {
         f_out_ << "<tr><td>" << (*arg_iter)->get_name();
         f_out_ << "</td><td>";
-        f_out_ << escape_html( (*arg_iter)->get_doc());
+        f_out_ << escape_html((*arg_iter)->get_doc());
         f_out_ << "</td></tr>" << endl;
       }
       f_out_ << "</table>";
@@ -876,20 +869,20 @@ void t_html_generator::print_fn_args_doc(t_function* tfunction) {
   vector<t_field*> excepts = tfunction->get_xceptions()->get_members();
   vector<t_field*>::iterator ex_iter = excepts.begin();
   if (ex_iter != excepts.end()) {
-    for ( ; ex_iter != excepts.end(); ex_iter++) {
+    for (; ex_iter != excepts.end(); ex_iter++) {
       if ((*ex_iter)->has_doc() && !(*ex_iter)->get_doc().empty())
         has_docs = true;
     }
     if (has_docs) {
       ex_iter = excepts.begin();
       f_out_ << "<br/><h4 id=\"Exceptions_" << service_name_ << "_" << tfunction->get_name()
-        << "\">Exceptions</h4>" << endl;
+             << "\">Exceptions</h4>" << endl;
       f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
       f_out_ << "<thead><th>Type</th><th>Description</th></thead>";
-      for ( ; ex_iter != excepts.end(); ex_iter++) {
+      for (; ex_iter != excepts.end(); ex_iter++) {
         f_out_ << "<tr><td>" << (*ex_iter)->get_type()->get_name();
         f_out_ << "</td><td>";
-        f_out_ << escape_html( (*ex_iter)->get_doc());
+        f_out_ << escape_html((*ex_iter)->get_doc());
         f_out_ << "</td></tr>" << endl;
       }
       f_out_ << "</table>";
@@ -905,8 +898,7 @@ void t_html_generator::print_fn_args_doc(t_function* tfunction) {
 void t_html_generator::generate_typedef(t_typedef* ttypedef) {
   string name = ttypedef->get_name();
   f_out_ << "<div class=\"definition\">";
-  f_out_ << "<h3 id=\"Typedef_" << name << "\">Typedef: " << name
-   << "</h3>" << endl;
+  f_out_ << "<h3 id=\"Typedef_" << name << "\">Typedef: " << name << "</h3>" << endl;
   f_out_ << "<p><strong>Base type:</strong>&nbsp;";
   print_type(ttypedef->get_type());
   f_out_ << "</p>" << endl;
@@ -922,8 +914,7 @@ void t_html_generator::generate_typedef(t_typedef* ttypedef) {
 void t_html_generator::generate_enum(t_enum* tenum) {
   string name = tenum->get_name();
   f_out_ << "<div class=\"definition\">";
-  f_out_ << "<h3 id=\"Enum_" << name << "\">Enumeration: " << name
-   << "</h3>" << endl;
+  f_out_ << "<h3 id=\"Enum_" << name << "\">Enumeration: " << name << "</h3>" << endl;
   print_doc(tenum);
   vector<t_enum_value*> values = tenum->get_constants();
   vector<t_enum_value*>::iterator val_iter;
@@ -945,8 +936,7 @@ void t_html_generator::generate_enum(t_enum* tenum) {
  */
 void t_html_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
-  f_out_ << "<tr id=\"Const_" << name << "\"><td><code>" << name
-   << "</code></td><td>";
+  f_out_ << "<tr id=\"Const_" << name << "\"><td><code>" << name << "</code></td><td>";
   print_type(tconst->get_type());
   f_out_ << "</td><td><code>";
   print_const_value(tconst->get_type(), tconst->get_value());
@@ -978,15 +968,15 @@ void t_html_generator::generate_struct(t_struct* tstruct) {
   vector<t_field*> members = tstruct->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
   f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
-  f_out_ << "<thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></thead>"
-    << endl;
-  for ( ; mem_iter != members.end(); mem_iter++) {
+  f_out_ << "<thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</"
+            "th><th>Default value</th></thead>" << endl;
+  for (; mem_iter != members.end(); mem_iter++) {
     f_out_ << "<tr><td>" << (*mem_iter)->get_key() << "</td><td>";
     f_out_ << (*mem_iter)->get_name();
     f_out_ << "</td><td>";
     print_type((*mem_iter)->get_type());
     f_out_ << "</td><td>";
-    f_out_ << escape_html( (*mem_iter)->get_doc());
+    f_out_ << escape_html((*mem_iter)->get_doc());
     f_out_ << "</td><td>";
     if ((*mem_iter)->get_req() == t_field::T_OPTIONAL) {
       f_out_ << "optional";
@@ -1024,8 +1014,7 @@ void t_html_generator::generate_xception(t_struct* txception) {
  * @param tservice The service definition
  */
 void t_html_generator::generate_service(t_service* tservice) {
-  f_out_ << "<h3 id=\"Svc_" << service_name_ << "\">Service: "
-    << service_name_ << "</h3>" << endl;
+  f_out_ << "<h3 id=\"Svc_" << service_name_ << "\">Service: " << service_name_ << "</h3>" << endl;
 
   if (tservice->get_extends()) {
     f_out_ << "<div class=\"extends\"><em>extends</em> ";
@@ -1035,12 +1024,11 @@ void t_html_generator::generate_service(t_service* tservice) {
   print_doc(tservice);
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator fn_iter = functions.begin();
-  for ( ; fn_iter != functions.end(); fn_iter++) {
+  for (; fn_iter != functions.end(); fn_iter++) {
     string fn_name = (*fn_iter)->get_name();
     f_out_ << "<div class=\"definition\">";
-    f_out_ << "<h4 id=\"Fn_" << service_name_ << "_" << fn_name
-      << "\">Function: " << service_name_ << "." << fn_name
-      << "</h4>" << endl;
+    f_out_ << "<h4 id=\"Fn_" << service_name_ << "_" << fn_name << "\">Function: " << service_name_
+           << "." << fn_name << "</h4>" << endl;
     f_out_ << "<pre>";
     int offset = print_type((*fn_iter)->get_returntype());
     bool first = true;
@@ -1048,7 +1036,7 @@ void t_html_generator::generate_service(t_service* tservice) {
     offset += fn_name.size() + 2;
     vector<t_field*> args = (*fn_iter)->get_arglist()->get_members();
     vector<t_field*>::iterator arg_iter = args.begin();
-    for ( ; arg_iter != args.end(); arg_iter++) {
+    for (; arg_iter != args.end(); arg_iter++) {
       if (!first) {
         f_out_ << "," << endl;
         for (int i = 0; i < offset; ++i) {
@@ -1069,7 +1057,7 @@ void t_html_generator::generate_service(t_service* tservice) {
     vector<t_field*>::iterator ex_iter = excepts.begin();
     if (ex_iter != excepts.end()) {
       f_out_ << "    throws ";
-      for ( ; ex_iter != excepts.end(); ex_iter++) {
+      for (; ex_iter != excepts.end(); ex_iter++) {
         if (!first) {
           f_out_ << ", ";
         }
@@ -1085,8 +1073,9 @@ void t_html_generator::generate_service(t_service* tservice) {
   }
 }
 
-THRIFT_REGISTER_GENERATOR(html, "HTML",
-"    standalone:      Self-contained mode, includes all CSS in the HTML files.\n"
-"                     Generates no style.css file, but HTML files will be larger.\n"
-"    noescape:        Do not escape html in doc text.\n"
-)
+THRIFT_REGISTER_GENERATOR(
+    html,
+    "HTML",
+    "    standalone:      Self-contained mode, includes all CSS in the HTML files.\n"
+    "                     Generates no style.css file, but HTML files will be larger.\n"
+    "    noescape:        Do not escape html in doc text.\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_html_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_html_generator.h b/compiler/cpp/src/generate/t_html_generator.h
index e40edd3..600b17f 100644
--- a/compiler/cpp/src/generate/t_html_generator.h
+++ b/compiler/cpp/src/generate/t_html_generator.h
@@ -1,176 +1,240 @@
-#define BOOTSTRAP_CSS() "/*!\n"\
-" * Bootstrap v2.0.3\n"\
-" *\n"\
-" * Copyright 2012 Twitter, Inc\n"\
-" * Licensed under the Apache License v2.0\n"\
-" * http://www.apache.org/licenses/LICENSE-2.0\n"\
-" *\n"\
-" * Designed and built with all the love in the world @twitter by @mdo and @fat.\n"\
-" */\n"\
-".clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:\"\";}\n"\
-".clearfix:after{clear:both;}\n"\
-".hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0;}\n"\
-".input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}\n"\
-"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block;}\n"\
-"audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}\n"\
-"audio:not([controls]){display:none;}\n"\
-"html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}\n"\
-"a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;}\n"\
-"a:hover,a:active{outline:0;}\n"\
-"sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline;}\n"\
-"sup{top:-0.5em;}\n"\
-"sub{bottom:-0.25em;}\n"\
-"img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic;}\n"\
-"button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle;}\n"\
-"button,input{*overflow:visible;line-height:normal;}\n"\
-"button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0;}\n"\
-"button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]{cursor:pointer;-webkit-appearance:button;}\n"\
-"input[type=\"search\"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield;}\n"\
-"input[type=\"search\"]::-webkit-search-decoration,input[type=\"search\"]::-webkit-search-cancel-button{-webkit-appearance:none;}\n"\
-"textarea{overflow:auto;vertical-align:top;}\n"\
-"body{margin:0;font-family:\"Helvetica Neue\",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333333;background-color:#ffffff;}\n"\
-"a{color:#0088cc;text-decoration:none;}\n"\
-"a:hover{color:#005580;text-decoration:underline;}\n"\
-".row{margin-left:-20px;*zoom:1;}.row:before,.row:after{display:table;content:\"\";}\n"\
-".row:after{clear:both;}\n"\
-"[class*=\"span\"]{float:left;margin-left:20px;}\n"\
-".container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px;}\n"\
-".span12{width:940px;}\n"\
-".span11{width:860px;}\n"\
-".span10{width:780px;}\n"\
-".span9{width:700px;}\n"\
-".span8{width:620px;}\n"\
-".span7{width:540px;}\n"\
-".span6{width:460px;}\n"\
-".span5{width:380px;}\n"\
-".span4{width:300px;}\n"\
-".span3{width:220px;}\n"\
-".span2{width:140px;}\n"\
-".span1{width:60px;}\n"\
-".offset12{margin-left:980px;}\n"\
-".offset11{margin-left:900px;}\n"\
-".offset10{margin-left:820px;}\n"\
-".offset9{margin-left:740px;}\n"\
-".offset8{margin-left:660px;}\n"\
-".offset7{margin-left:580px;}\n"\
-".offset6{margin-left:500px;}\n"\
-".offset5{margin-left:420px;}\n"\
-".offset4{margin-left:340px;}\n"\
-".offset3{margin-left:260px;}\n"\
-".offset2{margin-left:180px;}\n"\
-".offset1{margin-left:100px;}\n"\
-".row-fluid{width:100%;*zoom:1;}.row-fluid:before,.row-fluid:after{display:table;content:\"\";}\n"\
-".row-fluid:after{clear:both;}\n"\
-".row-fluid [class*=\"span\"]{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;float:left;margin-left:2.127659574%;*margin-left:2.0744680846382977%;}\n"\
-".row-fluid [class*=\"span\"]:first-child{margin-left:0;}\n"\
-".row-fluid .span12{width:99.99999998999999%;*width:99.94680850063828%;}\n"\
-".row-fluid .span11{width:91.489361693%;*width:91.4361702036383%;}\n"\
-".row-fluid .span10{width:82.97872339599999%;*width:82.92553190663828%;}\n"\
-".row-fluid .span9{width:74.468085099%;*width:74.4148936096383%;}\n"\
-".row-fluid .span8{width:65.95744680199999%;*width:65.90425531263828%;}\n"\
-".row-fluid .span7{width:57.446808505%;*width:57.3936170156383%;}\n"\
-".row-fluid .span6{width:48.93617020799999%;*width:48.88297871863829%;}\n"\
-".row-fluid .span5{width:40.425531911%;*width:40.3723404216383%;}\n"\
-".row-fluid .span4{width:31.914893614%;*width:31.8617021246383%;}\n"\
-".row-fluid .span3{width:23.404255317%;*width:23.3510638276383%;}\n"\
-".row-fluid .span2{width:14.89361702%;*width:14.8404255306383%;}\n"\
-".row-fluid .span1{width:6.382978723%;*width:6.329787233638298%;}\n"\
-".container{margin-right:auto;margin-left:auto;*zoom:1;}.container:before,.container:after{display:table;content:\"\";}\n"\
-".container:after{clear:both;}\n"\
-".container-fluid{padding-right:20px;padding-left:20px;*zoom:1;}.container-fluid:before,.container-fluid:after{display:table;content:\"\";}\n"\
-".container-fluid:after{clear:both;}\n"\
-"p{margin:0 0 9px;font-family:\"Helvetica Neue\",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;}p small{font-size:11px;color:#999999;}\n"\
-".lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px;}\n"\
-"h1,h2,h3,h4,h5,h6{margin:0;font-family:inherit;font-weight:bold;color:inherit;text-rendering:optimizelegibility;}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999999;}\n"\
-"h1{font-size:30px;line-height:36px;}h1 small{font-size:18px;}\n"\
-"h2{font-size:24px;line-height:36px;}h2 small{font-size:18px;}\n"\
-"h3{font-size:18px;line-height:27px;}h3 small{font-size:14px;}\n"\
-"h4,h5,h6{line-height:18px;}\n"\
-"h4{font-size:14px;}h4 small{font-size:12px;}\n"\
-"h5{font-size:12px;}\n"\
-"h6{font-size:11px;color:#999999;text-transform:uppercase;}\n"\
-".page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eeeeee;}\n"\
-".page-header h1{line-height:1;}\n"\
-"ul,ol{padding:0;margin:0 0 9px 25px;}\n"\
-"ul ul,ul ol,ol ol,ol ul{margin-bottom:0;}\n"\
-"ul{list-style:disc;}\n"\
-"ol{list-style:decimal;}\n"\
-"li{line-height:18px;}\n"\
-"ul.unstyled,ol.unstyled{margin-left:0;list-style:none;}\n"\
-"dl{margin-bottom:18px;}\n"\
-"dt,dd{line-height:18px;}\n"\
-"dt{font-weight:bold;line-height:17px;}\n"\
-"dd{margin-left:9px;}\n"\
-".dl-horizontal dt{float:left;width:120px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}\n"\
-".dl-horizontal dd{margin-left:130px;}\n"\
-"hr{margin:18px 0;border:0;border-top:1px solid #eeeeee;border-bottom:1px solid #ffffff;}\n"\
-"strong{font-weight:bold;}\n"\
-"em{font-style:italic;}\n"\
-".muted{color:#999999;}\n"\
-"abbr[title]{cursor:help;border-bottom:1px dotted #ddd;}\n"\
-"abbr.initialism{font-size:90%;text-transform:uppercase;}\n"\
-"blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eeeeee;}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px;}\n"\
-"blockquote small{display:block;line-height:18px;color:#999999;}blockquote small:before{content:'\\2014 \\00A0';}\n"\
-"blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eeeeee;border-left:0;}blockquote.pull-right p,blockquote.pull-right small{text-align:right;}\n"\
-"q:before,q:after,blockquote:before,blockquote:after{content:\"\";}\n"\
-"address{display:block;margin-bottom:18px;font-style:normal;line-height:18px;}\n"\
-"small{font-size:100%;}\n"\
-"cite{font-style:normal;}\n"\
-"code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,Consolas,\"Courier New\",monospace;font-size:12px;color:#333333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}\n"\
-"code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8;}\n"\
-"pre{display:block;padding:8.5px;margin:0 0 9px;font-size:12.025px;line-height:18px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0, 0, 0, 0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}pre.prettyprint{margin-bottom:18px;}\n"\
-"pre code{padding:0;color:inherit;background-color:transparent;border:0;}\n"\
-".pre-scrollable{max-height:340px;overflow-y:scroll;}\n"\
-".label,.badge{font-size:10.998px;font-weight:bold;line-height:14px;color:#ffffff;vertical-align:baseline;white-space:nowrap;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#999999;}\n"\
-".label{padding:1px 4px 2px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}\n"\
-".badge{padding:1px 9px 2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;}\n"\
-"a.label:hover,a.badge:hover{color:#ffffff;text-decoration:none;cursor:pointer;}\n"\
-".label-important,.badge-important{background-color:#b94a48;}\n"\
-".label-important[href],.badge-important[href]{background-color:#953b39;}\n"\
-".label-warning,.badge-warning{background-color:#f89406;}\n"\
-".label-warning[href],.badge-warning[href]{background-color:#c67605;}\n"\
-".label-success,.badge-success{background-color:#468847;}\n"\
-".label-success[href],.badge-success[href]{background-color:#356635;}\n"\
-".label-info,.badge-info{background-color:#3a87ad;}\n"\
-".label-info[href],.badge-info[href]{background-color:#2d6987;}\n"\
-".label-inverse,.badge-inverse{background-color:#333333;}\n"\
-".label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a;}\n"\
-"table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0;}\n"\
-".table{width:100%;margin-bottom:18px;}.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #dddddd;}\n"\
-".table th{font-weight:bold;}\n"\
-".table thead th{vertical-align:bottom;}\n"\
-".table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0;}\n"\
-".table tbody+tbody{border-top:2px solid #dddddd;}\n"\
-".table-condensed th,.table-condensed td{padding:4px 5px;}\n"\
-".table-bordered{border:1px solid #dddddd;border-collapse:separate;*border-collapse:collapsed;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}.table-bordered th,.table-bordered td{border-left:1px solid #dddddd;}\n"\
-".table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0;}\n"\
-".table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px;}\n"\
-".table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px;}\n"\
-".table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px;}\n"\
-".table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px;}\n"\
-".table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9;}\n"\
-".table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5;}\n"\
-"table .span1{float:none;width:44px;margin-left:0;}\n"\
-"table .span2{float:none;width:124px;margin-left:0;}\n"\
-"table .span3{float:none;width:204px;margin-left:0;}\n"\
-"table .span4{float:none;width:284px;margin-left:0;}\n"\
-"table .span5{float:none;width:364px;margin-left:0;}\n"\
-"table .span6{float:none;width:444px;margin-left:0;}\n"\
-"table .span7{float:none;width:524px;margin-left:0;}\n"\
-"table .span8{float:none;width:604px;margin-left:0;}\n"\
-"table .span9{float:none;width:684px;margin-left:0;}\n"\
-"table .span10{float:none;width:764px;margin-left:0;}\n"\
-"table .span11{float:none;width:844px;margin-left:0;}\n"\
-"table .span12{float:none;width:924px;margin-left:0;}\n"\
-"table .span13{float:none;width:1004px;margin-left:0;}\n"\
-"table .span14{float:none;width:1084px;margin-left:0;}\n"\
-"table .span15{float:none;width:1164px;margin-left:0;}\n"\
-"table .span16{float:none;width:1244px;margin-left:0;}\n"\
-"table .span17{float:none;width:1324px;margin-left:0;}\n"\
-"table .span18{float:none;width:1404px;margin-left:0;}\n"\
-"table .span19{float:none;width:1484px;margin-left:0;}\n"\
-"table .span20{float:none;width:1564px;margin-left:0;}\n"\
-"table .span21{float:none;width:1644px;margin-left:0;}\n"\
-"table .span22{float:none;width:1724px;margin-left:0;}\n"\
-"table .span23{float:none;width:1804px;margin-left:0;}\n"\
-"table .span24{float:none;width:1884px;margin-left:0;}"
+#define BOOTSTRAP_CSS()                                                                            \
+  "/*!\n"                                                                                          \
+  " * Bootstrap v2.0.3\n"                                                                          \
+  " *\n"                                                                                           \
+  " * Copyright 2012 Twitter, Inc\n"                                                               \
+  " * Licensed under the Apache License v2.0\n"                                                    \
+  " * http://www.apache.org/licenses/LICENSE-2.0\n"                                                \
+  " *\n"                                                                                           \
+  " * Designed and built with all the love in the world @twitter by @mdo and @fat.\n"              \
+  " */\n"                                                                                          \
+  ".clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:\"\";}\n"             \
+  ".clearfix:after{clear:both;}\n"                                                                 \
+  ".hide-text{font:0/0 "                                                                           \
+  "a;color:transparent;text-shadow:none;background-color:transparent;border:0;}\n"                 \
+  ".input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-"    \
+  "moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}\n"                  \
+  "article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block;}\n"     \
+  "audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}\n"                            \
+  "audio:not([controls]){display:none;}\n"                                                         \
+  "html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}\n"                \
+  "a:focus{outline:thin dotted #333;outline:5px auto "                                             \
+  "-webkit-focus-ring-color;outline-offset:-2px;}\n"                                               \
+  "a:hover,a:active{outline:0;}\n"                                                                 \
+  "sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline;}\n"              \
+  "sup{top:-0.5em;}\n"                                                                             \
+  "sub{bottom:-0.25em;}\n"                                                                         \
+  "img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic;}\n"           \
+  "button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle;}\n"                 \
+  "button,input{*overflow:visible;line-height:normal;}\n"                                          \
+  "button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0;}\n"                        \
+  "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]{cursor:pointer;-"    \
+  "webkit-appearance:button;}\n"                                                                   \
+  "input[type=\"search\"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:"  \
+  "content-box;-webkit-appearance:textfield;}\n"                                                   \
+  "input[type=\"search\"]::-webkit-search-decoration,input[type=\"search\"]::-webkit-search-"      \
+  "cancel-button{-webkit-appearance:none;}\n"                                                      \
+  "textarea{overflow:auto;vertical-align:top;}\n"                                                  \
+  "body{margin:0;font-family:\"Helvetica "                                                         \
+  "Neue\",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333333;background-"    \
+  "color:#ffffff;}\n"                                                                              \
+  "a{color:#0088cc;text-decoration:none;}\n"                                                       \
+  "a:hover{color:#005580;text-decoration:underline;}\n"                                            \
+  ".row{margin-left:-20px;*zoom:1;}.row:before,.row:after{display:table;content:\"\";}\n"          \
+  ".row:after{clear:both;}\n"                                                                      \
+  "[class*=\"span\"]{float:left;margin-left:20px;}\n"                                              \
+  ".container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px;}\n"        \
+  ".span12{width:940px;}\n"                                                                        \
+  ".span11{width:860px;}\n"                                                                        \
+  ".span10{width:780px;}\n"                                                                        \
+  ".span9{width:700px;}\n"                                                                         \
+  ".span8{width:620px;}\n"                                                                         \
+  ".span7{width:540px;}\n"                                                                         \
+  ".span6{width:460px;}\n"                                                                         \
+  ".span5{width:380px;}\n"                                                                         \
+  ".span4{width:300px;}\n"                                                                         \
+  ".span3{width:220px;}\n"                                                                         \
+  ".span2{width:140px;}\n"                                                                         \
+  ".span1{width:60px;}\n"                                                                          \
+  ".offset12{margin-left:980px;}\n"                                                                \
+  ".offset11{margin-left:900px;}\n"                                                                \
+  ".offset10{margin-left:820px;}\n"                                                                \
+  ".offset9{margin-left:740px;}\n"                                                                 \
+  ".offset8{margin-left:660px;}\n"                                                                 \
+  ".offset7{margin-left:580px;}\n"                                                                 \
+  ".offset6{margin-left:500px;}\n"                                                                 \
+  ".offset5{margin-left:420px;}\n"                                                                 \
+  ".offset4{margin-left:340px;}\n"                                                                 \
+  ".offset3{margin-left:260px;}\n"                                                                 \
+  ".offset2{margin-left:180px;}\n"                                                                 \
+  ".offset1{margin-left:100px;}\n"                                                                 \
+  ".row-fluid{width:100%;*zoom:1;}.row-fluid:before,.row-fluid:after{display:table;content:\"\";}" \
+  "\n"                                                                                             \
+  ".row-fluid:after{clear:both;}\n"                                                                \
+  ".row-fluid "                                                                                    \
+  "[class*=\"span\"]{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-" \
+  "box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;float:left;margin-left:"  \
+  "2.127659574%;*margin-left:2.0744680846382977%;}\n"                                              \
+  ".row-fluid [class*=\"span\"]:first-child{margin-left:0;}\n"                                     \
+  ".row-fluid .span12{width:99.99999998999999%;*width:99.94680850063828%;}\n"                      \
+  ".row-fluid .span11{width:91.489361693%;*width:91.4361702036383%;}\n"                            \
+  ".row-fluid .span10{width:82.97872339599999%;*width:82.92553190663828%;}\n"                      \
+  ".row-fluid .span9{width:74.468085099%;*width:74.4148936096383%;}\n"                             \
+  ".row-fluid .span8{width:65.95744680199999%;*width:65.90425531263828%;}\n"                       \
+  ".row-fluid .span7{width:57.446808505%;*width:57.3936170156383%;}\n"                             \
+  ".row-fluid .span6{width:48.93617020799999%;*width:48.88297871863829%;}\n"                       \
+  ".row-fluid .span5{width:40.425531911%;*width:40.3723404216383%;}\n"                             \
+  ".row-fluid .span4{width:31.914893614%;*width:31.8617021246383%;}\n"                             \
+  ".row-fluid .span3{width:23.404255317%;*width:23.3510638276383%;}\n"                             \
+  ".row-fluid .span2{width:14.89361702%;*width:14.8404255306383%;}\n"                              \
+  ".row-fluid .span1{width:6.382978723%;*width:6.329787233638298%;}\n"                             \
+  ".container{margin-right:auto;margin-left:auto;*zoom:1;}.container:before,.container:after{"     \
+  "display:table;content:\"\";}\n"                                                                 \
+  ".container:after{clear:both;}\n"                                                                \
+  ".container-fluid{padding-right:20px;padding-left:20px;*zoom:1;}.container-fluid:before,."       \
+  "container-fluid:after{display:table;content:\"\";}\n"                                           \
+  ".container-fluid:after{clear:both;}\n"                                                          \
+  "p{margin:0 0 9px;font-family:\"Helvetica "                                                      \
+  "Neue\",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;}p "                          \
+  "small{font-size:11px;color:#999999;}\n"                                                         \
+  ".lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px;}\n"                   \
+  "h1,h2,h3,h4,h5,h6{margin:0;font-family:inherit;font-weight:bold;color:inherit;text-rendering:"  \
+  "optimizelegibility;}h1 small,h2 small,h3 small,h4 small,h5 small,h6 "                           \
+  "small{font-weight:normal;color:#999999;}\n"                                                     \
+  "h1{font-size:30px;line-height:36px;}h1 small{font-size:18px;}\n"                                \
+  "h2{font-size:24px;line-height:36px;}h2 small{font-size:18px;}\n"                                \
+  "h3{font-size:18px;line-height:27px;}h3 small{font-size:14px;}\n"                                \
+  "h4,h5,h6{line-height:18px;}\n"                                                                  \
+  "h4{font-size:14px;}h4 small{font-size:12px;}\n"                                                 \
+  "h5{font-size:12px;}\n"                                                                          \
+  "h6{font-size:11px;color:#999999;text-transform:uppercase;}\n"                                   \
+  ".page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eeeeee;}\n"             \
+  ".page-header h1{line-height:1;}\n"                                                              \
+  "ul,ol{padding:0;margin:0 0 9px 25px;}\n"                                                        \
+  "ul ul,ul ol,ol ol,ol ul{margin-bottom:0;}\n"                                                    \
+  "ul{list-style:disc;}\n"                                                                         \
+  "ol{list-style:decimal;}\n"                                                                      \
+  "li{line-height:18px;}\n"                                                                        \
+  "ul.unstyled,ol.unstyled{margin-left:0;list-style:none;}\n"                                      \
+  "dl{margin-bottom:18px;}\n"                                                                      \
+  "dt,dd{line-height:18px;}\n"                                                                     \
+  "dt{font-weight:bold;line-height:17px;}\n"                                                       \
+  "dd{margin-left:9px;}\n"                                                                         \
+  ".dl-horizontal "                                                                                \
+  "dt{float:left;width:120px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;"  \
+  "white-space:nowrap;}\n"                                                                         \
+  ".dl-horizontal dd{margin-left:130px;}\n"                                                        \
+  "hr{margin:18px 0;border:0;border-top:1px solid #eeeeee;border-bottom:1px solid #ffffff;}\n"     \
+  "strong{font-weight:bold;}\n"                                                                    \
+  "em{font-style:italic;}\n"                                                                       \
+  ".muted{color:#999999;}\n"                                                                       \
+  "abbr[title]{cursor:help;border-bottom:1px dotted #ddd;}\n"                                      \
+  "abbr.initialism{font-size:90%;text-transform:uppercase;}\n"                                     \
+  "blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eeeeee;}blockquote "       \
+  "p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px;}\n"                        \
+  "blockquote small{display:block;line-height:18px;color:#999999;}blockquote "                     \
+  "small:before{content:'\\2014 \\00A0';}\n"                                                       \
+  "blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid "    \
+  "#eeeeee;border-left:0;}blockquote.pull-right p,blockquote.pull-right "                          \
+  "small{text-align:right;}\n"                                                                     \
+  "q:before,q:after,blockquote:before,blockquote:after{content:\"\";}\n"                           \
+  "address{display:block;margin-bottom:18px;font-style:normal;line-height:18px;}\n"                \
+  "small{font-size:100%;}\n"                                                                       \
+  "cite{font-style:normal;}\n"                                                                     \
+  "code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,Consolas,\"Courier "                        \
+  "New\",monospace;font-size:12px;color:#333333;-webkit-border-radius:3px;-moz-border-radius:3px;" \
+  "border-radius:3px;}\n"                                                                          \
+  "code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8;}\n"          \
+  "pre{display:block;padding:8.5px;margin:0 0 "                                                    \
+  "9px;font-size:12.025px;line-height:18px;word-break:break-all;word-wrap:break-word;white-space:" \
+  "pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid "      \
+  "rgba(0, 0, 0, "                                                                                 \
+  "0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}pre.prettyprint{"     \
+  "margin-bottom:18px;}\n"                                                                         \
+  "pre code{padding:0;color:inherit;background-color:transparent;border:0;}\n"                     \
+  ".pre-scrollable{max-height:340px;overflow-y:scroll;}\n"                                         \
+  ".label,.badge{font-size:10.998px;font-weight:bold;line-height:14px;color:#ffffff;vertical-"     \
+  "align:baseline;white-space:nowrap;text-shadow:0 -1px 0 rgba(0, 0, 0, "                          \
+  "0.25);background-color:#999999;}\n"                                                             \
+  ".label{padding:1px 4px "                                                                        \
+  "2px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}\n"                     \
+  ".badge{padding:1px 9px "                                                                        \
+  "2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;}\n"                     \
+  "a.label:hover,a.badge:hover{color:#ffffff;text-decoration:none;cursor:pointer;}\n"              \
+  ".label-important,.badge-important{background-color:#b94a48;}\n"                                 \
+  ".label-important[href],.badge-important[href]{background-color:#953b39;}\n"                     \
+  ".label-warning,.badge-warning{background-color:#f89406;}\n"                                     \
+  ".label-warning[href],.badge-warning[href]{background-color:#c67605;}\n"                         \
+  ".label-success,.badge-success{background-color:#468847;}\n"                                     \
+  ".label-success[href],.badge-success[href]{background-color:#356635;}\n"                         \
+  ".label-info,.badge-info{background-color:#3a87ad;}\n"                                           \
+  ".label-info[href],.badge-info[href]{background-color:#2d6987;}\n"                               \
+  ".label-inverse,.badge-inverse{background-color:#333333;}\n"                                     \
+  ".label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a;}\n"                         \
+  "table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0;}"  \
+  "\n"                                                                                             \
+  ".table{width:100%;margin-bottom:18px;}.table th,.table "                                        \
+  "td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid "       \
+  "#dddddd;}\n"                                                                                    \
+  ".table th{font-weight:bold;}\n"                                                                 \
+  ".table thead th{vertical-align:bottom;}\n"                                                      \
+  ".table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table "          \
+  "colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table "               \
+  "thead:first-child tr:first-child th,.table thead:first-child tr:first-child "                   \
+  "td{border-top:0;}\n"                                                                            \
+  ".table tbody+tbody{border-top:2px solid #dddddd;}\n"                                            \
+  ".table-condensed th,.table-condensed td{padding:4px 5px;}\n"                                    \
+  ".table-bordered{border:1px solid "                                                              \
+  "#dddddd;border-collapse:separate;*border-collapse:collapsed;border-left:0;-webkit-border-"      \
+  "radius:4px;-moz-border-radius:4px;border-radius:4px;}.table-bordered th,.table-bordered "       \
+  "td{border-left:1px solid #dddddd;}\n"                                                           \
+  ".table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child "  \
+  "th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead "             \
+  "tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered "            \
+  "colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child "             \
+  "th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child "      \
+  "tr:first-child td{border-top:0;}\n"                                                             \
+  ".table-bordered thead:first-child tr:first-child th:first-child,.table-bordered "               \
+  "tbody:first-child tr:first-child "                                                              \
+  "td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-"      \
+  "radius-topleft:4px;}\n"                                                                         \
+  ".table-bordered thead:first-child tr:first-child th:last-child,.table-bordered "                \
+  "tbody:first-child tr:first-child "                                                              \
+  "td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-"     \
+  "radius-topright:4px;}\n"                                                                        \
+  ".table-bordered thead:last-child tr:last-child th:first-child,.table-bordered "                 \
+  "tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 "                     \
+  "4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 "                                          \
+  "4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-"    \
+  "bottomleft:4px;}\n"                                                                             \
+  ".table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child " \
+  "tr:last-child "                                                                                 \
+  "td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-"      \
+  "border-radius-bottomright:4px;}\n"                                                              \
+  ".table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) "              \
+  "th{background-color:#f9f9f9;}\n"                                                                \
+  ".table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5;}\n"                 \
+  "table .span1{float:none;width:44px;margin-left:0;}\n"                                           \
+  "table .span2{float:none;width:124px;margin-left:0;}\n"                                          \
+  "table .span3{float:none;width:204px;margin-left:0;}\n"                                          \
+  "table .span4{float:none;width:284px;margin-left:0;}\n"                                          \
+  "table .span5{float:none;width:364px;margin-left:0;}\n"                                          \
+  "table .span6{float:none;width:444px;margin-left:0;}\n"                                          \
+  "table .span7{float:none;width:524px;margin-left:0;}\n"                                          \
+  "table .span8{float:none;width:604px;margin-left:0;}\n"                                          \
+  "table .span9{float:none;width:684px;margin-left:0;}\n"                                          \
+  "table .span10{float:none;width:764px;margin-left:0;}\n"                                         \
+  "table .span11{float:none;width:844px;margin-left:0;}\n"                                         \
+  "table .span12{float:none;width:924px;margin-left:0;}\n"                                         \
+  "table .span13{float:none;width:1004px;margin-left:0;}\n"                                        \
+  "table .span14{float:none;width:1084px;margin-left:0;}\n"                                        \
+  "table .span15{float:none;width:1164px;margin-left:0;}\n"                                        \
+  "table .span16{float:none;width:1244px;margin-left:0;}\n"                                        \
+  "table .span17{float:none;width:1324px;margin-left:0;}\n"                                        \
+  "table .span18{float:none;width:1404px;margin-left:0;}\n"                                        \
+  "table .span19{float:none;width:1484px;margin-left:0;}\n"                                        \
+  "table .span20{float:none;width:1564px;margin-left:0;}\n"                                        \
+  "table .span21{float:none;width:1644px;margin-left:0;}\n"                                        \
+  "table .span22{float:none;width:1724px;margin-left:0;}\n"                                        \
+  "table .span23{float:none;width:1804px;margin-left:0;}\n"                                        \
+  "table .span24{float:none;width:1884px;margin-left:0;}"


[09/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
index e068725..831c3a2 100644
--- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
@@ -22,7 +22,9 @@
 
 #include <thrift/protocol/TProtocol.h>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 using apache::thrift::transport::TTransport;
 
@@ -38,13 +40,11 @@ using apache::thrift::transport::TTransport;
  * instead.
  */
 class TProtocolDefaults : public TProtocol {
- public:
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid) {
-    (void) name;
-    (void) messageType;
-    (void) seqid;
+public:
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
+    (void)name;
+    (void)messageType;
+    (void)seqid;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -55,7 +55,7 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t readStructBegin(std::string& name) {
-    (void) name;
+    (void)name;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -65,12 +65,10 @@ class TProtocolDefaults : public TProtocol {
                              "this protocol does not support reading (yet).");
   }
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId) {
-    (void) name;
-    (void) fieldType;
-    (void) fieldId;
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
+    (void)name;
+    (void)fieldType;
+    (void)fieldId;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -81,9 +79,9 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
-    (void) keyType;
-    (void) valType;
-    (void) size;
+    (void)keyType;
+    (void)valType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -94,8 +92,8 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t readListBegin(TType& elemType, uint32_t& size) {
-    (void) elemType;
-    (void) size;
+    (void)elemType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -106,8 +104,8 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t readSetBegin(TType& elemType, uint32_t& size) {
-    (void) elemType;
-    (void) size;
+    (void)elemType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -118,55 +116,55 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t readBool(bool& value) {
-    (void) value;
+    (void)value;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readBool(std::vector<bool>::reference value) {
-    (void) value;
+    (void)value;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readByte(int8_t& byte) {
-    (void) byte;
+    (void)byte;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readI16(int16_t& i16) {
-    (void) i16;
+    (void)i16;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readI32(int32_t& i32) {
-    (void) i32;
+    (void)i32;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readI64(int64_t& i64) {
-    (void) i64;
+    (void)i64;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readDouble(double& dub) {
-    (void) dub;
+    (void)dub;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readString(std::string& str) {
-    (void) str;
+    (void)str;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
 
   uint32_t readBinary(std::string& str) {
-    (void) str;
+    (void)str;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support reading (yet).");
   }
@@ -174,9 +172,9 @@ class TProtocolDefaults : public TProtocol {
   uint32_t writeMessageBegin(const std::string& name,
                              const TMessageType messageType,
                              const int32_t seqid) {
-    (void) name;
-    (void) messageType;
-    (void) seqid;
+    (void)name;
+    (void)messageType;
+    (void)seqid;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -186,9 +184,8 @@ class TProtocolDefaults : public TProtocol {
                              "this protocol does not support writing (yet).");
   }
 
-
   uint32_t writeStructBegin(const char* name) {
-    (void) name;
+    (void)name;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -198,12 +195,10 @@ class TProtocolDefaults : public TProtocol {
                              "this protocol does not support writing (yet).");
   }
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId) {
-    (void) name;
-    (void) fieldType;
-    (void) fieldId;
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId) {
+    (void)name;
+    (void)fieldType;
+    (void)fieldId;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -218,12 +213,10 @@ class TProtocolDefaults : public TProtocol {
                              "this protocol does not support writing (yet).");
   }
 
-  uint32_t writeMapBegin(const TType keyType,
-                         const TType valType,
-                         const uint32_t size) {
-    (void) keyType;
-    (void) valType;
-    (void) size;
+  uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size) {
+    (void)keyType;
+    (void)valType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -234,8 +227,8 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t writeListBegin(const TType elemType, const uint32_t size) {
-    (void) elemType;
-    (void) size;
+    (void)elemType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -246,8 +239,8 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t writeSetBegin(const TType elemType, const uint32_t size) {
-    (void) elemType;
-    (void) size;
+    (void)elemType;
+    (void)size;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
@@ -258,70 +251,66 @@ class TProtocolDefaults : public TProtocol {
   }
 
   uint32_t writeBool(const bool value) {
-    (void) value;
+    (void)value;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeByte(const int8_t byte) {
-    (void) byte;
+    (void)byte;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeI16(const int16_t i16) {
-    (void) i16;
+    (void)i16;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeI32(const int32_t i32) {
-    (void) i32;
+    (void)i32;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeI64(const int64_t i64) {
-    (void) i64;
+    (void)i64;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeDouble(const double dub) {
-    (void) dub;
+    (void)dub;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeString(const std::string& str) {
-    (void) str;
+    (void)str;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
   uint32_t writeBinary(const std::string& str) {
-    (void) str;
+    (void)str;
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
                              "this protocol does not support writing (yet).");
   }
 
-  uint32_t skip(TType type) {
-    return ::apache::thrift::protocol::skip(*this, type);
-  }
+  uint32_t skip(TType type) { return ::apache::thrift::protocol::skip(*this, type); }
 
- protected:
-  TProtocolDefaults(boost::shared_ptr<TTransport> ptrans)
-    : TProtocol(ptrans)
-  {}
+protected:
+  TProtocolDefaults(boost::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {}
 };
 
 /**
  * Concrete TProtocol classes should inherit from TVirtualProtocol
  * so they don't have to manually override virtual methods.
  */
-template <class Protocol_, class Super_=TProtocolDefaults>
+template <class Protocol_, class Super_ = TProtocolDefaults>
 class TVirtualProtocol : public Super_ {
- public:
+public:
   /**
    * Writing functions.
    */
@@ -329,37 +318,28 @@ class TVirtualProtocol : public Super_ {
   virtual uint32_t writeMessageBegin_virt(const std::string& name,
                                           const TMessageType messageType,
                                           const int32_t seqid) {
-    return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType,
-                                                            seqid);
+    return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType, seqid);
   }
 
   virtual uint32_t writeMessageEnd_virt() {
     return static_cast<Protocol_*>(this)->writeMessageEnd();
   }
 
-
   virtual uint32_t writeStructBegin_virt(const char* name) {
     return static_cast<Protocol_*>(this)->writeStructBegin(name);
   }
 
-  virtual uint32_t writeStructEnd_virt() {
-    return static_cast<Protocol_*>(this)->writeStructEnd();
-  }
+  virtual uint32_t writeStructEnd_virt() { return static_cast<Protocol_*>(this)->writeStructEnd(); }
 
   virtual uint32_t writeFieldBegin_virt(const char* name,
                                         const TType fieldType,
                                         const int16_t fieldId) {
-    return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType,
-                                                          fieldId);
+    return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType, fieldId);
   }
 
-  virtual uint32_t writeFieldEnd_virt() {
-    return static_cast<Protocol_*>(this)->writeFieldEnd();
-  }
+  virtual uint32_t writeFieldEnd_virt() { return static_cast<Protocol_*>(this)->writeFieldEnd(); }
 
-  virtual uint32_t writeFieldStop_virt() {
-    return static_cast<Protocol_*>(this)->writeFieldStop();
-  }
+  virtual uint32_t writeFieldStop_virt() { return static_cast<Protocol_*>(this)->writeFieldStop(); }
 
   virtual uint32_t writeMapBegin_virt(const TType keyType,
                                       const TType valType,
@@ -367,27 +347,19 @@ class TVirtualProtocol : public Super_ {
     return static_cast<Protocol_*>(this)->writeMapBegin(keyType, valType, size);
   }
 
-  virtual uint32_t writeMapEnd_virt() {
-    return static_cast<Protocol_*>(this)->writeMapEnd();
-  }
+  virtual uint32_t writeMapEnd_virt() { return static_cast<Protocol_*>(this)->writeMapEnd(); }
 
-  virtual uint32_t writeListBegin_virt(const TType elemType,
-                                       const uint32_t size) {
+  virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
     return static_cast<Protocol_*>(this)->writeListBegin(elemType, size);
   }
 
-  virtual uint32_t writeListEnd_virt() {
-    return static_cast<Protocol_*>(this)->writeListEnd();
-  }
+  virtual uint32_t writeListEnd_virt() { return static_cast<Protocol_*>(this)->writeListEnd(); }
 
-  virtual uint32_t writeSetBegin_virt(const TType elemType,
-                                      const uint32_t size) {
+  virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
     return static_cast<Protocol_*>(this)->writeSetBegin(elemType, size);
   }
 
-  virtual uint32_t writeSetEnd_virt() {
-    return static_cast<Protocol_*>(this)->writeSetEnd();
-  }
+  virtual uint32_t writeSetEnd_virt() { return static_cast<Protocol_*>(this)->writeSetEnd(); }
 
   virtual uint32_t writeBool_virt(const bool value) {
     return static_cast<Protocol_*>(this)->writeBool(value);
@@ -428,60 +400,40 @@ class TVirtualProtocol : public Super_ {
   virtual uint32_t readMessageBegin_virt(std::string& name,
                                          TMessageType& messageType,
                                          int32_t& seqid) {
-    return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType,
-                                                           seqid);
+    return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType, seqid);
   }
 
-  virtual uint32_t readMessageEnd_virt() {
-    return static_cast<Protocol_*>(this)->readMessageEnd();
-  }
+  virtual uint32_t readMessageEnd_virt() { return static_cast<Protocol_*>(this)->readMessageEnd(); }
 
   virtual uint32_t readStructBegin_virt(std::string& name) {
     return static_cast<Protocol_*>(this)->readStructBegin(name);
   }
 
-  virtual uint32_t readStructEnd_virt() {
-    return static_cast<Protocol_*>(this)->readStructEnd();
-  }
+  virtual uint32_t readStructEnd_virt() { return static_cast<Protocol_*>(this)->readStructEnd(); }
 
-  virtual uint32_t readFieldBegin_virt(std::string& name,
-                                       TType& fieldType,
-                                       int16_t& fieldId) {
-    return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType,
-                                                         fieldId);
+  virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+    return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType, fieldId);
   }
 
-  virtual uint32_t readFieldEnd_virt() {
-    return static_cast<Protocol_*>(this)->readFieldEnd();
-  }
+  virtual uint32_t readFieldEnd_virt() { return static_cast<Protocol_*>(this)->readFieldEnd(); }
 
-  virtual uint32_t readMapBegin_virt(TType& keyType,
-                                     TType& valType,
-                                     uint32_t& size) {
+  virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
     return static_cast<Protocol_*>(this)->readMapBegin(keyType, valType, size);
   }
 
-  virtual uint32_t readMapEnd_virt() {
-    return static_cast<Protocol_*>(this)->readMapEnd();
-  }
+  virtual uint32_t readMapEnd_virt() { return static_cast<Protocol_*>(this)->readMapEnd(); }
 
-  virtual uint32_t readListBegin_virt(TType& elemType,
-                                      uint32_t& size) {
+  virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
     return static_cast<Protocol_*>(this)->readListBegin(elemType, size);
   }
 
-  virtual uint32_t readListEnd_virt() {
-    return static_cast<Protocol_*>(this)->readListEnd();
-  }
+  virtual uint32_t readListEnd_virt() { return static_cast<Protocol_*>(this)->readListEnd(); }
 
-  virtual uint32_t readSetBegin_virt(TType& elemType,
-                                     uint32_t& size) {
+  virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
     return static_cast<Protocol_*>(this)->readSetBegin(elemType, size);
   }
 
-  virtual uint32_t readSetEnd_virt() {
-    return static_cast<Protocol_*>(this)->readSetEnd();
-  }
+  virtual uint32_t readSetEnd_virt() { return static_cast<Protocol_*>(this)->readSetEnd(); }
 
   virtual uint32_t readBool_virt(bool& value) {
     return static_cast<Protocol_*>(this)->readBool(value);
@@ -519,9 +471,7 @@ class TVirtualProtocol : public Super_ {
     return static_cast<Protocol_*>(this)->readBinary(str);
   }
 
-  virtual uint32_t skip_virt(TType type) {
-    return static_cast<Protocol_*>(this)->skip(type);
-  }
+  virtual uint32_t skip_virt(TType type) { return static_cast<Protocol_*>(this)->skip(type); }
 
   /*
    * Provide a default skip() implementation that uses non-virtual read
@@ -553,12 +503,11 @@ class TVirtualProtocol : public Super_ {
   }
   using Super_::readBool; // so we don't hide readBool(bool&)
 
- protected:
-  TVirtualProtocol(boost::shared_ptr<TTransport> ptrans)
-    : Super_(ptrans)
-  {}
+protected:
+  TVirtualProtocol(boost::shared_ptr<TTransport> ptrans) : Super_(ptrans) {}
 };
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #endif // #define _THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
index 2c82847..686f242 100644
--- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
+++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
@@ -26,43 +26,37 @@
 
 using boost::shared_ptr;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
-TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev)
-  : dev_(dev)
-{
+TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev) : dev_(dev) {
 }
 
-TQIODeviceTransport::~TQIODeviceTransport()
-{
+TQIODeviceTransport::~TQIODeviceTransport() {
   dev_->close();
 }
 
-void TQIODeviceTransport::open()
-{
+void TQIODeviceTransport::open() {
   if (!isOpen()) {
     throw TTransportException(TTransportException::NOT_OPEN,
                               "open(): underlying QIODevice isn't open");
   }
 }
 
-bool TQIODeviceTransport::isOpen()
-{
+bool TQIODeviceTransport::isOpen() {
   return dev_->isOpen();
 }
 
-bool TQIODeviceTransport::peek()
-{
+bool TQIODeviceTransport::peek() {
   return dev_->bytesAvailable() > 0;
 }
 
-void TQIODeviceTransport::close()
-{
+void TQIODeviceTransport::close() {
   dev_->close();
 }
 
-uint32_t TQIODeviceTransport::readAll(uint8_t* buf, uint32_t len)
-{
+uint32_t TQIODeviceTransport::readAll(uint8_t* buf, uint32_t len) {
   uint32_t requestLen = len;
   while (len) {
     uint32_t readSize;
@@ -86,8 +80,7 @@ uint32_t TQIODeviceTransport::readAll(uint8_t* buf, uint32_t len)
   return requestLen;
 }
 
-uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len)
-{
+uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len) {
   uint32_t actualSize;
   qint64 readSize;
 
@@ -97,24 +90,22 @@ uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len)
   }
 
   actualSize = (uint32_t)std::min((qint64)len, dev_->bytesAvailable());
-  readSize = dev_->read(reinterpret_cast<char *>(buf), actualSize);
+  readSize = dev_->read(reinterpret_cast<char*>(buf), actualSize);
 
   if (readSize < 0) {
     QAbstractSocket* socket;
-    if ((socket = qobject_cast<QAbstractSocket* >(dev_.get()))) {
+    if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) {
       throw TTransportException(TTransportException::UNKNOWN,
                                 "Failed to read() from QAbstractSocket",
                                 socket->error());
     }
-    throw TTransportException(TTransportException::UNKNOWN,
-                              "Failed to read from from QIODevice");
+    throw TTransportException(TTransportException::UNKNOWN, "Failed to read from from QIODevice");
   }
 
   return (uint32_t)readSize;
 }
 
-void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len)
-{
+void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len) {
   while (len) {
     uint32_t written = write_partial(buf, len);
     len -= written;
@@ -122,8 +113,7 @@ void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len)
   }
 }
 
-uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len)
-{
+uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len) {
   qint64 written;
 
   if (!dev_->isOpen()) {
@@ -136,7 +126,8 @@ uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len)
     QAbstractSocket* socket;
     if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) {
       throw TTransportException(TTransportException::UNKNOWN,
-                                "write_partial(): failed to write to QAbstractSocket", socket->error());
+                                "write_partial(): failed to write to QAbstractSocket",
+                                socket->error());
     }
 
     throw TTransportException(TTransportException::UNKNOWN,
@@ -146,8 +137,7 @@ uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len)
   return (uint32_t)written;
 }
 
-void TQIODeviceTransport::flush()
-{
+void TQIODeviceTransport::flush() {
   if (!dev_->isOpen()) {
     throw TTransportException(TTransportException::NOT_OPEN,
                               "flush(): underlying QIODevice is not open");
@@ -162,18 +152,16 @@ void TQIODeviceTransport::flush()
   }
 }
 
-uint8_t* TQIODeviceTransport::borrow(uint8_t* buf, uint32_t* len)
-{
-  (void) buf;
-  (void) len;
+uint8_t* TQIODeviceTransport::borrow(uint8_t* buf, uint32_t* len) {
+  (void)buf;
+  (void)len;
   return NULL;
 }
 
-void TQIODeviceTransport::consume(uint32_t len)
-{
-  (void) len;
+void TQIODeviceTransport::consume(uint32_t len) {
+  (void)len;
   throw TTransportException(TTransportException::UNKNOWN);
 }
-
-}}} // apache::thrift::transport
-
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
index c5221dd..8091d32 100644
--- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
+++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
@@ -26,13 +26,16 @@
 
 class QIODevice;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  *  Transport that operates on a QIODevice (socket, file, etc).
  */
-class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> {
- public:
+class TQIODeviceTransport
+    : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> {
+public:
   explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev);
   virtual ~TQIODeviceTransport();
 
@@ -41,7 +44,7 @@ class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<
   bool peek();
   void close();
 
-  uint32_t readAll(uint8_t *buf, uint32_t len);
+  uint32_t readAll(uint8_t* buf, uint32_t len);
   uint32_t read(uint8_t* buf, uint32_t len);
 
   void write(const uint8_t* buf, uint32_t len);
@@ -52,13 +55,14 @@ class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<
   uint8_t* borrow(uint8_t* buf, uint32_t* len);
   void consume(uint32_t len);
 
- private:
-   TQIODeviceTransport(const TQIODeviceTransport&);
-   TQIODeviceTransport& operator=(const TQIODeviceTransport&);
+private:
+  TQIODeviceTransport(const TQIODeviceTransport&);
+  TQIODeviceTransport& operator=(const TQIODeviceTransport&);
 
-   boost::shared_ptr<QIODevice> dev_;
+  boost::shared_ptr<QIODevice> dev_;
 };
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/qt/TQTcpServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.cpp b/lib/cpp/src/thrift/qt/TQTcpServer.cpp
index 2b3cf98..a3211df 100644
--- a/lib/cpp/src/thrift/qt/TQTcpServer.cpp
+++ b/lib/cpp/src/thrift/qt/TQTcpServer.cpp
@@ -38,7 +38,9 @@ using apache::thrift::stdcxx::bind;
 
 QT_USE_NAMESPACE
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 struct TQTcpServer::ConnectionContext {
   shared_ptr<QTcpSocket> connection_;
@@ -50,31 +52,21 @@ struct TQTcpServer::ConnectionContext {
                              shared_ptr<TTransport> transport,
                              shared_ptr<TProtocol> iprot,
                              shared_ptr<TProtocol> oprot)
-    : connection_(connection)
-    , transport_(transport)
-    , iprot_(iprot)
-    , oprot_(oprot)
-  {}
+    : connection_(connection), transport_(transport), iprot_(iprot), oprot_(oprot) {}
 };
 
 TQTcpServer::TQTcpServer(shared_ptr<QTcpServer> server,
                          shared_ptr<TAsyncProcessor> processor,
                          shared_ptr<TProtocolFactory> pfact,
                          QObject* parent)
-  : QObject(parent)
-  , server_(server)
-  , processor_(processor)
-  , pfact_(pfact)
-{
+  : QObject(parent), server_(server), processor_(processor), pfact_(pfact) {
   connect(server.get(), SIGNAL(newConnection()), SLOT(processIncoming()));
 }
 
-TQTcpServer::~TQTcpServer()
-{
+TQTcpServer::~TQTcpServer() {
 }
 
-void TQTcpServer::processIncoming()
-{
+void TQTcpServer::processIncoming() {
   while (server_->hasPendingConnections()) {
     // take ownership of the QTcpSocket; technically it could be deleted
     // when the QTcpServer is destroyed, but any real app should delete this
@@ -89,25 +81,22 @@ void TQTcpServer::processIncoming()
       transport = shared_ptr<TTransport>(new TQIODeviceTransport(connection));
       iprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport));
       oprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport));
-    } catch(...) {
+    } catch (...) {
       qWarning("[TQTcpServer] Failed to initialize transports/protocols");
       continue;
     }
 
-    ctxMap_[connection.get()] =
-      shared_ptr<ConnectionContext>(
-         new ConnectionContext(connection, transport, iprot, oprot));
+    ctxMap_[connection.get()]
+        = shared_ptr<ConnectionContext>(new ConnectionContext(connection, transport, iprot, oprot));
 
     connect(connection.get(), SIGNAL(readyRead()), SLOT(beginDecode()));
 
     // need to use QueuedConnection since we will be deleting the socket in the slot
-    connect(connection.get(), SIGNAL(disconnected()), SLOT(socketClosed()),
-            Qt::QueuedConnection);
+    connect(connection.get(), SIGNAL(disconnected()), SLOT(socketClosed()), Qt::QueuedConnection);
   }
 }
 
-void TQTcpServer::beginDecode()
-{
+void TQTcpServer::beginDecode() {
   QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
   Q_ASSERT(connection);
 
@@ -119,22 +108,20 @@ void TQTcpServer::beginDecode()
   shared_ptr<ConnectionContext> ctx = ctxMap_[connection];
 
   try {
-    processor_->process(
-      bind(&TQTcpServer::finish, this,
-           ctx, apache::thrift::stdcxx::placeholders::_1),
-      ctx->iprot_, ctx->oprot_);
-  } catch(const TTransportException& ex) {
-    qWarning("[TQTcpServer] TTransportException during processing: '%s'",
-             ex.what());
+    processor_
+        ->process(bind(&TQTcpServer::finish, this, ctx, apache::thrift::stdcxx::placeholders::_1),
+                  ctx->iprot_,
+                  ctx->oprot_);
+  } catch (const TTransportException& ex) {
+    qWarning("[TQTcpServer] TTransportException during processing: '%s'", ex.what());
     ctxMap_.erase(connection);
-  } catch(...) {
+  } catch (...) {
     qWarning("[TQTcpServer] Unknown processor exception");
     ctxMap_.erase(connection);
   }
 }
 
-void TQTcpServer::socketClosed()
-{
+void TQTcpServer::socketClosed() {
   QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
   Q_ASSERT(connection);
 
@@ -146,12 +133,12 @@ void TQTcpServer::socketClosed()
   ctxMap_.erase(connection);
 }
 
-void TQTcpServer::finish(shared_ptr<ConnectionContext> ctx, bool healthy)
-{
+void TQTcpServer::finish(shared_ptr<ConnectionContext> ctx, bool healthy) {
   if (!healthy) {
     qWarning("[TQTcpServer] Processor failed to process data successfully");
     ctxMap_.erase(ctx->connection_.get());
   }
 }
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/qt/TQTcpServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.h b/lib/cpp/src/thrift/qt/TQTcpServer.h
index 2ef64a7..3403f1e 100644
--- a/lib/cpp/src/thrift/qt/TQTcpServer.h
+++ b/lib/cpp/src/thrift/qt/TQTcpServer.h
@@ -25,11 +25,17 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 class TProtocolFactory;
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 class TAsyncProcessor;
 
@@ -39,20 +45,20 @@ class TAsyncProcessor;
  *  processor and a protocol factory, and then run the Qt event loop.
  */
 class TQTcpServer : public QObject {
- Q_OBJECT
- public:
+  Q_OBJECT
+public:
   TQTcpServer(boost::shared_ptr<QTcpServer> server,
               boost::shared_ptr<TAsyncProcessor> processor,
               boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
               QT_PREPEND_NAMESPACE(QObject)* parent = NULL);
   virtual ~TQTcpServer();
 
- private Q_SLOTS:
+private Q_SLOTS:
   void processIncoming();
   void beginDecode();
   void socketClosed();
 
- private:
+private:
   TQTcpServer(const TQTcpServer&);
   TQTcpServer& operator=(const TQTcpServer&);
 
@@ -66,7 +72,8 @@ class TQTcpServer : public QObject {
 
   std::map<QT_PREPEND_NAMESPACE(QTcpSocket)*, boost::shared_ptr<ConnectionContext> > ctxMap_;
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_TASYNC_QTCP_SERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TNonblockingServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 86a96c6..1cfdef8 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -65,7 +65,9 @@
 #define PRIu64 "I64u"
 #endif
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using namespace apache::thrift::protocol;
 using namespace apache::thrift::transport;
@@ -76,11 +78,7 @@ using apache::thrift::transport::TTransportException;
 using boost::shared_ptr;
 
 /// Three states for sockets: recv frame size, recv data, and send mode
-enum TSocketState {
-  SOCKET_RECV_FRAMING,
-  SOCKET_RECV,
-  SOCKET_SEND
-};
+enum TSocketState { SOCKET_RECV_FRAMING, SOCKET_RECV, SOCKET_SEND };
 
 /**
  * Five states for the nonblocking server:
@@ -104,7 +102,7 @@ enum TAppState {
  * essentially encapsulates a socket that has some associated libevent state.
  */
 class TNonblockingServer::TConnection {
- private:
+private:
   /// Server IO Thread handling this connection
   TNonblockingIOThread* ioThread_;
 
@@ -176,22 +174,16 @@ class TNonblockingServer::TConnection {
   boost::shared_ptr<TServerEventHandler> serverEventHandler_;
 
   /// Thrift call context, if any
-  void *connectionContext_;
+  void* connectionContext_;
 
   /// Go into read mode
-  void setRead() {
-    setFlags(EV_READ | EV_PERSIST);
-  }
+  void setRead() { setFlags(EV_READ | EV_PERSIST); }
 
   /// Go into write mode
-  void setWrite() {
-    setFlags(EV_WRITE | EV_PERSIST);
-  }
+  void setWrite() { setFlags(EV_WRITE | EV_PERSIST); }
 
   /// Set socket idle
-  void setIdle() {
-    setFlags(0);
-  }
+  void setIdle() { setFlags(0); }
 
   /**
    * Set event flags for this connection.
@@ -208,13 +200,14 @@ class TNonblockingServer::TConnection {
    */
   void workSocket();
 
- public:
-
+public:
   class Task;
 
   /// Constructor
-  TConnection(THRIFT_SOCKET socket, TNonblockingIOThread* ioThread,
-              const sockaddr* addr, socklen_t addrLen) {
+  TConnection(THRIFT_SOCKET socket,
+              TNonblockingIOThread* ioThread,
+              const sockaddr* addr,
+              socklen_t addrLen) {
     readBuffer_ = NULL;
     readBufferSize_ = 0;
 
@@ -225,29 +218,29 @@ class TNonblockingServer::TConnection {
     // once per TConnection (they don't need to be reallocated on init() call)
     inputTransport_.reset(new TMemoryBuffer(readBuffer_, readBufferSize_));
     outputTransport_.reset(
-      new TMemoryBuffer(static_cast<uint32_t>(server_->getWriteBufferDefaultSize())));
+        new TMemoryBuffer(static_cast<uint32_t>(server_->getWriteBufferDefaultSize())));
     tSocket_.reset(new TSocket());
     init(socket, ioThread, addr, addrLen);
   }
 
-  ~TConnection() {
-    std::free(readBuffer_);
-  }
+  ~TConnection() { std::free(readBuffer_); }
 
   /// Close this connection and free or reset its resources.
   void close();
 
- /**
-   * Check buffers against any size limits and shrink it if exceeded.
-   *
-   * @param readLimit we reduce read buffer size to this (if nonzero).
-   * @param writeLimit if nonzero and write buffer is larger, replace it.
-   */
+  /**
+    * Check buffers against any size limits and shrink it if exceeded.
+    *
+    * @param readLimit we reduce read buffer size to this (if nonzero).
+    * @param writeLimit if nonzero and write buffer is larger, replace it.
+    */
   void checkIdleBufferMemLimit(size_t readLimit, size_t writeLimit);
 
   /// Initialize
-  void init(THRIFT_SOCKET socket, TNonblockingIOThread* ioThread,
-            const sockaddr* addr, socklen_t addrLen);
+  void init(THRIFT_SOCKET socket,
+            TNonblockingIOThread* ioThread,
+            const sockaddr* addr,
+            socklen_t addrLen);
 
   /**
    * This is called when the application transitions from one state into
@@ -278,17 +271,13 @@ class TNonblockingServer::TConnection {
    *
    * @return true if successful, false if unable to notify (check THRIFT_GET_SOCKET_ERROR).
    */
-  bool notifyIOThread() {
-    return ioThread_->notify(this);
-  }
+  bool notifyIOThread() { return ioThread_->notify(this); }
 
   /*
    * Returns the number of this connection's currently assigned IO
    * thread.
    */
-  int getIOThreadNumber() const {
-    return ioThread_->getThreadNumber();
-  }
+  int getIOThreadNumber() const { return ioThread_->getThreadNumber(); }
 
   /// Force connection shutdown for this connection.
   void forceClose() {
@@ -299,44 +288,33 @@ class TNonblockingServer::TConnection {
   }
 
   /// return the server this connection was initialized for.
-  TNonblockingServer* getServer() const {
-    return server_;
-  }
+  TNonblockingServer* getServer() const { return server_; }
 
   /// get state of connection.
-  TAppState getState() const {
-    return appState_;
-  }
+  TAppState getState() const { return appState_; }
 
   /// return the TSocket transport wrapping this network connection
-  boost::shared_ptr<TSocket> getTSocket() const {
-    return tSocket_;
-  }
+  boost::shared_ptr<TSocket> getTSocket() const { return tSocket_; }
 
   /// return the server event handler if any
-  boost::shared_ptr<TServerEventHandler> getServerEventHandler() {
-    return serverEventHandler_;
-  }
+  boost::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; }
 
   /// return the Thrift connection context if any
-  void* getConnectionContext() {
-    return connectionContext_;
-  }
-
+  void* getConnectionContext() { return connectionContext_; }
 };
 
-class TNonblockingServer::TConnection::Task: public Runnable {
- public:
+class TNonblockingServer::TConnection::Task : public Runnable {
+public:
   Task(boost::shared_ptr<TProcessor> processor,
        boost::shared_ptr<TProtocol> input,
        boost::shared_ptr<TProtocol> output,
-       TConnection* connection) :
-    processor_(processor),
-    input_(input),
-    output_(output),
-    connection_(connection),
-    serverEventHandler_(connection_->getServerEventHandler()),
-    connectionContext_(connection_->getConnectionContext()) {}
+       TConnection* connection)
+    : processor_(processor),
+      input_(input),
+      output_(output),
+      connection_(connection),
+      serverEventHandler_(connection_->getServerEventHandler()),
+      connectionContext_(connection_->getConnectionContext()) {}
 
   void run() {
     try {
@@ -344,8 +322,8 @@ class TNonblockingServer::TConnection::Task: public Runnable {
         if (serverEventHandler_) {
           serverEventHandler_->processContext(connectionContext_, connection_->getTSocket());
         }
-        if (!processor_->process(input_, output_, connectionContext_) ||
-            !input_->getTransport()->peek()) {
+        if (!processor_->process(input_, output_, connectionContext_)
+            || !input_->getTransport()->peek()) {
           break;
         }
       }
@@ -356,10 +334,10 @@ class TNonblockingServer::TConnection::Task: public Runnable {
       exit(1);
     } catch (const std::exception& x) {
       GlobalOutput.printf("TNonblockingServer: process() exception: %s: %s",
-                          typeid(x).name(), x.what());
+                          typeid(x).name(),
+                          x.what());
     } catch (...) {
-      GlobalOutput.printf(
-        "TNonblockingServer: unknown exception while processing.");
+      GlobalOutput.printf("TNonblockingServer: unknown exception while processing.");
     }
 
     // Signal completion back to the libevent thread via a pipe
@@ -368,11 +346,9 @@ class TNonblockingServer::TConnection::Task: public Runnable {
     }
   }
 
-  TConnection* getTConnection() {
-    return connection_;
-  }
+  TConnection* getTConnection() { return connection_; }
 
- private:
+private:
   boost::shared_ptr<TProcessor> processor_;
   boost::shared_ptr<TProtocol> input_;
   boost::shared_ptr<TProtocol> output_;
@@ -405,22 +381,17 @@ void TNonblockingServer::TConnection::init(THRIFT_SOCKET socket,
   callsForResize_ = 0;
 
   // get input/transports
-  factoryInputTransport_ = server_->getInputTransportFactory()->getTransport(
-                             inputTransport_);
-  factoryOutputTransport_ = server_->getOutputTransportFactory()->getTransport(
-                             outputTransport_);
+  factoryInputTransport_ = server_->getInputTransportFactory()->getTransport(inputTransport_);
+  factoryOutputTransport_ = server_->getOutputTransportFactory()->getTransport(outputTransport_);
 
   // Create protocol
-  inputProtocol_ = server_->getInputProtocolFactory()->getProtocol(
-                     factoryInputTransport_);
-  outputProtocol_ = server_->getOutputProtocolFactory()->getProtocol(
-                     factoryOutputTransport_);
+  inputProtocol_ = server_->getInputProtocolFactory()->getProtocol(factoryInputTransport_);
+  outputProtocol_ = server_->getOutputProtocolFactory()->getProtocol(factoryOutputTransport_);
 
   // Set up for any server event handler
   serverEventHandler_ = server_->getEventHandler();
   if (serverEventHandler_) {
-    connectionContext_ = serverEventHandler_->createContext(inputProtocol_,
-                                                            outputProtocol_);
+    connectionContext_ = serverEventHandler_->createContext(inputProtocol_, outputProtocol_);
   } else {
     connectionContext_ = NULL;
   }
@@ -430,7 +401,7 @@ void TNonblockingServer::TConnection::init(THRIFT_SOCKET socket,
 }
 
 void TNonblockingServer::TConnection::workSocket() {
-  int got=0, left=0, sent=0;
+  int got = 0, left = 0, sent = 0;
   uint32_t fetch = 0;
 
   switch (socketState_) {
@@ -470,12 +441,14 @@ void TNonblockingServer::TConnection::workSocket() {
     if (readWant_ > server_->getMaxFrameSize()) {
       // Don't allow giant frame sizes.  This prevents bad clients from
       // causing us to try and allocate a giant buffer.
-      GlobalOutput.printf("TNonblockingServer: frame size too large "
-                          "(%" PRIu32 " > %" PRIu64 ") from client %s. "
-                          "Remote side not using TFramedTransport?",
-                          readWant_,
-                          (uint64_t)server_->getMaxFrameSize(),
-                          tSocket_->getSocketInfo().c_str());
+      GlobalOutput.printf(
+          "TNonblockingServer: frame size too large "
+          "(%" PRIu32 " > %" PRIu64
+          ") from client %s. "
+          "Remote side not using TFramedTransport?",
+          readWant_,
+          (uint64_t)server_->getMaxFrameSize(),
+          tSocket_->getSocketInfo().c_str());
       close();
       return;
     }
@@ -491,8 +464,7 @@ void TNonblockingServer::TConnection::workSocket() {
       // Read from the socket
       fetch = readWant_ - readBufferPos_;
       got = tSocket_->read(readBuffer_ + readBufferPos_, fetch);
-    }
-    catch (TTransportException& te) {
+    } catch (TTransportException& te) {
       GlobalOutput.printf("TConnection::workSocket(): %s", te.what());
       close();
 
@@ -532,8 +504,7 @@ void TNonblockingServer::TConnection::workSocket() {
     try {
       left = writeBufferSize_ - writeBufferPos_;
       sent = tSocket_->write_partial(writeBuffer_ + writeBufferPos_, left);
-    }
-    catch (TTransportException& te) {
+    } catch (TTransportException& te) {
       GlobalOutput.printf("TConnection::workSocket(): %s ", te.what());
       close();
       return;
@@ -586,21 +557,18 @@ void TNonblockingServer::TConnection::transition() {
       // We are setting up a Task to do this work and we will wait on it
 
       // Create task and dispatch to the thread manager
-      boost::shared_ptr<Runnable> task =
-        boost::shared_ptr<Runnable>(new Task(processor_,
-                                             inputProtocol_,
-                                             outputProtocol_,
-                                             this));
+      boost::shared_ptr<Runnable> task = boost::shared_ptr<Runnable>(
+          new Task(processor_, inputProtocol_, outputProtocol_, this));
       // The application is now waiting on the task to finish
       appState_ = APP_WAIT_TASK;
 
-        try {
-          server_->addTask(task);
-        } catch (IllegalStateException & ise) {
-          // The ThreadManager is not ready to handle any more tasks (it's probably shutting down).
-          GlobalOutput.printf("IllegalStateException: Server::process() %s", ise.what());
-          close();
-        }
+      try {
+        server_->addTask(task);
+      } catch (IllegalStateException& ise) {
+        // The ThreadManager is not ready to handle any more tasks (it's probably shutting down).
+        GlobalOutput.printf("IllegalStateException: Server::process() %s", ise.what());
+        close();
+      }
 
       // Set this connection idle so that libevent doesn't process more
       // data on it while we're still waiting for the threadmanager to
@@ -610,21 +578,22 @@ void TNonblockingServer::TConnection::transition() {
     } else {
       try {
         if (serverEventHandler_) {
-          serverEventHandler_->processContext(connectionContext_,
-                                              getTSocket());
+          serverEventHandler_->processContext(connectionContext_, getTSocket());
         }
         // Invoke the processor
-        processor_->process(inputProtocol_, outputProtocol_,
-                            connectionContext_);
-      } catch (const TTransportException &ttx) {
-        GlobalOutput.printf("TNonblockingServer transport error in "
-                            "process(): %s", ttx.what());
+        processor_->process(inputProtocol_, outputProtocol_, connectionContext_);
+      } catch (const TTransportException& ttx) {
+        GlobalOutput.printf(
+            "TNonblockingServer transport error in "
+            "process(): %s",
+            ttx.what());
         server_->decrementActiveProcessors();
         close();
         return;
-      } catch (const std::exception &x) {
+      } catch (const std::exception& x) {
         GlobalOutput.printf("Server::process() uncaught exception: %s: %s",
-                            typeid(x).name(), x.what());
+                            typeid(x).name(),
+                            x.what());
         server_->decrementActiveProcessors();
         close();
         return;
@@ -636,8 +605,8 @@ void TNonblockingServer::TConnection::transition() {
       }
     }
 
-    // Intentionally fall through here, the call to process has written into
-    // the writeBuffer_
+  // Intentionally fall through here, the call to process has written into
+  // the writeBuffer_
 
   case APP_WAIT_TASK:
     // We have now finished processing a task and the result has been written
@@ -687,7 +656,7 @@ void TNonblockingServer::TConnection::transition() {
       callsForResize_ = 0;
     }
 
-    // N.B.: We also intentionally fall through here into the INIT state!
+  // N.B.: We also intentionally fall through here into the INIT state!
 
   LABEL_APP_INIT:
   case APP_INIT:
@@ -732,7 +701,7 @@ void TNonblockingServer::TConnection::transition() {
       readBufferSize_ = newSize;
     }
 
-    readBufferPos_= 0;
+    readBufferPos_ = 0;
 
     // Move into read request state
     socketState_ = SOCKET_RECV;
@@ -803,8 +772,7 @@ void TNonblockingServer::TConnection::setFlags(short eventFlags) {
    * ev structure for multiple monitored descriptors; each descriptor needs
    * its own ev.
    */
-  event_set(&event_, tSocket_->getSocketFD(), eventFlags_,
-            TConnection::eventHandler, this);
+  event_set(&event_, tSocket_->getSocketFD(), eventFlags_, TConnection::eventHandler, this);
   event_base_set(ioThread_->getEventBase(), &event_);
 
   // Add the event
@@ -841,9 +809,7 @@ void TNonblockingServer::TConnection::close() {
   server_->returnConnection(this);
 }
 
-void TNonblockingServer::TConnection::checkIdleBufferMemLimit(
-    size_t readLimit,
-    size_t writeLimit) {
+void TNonblockingServer::TConnection::checkIdleBufferMemLimit(size_t readLimit, size_t writeLimit) {
   if (readLimit > 0 && readBufferSize_ > readLimit) {
     free(readBuffer_);
     readBuffer_ = NULL;
@@ -860,7 +826,7 @@ void TNonblockingServer::TConnection::checkIdleBufferMemLimit(
 TNonblockingServer::~TNonblockingServer() {
   // Close any active connections (moves them to the idle connection stack)
   while (activeConnections_.size()) {
-	  activeConnections_.front()->close();
+    activeConnections_.front()->close();
   }
   // Clean up unused TConnection objects in connectionStack_
   while (!connectionStack_.empty()) {
@@ -872,9 +838,9 @@ TNonblockingServer::~TNonblockingServer() {
   // objects and the Thread objects have shared_ptrs to the TNonblockingIOThread
   // objects (as runnable) so these objects will never deallocate without help.
   while (!ioThreads_.empty()) {
-	  boost::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back();
-	  ioThreads_.pop_back();
-	  iot->setThread(boost::shared_ptr<Thread>());
+    boost::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back();
+    ioThreads_.pop_back();
+    iot->setThread(boost::shared_ptr<Thread>());
   }
 }
 
@@ -882,8 +848,9 @@ TNonblockingServer::~TNonblockingServer() {
  * Creates a new connection either by reusing an object off the stack or
  * by allocating a new one entirely
  */
-TNonblockingServer::TConnection* TNonblockingServer::createConnection(
-    THRIFT_SOCKET socket, const sockaddr* addr, socklen_t addrLen) {
+TNonblockingServer::TConnection* TNonblockingServer::createConnection(THRIFT_SOCKET socket,
+                                                                      const sockaddr* addr,
+                                                                      socklen_t addrLen) {
   // Check the stack
   Guard g(connMutex_);
 
@@ -914,10 +881,12 @@ TNonblockingServer::TConnection* TNonblockingServer::createConnection(
 void TNonblockingServer::returnConnection(TConnection* connection) {
   Guard g(connMutex_);
 
-  activeConnections_.erase(std::remove(activeConnections_.begin(), activeConnections_.end(), connection), activeConnections_.end());
+  activeConnections_.erase(std::remove(activeConnections_.begin(),
+                                       activeConnections_.end(),
+                                       connection),
+                           activeConnections_.end());
 
-  if (connectionStackLimit_ &&
-      (connectionStack_.size() >= connectionStackLimit_)) {
+  if (connectionStackLimit_ && (connectionStack_.size() >= connectionStackLimit_)) {
     delete connection;
     --numTConnections_;
   } else {
@@ -931,7 +900,7 @@ void TNonblockingServer::returnConnection(TConnection* connection) {
  * connections on fd and assign TConnection objects to handle those requests.
  */
 void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) {
-  (void) which;
+  (void)which;
   // Make sure that libevent didn't mess up the socket handles
   assert(fd == serverSocket_);
 
@@ -967,16 +936,16 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) {
 
     // Explicitly set this socket to NONBLOCK mode
     int flags;
-    if ((flags = THRIFT_FCNTL(clientSocket, THRIFT_F_GETFL, 0)) < 0 ||
-        THRIFT_FCNTL(clientSocket, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
-      GlobalOutput.perror("thriftServerEventHandler: set THRIFT_O_NONBLOCK (THRIFT_FCNTL) ", THRIFT_GET_SOCKET_ERROR);
+    if ((flags = THRIFT_FCNTL(clientSocket, THRIFT_F_GETFL, 0)) < 0
+        || THRIFT_FCNTL(clientSocket, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
+      GlobalOutput.perror("thriftServerEventHandler: set THRIFT_O_NONBLOCK (THRIFT_FCNTL) ",
+                          THRIFT_GET_SOCKET_ERROR);
       ::THRIFT_CLOSESOCKET(clientSocket);
       return;
     }
 
     // Create a new TConnection for this client socket.
-    TConnection* clientConnection =
-      createConnection(clientSocket, addrp, addrLen);
+    TConnection* clientConnection = createConnection(clientSocket, addrp, addrLen);
 
     // Fail fast if we could not create a TConnection object
     if (clientConnection == NULL) {
@@ -1007,7 +976,6 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) {
     addrLen = sizeof(addrStorage);
   }
 
-
   // Done looping accept, now we have to make sure the error is due to
   // blocking. Any other error is a problem
   if (THRIFT_GET_SOCKET_ERROR != THRIFT_EAGAIN && THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK) {
@@ -1034,8 +1002,8 @@ void TNonblockingServer::createAndListenOnSocket() {
   // Wildcard address
   error = getaddrinfo(NULL, port, &hints, &res0);
   if (error) {
-    throw TException("TNonblockingServer::serve() getaddrinfo " +
-                     string(THRIFT_GAI_STRERROR(error)));
+    throw TException("TNonblockingServer::serve() getaddrinfo "
+                     + string(THRIFT_GAI_STRERROR(error)));
   }
 
   // Pick the ipv6 address first since ipv4 addresses can be mapped
@@ -1052,15 +1020,14 @@ void TNonblockingServer::createAndListenOnSocket() {
     throw TException("TNonblockingServer::serve() socket() -1");
   }
 
-  #ifdef IPV6_V6ONLY
+#ifdef IPV6_V6ONLY
   if (res->ai_family == AF_INET6) {
     int zero = 0;
     if (-1 == setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, const_cast_sockopt(&zero), sizeof(zero))) {
       GlobalOutput("TServerSocket::listen() IPV6_V6ONLY");
     }
   }
-  #endif // #ifdef IPV6_V6ONLY
-
+#endif // #ifdef IPV6_V6ONLY
 
   int one = 1;
 
@@ -1089,8 +1056,8 @@ void TNonblockingServer::createAndListenOnSocket() {
 void TNonblockingServer::listenSocket(THRIFT_SOCKET s) {
   // Set socket to nonblocking mode
   int flags;
-  if ((flags = THRIFT_FCNTL(s, THRIFT_F_GETFL, 0)) < 0 ||
-      THRIFT_FCNTL(s, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
+  if ((flags = THRIFT_FCNTL(s, THRIFT_F_GETFL, 0)) < 0
+      || THRIFT_FCNTL(s, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
     ::THRIFT_CLOSESOCKET(s);
     throw TException("TNonblockingServer::serve() THRIFT_O_NONBLOCK");
   }
@@ -1104,17 +1071,17 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET s) {
   // Turn linger off to avoid hung sockets
   setsockopt(s, SOL_SOCKET, SO_LINGER, const_cast_sockopt(&ling), sizeof(ling));
 
-  // Set TCP nodelay if available, MAC OS X Hack
-  // See http://lists.danga.com/pipermail/memcached/2005-March/001240.html
-  #ifndef TCP_NOPUSH
+// Set TCP nodelay if available, MAC OS X Hack
+// See http://lists.danga.com/pipermail/memcached/2005-March/001240.html
+#ifndef TCP_NOPUSH
   setsockopt(s, IPPROTO_TCP, TCP_NODELAY, const_cast_sockopt(&one), sizeof(one));
-  #endif
+#endif
 
-  #ifdef TCP_LOW_MIN_RTO
+#ifdef TCP_LOW_MIN_RTO
   if (TSocket::getUseLowMinRto()) {
     setsockopt(s, IPPROTO_TCP, TCP_LOW_MIN_RTO, const_cast_sockopt(&one), sizeof(one));
   }
-  #endif
+#endif
 
   if (listen(s, LISTEN_BACKLOG) == -1) {
     ::THRIFT_CLOSESOCKET(s);
@@ -1128,28 +1095,31 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET s) {
 void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) {
   threadManager_ = threadManager;
   if (threadManager) {
-    threadManager->setExpireCallback(apache::thrift::stdcxx::bind(&TNonblockingServer::expireClose, this, apache::thrift::stdcxx::placeholders::_1));
+    threadManager->setExpireCallback(
+        apache::thrift::stdcxx::bind(&TNonblockingServer::expireClose,
+                                     this,
+                                     apache::thrift::stdcxx::placeholders::_1));
     threadPoolProcessing_ = true;
   } else {
     threadPoolProcessing_ = false;
   }
 }
 
-bool  TNonblockingServer::serverOverloaded() {
+bool TNonblockingServer::serverOverloaded() {
   size_t activeConnections = numTConnections_ - connectionStack_.size();
-  if (numActiveProcessors_ > maxActiveProcessors_ ||
-      activeConnections > maxConnections_) {
+  if (numActiveProcessors_ > maxActiveProcessors_ || activeConnections > maxConnections_) {
     if (!overloaded_) {
-       GlobalOutput.printf("TNonblockingServer: overload condition begun.");
+      GlobalOutput.printf("TNonblockingServer: overload condition begun.");
       overloaded_ = true;
     }
   } else {
-    if (overloaded_ &&
-        (numActiveProcessors_ <= overloadHysteresis_ * maxActiveProcessors_) &&
-        (activeConnections <= overloadHysteresis_ * maxConnections_)) {
-      GlobalOutput.printf("TNonblockingServer: overload ended; "
-                          "%u dropped (%llu total)",
-                          nConnectionsDropped_, nTotalConnectionsDropped_);
+    if (overloaded_ && (numActiveProcessors_ <= overloadHysteresis_ * maxActiveProcessors_)
+        && (activeConnections <= overloadHysteresis_ * maxConnections_)) {
+      GlobalOutput.printf(
+          "TNonblockingServer: overload ended; "
+          "%u dropped (%llu total)",
+          nConnectionsDropped_,
+          nTotalConnectionsDropped_);
       nConnectionsDropped_ = 0;
       overloaded_ = false;
     }
@@ -1162,10 +1132,8 @@ bool TNonblockingServer::drainPendingTask() {
   if (threadManager_) {
     boost::shared_ptr<Runnable> task = threadManager_->removeNextPending();
     if (task) {
-      TConnection* connection =
-        static_cast<TConnection::Task*>(task.get())->getTConnection();
-      assert(connection && connection->getServer()
-             && connection->getState() == APP_WAIT_TASK);
+      TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection();
+      assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK);
       connection->forceClose();
       return true;
     }
@@ -1174,10 +1142,8 @@ bool TNonblockingServer::drainPendingTask() {
 }
 
 void TNonblockingServer::expireClose(boost::shared_ptr<Runnable> task) {
-  TConnection* connection =
-    static_cast<TConnection::Task*>(task.get())->getTConnection();
-  assert(connection && connection->getServer() &&
-         connection->getState() == APP_WAIT_TASK);
+  TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection();
+  assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK);
   connection->forceClose();
 }
 
@@ -1206,7 +1172,7 @@ void TNonblockingServer::registerEvents(event_base* user_event_base) {
     THRIFT_SOCKET listenFd = (id == 0 ? serverSocket_ : THRIFT_INVALID_SOCKET);
 
     shared_ptr<TNonblockingIOThread> thread(
-      new TNonblockingIOThread(this, id, listenFd, useHighPriorityIOThreads_));
+        new TNonblockingIOThread(this, id, listenFd, useHighPriorityIOThreads_));
     ioThreads_.push_back(thread);
   }
 
@@ -1221,18 +1187,19 @@ void TNonblockingServer::registerEvents(event_base* user_event_base) {
   assert(ioThreads_.size() > 0);
 
   GlobalOutput.printf("TNonblockingServer: Serving on port %d, %d io threads.",
-               port_, ioThreads_.size());
+                      port_,
+                      ioThreads_.size());
 
   // Launch all the secondary IO threads in separate threads
   if (ioThreads_.size() > 1) {
     ioThreadFactory_.reset(new PlatformThreadFactory(
 #if !defined(USE_BOOST_THREAD) && !defined(USE_STD_THREAD)
-      PlatformThreadFactory::OTHER,  // scheduler
-      PlatformThreadFactory::NORMAL, // priority
-      1,                          // stack size (MB)
+        PlatformThreadFactory::OTHER,  // scheduler
+        PlatformThreadFactory::NORMAL, // priority
+        1,                             // stack size (MB)
 #endif
-      false                       // detached
-    ));
+        false // detached
+        ));
 
     assert(ioThreadFactory_.get());
 
@@ -1271,12 +1238,12 @@ TNonblockingIOThread::TNonblockingIOThread(TNonblockingServer* server,
                                            int number,
                                            THRIFT_SOCKET listenSocket,
                                            bool useHighPriority)
-      : server_(server)
-      , number_(number)
-      , listenSocket_(listenSocket)
-      , useHighPriority_(useHighPriority)
-      , eventBase_(NULL)
-      , ownEventBase_(false) {
+  : server_(server),
+    number_(number),
+    listenSocket_(listenSocket),
+    useHighPriority_(useHighPriority),
+    eventBase_(NULL),
+    ownEventBase_(false) {
   notificationPipeFDs_[0] = -1;
   notificationPipeFDs_[1] = -1;
 }
@@ -1292,8 +1259,7 @@ TNonblockingIOThread::~TNonblockingIOThread() {
 
   if (listenSocket_ >= 0) {
     if (0 != ::THRIFT_CLOSESOCKET(listenSocket_)) {
-      GlobalOutput.perror("TNonblockingIOThread listenSocket_ close(): ",
-                          THRIFT_GET_SOCKET_ERROR);
+      GlobalOutput.perror("TNonblockingIOThread listenSocket_ close(): ", THRIFT_GET_SOCKET_ERROR);
     }
     listenSocket_ = THRIFT_INVALID_SOCKET;
   }
@@ -1310,12 +1276,12 @@ TNonblockingIOThread::~TNonblockingIOThread() {
 }
 
 void TNonblockingIOThread::createNotificationPipe() {
-  if(evutil_socketpair(AF_LOCAL, SOCK_STREAM, 0, notificationPipeFDs_) == -1) {
+  if (evutil_socketpair(AF_LOCAL, SOCK_STREAM, 0, notificationPipeFDs_) == -1) {
     GlobalOutput.perror("TNonblockingServer::createNotificationPipe ", EVUTIL_SOCKET_ERROR());
     throw TException("can't create notification pipe");
   }
-  if(evutil_make_socket_nonblocking(notificationPipeFDs_[0])<0 ||
-     evutil_make_socket_nonblocking(notificationPipeFDs_[1])<0) {
+  if (evutil_make_socket_nonblocking(notificationPipeFDs_[0]) < 0
+      || evutil_make_socket_nonblocking(notificationPipeFDs_[1]) < 0) {
     ::THRIFT_CLOSESOCKET(notificationPipeFDs_[0]);
     ::THRIFT_CLOSESOCKET(notificationPipeFDs_[1]);
     throw TException("TNonblockingServer::createNotificationPipe() THRIFT_O_NONBLOCK");
@@ -1323,15 +1289,16 @@ void TNonblockingIOThread::createNotificationPipe() {
   for (int i = 0; i < 2; ++i) {
 #if LIBEVENT_VERSION_NUMBER < 0x02000000
     int flags;
-    if ((flags = THRIFT_FCNTL(notificationPipeFDs_[i], F_GETFD, 0)) < 0 ||
-        THRIFT_FCNTL(notificationPipeFDs_[i], F_SETFD, flags | FD_CLOEXEC) < 0) {
+    if ((flags = THRIFT_FCNTL(notificationPipeFDs_[i], F_GETFD, 0)) < 0
+        || THRIFT_FCNTL(notificationPipeFDs_[i], F_SETFD, flags | FD_CLOEXEC) < 0) {
 #else
     if (evutil_make_socket_closeonexec(notificationPipeFDs_[i]) < 0) {
 #endif
       ::THRIFT_CLOSESOCKET(notificationPipeFDs_[0]);
       ::THRIFT_CLOSESOCKET(notificationPipeFDs_[1]);
-      throw TException("TNonblockingServer::createNotificationPipe() "
-        "FD_CLOEXEC");
+      throw TException(
+          "TNonblockingServer::createNotificationPipe() "
+          "FD_CLOEXEC");
     }
   }
 }
@@ -1352,8 +1319,8 @@ void TNonblockingIOThread::registerEvents() {
   // Print some libevent stats
   if (number_ == 0) {
     GlobalOutput.printf("TNonblockingServer: using libevent %s method %s",
-            event_get_version(),
-            event_base_get_method(eventBase_));
+                        event_get_version(),
+                        event_base_get_method(eventBase_));
   }
 
   if (listenSocket_ >= 0) {
@@ -1367,11 +1334,11 @@ void TNonblockingIOThread::registerEvents() {
 
     // Add the event and start up the server
     if (-1 == event_add(&serverEvent_, 0)) {
-      throw TException("TNonblockingServer::serve(): "
-                       "event_add() failed on server listen event");
+      throw TException(
+          "TNonblockingServer::serve(): "
+          "event_add() failed on server listen event");
     }
-    GlobalOutput.printf("TNonblocking: IO thread #%d registered for listen.",
-                        number_);
+    GlobalOutput.printf("TNonblocking: IO thread #%d registered for listen.", number_);
   }
 
   createNotificationPipe();
@@ -1388,11 +1355,11 @@ void TNonblockingIOThread::registerEvents() {
 
   // Add the event and start up the server
   if (-1 == event_add(&notificationEvent_, 0)) {
-    throw TException("TNonblockingServer::serve(): "
-                     "event_add() failed on task-done notification event");
+    throw TException(
+        "TNonblockingServer::serve(): "
+        "event_add() failed on task-done notification event");
   }
-  GlobalOutput.printf("TNonblocking: IO thread #%d registered for notify.",
-                      number_);
+  GlobalOutput.printf("TNonblocking: IO thread #%d registered for notify.", number_);
 }
 
 bool TNonblockingIOThread::notify(TNonblockingServer::TConnection* conn) {
@@ -1411,7 +1378,7 @@ bool TNonblockingIOThread::notify(TNonblockingServer::TConnection* conn) {
 
 /* static */
 void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void* v) {
-  TNonblockingIOThread* ioThread = (TNonblockingIOThread*) v;
+  TNonblockingIOThread* ioThread = (TNonblockingIOThread*)v;
   assert(ioThread);
   (void)which;
 
@@ -1427,8 +1394,7 @@ void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void*
       connection->transition();
     } else if (nBytes > 0) {
       // throw away these bytes and hope that next time we get a solid read
-      GlobalOutput.printf("notifyHandler: Bad read of %d bytes, wanted %d",
-                          nBytes, kSize);
+      GlobalOutput.printf("notifyHandler: Bad read of %d bytes, wanted %d", nBytes, kSize);
       ioThread->breakLoop(true);
       return;
     } else if (nBytes == 0) {
@@ -1436,11 +1402,11 @@ void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void*
       // exit the loop
       break;
     } else { // nBytes < 0
-      if (THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK && THRIFT_GET_SOCKET_ERROR != THRIFT_EAGAIN) {
-          GlobalOutput.perror(
-            "TNonblocking: notifyHandler read() failed: ", THRIFT_GET_SOCKET_ERROR);
-          ioThread->breakLoop(true);
-          return;
+      if (THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK
+          && THRIFT_GET_SOCKET_ERROR != THRIFT_EAGAIN) {
+        GlobalOutput.perror("TNonblocking: notifyHandler read() failed: ", THRIFT_GET_SOCKET_ERROR);
+        ioThread->breakLoop(true);
+        return;
       }
       // exit the loop
       break;
@@ -1450,8 +1416,7 @@ void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void*
 
 void TNonblockingIOThread::breakLoop(bool error) {
   if (error) {
-    GlobalOutput.printf(
-      "TNonblockingServer: IO thread #%d exiting with error.", number_);
+    GlobalOutput.printf("TNonblockingServer: IO thread #%d exiting with error.", number_);
     // TODO: figure out something better to do here, but for now kill the
     // whole process.
     GlobalOutput.printf("TNonblockingServer: aborting process.");
@@ -1478,7 +1443,7 @@ void TNonblockingIOThread::setCurrentThreadHighPriority(bool value) {
 #ifdef HAVE_SCHED_H
   // Start out with a standard, low-priority setup for the sched params.
   struct sched_param sp;
-  bzero((void*) &sp, sizeof(sp));
+  bzero((void*)&sp, sizeof(sp));
   int policy = SCHED_OTHER;
 
   // If desired, set up high-priority sched params structure.
@@ -1487,16 +1452,14 @@ void TNonblockingIOThread::setCurrentThreadHighPriority(bool value) {
     policy = SCHED_FIFO;
     // The priority only compares us to other SCHED_FIFO threads, so we
     // just pick a random priority halfway between min & max.
-    const int priority = (sched_get_priority_max(policy) +
-                          sched_get_priority_min(policy)) / 2;
+    const int priority = (sched_get_priority_max(policy) + sched_get_priority_min(policy)) / 2;
 
     sp.sched_priority = priority;
   }
 
   // Actually set the sched params for the current thread.
   if (0 == pthread_setschedparam(pthread_self(), policy, &sp)) {
-    GlobalOutput.printf(
-      "TNonblocking: IO Thread #%d using high-priority scheduler!", number_);
+    GlobalOutput.printf("TNonblocking: IO Thread #%d using high-priority scheduler!", number_);
   } else {
     GlobalOutput.perror("TNonblocking: pthread_setschedparam(): ", THRIFT_GET_SOCKET_ERROR);
   }
@@ -1509,8 +1472,7 @@ void TNonblockingIOThread::run() {
   if (eventBase_ == NULL)
     registerEvents();
 
-  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...",
-                      number_);
+  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...", number_);
 
   if (useHighPriority_) {
     setCurrentThreadHighPriority(true);
@@ -1526,8 +1488,7 @@ void TNonblockingIOThread::run() {
   // cleans up our registered events
   cleanupEvents();
 
-  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!",
-    number_);
+  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!", number_);
 }
 
 void TNonblockingIOThread::cleanupEvents() {
@@ -1541,7 +1502,6 @@ void TNonblockingIOThread::cleanupEvents() {
   event_del(&notificationEvent_);
 }
 
-
 void TNonblockingIOThread::stop() {
   // This should cause the thread to fall out of its event loop ASAP.
   breakLoop(false);
@@ -1555,10 +1515,11 @@ void TNonblockingIOThread::join() {
       // Note that it is safe to both join() ourselves twice, as well as join
       // the current thread as the pthread implementation checks for deadlock.
       thread_->join();
-    } catch(...) {
+    } catch (...) {
       // swallow everything
     }
   }
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server


[12/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp
index c45a964..5f6dade 100644
--- a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp
+++ b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp
@@ -29,7 +29,9 @@
 #include <boost/weak_ptr.hpp>
 #include <boost/thread.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 using boost::shared_ptr;
 using boost::weak_ptr;
@@ -39,38 +41,29 @@ using boost::weak_ptr;
  *
  * @version $Id:$
  */
-class BoostThread: public Thread {
- public:
-
-  enum STATE {
-    uninitialized,
-    starting,
-    started,
-    stopping,
-    stopped
-  };
+class BoostThread : public Thread {
+public:
+  enum STATE { uninitialized, starting, started, stopping, stopped };
 
   static void* threadMain(void* arg);
 
- private:
+private:
   std::auto_ptr<boost::thread> thread_;
   STATE state_;
   weak_ptr<BoostThread> self_;
   bool detached_;
 
- public:
-
-  BoostThread(bool detached, shared_ptr<Runnable> runnable) :
-    state_(uninitialized),
-    detached_(detached) {
-      this->Thread::runnable(runnable);
-    }
+public:
+  BoostThread(bool detached, shared_ptr<Runnable> runnable)
+    : state_(uninitialized), detached_(detached) {
+    this->Thread::runnable(runnable);
+  }
 
   ~BoostThread() {
-    if(!detached_) {
+    if (!detached_) {
       try {
         join();
-      } catch(...) {
+      } catch (...) {
         // We're really hosed.
       }
     }
@@ -81,15 +74,16 @@ class BoostThread: public Thread {
       return;
     }
 
-  // Create reference
+    // Create reference
     shared_ptr<BoostThread>* selfRef = new shared_ptr<BoostThread>();
     *selfRef = self_.lock();
 
     state_ = starting;
 
-    thread_ = std::auto_ptr<boost::thread>(new boost::thread(boost::bind(threadMain, (void*)selfRef)));
+    thread_
+        = std::auto_ptr<boost::thread>(new boost::thread(boost::bind(threadMain, (void*)selfRef)));
 
-    if(detached_)
+    if (detached_)
       thread_->detach();
   }
 
@@ -99,9 +93,7 @@ class BoostThread: public Thread {
     }
   }
 
-  Thread::id_t getId() {
-    return thread_.get() ? thread_->get_id() : boost::thread::id();
-  }
+  Thread::id_t getId() { return thread_.get() ? thread_->get_id() : boost::thread::id(); }
 
   shared_ptr<Runnable> runnable() const { return Thread::runnable(); }
 
@@ -139,13 +131,11 @@ void* BoostThread::threadMain(void* arg) {
  */
 class BoostThreadFactory::Impl {
 
- private:
+private:
   bool detached_;
 
- public:
-
-  Impl(bool detached) :
-    detached_(detached) {}
+public:
+  Impl(bool detached) : detached_(detached) {}
 
   /**
    * Creates a new POSIX thread to run the runnable object
@@ -163,22 +153,30 @@ class BoostThreadFactory::Impl {
 
   void setDetached(bool value) { detached_ = value; }
 
-  Thread::id_t getCurrentThreadId() const {
-    return boost::this_thread::get_id();
-  }
+  Thread::id_t getCurrentThreadId() const { return boost::this_thread::get_id(); }
 };
 
-BoostThreadFactory::BoostThreadFactory(bool detached) :
-  impl_(new BoostThreadFactory::Impl(detached)) {}
-
-shared_ptr<Thread> BoostThreadFactory::newThread(shared_ptr<Runnable> runnable) const { return impl_->newThread(runnable); }
+BoostThreadFactory::BoostThreadFactory(bool detached)
+  : impl_(new BoostThreadFactory::Impl(detached)) {
+}
 
-bool BoostThreadFactory::isDetached() const { return impl_->isDetached(); }
+shared_ptr<Thread> BoostThreadFactory::newThread(shared_ptr<Runnable> runnable) const {
+  return impl_->newThread(runnable);
+}
 
-void BoostThreadFactory::setDetached(bool value) { impl_->setDetached(value); }
+bool BoostThreadFactory::isDetached() const {
+  return impl_->isDetached();
+}
 
-Thread::id_t BoostThreadFactory::getCurrentThreadId() const { return impl_->getCurrentThreadId(); }
+void BoostThreadFactory::setDetached(bool value) {
+  impl_->setDetached(value);
+}
 
-}}} // apache::thrift::concurrency
+Thread::id_t BoostThreadFactory::getCurrentThreadId() const {
+  return impl_->getCurrentThreadId();
+}
+}
+}
+} // apache::thrift::concurrency
 
 #endif // USE_BOOST_THREAD

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h
index 6a236d3..fc06e56 100644
--- a/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h
+++ b/lib/cpp/src/thrift/concurrency/BoostThreadFactory.h
@@ -24,7 +24,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * A thread factory to create posix threads
@@ -33,21 +35,21 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class BoostThreadFactory : public ThreadFactory {
 
- public:
-
+public:
   /**
    * Boost thread factory.  All threads created by a factory are reference-counted
    * via boost::shared_ptr and boost::weak_ptr.  The factory guarantees that threads and
    * the Runnable tasks they host will be properly cleaned up once the last strong reference
    * to both is given up.
    *
-   * Threads are created with the specified boost policy, priority, stack-size. A detachable thread is not
+   * Threads are created with the specified boost policy, priority, stack-size. A detachable thread
+   *is not
    * joinable.
    *
    * By default threads are not joinable.
    */
 
-  BoostThreadFactory(bool detached=true);
+  BoostThreadFactory(bool detached = true);
 
   // From ThreadFactory;
   boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
@@ -69,7 +71,8 @@ private:
   class Impl;
   boost::shared_ptr<Impl> impl_;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Exception.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Exception.h b/lib/cpp/src/thrift/concurrency/Exception.h
index c62f116..6438fda 100644
--- a/lib/cpp/src/thrift/concurrency/Exception.h
+++ b/lib/cpp/src/thrift/concurrency/Exception.h
@@ -23,7 +23,9 @@
 #include <exception>
 #include <thrift/Thrift.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 class NoSuchTaskException : public apache::thrift::TException {};
 
@@ -39,26 +41,24 @@ public:
 
 class TimedOutException : public apache::thrift::TException {
 public:
-  TimedOutException():TException("TimedOutException"){};
-  TimedOutException(const std::string& message ) :
-    TException(message) {}
+  TimedOutException() : TException("TimedOutException"){};
+  TimedOutException(const std::string& message) : TException(message) {}
 };
 
 class TooManyPendingTasksException : public apache::thrift::TException {
 public:
-  TooManyPendingTasksException():TException("TooManyPendingTasksException"){};
-  TooManyPendingTasksException(const std::string& message ) :
-    TException(message) {}
+  TooManyPendingTasksException() : TException("TooManyPendingTasksException"){};
+  TooManyPendingTasksException(const std::string& message) : TException(message) {}
 };
 
 class SystemResourceException : public apache::thrift::TException {
 public:
-    SystemResourceException() {}
+  SystemResourceException() {}
 
-    SystemResourceException(const std::string& message) :
-        TException(message) {}
+  SystemResourceException(const std::string& message) : TException(message) {}
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_EXCEPTION_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/FunctionRunner.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/FunctionRunner.h b/lib/cpp/src/thrift/concurrency/FunctionRunner.h
index e3b2bf3..b776794 100644
--- a/lib/cpp/src/thrift/concurrency/FunctionRunner.h
+++ b/lib/cpp/src/thrift/concurrency/FunctionRunner.h
@@ -23,7 +23,9 @@
 #include <thrift/cxxfunctional.h>
 #include <thrift/concurrency/Thread.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Convenient implementation of Runnable that will execute arbitrary callbacks.
@@ -47,9 +49,9 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 
 class FunctionRunner : public Runnable {
- public:
+public:
   // This is the type of callback 'pthread_create()' expects.
-  typedef void* (*PthreadFuncPtr)(void *arg);
+  typedef void* (*PthreadFuncPtr)(void* arg);
   // This a fully-generic void(void) callback for custom bindings.
   typedef apache::thrift::stdcxx::function<void()> VoidFunc;
 
@@ -63,32 +65,28 @@ class FunctionRunner : public Runnable {
     return boost::shared_ptr<FunctionRunner>(new FunctionRunner(cob));
   }
 
-  static boost::shared_ptr<FunctionRunner> create(PthreadFuncPtr func,
-                                                  void* arg) {
+  static boost::shared_ptr<FunctionRunner> create(PthreadFuncPtr func, void* arg) {
     return boost::shared_ptr<FunctionRunner>(new FunctionRunner(func, arg));
   }
 
 private:
-  static void pthread_func_wrapper(PthreadFuncPtr func, void *arg)
-  {
-    //discard return value
+  static void pthread_func_wrapper(PthreadFuncPtr func, void* arg) {
+    // discard return value
     func(arg);
   }
+
 public:
   /**
    * Given a 'pthread_create' style callback, this FunctionRunner will
    * execute the given callback.  Note that the 'void*' return value is ignored.
    */
   FunctionRunner(PthreadFuncPtr func, void* arg)
-   : func_(apache::thrift::stdcxx::bind(pthread_func_wrapper, func, arg))
-  { }
+    : func_(apache::thrift::stdcxx::bind(pthread_func_wrapper, func, arg)) {}
 
   /**
    * Given a generic callback, this FunctionRunner will execute it.
    */
-  FunctionRunner(const VoidFunc& cob)
-   : func_(cob)
-  { }
+  FunctionRunner(const VoidFunc& cob) : func_(cob) {}
 
   /**
    * Given a bool foo(...) type callback, FunctionRunner will execute
@@ -96,26 +94,25 @@ public:
    * until it returns false. Note that the actual interval between calls will
    * be intervalMs plus execution time of the callback.
    */
-  FunctionRunner(const BoolFunc& cob, int intervalMs)
-   : repFunc_(cob), intervalMs_(intervalMs)
-  { }
+  FunctionRunner(const BoolFunc& cob, int intervalMs) : repFunc_(cob), intervalMs_(intervalMs) {}
 
   void run() {
     if (repFunc_) {
-      while(repFunc_()) {
-        THRIFT_SLEEP_USEC(intervalMs_*1000);
+      while (repFunc_()) {
+        THRIFT_SLEEP_USEC(intervalMs_ * 1000);
       }
     } else {
       func_();
     }
   }
 
- private:
+private:
   VoidFunc func_;
   BoolFunc repFunc_;
   int intervalMs_;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Monitor.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Monitor.cpp b/lib/cpp/src/thrift/concurrency/Monitor.cpp
index d94b2a4..5e713c0 100644
--- a/lib/cpp/src/thrift/concurrency/Monitor.cpp
+++ b/lib/cpp/src/thrift/concurrency/Monitor.cpp
@@ -30,7 +30,9 @@
 
 #include <pthread.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 using boost::scoped_ptr;
 
@@ -41,26 +43,14 @@ using boost::scoped_ptr;
  */
 class Monitor::Impl {
 
- public:
-
-  Impl()
-     : ownedMutex_(new Mutex()),
-       mutex_(NULL),
-       condInitialized_(false) {
+public:
+  Impl() : ownedMutex_(new Mutex()), mutex_(NULL), condInitialized_(false) {
     init(ownedMutex_.get());
   }
 
-  Impl(Mutex* mutex)
-     : mutex_(NULL),
-       condInitialized_(false) {
-    init(mutex);
-  }
+  Impl(Mutex* mutex) : mutex_(NULL), condInitialized_(false) { init(mutex); }
 
-  Impl(Monitor* monitor)
-     : mutex_(NULL),
-       condInitialized_(false) {
-    init(&(monitor->mutex()));
-  }
+  Impl(Monitor* monitor) : mutex_(NULL), condInitialized_(false) { init(&(monitor->mutex())); }
 
   ~Impl() { cleanup(); }
 
@@ -80,11 +70,10 @@ class Monitor::Impl {
     if (result == THRIFT_ETIMEDOUT) {
       // pthread_cond_timedwait has been observed to return early on
       // various platforms, so comment out this assert.
-      //assert(Util::currentTime() >= (now + timeout));
+      // assert(Util::currentTime() >= (now + timeout));
       throw TimedOutException();
     } else if (result != 0) {
-      throw TException(
-        "pthread_cond_wait() or pthread_cond_timedwait() failed");
+      throw TException("pthread_cond_wait() or pthread_cond_timedwait() failed");
     }
   }
 
@@ -110,19 +99,16 @@ class Monitor::Impl {
    */
   int waitForTime(const THRIFT_TIMESPEC* abstime) const {
     assert(mutex_);
-    pthread_mutex_t* mutexImpl =
-      reinterpret_cast<pthread_mutex_t*>(mutex_->getUnderlyingImpl());
+    pthread_mutex_t* mutexImpl = reinterpret_cast<pthread_mutex_t*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
     // XXX Need to assert that caller owns mutex
-    return pthread_cond_timedwait(&pthread_cond_,
-                                  mutexImpl,
-                                  abstime);
+    return pthread_cond_timedwait(&pthread_cond_, mutexImpl, abstime);
   }
 
   int waitForTime(const struct timeval* abstime) const {
     struct THRIFT_TIMESPEC temp;
-    temp.tv_sec  = abstime->tv_sec;
+    temp.tv_sec = abstime->tv_sec;
     temp.tv_nsec = abstime->tv_usec * 1000;
     return waitForTime(&temp);
   }
@@ -132,13 +118,11 @@ class Monitor::Impl {
    */
   int waitForever() const {
     assert(mutex_);
-    pthread_mutex_t* mutexImpl =
-      reinterpret_cast<pthread_mutex_t*>(mutex_->getUnderlyingImpl());
+    pthread_mutex_t* mutexImpl = reinterpret_cast<pthread_mutex_t*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
     return pthread_cond_wait(&pthread_cond_, mutexImpl);
   }
 
-
   void notify() {
     // XXX Need to assert that caller owns mutex
     int iret = pthread_cond_signal(&pthread_cond_);
@@ -153,8 +137,7 @@ class Monitor::Impl {
     assert(iret == 0);
   }
 
- private:
-
+private:
   void init(Mutex* mutex) {
     mutex_ = mutex;
 
@@ -184,19 +167,32 @@ class Monitor::Impl {
   mutable bool condInitialized_;
 };
 
-Monitor::Monitor() : impl_(new Monitor::Impl()) {}
-Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {}
-Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {}
+Monitor::Monitor() : impl_(new Monitor::Impl()) {
+}
+Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {
+}
+Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {
+}
 
-Monitor::~Monitor() { delete impl_; }
+Monitor::~Monitor() {
+  delete impl_;
+}
 
-Mutex& Monitor::mutex() const { return impl_->mutex(); }
+Mutex& Monitor::mutex() const {
+  return impl_->mutex();
+}
 
-void Monitor::lock() const { impl_->lock(); }
+void Monitor::lock() const {
+  impl_->lock();
+}
 
-void Monitor::unlock() const { impl_->unlock(); }
+void Monitor::unlock() const {
+  impl_->unlock();
+}
 
-void Monitor::wait(int64_t timeout) const { impl_->wait(timeout); }
+void Monitor::wait(int64_t timeout) const {
+  impl_->wait(timeout);
+}
 
 int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const {
   return impl_->waitForTime(abstime);
@@ -214,8 +210,13 @@ int Monitor::waitForever() const {
   return impl_->waitForever();
 }
 
-void Monitor::notify() const { impl_->notify(); }
-
-void Monitor::notifyAll() const { impl_->notifyAll(); }
+void Monitor::notify() const {
+  impl_->notify();
+}
 
-}}} // apache::thrift::concurrency
+void Monitor::notifyAll() const {
+  impl_->notifyAll();
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Monitor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Monitor.h b/lib/cpp/src/thrift/concurrency/Monitor.h
index 811e0e1..5472f85 100644
--- a/lib/cpp/src/thrift/concurrency/Monitor.h
+++ b/lib/cpp/src/thrift/concurrency/Monitor.h
@@ -25,8 +25,9 @@
 
 #include <boost/utility.hpp>
 
-
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * A monitor is a combination mutex and condition-event.  Waiting and
@@ -47,7 +48,7 @@ namespace apache { namespace thrift { namespace concurrency {
  * @version $Id:$
  */
 class Monitor : boost::noncopyable {
- public:
+public:
   /** Creates a new mutex, and takes ownership of it. */
   Monitor();
 
@@ -101,30 +102,28 @@ class Monitor : boost::noncopyable {
    */
   void wait(int64_t timeout_ms = 0LL) const;
 
-
   /** Wakes up one thread waiting on this monitor. */
   virtual void notify() const;
 
   /** Wakes up all waiting threads on this monitor. */
   virtual void notifyAll() const;
 
- private:
-
+private:
   class Impl;
 
   Impl* impl_;
 };
 
 class Synchronized {
- public:
- Synchronized(const Monitor* monitor) : g(monitor->mutex()) { }
- Synchronized(const Monitor& monitor) : g(monitor.mutex()) { }
+public:
+  Synchronized(const Monitor* monitor) : g(monitor->mutex()) {}
+  Synchronized(const Monitor& monitor) : g(monitor.mutex()) {}
 
- private:
+private:
   Guard g;
 };
-
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_MONITOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Mutex.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Mutex.cpp b/lib/cpp/src/thrift/concurrency/Mutex.cpp
index 3f7bb5b..d9921aa 100644
--- a/lib/cpp/src/thrift/concurrency/Mutex.cpp
+++ b/lib/cpp/src/thrift/concurrency/Mutex.cpp
@@ -31,7 +31,9 @@
 
 using boost::shared_ptr;
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 #ifndef THRIFT_NO_CONTENTION_PROFILING
 
@@ -40,40 +42,38 @@ static MutexWaitCallback mutexProfilingCallback = 0;
 
 volatile static sig_atomic_t mutexProfilingCounter = 0;
 
-void enableMutexProfiling(int32_t profilingSampleRate,
-                          MutexWaitCallback callback) {
+void enableMutexProfiling(int32_t profilingSampleRate, MutexWaitCallback callback) {
   mutexProfilingSampleRate = profilingSampleRate;
   mutexProfilingCallback = callback;
 }
 
-#define PROFILE_MUTEX_START_LOCK() \
-    int64_t _lock_startTime = maybeGetProfilingStartTime();
+#define PROFILE_MUTEX_START_LOCK() int64_t _lock_startTime = maybeGetProfilingStartTime();
 
-#define PROFILE_MUTEX_NOT_LOCKED() \
-  do { \
-    if (_lock_startTime > 0) { \
-      int64_t endTime = Util::currentTimeUsec(); \
-      (*mutexProfilingCallback)(this, endTime - _lock_startTime); \
-    } \
+#define PROFILE_MUTEX_NOT_LOCKED()                                                                 \
+  do {                                                                                             \
+    if (_lock_startTime > 0) {                                                                     \
+      int64_t endTime = Util::currentTimeUsec();                                                   \
+      (*mutexProfilingCallback)(this, endTime - _lock_startTime);                                  \
+    }                                                                                              \
   } while (0)
 
-#define PROFILE_MUTEX_LOCKED() \
-  do { \
-    profileTime_ = _lock_startTime; \
-    if (profileTime_ > 0) { \
-      profileTime_ = Util::currentTimeUsec() - profileTime_; \
-    } \
+#define PROFILE_MUTEX_LOCKED()                                                                     \
+  do {                                                                                             \
+    profileTime_ = _lock_startTime;                                                                \
+    if (profileTime_ > 0) {                                                                        \
+      profileTime_ = Util::currentTimeUsec() - profileTime_;                                       \
+    }                                                                                              \
   } while (0)
 
-#define PROFILE_MUTEX_START_UNLOCK() \
-  int64_t _temp_profileTime = profileTime_; \
+#define PROFILE_MUTEX_START_UNLOCK()                                                               \
+  int64_t _temp_profileTime = profileTime_;                                                        \
   profileTime_ = 0;
 
-#define PROFILE_MUTEX_UNLOCKED() \
-  do { \
-    if (_temp_profileTime > 0) { \
-      (*mutexProfilingCallback)(this, _temp_profileTime); \
-    } \
+#define PROFILE_MUTEX_UNLOCKED()                                                                   \
+  do {                                                                                             \
+    if (_temp_profileTime > 0) {                                                                   \
+      (*mutexProfilingCallback)(this, _temp_profileTime);                                          \
+    }                                                                                              \
   } while (0)
 
 static inline int64_t maybeGetProfilingStartTime() {
@@ -101,11 +101,11 @@ static inline int64_t maybeGetProfilingStartTime() {
 }
 
 #else
-#  define PROFILE_MUTEX_START_LOCK()
-#  define PROFILE_MUTEX_NOT_LOCKED()
-#  define PROFILE_MUTEX_LOCKED()
-#  define PROFILE_MUTEX_START_UNLOCK()
-#  define PROFILE_MUTEX_UNLOCKED()
+#define PROFILE_MUTEX_START_LOCK()
+#define PROFILE_MUTEX_NOT_LOCKED()
+#define PROFILE_MUTEX_LOCKED()
+#define PROFILE_MUTEX_START_UNLOCK()
+#define PROFILE_MUTEX_UNLOCKED()
 #endif // THRIFT_NO_CONTENTION_PROFILING
 
 /**
@@ -114,7 +114,7 @@ static inline int64_t maybeGetProfilingStartTime() {
  * @version $Id:$
  */
 class Mutex::impl {
- public:
+public:
   impl(Initializer init) : initialized_(false) {
 #ifndef THRIFT_NO_CONTENTION_PROFILING
     profileTime_ = 0;
@@ -182,9 +182,9 @@ class Mutex::impl {
     PROFILE_MUTEX_UNLOCKED();
   }
 
-  void* getUnderlyingImpl() const { return (void*) &pthread_mutex_; }
+  void* getUnderlyingImpl() const { return (void*)&pthread_mutex_; }
 
- private:
+private:
   mutable pthread_mutex_t pthread_mutex_;
   mutable bool initialized_;
 #ifndef THRIFT_NO_CONTENTION_PROFILING
@@ -192,17 +192,28 @@ class Mutex::impl {
 #endif
 };
 
-Mutex::Mutex(Initializer init) : impl_(new Mutex::impl(init)) {}
+Mutex::Mutex(Initializer init) : impl_(new Mutex::impl(init)) {
+}
 
-void* Mutex::getUnderlyingImpl() const { return impl_->getUnderlyingImpl(); }
+void* Mutex::getUnderlyingImpl() const {
+  return impl_->getUnderlyingImpl();
+}
 
-void Mutex::lock() const { impl_->lock(); }
+void Mutex::lock() const {
+  impl_->lock();
+}
 
-bool Mutex::trylock() const { return impl_->trylock(); }
+bool Mutex::trylock() const {
+  return impl_->trylock();
+}
 
-bool Mutex::timedlock(int64_t ms) const { return impl_->timedlock(ms); }
+bool Mutex::timedlock(int64_t ms) const {
+  return impl_->timedlock(ms);
+}
 
-void Mutex::unlock() const { impl_->unlock(); }
+void Mutex::unlock() const {
+  impl_->unlock();
+}
 
 void Mutex::DEFAULT_INITIALIZER(void* arg) {
   pthread_mutex_t* pthread_mutex = (pthread_mutex_t*)arg;
@@ -211,7 +222,8 @@ void Mutex::DEFAULT_INITIALIZER(void* arg) {
   assert(ret == 0);
 }
 
-#if defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) || defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#if defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)                                                 \
+    || defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
 static void init_with_kind(pthread_mutex_t* mutex, int kind) {
   pthread_mutexattr_t mutexattr;
   int ret = pthread_mutexattr_init(&mutexattr);
@@ -250,7 +262,6 @@ void Mutex::RECURSIVE_INITIALIZER(void* arg) {
 }
 #endif
 
-
 /**
  * Implementation of ReadWriteMutex class using POSIX rw lock
  *
@@ -269,7 +280,7 @@ public:
   }
 
   ~impl() {
-    if(initialized_) {
+    if (initialized_) {
       initialized_ = false;
       int ret = pthread_rwlock_destroy(&rw_lock_);
       THRIFT_UNUSED_VARIABLE(ret);
@@ -280,7 +291,7 @@ public:
   void acquireRead() const {
     PROFILE_MUTEX_START_LOCK();
     pthread_rwlock_rdlock(&rw_lock_);
-    PROFILE_MUTEX_NOT_LOCKED();  // not exclusive, so use not-locked path
+    PROFILE_MUTEX_NOT_LOCKED(); // not exclusive, so use not-locked path
   }
 
   void acquireWrite() const {
@@ -307,22 +318,33 @@ private:
 #endif
 };
 
-ReadWriteMutex::ReadWriteMutex() : impl_(new ReadWriteMutex::impl()) {}
+ReadWriteMutex::ReadWriteMutex() : impl_(new ReadWriteMutex::impl()) {
+}
 
-void ReadWriteMutex::acquireRead() const { impl_->acquireRead(); }
+void ReadWriteMutex::acquireRead() const {
+  impl_->acquireRead();
+}
 
-void ReadWriteMutex::acquireWrite() const { impl_->acquireWrite(); }
+void ReadWriteMutex::acquireWrite() const {
+  impl_->acquireWrite();
+}
 
-bool ReadWriteMutex::attemptRead() const { return impl_->attemptRead(); }
+bool ReadWriteMutex::attemptRead() const {
+  return impl_->attemptRead();
+}
 
-bool ReadWriteMutex::attemptWrite() const { return impl_->attemptWrite(); }
+bool ReadWriteMutex::attemptWrite() const {
+  return impl_->attemptWrite();
+}
 
-void ReadWriteMutex::release() const { impl_->release(); }
+void ReadWriteMutex::release() const {
+  impl_->release();
+}
 
-NoStarveReadWriteMutex::NoStarveReadWriteMutex() : writerWaiting_(false) {}
+NoStarveReadWriteMutex::NoStarveReadWriteMutex() : writerWaiting_(false) {
+}
 
-void NoStarveReadWriteMutex::acquireRead() const
-{
+void NoStarveReadWriteMutex::acquireRead() const {
   if (writerWaiting_) {
     // writer is waiting, block on the writer's mutex until he's done with it
     mutex_.lock();
@@ -332,8 +354,7 @@ void NoStarveReadWriteMutex::acquireRead() const
   ReadWriteMutex::acquireRead();
 }
 
-void NoStarveReadWriteMutex::acquireWrite() const
-{
+void NoStarveReadWriteMutex::acquireWrite() const {
   // if we can acquire the rwlock the easy way, we're done
   if (attemptWrite()) {
     return;
@@ -348,6 +369,6 @@ void NoStarveReadWriteMutex::acquireWrite() const
   writerWaiting_ = false;
   mutex_.unlock();
 }
-
-}}} // apache::thrift::concurrency
-
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Mutex.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Mutex.h b/lib/cpp/src/thrift/concurrency/Mutex.h
index 3cd8440..e3142fa 100644
--- a/lib/cpp/src/thrift/concurrency/Mutex.h
+++ b/lib/cpp/src/thrift/concurrency/Mutex.h
@@ -23,7 +23,9 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 #ifndef THRIFT_NO_CONTENTION_PROFILING
 
@@ -46,8 +48,7 @@ namespace apache { namespace thrift { namespace concurrency {
  * particular time period.
  */
 typedef void (*MutexWaitCallback)(const void* id, int64_t waitTimeMicros);
-void enableMutexProfiling(int32_t profilingSampleRate,
-                          MutexWaitCallback callback);
+void enableMutexProfiling(int32_t profilingSampleRate, MutexWaitCallback callback);
 
 #endif
 
@@ -57,7 +58,7 @@ void enableMutexProfiling(int32_t profilingSampleRate,
  * @version $Id:$
  */
 class Mutex {
- public:
+public:
   typedef void (*Initializer)(void*);
 
   Mutex(Initializer init = DEFAULT_INITIALIZER);
@@ -73,8 +74,7 @@ class Mutex {
   static void ADAPTIVE_INITIALIZER(void*);
   static void RECURSIVE_INITIALIZER(void*);
 
- private:
-
+private:
   class impl;
   boost::shared_ptr<impl> impl_;
 };
@@ -96,7 +96,6 @@ public:
   virtual void release() const;
 
 private:
-
   class impl;
   boost::shared_ptr<impl> impl_;
 };
@@ -121,7 +120,7 @@ private:
 };
 
 class Guard : boost::noncopyable {
- public:
+public:
   Guard(const Mutex& value, int64_t timeout = 0) : mutex_(&value) {
     if (timeout == 0) {
       value.lock();
@@ -141,48 +140,40 @@ class Guard : boost::noncopyable {
     }
   }
 
-  operator bool() const {
-    return (mutex_ != NULL);
-  }
+  operator bool() const { return (mutex_ != NULL); }
 
- private:
+private:
   const Mutex* mutex_;
 };
 
 // Can be used as second argument to RWGuard to make code more readable
 // as to whether we're doing acquireRead() or acquireWrite().
-enum RWGuardType {
-  RW_READ = 0,
-  RW_WRITE = 1
-};
-
+enum RWGuardType { RW_READ = 0, RW_WRITE = 1 };
 
 class RWGuard : boost::noncopyable {
-  public:
-    RWGuard(const ReadWriteMutex& value, bool write = false)
-         : rw_mutex_(value) {
-      if (write) {
-        rw_mutex_.acquireWrite();
-      } else {
-        rw_mutex_.acquireRead();
-      }
+public:
+  RWGuard(const ReadWriteMutex& value, bool write = false) : rw_mutex_(value) {
+    if (write) {
+      rw_mutex_.acquireWrite();
+    } else {
+      rw_mutex_.acquireRead();
     }
+  }
 
-    RWGuard(const ReadWriteMutex& value, RWGuardType type)
-         : rw_mutex_(value) {
-      if (type == RW_WRITE) {
-        rw_mutex_.acquireWrite();
-      } else {
-        rw_mutex_.acquireRead();
-      }
-    }
-    ~RWGuard() {
-      rw_mutex_.release();
+  RWGuard(const ReadWriteMutex& value, RWGuardType type) : rw_mutex_(value) {
+    if (type == RW_WRITE) {
+      rw_mutex_.acquireWrite();
+    } else {
+      rw_mutex_.acquireRead();
     }
-  private:
-    const ReadWriteMutex& rw_mutex_;
-};
+  }
+  ~RWGuard() { rw_mutex_.release(); }
 
-}}} // apache::thrift::concurrency
+private:
+  const ReadWriteMutex& rw_mutex_;
+};
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_MUTEX_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/PlatformThreadFactory.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/PlatformThreadFactory.h b/lib/cpp/src/thrift/concurrency/PlatformThreadFactory.h
index 6e46dfc..311c3db 100644
--- a/lib/cpp/src/thrift/concurrency/PlatformThreadFactory.h
+++ b/lib/cpp/src/thrift/concurrency/PlatformThreadFactory.h
@@ -20,6 +20,7 @@
 #ifndef _THRIFT_CONCURRENCY_PLATFORMTHREADFACTORY_H_
 #define _THRIFT_CONCURRENCY_PLATFORMTHREADFACTORY_H_ 1
 
+// clang-format off
 #include <thrift/thrift-config.h>
 #if USE_BOOST_THREAD
 #  include <thrift/concurrency/BoostThreadFactory.h>
@@ -28,9 +29,13 @@
 #else
 #  include <thrift/concurrency/PosixThreadFactory.h>
 #endif
+// clang-format on
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
+// clang-format off
 #ifdef USE_BOOST_THREAD
   typedef BoostThreadFactory PlatformThreadFactory;
 #elif USE_STD_THREAD
@@ -38,7 +43,10 @@ namespace apache { namespace thrift { namespace concurrency {
 #else
   typedef PosixThreadFactory PlatformThreadFactory;
 #endif
+// clang-format on
 
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_PLATFORMTHREADFACTORY_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
index 52ceead..47c5034 100644
--- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
@@ -23,7 +23,7 @@
 #include <thrift/concurrency/Exception.h>
 
 #if GOOGLE_PERFTOOLS_REGISTER_THREAD
-#  include <google/profiler.h>
+#include <google/profiler.h>
 #endif
 
 #include <assert.h>
@@ -33,7 +33,9 @@
 
 #include <boost/weak_ptr.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 using boost::shared_ptr;
 using boost::weak_ptr;
@@ -43,22 +45,15 @@ using boost::weak_ptr;
  *
  * @version $Id:$
  */
-class PthreadThread: public Thread {
- public:
-
-  enum STATE {
-    uninitialized,
-    starting,
-    started,
-    stopping,
-    stopped
-  };
+class PthreadThread : public Thread {
+public:
+  enum STATE { uninitialized, starting, started, stopping, stopped };
 
   static const int MB = 1024 * 1024;
 
   static void* threadMain(void* arg);
 
- private:
+private:
   pthread_t pthread_;
   STATE state_;
   int policy_;
@@ -67,19 +62,23 @@ class PthreadThread: public Thread {
   weak_ptr<PthreadThread> self_;
   bool detached_;
 
- public:
-
-  PthreadThread(int policy, int priority, int stackSize, bool detached, shared_ptr<Runnable> runnable) :
+public:
+  PthreadThread(int policy,
+                int priority,
+                int stackSize,
+                bool detached,
+                shared_ptr<Runnable> runnable)
+    :
 
 #ifndef _WIN32
-    pthread_(0),
+      pthread_(0),
 #endif // _WIN32
 
-    state_(uninitialized),
-    policy_(policy),
-    priority_(priority),
-    stackSize_(stackSize),
-    detached_(detached) {
+      state_(uninitialized),
+      policy_(policy),
+      priority_(priority),
+      stackSize_(stackSize),
+      detached_(detached) {
 
     this->Thread::runnable(runnable);
   }
@@ -88,10 +87,10 @@ class PthreadThread: public Thread {
     /* Nothing references this thread, if is is not detached, do a join
        now, otherwise the thread-id and, possibly, other resources will
        be leaked. */
-    if(!detached_) {
+    if (!detached_) {
       try {
         join();
-      } catch(...) {
+      } catch (...) {
         // We're really hosed.
       }
     }
@@ -104,14 +103,13 @@ class PthreadThread: public Thread {
 
     pthread_attr_t thread_attr;
     if (pthread_attr_init(&thread_attr) != 0) {
-        throw SystemResourceException("pthread_attr_init failed");
+      throw SystemResourceException("pthread_attr_init failed");
     }
 
-    if(pthread_attr_setdetachstate(&thread_attr,
-                                   detached_ ?
-                                   PTHREAD_CREATE_DETACHED :
-                                   PTHREAD_CREATE_JOINABLE) != 0) {
-        throw SystemResourceException("pthread_attr_setdetachstate failed");
+    if (pthread_attr_setdetachstate(&thread_attr,
+                                    detached_ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE)
+        != 0) {
+      throw SystemResourceException("pthread_attr_setdetachstate failed");
     }
 
     // Set thread stack size
@@ -119,11 +117,12 @@ class PthreadThread: public Thread {
       throw SystemResourceException("pthread_attr_setstacksize failed");
     }
 
-    // Set thread policy
-    #ifdef _WIN32
-	//WIN32 Pthread implementation doesn't seem to support sheduling policies other then PosixThreadFactory::OTHER - runtime error
-	policy_ = PosixThreadFactory::OTHER;
-    #endif
+// Set thread policy
+#ifdef _WIN32
+    // WIN32 Pthread implementation doesn't seem to support sheduling policies other then
+    // PosixThreadFactory::OTHER - runtime error
+    policy_ = PosixThreadFactory::OTHER;
+#endif
 
     if (pthread_attr_setschedpolicy(&thread_attr, policy_) != 0) {
       throw SystemResourceException("pthread_attr_setschedpolicy failed");
@@ -217,7 +216,7 @@ void* PthreadThread::threadMain(void* arg) {
  */
 class PosixThreadFactory::Impl {
 
- private:
+private:
   POLICY policy_;
   PRIORITY priority_;
   int stackSize_;
@@ -269,13 +268,9 @@ class PosixThreadFactory::Impl {
     }
   }
 
- public:
-
-  Impl(POLICY policy, PRIORITY priority, int stackSize, bool detached) :
-    policy_(policy),
-    priority_(priority),
-    stackSize_(stackSize),
-    detached_(detached) {}
+public:
+  Impl(POLICY policy, PRIORITY priority, int stackSize, bool detached)
+    : policy_(policy), priority_(priority), stackSize_(stackSize), detached_(detached) {}
 
   /**
    * Creates a new POSIX thread to run the runnable object
@@ -283,7 +278,12 @@ class PosixThreadFactory::Impl {
    * @param runnable A runnable object
    */
   shared_ptr<Thread> newThread(shared_ptr<Runnable> runnable) const {
-    shared_ptr<PthreadThread> result = shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_), toPthreadPriority(policy_, priority_), stackSize_, detached_, runnable));
+    shared_ptr<PthreadThread> result
+        = shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_),
+                                                      toPthreadPriority(policy_, priority_),
+                                                      stackSize_,
+                                                      detached_,
+                                                      runnable));
     result->weakRef(result);
     runnable->thread(result);
     return result;
@@ -314,28 +314,47 @@ class PosixThreadFactory::Impl {
 #else
     return (Thread::id_t)pthread_self().p;
 #endif // _WIN32
-
   }
-
 };
 
-PosixThreadFactory::PosixThreadFactory(POLICY policy, PRIORITY priority, int stackSize, bool detached) :
-  impl_(new PosixThreadFactory::Impl(policy, priority, stackSize, detached)) {}
-
-shared_ptr<Thread> PosixThreadFactory::newThread(shared_ptr<Runnable> runnable) const { return impl_->newThread(runnable); }
+PosixThreadFactory::PosixThreadFactory(POLICY policy,
+                                       PRIORITY priority,
+                                       int stackSize,
+                                       bool detached)
+  : impl_(new PosixThreadFactory::Impl(policy, priority, stackSize, detached)) {
+}
 
-int PosixThreadFactory::getStackSize() const { return impl_->getStackSize(); }
+shared_ptr<Thread> PosixThreadFactory::newThread(shared_ptr<Runnable> runnable) const {
+  return impl_->newThread(runnable);
+}
 
-void PosixThreadFactory::setStackSize(int value) { impl_->setStackSize(value); }
+int PosixThreadFactory::getStackSize() const {
+  return impl_->getStackSize();
+}
 
-PosixThreadFactory::PRIORITY PosixThreadFactory::getPriority() const { return impl_->getPriority(); }
+void PosixThreadFactory::setStackSize(int value) {
+  impl_->setStackSize(value);
+}
 
-void PosixThreadFactory::setPriority(PosixThreadFactory::PRIORITY value) { impl_->setPriority(value); }
+PosixThreadFactory::PRIORITY PosixThreadFactory::getPriority() const {
+  return impl_->getPriority();
+}
 
-bool PosixThreadFactory::isDetached() const { return impl_->isDetached(); }
+void PosixThreadFactory::setPriority(PosixThreadFactory::PRIORITY value) {
+  impl_->setPriority(value);
+}
 
-void PosixThreadFactory::setDetached(bool value) { impl_->setDetached(value); }
+bool PosixThreadFactory::isDetached() const {
+  return impl_->isDetached();
+}
 
-Thread::id_t PosixThreadFactory::getCurrentThreadId() const { return impl_->getCurrentThreadId(); }
+void PosixThreadFactory::setDetached(bool value) {
+  impl_->setDetached(value);
+}
 
-}}} // apache::thrift::concurrency
+Thread::id_t PosixThreadFactory::getCurrentThreadId() const {
+  return impl_->getCurrentThreadId();
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h
index 72368ca..4004231 100644
--- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h
+++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h
@@ -24,7 +24,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * A thread factory to create posix threads
@@ -33,16 +35,11 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class PosixThreadFactory : public ThreadFactory {
 
- public:
-
+public:
   /**
    * POSIX Thread scheduler policies
    */
-  enum POLICY {
-    OTHER,
-    FIFO,
-    ROUND_ROBIN
-  };
+  enum POLICY { OTHER, FIFO, ROUND_ROBIN };
 
   /**
    * POSIX Thread scheduler relative priorities,
@@ -78,7 +75,10 @@ class PosixThreadFactory : public ThreadFactory {
    * By default threads are not joinable.
    */
 
-  PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=true);
+  PosixThreadFactory(POLICY policy = ROUND_ROBIN,
+                     PRIORITY priority = NORMAL,
+                     int stackSize = 1,
+                     bool detached = true);
 
   // From ThreadFactory;
   boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
@@ -120,11 +120,12 @@ class PosixThreadFactory : public ThreadFactory {
    */
   virtual bool isDetached() const;
 
- private:
+private:
   class Impl;
   boost::shared_ptr<Impl> impl_;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/StdMonitor.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/StdMonitor.cpp b/lib/cpp/src/thrift/concurrency/StdMonitor.cpp
index cf257e6..7b3b209 100644
--- a/lib/cpp/src/thrift/concurrency/StdMonitor.cpp
+++ b/lib/cpp/src/thrift/concurrency/StdMonitor.cpp
@@ -30,7 +30,9 @@
 #include <thread>
 #include <mutex>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Monitor implementation using the std thread library
@@ -39,26 +41,12 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class Monitor::Impl {
 
- public:
+public:
+  Impl() : ownedMutex_(new Mutex()), conditionVariable_(), mutex_(NULL) { init(ownedMutex_.get()); }
 
-  Impl()
-     : ownedMutex_(new Mutex()),
-       conditionVariable_(),
-       mutex_(NULL) {
-    init(ownedMutex_.get());
-  }
-
-  Impl(Mutex* mutex)
-     : ownedMutex_(),
-       conditionVariable_(),
-       mutex_(NULL) {
-    init(mutex);
-  }
+  Impl(Mutex* mutex) : ownedMutex_(), conditionVariable_(), mutex_(NULL) { init(mutex); }
 
-  Impl(Monitor* monitor)
-     : ownedMutex_(),
-       conditionVariable_(),
-       mutex_(NULL) {
+  Impl(Monitor* monitor) : ownedMutex_(), conditionVariable_(), mutex_(NULL) {
     init(&(monitor->mutex()));
   }
 
@@ -78,8 +66,7 @@ class Monitor::Impl {
     if (result == THRIFT_ETIMEDOUT) {
       throw TimedOutException();
     } else if (result != 0) {
-      throw TException(
-        "Monitor::wait() failed");
+      throw TException("Monitor::wait() failed");
     }
   }
 
@@ -95,12 +82,12 @@ class Monitor::Impl {
     }
 
     assert(mutex_);
-    std::timed_mutex* mutexImpl =
-      static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+    std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
     std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
-    bool timedout = (conditionVariable_.wait_for(lock, std::chrono::milliseconds(timeout_ms)) == std::cv_status::timeout);
+    bool timedout = (conditionVariable_.wait_for(lock, std::chrono::milliseconds(timeout_ms))
+                     == std::cv_status::timeout);
     lock.release();
     return (timedout ? THRIFT_ETIMEDOUT : 0);
   }
@@ -111,7 +98,7 @@ class Monitor::Impl {
    */
   int waitForTime(const THRIFT_TIMESPEC* abstime) {
     struct timeval temp;
-    temp.tv_sec  = static_cast<long>(abstime->tv_sec);
+    temp.tv_sec = static_cast<long>(abstime->tv_sec);
     temp.tv_usec = static_cast<long>(abstime->tv_nsec) / 1000;
     return waitForTime(&temp);
   }
@@ -122,24 +109,24 @@ class Monitor::Impl {
    */
   int waitForTime(const struct timeval* abstime) {
     assert(mutex_);
-    std::timed_mutex* mutexImpl =
-      static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+    std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
     struct timeval currenttime;
     Util::toTimeval(currenttime, Util::currentTime());
 
-    long tv_sec  = static_cast<long>(abstime->tv_sec  - currenttime.tv_sec);
+    long tv_sec = static_cast<long>(abstime->tv_sec - currenttime.tv_sec);
     long tv_usec = static_cast<long>(abstime->tv_usec - currenttime.tv_usec);
-    if(tv_sec < 0)
+    if (tv_sec < 0)
       tv_sec = 0;
-    if(tv_usec < 0)
+    if (tv_usec < 0)
       tv_usec = 0;
 
     std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
     bool timedout = (conditionVariable_.wait_for(lock,
-      std::chrono::seconds(tv_sec) +
-      std::chrono::microseconds(tv_usec)) == std::cv_status::timeout);
+                                                 std::chrono::seconds(tv_sec)
+                                                 + std::chrono::microseconds(tv_usec))
+                     == std::cv_status::timeout);
     lock.release();
     return (timedout ? THRIFT_ETIMEDOUT : 0);
   }
@@ -150,8 +137,7 @@ class Monitor::Impl {
    */
   int waitForever() {
     assert(mutex_);
-    std::timed_mutex* mutexImpl =
-      static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+    std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
     std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
@@ -160,39 +146,44 @@ class Monitor::Impl {
     return 0;
   }
 
+  void notify() { conditionVariable_.notify_one(); }
 
-  void notify() {
-    conditionVariable_.notify_one();
-  }
-
-  void notifyAll() {
-    conditionVariable_.notify_all();
-  }
+  void notifyAll() { conditionVariable_.notify_all(); }
 
- private:
-
-  void init(Mutex* mutex) {
-    mutex_ = mutex;
-  }
+private:
+  void init(Mutex* mutex) { mutex_ = mutex; }
 
   const std::unique_ptr<Mutex> ownedMutex_;
   std::condition_variable_any conditionVariable_;
   Mutex* mutex_;
 };
 
-Monitor::Monitor() : impl_(new Monitor::Impl()) {}
-Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {}
-Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {}
+Monitor::Monitor() : impl_(new Monitor::Impl()) {
+}
+Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {
+}
+Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {
+}
 
-Monitor::~Monitor() { delete impl_; }
+Monitor::~Monitor() {
+  delete impl_;
+}
 
-Mutex& Monitor::mutex() const { return const_cast<Monitor::Impl*>(impl_)->mutex(); }
+Mutex& Monitor::mutex() const {
+  return const_cast<Monitor::Impl*>(impl_)->mutex();
+}
 
-void Monitor::lock() const { const_cast<Monitor::Impl*>(impl_)->lock(); }
+void Monitor::lock() const {
+  const_cast<Monitor::Impl*>(impl_)->lock();
+}
 
-void Monitor::unlock() const { const_cast<Monitor::Impl*>(impl_)->unlock(); }
+void Monitor::unlock() const {
+  const_cast<Monitor::Impl*>(impl_)->unlock();
+}
 
-void Monitor::wait(int64_t timeout) const { const_cast<Monitor::Impl*>(impl_)->wait(timeout); }
+void Monitor::wait(int64_t timeout) const {
+  const_cast<Monitor::Impl*>(impl_)->wait(timeout);
+}
 
 int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const {
   return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime);
@@ -210,8 +201,13 @@ int Monitor::waitForever() const {
   return const_cast<Monitor::Impl*>(impl_)->waitForever();
 }
 
-void Monitor::notify() const { const_cast<Monitor::Impl*>(impl_)->notify(); }
-
-void Monitor::notifyAll() const { const_cast<Monitor::Impl*>(impl_)->notifyAll(); }
+void Monitor::notify() const {
+  const_cast<Monitor::Impl*>(impl_)->notify();
+}
 
-}}} // apache::thrift::concurrency
+void Monitor::notifyAll() const {
+  const_cast<Monitor::Impl*>(impl_)->notifyAll();
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/StdMutex.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/StdMutex.cpp b/lib/cpp/src/thrift/concurrency/StdMutex.cpp
index 28f889a..69678a2 100644
--- a/lib/cpp/src/thrift/concurrency/StdMutex.cpp
+++ b/lib/cpp/src/thrift/concurrency/StdMutex.cpp
@@ -26,30 +26,42 @@
 #include <chrono>
 #include <mutex>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Implementation of Mutex class using C++11 std::timed_mutex
  *
  * @version $Id:$
  */
-class Mutex::impl : public std::timed_mutex {
-};
+class Mutex::impl : public std::timed_mutex {};
 
-Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {}
+Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {
+}
 
-void* Mutex::getUnderlyingImpl() const { return impl_.get(); }
+void* Mutex::getUnderlyingImpl() const {
+  return impl_.get();
+}
 
-void Mutex::lock() const { impl_->lock(); }
+void Mutex::lock() const {
+  impl_->lock();
+}
 
-bool Mutex::trylock() const { return impl_->try_lock(); }
+bool Mutex::trylock() const {
+  return impl_->try_lock();
+}
 
-bool Mutex::timedlock(int64_t ms) const { return impl_->try_lock_for(std::chrono::milliseconds(ms)); }
+bool Mutex::timedlock(int64_t ms) const {
+  return impl_->try_lock_for(std::chrono::milliseconds(ms));
+}
 
-void Mutex::unlock() const { impl_->unlock(); }
+void Mutex::unlock() const {
+  impl_->unlock();
+}
 
 void Mutex::DEFAULT_INITIALIZER(void* arg) {
 }
-
-}}} // apache::thrift::concurrency
-
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp
index 6014b32..1ff4e73 100644
--- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp
+++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp
@@ -30,7 +30,9 @@
 #include <boost/weak_ptr.hpp>
 #include <thread>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * The C++11 thread class.
@@ -41,37 +43,28 @@ namespace apache { namespace thrift { namespace concurrency {
  *
  * @version $Id:$
  */
-class StdThread: public Thread, public boost::enable_shared_from_this<StdThread> {
- public:
+class StdThread : public Thread, public boost::enable_shared_from_this<StdThread> {
+public:
+  enum STATE { uninitialized, starting, started, stopping, stopped };
 
-  enum STATE {
-    uninitialized,
-    starting,
-    started,
-    stopping,
-    stopped
-  };
+  static void threadMain(boost::shared_ptr<StdThread> thread);
 
-   static void threadMain(boost::shared_ptr<StdThread> thread);
-
- private:
+private:
   std::unique_ptr<std::thread> thread_;
   STATE state_;
   bool detached_;
 
- public:
-
-  StdThread(bool detached, boost::shared_ptr<Runnable> runnable) :
-      state_(uninitialized),
-      detached_(detached) {
+public:
+  StdThread(bool detached, boost::shared_ptr<Runnable> runnable)
+    : state_(uninitialized), detached_(detached) {
     this->Thread::runnable(runnable);
   }
 
   ~StdThread() {
-    if(!detached_) {
+    if (!detached_) {
       try {
         join();
-      } catch(...) {
+      } catch (...) {
         // We're really hosed.
       }
     }
@@ -87,7 +80,7 @@ class StdThread: public Thread, public boost::enable_shared_from_this<StdThread>
 
     thread_ = std::unique_ptr<std::thread>(new std::thread(threadMain, selfRef));
 
-    if(detached_)
+    if (detached_)
       thread_->detach();
   }
 
@@ -97,9 +90,7 @@ class StdThread: public Thread, public boost::enable_shared_from_this<StdThread>
     }
   }
 
-  Thread::id_t getId() {
-    return thread_.get() ? thread_->get_id() : std::thread::id();
-  }
+  Thread::id_t getId() { return thread_.get() ? thread_->get_id() : std::thread::id(); }
 
   boost::shared_ptr<Runnable> runnable() const { return Thread::runnable(); }
 
@@ -130,13 +121,11 @@ void StdThread::threadMain(boost::shared_ptr<StdThread> thread) {
  */
 class StdThreadFactory::Impl {
 
- private:
+private:
   bool detached_;
 
- public:
-
-  Impl(bool detached) :
-    detached_(detached) {}
+public:
+  Impl(bool detached) : detached_(detached) {}
 
   /**
    * Creates a new std::thread to run the runnable object
@@ -144,7 +133,8 @@ class StdThreadFactory::Impl {
    * @param runnable A runnable object
    */
   boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const {
-    boost::shared_ptr<StdThread> result = boost::shared_ptr<StdThread>(new StdThread(detached_, runnable));
+    boost::shared_ptr<StdThread> result
+        = boost::shared_ptr<StdThread>(new StdThread(detached_, runnable));
     runnable->thread(result);
     return result;
   }
@@ -153,23 +143,29 @@ class StdThreadFactory::Impl {
 
   void setDetached(bool value) { detached_ = value; }
 
-  Thread::id_t getCurrentThreadId() const {
-    return std::this_thread::get_id();
-  }
-
+  Thread::id_t getCurrentThreadId() const { return std::this_thread::get_id(); }
 };
 
-StdThreadFactory::StdThreadFactory(bool detached) :
-  impl_(new StdThreadFactory::Impl(detached)) {}
-
-boost::shared_ptr<Thread> StdThreadFactory::newThread(boost::shared_ptr<Runnable> runnable) const { return impl_->newThread(runnable); }
+StdThreadFactory::StdThreadFactory(bool detached) : impl_(new StdThreadFactory::Impl(detached)) {
+}
 
-bool StdThreadFactory::isDetached() const { return impl_->isDetached(); }
+boost::shared_ptr<Thread> StdThreadFactory::newThread(boost::shared_ptr<Runnable> runnable) const {
+  return impl_->newThread(runnable);
+}
 
-void StdThreadFactory::setDetached(bool value) { impl_->setDetached(value); }
+bool StdThreadFactory::isDetached() const {
+  return impl_->isDetached();
+}
 
-Thread::id_t StdThreadFactory::getCurrentThreadId() const { return impl_->getCurrentThreadId(); }
+void StdThreadFactory::setDetached(bool value) {
+  impl_->setDetached(value);
+}
 
-}}} // apache::thrift::concurrency
+Thread::id_t StdThreadFactory::getCurrentThreadId() const {
+  return impl_->getCurrentThreadId();
+}
+}
+}
+} // apache::thrift::concurrency
 
 #endif // USE_STD_THREAD

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/StdThreadFactory.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h
index 307f970..fb86bbf 100644
--- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h
+++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h
@@ -24,7 +24,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * A thread factory to create std::threads.
@@ -33,8 +35,7 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class StdThreadFactory : public ThreadFactory {
 
- public:
-
+public:
   /**
    * Std thread factory.  All threads created by a factory are reference-counted
    * via boost::shared_ptr and boost::weak_ptr.  The factory guarantees that threads and
@@ -44,7 +45,7 @@ class StdThreadFactory : public ThreadFactory {
    * By default threads are not joinable.
    */
 
-  StdThreadFactory(bool detached=true);
+  StdThreadFactory(bool detached = true);
 
   // From ThreadFactory;
   boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
@@ -66,7 +67,8 @@ private:
   class Impl;
   boost::shared_ptr<Impl> impl_;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_STDTHREADFACTORY_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Thread.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Thread.h b/lib/cpp/src/thrift/concurrency/Thread.h
old mode 100755
new mode 100644
index 7012933..1d9153f
--- a/lib/cpp/src/thrift/concurrency/Thread.h
+++ b/lib/cpp/src/thrift/concurrency/Thread.h
@@ -27,16 +27,18 @@
 #include <thrift/thrift-config.h>
 
 #if USE_BOOST_THREAD
-#  include <boost/thread.hpp>
+#include <boost/thread.hpp>
 #elif USE_STD_THREAD
-#  include <thread>
+#include <thread>
 #else
-#  ifdef HAVE_PTHREAD_H
-#    include <pthread.h>
-#  endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
 #endif
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 class Thread;
 
@@ -47,8 +49,8 @@ class Thread;
  */
 class Runnable {
 
- public:
-  virtual ~Runnable() {};
+public:
+  virtual ~Runnable(){};
   virtual void run() = 0;
 
   /**
@@ -63,7 +65,7 @@ class Runnable {
    */
   virtual void thread(boost::shared_ptr<Thread> value) { thread_ = value; }
 
- private:
+private:
   boost::weak_ptr<Thread> thread_;
 };
 
@@ -78,8 +80,7 @@ class Runnable {
  */
 class Thread {
 
- public:
-
+public:
 #if USE_BOOST_THREAD
   typedef boost::thread::id id_t;
 
@@ -97,7 +98,7 @@ class Thread {
   static inline id_t get_current() { return pthread_self(); }
 #endif
 
-  virtual ~Thread() {};
+  virtual ~Thread(){};
 
   /**
    * Starts the thread. Does platform specific thread creation and
@@ -122,12 +123,11 @@ class Thread {
    */
   virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; }
 
- protected:
+protected:
   virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; }
 
- private:
+private:
   boost::shared_ptr<Runnable> _runnable;
-
 };
 
 /**
@@ -136,17 +136,19 @@ class Thread {
  */
 class ThreadFactory {
 
- public:
+public:
   virtual ~ThreadFactory() {}
   virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0;
 
-  /** Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread */
+  /** Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread
+   */
 
   static const Thread::id_t unknown_thread_id;
 
   virtual Thread::id_t getCurrentThreadId() const = 0;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_THREAD_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
index 204d5dc..9ff2c9a 100644
--- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
+++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
@@ -32,9 +32,11 @@
 
 #if defined(DEBUG)
 #include <iostream>
-#endif //defined(DEBUG)
+#endif // defined(DEBUG)
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
@@ -49,18 +51,18 @@ using boost::dynamic_pointer_cast;
  *
  * @version $Id:$
  */
-class ThreadManager::Impl : public ThreadManager  {
-
- public:
-  Impl() :
-    workerCount_(0),
-    workerMaxCount_(0),
-    idleCount_(0),
-    pendingTaskCountMax_(0),
-    expiredCount_(0),
-    state_(ThreadManager::UNINITIALIZED),
-    monitor_(&mutex_),
-    maxMonitor_(&mutex_) {}
+class ThreadManager::Impl : public ThreadManager {
+
+public:
+  Impl()
+    : workerCount_(0),
+      workerMaxCount_(0),
+      idleCount_(0),
+      pendingTaskCountMax_(0),
+      expiredCount_(0),
+      state_(ThreadManager::UNINITIALIZED),
+      monitor_(&mutex_),
+      maxMonitor_(&mutex_) {}
 
   ~Impl() { stop(); }
 
@@ -70,9 +72,7 @@ class ThreadManager::Impl : public ThreadManager  {
 
   void join() { stopImpl(true); }
 
-  ThreadManager::STATE state() const {
-    return state_;
-  }
+  ThreadManager::STATE state() const { return state_; }
 
   shared_ptr<ThreadFactory> threadFactory() const {
     Synchronized s(monitor_);
@@ -88,9 +88,7 @@ class ThreadManager::Impl : public ThreadManager  {
 
   void removeWorker(size_t value);
 
-  size_t idleWorkerCount() const {
-    return idleCount_;
-  }
+  size_t idleWorkerCount() const { return idleCount_; }
 
   size_t workerCount() const {
     Synchronized s(monitor_);
@@ -149,7 +147,6 @@ private:
   ThreadManager::STATE state_;
   shared_ptr<ThreadFactory> threadFactory_;
 
-
   friend class ThreadManager::Task;
   std::queue<shared_ptr<Task> > tasks_;
   Mutex mutex_;
@@ -165,18 +162,13 @@ private:
 
 class ThreadManager::Task : public Runnable {
 
- public:
-  enum STATE {
-    WAITING,
-    EXECUTING,
-    CANCELLED,
-    COMPLETE
-  };
+public:
+  enum STATE { WAITING, EXECUTING, CANCELLED, COMPLETE };
 
-  Task(shared_ptr<Runnable> runnable, int64_t expiration=0LL)  :
-    runnable_(runnable),
-    state_(WAITING),
-    expireTime_(expiration != 0LL ? Util::currentTime() + expiration : 0LL) {}
+  Task(shared_ptr<Runnable> runnable, int64_t expiration = 0LL)
+    : runnable_(runnable),
+      state_(WAITING),
+      expireTime_(expiration != 0LL ? Util::currentTime() + expiration : 0LL) {}
 
   ~Task() {}
 
@@ -187,46 +179,32 @@ class ThreadManager::Task : public Runnable {
     }
   }
 
-  shared_ptr<Runnable> getRunnable() {
-    return runnable_;
-  }
+  shared_ptr<Runnable> getRunnable() { return runnable_; }
 
-  int64_t getExpireTime() const {
-    return expireTime_;
-  }
+  int64_t getExpireTime() const { return expireTime_; }
 
- private:
+private:
   shared_ptr<Runnable> runnable_;
   friend class ThreadManager::Worker;
   STATE state_;
   int64_t expireTime_;
 };
 
-class ThreadManager::Worker: public Runnable {
-  enum STATE {
-    UNINITIALIZED,
-    STARTING,
-    STARTED,
-    STOPPING,
-    STOPPED
-  };
-
- public:
-  Worker(ThreadManager::Impl* manager) :
-    manager_(manager),
-    state_(UNINITIALIZED),
-    idle_(false) {}
+class ThreadManager::Worker : public Runnable {
+  enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED };
+
+public:
+  Worker(ThreadManager::Impl* manager) : manager_(manager), state_(UNINITIALIZED), idle_(false) {}
 
   ~Worker() {}
 
- private:
+private:
   bool isActive() const {
-    return
-      (manager_->workerCount_ <= manager_->workerMaxCount_) ||
-      (manager_->state_ == JOINING && !manager_->tasks_.empty());
+    return (manager_->workerCount_ <= manager_->workerMaxCount_)
+           || (manager_->state_ == JOINING && !manager_->tasks_.empty());
   }
 
- public:
+public:
   /**
    * Worker entry point
    *
@@ -296,8 +274,8 @@ class ThreadManager::Worker: public Runnable {
 
             /* If we have a pending task max and we just dropped below it, wakeup any
                thread that might be blocked on add. */
-            if (manager_->pendingTaskCountMax_ != 0 &&
-                manager_->tasks_.size() <= manager_->pendingTaskCountMax_ - 1) {
+            if (manager_->pendingTaskCountMax_ != 0
+                && manager_->tasks_.size() <= manager_->pendingTaskCountMax_ - 1) {
               manager_->maxMonitor_.notify();
             }
           }
@@ -312,7 +290,7 @@ class ThreadManager::Worker: public Runnable {
         if (task->state_ == ThreadManager::Task::EXECUTING) {
           try {
             task->run();
-          } catch(...) {
+          } catch (...) {
             // XXX need to log this
           }
         }
@@ -330,18 +308,18 @@ class ThreadManager::Worker: public Runnable {
     return;
   }
 
-  private:
-    ThreadManager::Impl* manager_;
-    friend class ThreadManager::Impl;
-    STATE state_;
-    bool idle_;
+private:
+  ThreadManager::Impl* manager_;
+  friend class ThreadManager::Impl;
+  STATE state_;
+  bool idle_;
 };
 
-
-  void ThreadManager::Impl::addWorker(size_t value) {
+void ThreadManager::Impl::addWorker(size_t value) {
   std::set<shared_ptr<Thread> > newThreads;
   for (size_t ix = 0; ix < value; ix++) {
-    shared_ptr<ThreadManager::Worker> worker = shared_ptr<ThreadManager::Worker>(new ThreadManager::Worker(this));
+    shared_ptr<ThreadManager::Worker> worker
+        = shared_ptr<ThreadManager::Worker>(new ThreadManager::Worker(this));
     newThreads.insert(threadFactory_->newThread(worker));
   }
 
@@ -351,8 +329,10 @@ class ThreadManager::Worker: public Runnable {
     workers_.insert(newThreads.begin(), newThreads.end());
   }
 
-  for (std::set<shared_ptr<Thread> >::iterator ix = newThreads.begin(); ix != newThreads.end(); ix++) {
-    shared_ptr<ThreadManager::Worker> worker = dynamic_pointer_cast<ThreadManager::Worker, Runnable>((*ix)->runnable());
+  for (std::set<shared_ptr<Thread> >::iterator ix = newThreads.begin(); ix != newThreads.end();
+       ix++) {
+    shared_ptr<ThreadManager::Worker> worker
+        = dynamic_pointer_cast<ThreadManager::Worker, Runnable>((*ix)->runnable());
     worker->state_ = ThreadManager::Worker::STARTING;
     (*ix)->start();
     idMap_.insert(std::pair<const Thread::id_t, shared_ptr<Thread> >((*ix)->getId(), *ix));
@@ -396,9 +376,8 @@ void ThreadManager::Impl::stopImpl(bool join) {
 
   {
     Synchronized s(monitor_);
-    if (state_ != ThreadManager::STOPPING &&
-        state_ != ThreadManager::JOINING &&
-        state_ != ThreadManager::STOPPED) {
+    if (state_ != ThreadManager::STOPPING && state_ != ThreadManager::JOINING
+        && state_ != ThreadManager::STOPPED) {
       doStop = true;
       state_ = join ? ThreadManager::JOINING : ThreadManager::STOPPING;
     }
@@ -416,7 +395,6 @@ void ThreadManager::Impl::stopImpl(bool join) {
     Synchronized s(monitor_);
     state_ = ThreadManager::STOPPED;
   }
-
 }
 
 void ThreadManager::Impl::removeWorker(size_t value) {
@@ -445,7 +423,9 @@ void ThreadManager::Impl::removeWorker(size_t value) {
       workerMonitor_.wait();
     }
 
-    for (std::set<shared_ptr<Thread> >::iterator ix = deadWorkers_.begin(); ix != deadWorkers_.end(); ix++) {
+    for (std::set<shared_ptr<Thread> >::iterator ix = deadWorkers_.begin();
+         ix != deadWorkers_.end();
+         ix++) {
       idMap_.erase((*ix)->getId());
       workers_.erase(*ix);
     }
@@ -454,60 +434,61 @@ void ThreadManager::Impl::removeWorker(size_t value) {
   }
 }
 
-  bool ThreadManager::Impl::canSleep() {
-    const Thread::id_t id = threadFactory_->getCurrentThreadId();
-    return idMap_.find(id) == idMap_.end();
-  }
+bool ThreadManager::Impl::canSleep() {
+  const Thread::id_t id = threadFactory_->getCurrentThreadId();
+  return idMap_.find(id) == idMap_.end();
+}
 
-  void ThreadManager::Impl::add(shared_ptr<Runnable> value,
-                                int64_t timeout,
-                                int64_t expiration) {
-    Guard g(mutex_, timeout);
+void ThreadManager::Impl::add(shared_ptr<Runnable> value, int64_t timeout, int64_t expiration) {
+  Guard g(mutex_, timeout);
 
-    if (!g) {
-      throw TimedOutException();
-    }
+  if (!g) {
+    throw TimedOutException();
+  }
 
-    if (state_ != ThreadManager::STARTED) {
-      throw IllegalStateException("ThreadManager::Impl::add ThreadManager "
-                                  "not started");
-    }
+  if (state_ != ThreadManager::STARTED) {
+    throw IllegalStateException(
+        "ThreadManager::Impl::add ThreadManager "
+        "not started");
+  }
 
-    removeExpiredTasks();
-    if (pendingTaskCountMax_ > 0 && (tasks_.size() >= pendingTaskCountMax_)) {
-      if (canSleep() && timeout >= 0) {
-        while (pendingTaskCountMax_ > 0 && tasks_.size() >= pendingTaskCountMax_) {
-          // This is thread safe because the mutex is shared between monitors.
-          maxMonitor_.wait(timeout);
-        }
-      } else {
-        throw TooManyPendingTasksException();
+  removeExpiredTasks();
+  if (pendingTaskCountMax_ > 0 && (tasks_.size() >= pendingTaskCountMax_)) {
+    if (canSleep() && timeout >= 0) {
+      while (pendingTaskCountMax_ > 0 && tasks_.size() >= pendingTaskCountMax_) {
+        // This is thread safe because the mutex is shared between monitors.
+        maxMonitor_.wait(timeout);
       }
+    } else {
+      throw TooManyPendingTasksException();
     }
+  }
 
-    tasks_.push(shared_ptr<ThreadManager::Task>(new ThreadManager::Task(value, expiration)));
+  tasks_.push(shared_ptr<ThreadManager::Task>(new ThreadManager::Task(value, expiration)));
 
-    // If idle thread is available notify it, otherwise all worker threads are
-    // running and will get around to this task in time.
-    if (idleCount_ > 0) {
-      monitor_.notify();
-    }
+  // If idle thread is available notify it, otherwise all worker threads are
+  // running and will get around to this task in time.
+  if (idleCount_ > 0) {
+    monitor_.notify();
   }
+}
 
 void ThreadManager::Impl::remove(shared_ptr<Runnable> task) {
-  (void) task;
+  (void)task;
   Synchronized s(monitor_);
   if (state_ != ThreadManager::STARTED) {
-    throw IllegalStateException("ThreadManager::Impl::remove ThreadManager not "
-                                "started");
+    throw IllegalStateException(
+        "ThreadManager::Impl::remove ThreadManager not "
+        "started");
   }
 }
 
 boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() {
   Guard g(mutex_);
   if (state_ != ThreadManager::STARTED) {
-    throw IllegalStateException("ThreadManager::Impl::removeNextPending "
-                                "ThreadManager not started");
+    throw IllegalStateException(
+        "ThreadManager::Impl::removeNextPending "
+        "ThreadManager not started");
   }
 
   if (tasks_.empty()) {
@@ -543,18 +524,15 @@ void ThreadManager::Impl::removeExpiredTasks() {
   }
 }
 
-
 void ThreadManager::Impl::setExpireCallback(ExpireCallback expireCallback) {
   expireCallback_ = expireCallback;
 }
 
 class SimpleThreadManager : public ThreadManager::Impl {
 
- public:
-  SimpleThreadManager(size_t workerCount=4, size_t pendingTaskCountMax=0) :
-    workerCount_(workerCount),
-    pendingTaskCountMax_(pendingTaskCountMax) {
-  }
+public:
+  SimpleThreadManager(size_t workerCount = 4, size_t pendingTaskCountMax = 0)
+    : workerCount_(workerCount), pendingTaskCountMax_(pendingTaskCountMax) {}
 
   void start() {
     ThreadManager::Impl::pendingTaskCountMax(pendingTaskCountMax_);
@@ -562,20 +540,20 @@ class SimpleThreadManager : public ThreadManager::Impl {
     addWorker(workerCount_);
   }
 
- private:
+private:
   const size_t workerCount_;
   const size_t pendingTaskCountMax_;
   Monitor monitor_;
 };
 
-
 shared_ptr<ThreadManager> ThreadManager::newThreadManager() {
   return shared_ptr<ThreadManager>(new ThreadManager::Impl());
 }
 
-shared_ptr<ThreadManager> ThreadManager::newSimpleThreadManager(size_t count, size_t pendingTaskCountMax) {
+shared_ptr<ThreadManager> ThreadManager::newSimpleThreadManager(size_t count,
+                                                                size_t pendingTaskCountMax) {
   return shared_ptr<ThreadManager>(new SimpleThreadManager(count, pendingTaskCountMax));
 }
-
-}}} // apache::thrift::concurrency
-
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/ThreadManager.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.h b/lib/cpp/src/thrift/concurrency/ThreadManager.h
index 0fedc88..7bb71d1 100644
--- a/lib/cpp/src/thrift/concurrency/ThreadManager.h
+++ b/lib/cpp/src/thrift/concurrency/ThreadManager.h
@@ -25,7 +25,9 @@
 #include <sys/types.h>
 #include <thrift/concurrency/Thread.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Thread Pool Manager and related classes
@@ -53,10 +55,10 @@ class ThreadManager;
  */
 class ThreadManager {
 
- protected:
+protected:
   ThreadManager() {}
 
- public:
+public:
   typedef apache::thrift::stdcxx::function<void(boost::shared_ptr<Runnable>)> ExpireCallback;
 
   virtual ~ThreadManager() {}
@@ -83,14 +85,7 @@ class ThreadManager {
    */
   virtual void join() = 0;
 
-  enum STATE {
-    UNINITIALIZED,
-    STARTING,
-    STARTED,
-    JOINING,
-    STOPPING,
-    STOPPED
-  };
+  enum STATE { UNINITIALIZED, STARTING, STARTED, JOINING, STOPPING, STOPPED };
 
   virtual STATE state() const = 0;
 
@@ -98,9 +93,9 @@ class ThreadManager {
 
   virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0;
 
-  virtual void addWorker(size_t value=1) = 0;
+  virtual void addWorker(size_t value = 1) = 0;
 
-  virtual void removeWorker(size_t value=1) = 0;
+  virtual void removeWorker(size_t value = 1) = 0;
 
   /**
    * Gets the current number of idle worker threads
@@ -115,7 +110,7 @@ class ThreadManager {
   /**
    * Gets the current number of pending tasks
    */
-  virtual size_t pendingTaskCount() const  = 0;
+  virtual size_t pendingTaskCount() const = 0;
 
   /**
    * Gets the current number of pending and executing tasks
@@ -151,9 +146,9 @@ class ThreadManager {
    *
    * @throws TooManyPendingTasksException Pending task count exceeds max pending task count
    */
-  virtual void add(boost::shared_ptr<Runnable>task,
-                   int64_t timeout=0LL,
-                   int64_t expiration=0LL) = 0;
+  virtual void add(boost::shared_ptr<Runnable> task,
+                   int64_t timeout = 0LL,
+                   int64_t expiration = 0LL) = 0;
 
   /**
    * Removes a pending task
@@ -187,7 +182,8 @@ class ThreadManager {
    * a pendingTaskCountMax maximum pending tasks. The default, 0, specified no limit
    * on pending tasks
    */
-  static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4, size_t pendingTaskCountMax=0);
+  static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count = 4,
+                                                                 size_t pendingTaskCountMax = 0);
 
   class Task;
 
@@ -195,7 +191,8 @@ class ThreadManager {
 
   class Impl;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_THREADMANAGER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/TimerManager.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
index 6821b2e..60b8c85 100644
--- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
@@ -25,7 +25,9 @@
 #include <iostream>
 #include <set>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 using boost::shared_ptr;
 
@@ -36,20 +38,12 @@ using boost::shared_ptr;
  */
 class TimerManager::Task : public Runnable {
 
- public:
-  enum STATE {
-    WAITING,
-    EXECUTING,
-    CANCELLED,
-    COMPLETE
-  };
+public:
+  enum STATE { WAITING, EXECUTING, CANCELLED, COMPLETE };
 
-  Task(shared_ptr<Runnable> runnable) :
-    runnable_(runnable),
-    state_(WAITING) {}
+  Task(shared_ptr<Runnable> runnable) : runnable_(runnable), state_(WAITING) {}
 
-  ~Task() {
-  }
+  ~Task() {}
 
   void run() {
     if (state_ == EXECUTING) {
@@ -58,17 +52,16 @@ class TimerManager::Task : public Runnable {
     }
   }
 
- private:
+private:
   shared_ptr<Runnable> runnable_;
   friend class TimerManager::Dispatcher;
   STATE state_;
 };
 
-class TimerManager::Dispatcher: public Runnable {
+class TimerManager::Dispatcher : public Runnable {
 
- public:
-  Dispatcher(TimerManager* manager) :
-    manager_(manager) {}
+public:
+  Dispatcher(TimerManager* manager) : manager_(manager) {}
 
   ~Dispatcher() {}
 
@@ -93,16 +86,19 @@ class TimerManager::Dispatcher: public Runnable {
         Synchronized s(manager_->monitor_);
         task_iterator expiredTaskEnd;
         int64_t now = Util::currentTime();
-        while (manager_->state_ == TimerManager::STARTED &&
-               (expiredTaskEnd = manager_->taskMap_.upper_bound(now)) == manager_->taskMap_.begin()) {
+        while (manager_->state_ == TimerManager::STARTED
+               && (expiredTaskEnd = manager_->taskMap_.upper_bound(now))
+                  == manager_->taskMap_.begin()) {
           int64_t timeout = 0LL;
           if (!manager_->taskMap_.empty()) {
             timeout = manager_->taskMap_.begin()->first - now;
           }
-          assert((timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0));
+          assert((timeout != 0 && manager_->taskCount_ > 0)
+                 || (timeout == 0 && manager_->taskCount_ == 0));
           try {
             manager_->monitor_.wait(timeout);
-          } catch (TimedOutException &) {}
+          } catch (TimedOutException&) {
+          }
           now = Util::currentTime();
         }
 
@@ -119,7 +115,9 @@ class TimerManager::Dispatcher: public Runnable {
         }
       }
 
-      for (std::set<shared_ptr<Task> >::iterator ix =  expiredTasks.begin(); ix != expiredTasks.end(); ix++) {
+      for (std::set<shared_ptr<Task> >::iterator ix = expiredTasks.begin();
+           ix != expiredTasks.end();
+           ix++) {
         (*ix)->run();
       }
 
@@ -135,20 +133,20 @@ class TimerManager::Dispatcher: public Runnable {
     return;
   }
 
- private:
+private:
   TimerManager* manager_;
   friend class TimerManager;
 };
 
 #if defined(_MSC_VER)
 #pragma warning(push)
-#pragma warning(disable: 4355) // 'this' used in base member initializer list
+#pragma warning(disable : 4355) // 'this' used in base member initializer list
 #endif
 
-TimerManager::TimerManager() :
-  taskCount_(0),
-  state_(TimerManager::UNINITIALIZED),
-  dispatcher_(shared_ptr<Dispatcher>(new Dispatcher(this))) {
+TimerManager::TimerManager()
+  : taskCount_(0),
+    state_(TimerManager::UNINITIALIZED),
+    dispatcher_(shared_ptr<Dispatcher>(new Dispatcher(this))) {
 }
 
 #if defined(_MSC_VER)
@@ -163,7 +161,7 @@ TimerManager::~TimerManager() {
   if (state_ != STOPPED) {
     try {
       stop();
-    } catch(...) {
+    } catch (...) {
       throw;
       // uhoh
     }
@@ -203,7 +201,7 @@ void TimerManager::stop() {
     Synchronized s(monitor_);
     if (state_ == TimerManager::UNINITIALIZED) {
       state_ = TimerManager::STOPPED;
-    } else if (state_ != STOPPING &&  state_ != STOPPED) {
+    } else if (state_ != STOPPING && state_ != STOPPED) {
       doStop = true;
       state_ = STOPPING;
       monitor_.notifyAll();
@@ -227,7 +225,7 @@ shared_ptr<const ThreadFactory> TimerManager::threadFactory() const {
   return threadFactory_;
 }
 
-void TimerManager::threadFactory(shared_ptr<const ThreadFactory>  value) {
+void TimerManager::threadFactory(shared_ptr<const ThreadFactory> value) {
   Synchronized s(monitor_);
   threadFactory_ = value;
 }
@@ -252,7 +250,8 @@ void TimerManager::add(shared_ptr<Runnable> task, int64_t timeout) {
     bool notifyRequired = (taskCount_ == 0) ? true : timeout < taskMap_.begin()->first;
 
     taskCount_++;
-    taskMap_.insert(std::pair<int64_t, shared_ptr<Task> >(timeout, shared_ptr<Task>(new Task(task))));
+    taskMap_.insert(
+        std::pair<int64_t, shared_ptr<Task> >(timeout, shared_ptr<Task>(new Task(task))));
 
     // If the task map was empty, or if we have an expiration that is earlier
     // than any previously seen, kick the dispatcher so it can update its
@@ -271,7 +270,7 @@ void TimerManager::add(shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC&
   int64_t now = Util::currentTime();
 
   if (expiration < now) {
-    throw  InvalidArgumentException();
+    throw InvalidArgumentException();
   }
 
   add(task, expiration - now);
@@ -285,21 +284,23 @@ void TimerManager::add(shared_ptr<Runnable> task, const struct timeval& value) {
   int64_t now = Util::currentTime();
 
   if (expiration < now) {
-    throw  InvalidArgumentException();
+    throw InvalidArgumentException();
   }
 
   add(task, expiration - now);
 }
 
 void TimerManager::remove(shared_ptr<Runnable> task) {
-  (void) task;
+  (void)task;
   Synchronized s(monitor_);
   if (state_ != TimerManager::STARTED) {
     throw IllegalStateException();
   }
 }
 
-TimerManager::STATE TimerManager::state() const { return state_; }
-
-}}} // apache::thrift::concurrency
-
+TimerManager::STATE TimerManager::state() const {
+  return state_;
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/TimerManager.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.h b/lib/cpp/src/thrift/concurrency/TimerManager.h
index d8200cb..3946827 100644
--- a/lib/cpp/src/thrift/concurrency/TimerManager.h
+++ b/lib/cpp/src/thrift/concurrency/TimerManager.h
@@ -28,7 +28,9 @@
 #include <map>
 #include <time.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Timer Manager
@@ -39,8 +41,7 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class TimerManager {
 
- public:
-
+public:
   TimerManager();
 
   virtual ~TimerManager();
@@ -61,7 +62,7 @@ class TimerManager {
    */
   virtual void stop();
 
-  virtual size_t taskCount() const ;
+  virtual size_t taskCount() const;
 
   /**
    * Adds a task to be executed at some time in the future by a worker thread.
@@ -99,17 +100,11 @@ class TimerManager {
    */
   virtual void remove(boost::shared_ptr<Runnable> task);
 
-  enum STATE {
-    UNINITIALIZED,
-    STARTING,
-    STARTED,
-    STOPPING,
-    STOPPED
-  };
+  enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED };
 
   virtual STATE state() const;
 
- private:
+private:
   boost::shared_ptr<const ThreadFactory> threadFactory_;
   class Task;
   friend class Task;
@@ -124,7 +119,8 @@ class TimerManager {
   typedef std::multimap<int64_t, boost::shared_ptr<TimerManager::Task> >::iterator task_iterator;
   typedef std::pair<task_iterator, task_iterator> task_range;
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_TIMERMANAGER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Util.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Util.cpp b/lib/cpp/src/thrift/concurrency/Util.cpp
index 7d9085e..dd6d19f 100644
--- a/lib/cpp/src/thrift/concurrency/Util.cpp
+++ b/lib/cpp/src/thrift/concurrency/Util.cpp
@@ -26,16 +26,19 @@
 #include <sys/time.h>
 #endif
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 int64_t Util::currentTimeTicks(int64_t ticksPerSec) {
   int64_t result;
   struct timeval now;
   int ret = THRIFT_GETTIMEOFDAY(&now, NULL);
   assert(ret == 0);
-  THRIFT_UNUSED_VARIABLE(ret); //squelching "unused variable" warning
+  THRIFT_UNUSED_VARIABLE(ret); // squelching "unused variable" warning
   toTicks(result, now, ticksPerSec);
   return result;
 }
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/Util.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/Util.h b/lib/cpp/src/thrift/concurrency/Util.h
index 63d80a2..ba070b6 100644
--- a/lib/cpp/src/thrift/concurrency/Util.h
+++ b/lib/cpp/src/thrift/concurrency/Util.h
@@ -31,7 +31,9 @@
 
 #include <thrift/transport/PlatformSocket.h>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Utility methods
@@ -55,8 +57,7 @@ class Util {
   static const int64_t NS_PER_US = NS_PER_S / US_PER_S;
   static const int64_t US_PER_MS = US_PER_S / MS_PER_S;
 
- public:
-
+public:
   /**
    * Converts millisecond timestamp into a THRIFT_TIMESPEC struct
    *
@@ -64,17 +65,20 @@ class Util {
    * @param time or duration in milliseconds
    */
   static void toTimespec(struct THRIFT_TIMESPEC& result, int64_t value) {
-    result.tv_sec = value / MS_PER_S; // ms to s
+    result.tv_sec = value / MS_PER_S;                // ms to s
     result.tv_nsec = (value % MS_PER_S) * NS_PER_MS; // ms to ns
   }
 
   static void toTimeval(struct timeval& result, int64_t value) {
-    result.tv_sec  = static_cast<uint32_t>(value / MS_PER_S); // ms to s
+    result.tv_sec = static_cast<uint32_t>(value / MS_PER_S);                // ms to s
     result.tv_usec = static_cast<uint32_t>((value % MS_PER_S) * US_PER_MS); // ms to us
   }
 
-  static void toTicks(int64_t& result, int64_t secs, int64_t oldTicks,
-                      int64_t oldTicksPerSec, int64_t newTicksPerSec) {
+  static void toTicks(int64_t& result,
+                      int64_t secs,
+                      int64_t oldTicks,
+                      int64_t oldTicksPerSec,
+                      int64_t newTicksPerSec) {
     result = secs * newTicksPerSec;
     result += oldTicks * newTicksPerSec / oldTicksPerSec;
 
@@ -86,34 +90,28 @@ class Util {
   /**
    * Converts struct THRIFT_TIMESPEC to arbitrary-sized ticks since epoch
    */
-  static void toTicks(int64_t& result,
-                      const struct THRIFT_TIMESPEC& value,
-                      int64_t ticksPerSec) {
+  static void toTicks(int64_t& result, const struct THRIFT_TIMESPEC& value, int64_t ticksPerSec) {
     return toTicks(result, value.tv_sec, value.tv_nsec, NS_PER_S, ticksPerSec);
   }
 
   /**
    * Converts struct timeval to arbitrary-sized ticks since epoch
    */
-  static void toTicks(int64_t& result,
-                      const struct timeval& value,
-                      int64_t ticksPerSec) {
+  static void toTicks(int64_t& result, const struct timeval& value, int64_t ticksPerSec) {
     return toTicks(result, value.tv_sec, value.tv_usec, US_PER_S, ticksPerSec);
   }
 
   /**
    * Converts struct THRIFT_TIMESPEC to milliseconds
    */
-  static void toMilliseconds(int64_t& result,
-                             const struct THRIFT_TIMESPEC& value) {
+  static void toMilliseconds(int64_t& result, const struct THRIFT_TIMESPEC& value) {
     return toTicks(result, value, MS_PER_S);
   }
 
   /**
    * Converts struct timeval to milliseconds
    */
-  static void toMilliseconds(int64_t& result,
-                             const struct timeval& value) {
+  static void toMilliseconds(int64_t& result, const struct timeval& value) {
     return toTicks(result, value, MS_PER_S);
   }
 
@@ -146,7 +144,8 @@ class Util {
    */
   static int64_t currentTimeUsec() { return currentTimeTicks(US_PER_S); }
 };
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency
 
 #endif // #ifndef _THRIFT_CONCURRENCY_UTIL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/cxxfunctional.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h
index c24b91b..dadaac3 100644
--- a/lib/cpp/src/thrift/cxxfunctional.h
+++ b/lib/cpp/src/thrift/cxxfunctional.h
@@ -20,6 +20,8 @@
 #ifndef _THRIFT_CXXFUNCTIONAL_H_
 #define _THRIFT_CXXFUNCTIONAL_H_ 1
 
+// clang-format off
+
 /**
  * Loads <functional> from the 'right' location, depending
  * on compiler and whether or not it's using C++03 with TR1


[35/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index dbebedb..a97267e 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -38,7 +38,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /* forward declarations */
 string initial_caps_to_underscores(string name);
@@ -50,15 +50,14 @@ string to_lower_case(string name);
  * C code generator, using glib for C typing.
  */
 class t_c_glib_generator : public t_oop_generator {
- public:
-
+public:
   /* constructor */
-  t_c_glib_generator(t_program *program,
-                     const map<string, string> &parsed_options,
-                     const string &option_string) : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+  t_c_glib_generator(t_program* program,
+                     const map<string, string>& parsed_options,
+                     const string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     /* set the output directory */
     this->out_dir_base_ = "gen-c_glib";
 
@@ -72,7 +71,7 @@ class t_c_glib_generator : public t_oop_generator {
       this->nspace_lc = "";
     } else {
       /* replace dots with underscores */
-      char *tmp = strdup(this->nspace.c_str());
+      char* tmp = strdup(this->nspace.c_str());
       for (unsigned int i = 0; i < strlen(tmp); i++) {
         if (tmp[i] == '.') {
           tmp[i] = '_';
@@ -101,15 +100,14 @@ class t_c_glib_generator : public t_oop_generator {
   void close_generator();
 
   /* generation functions */
-  void generate_typedef(t_typedef *ttypedef);
-  void generate_enum(t_enum *tenum);
-  void generate_consts(vector<t_const *> consts);
-  void generate_struct(t_struct *tstruct);
-  void generate_service(t_service *tservice);
-  void generate_xception(t_struct *tstruct);
-
- private:
-
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_consts(vector<t_const*> consts);
+  void generate_struct(t_struct* tstruct);
+  void generate_service(t_service* tservice);
+  void generate_xception(t_struct* tstruct);
+
+private:
   /* file streams */
   ofstream f_types_;
   ofstream f_types_impl_;
@@ -123,50 +121,87 @@ class t_c_glib_generator : public t_oop_generator {
   string nspace_lc;
 
   /* helper functions */
-  bool is_complex_type(t_type *ttype);
-  string type_name(t_type* ttype, bool in_typedef=false, bool is_const=false);
-  string property_type_name(t_type* ttype, bool in_typedef=false, bool is_const=false);
-  string base_type_name(t_base_type *type);
-  string type_to_enum(t_type *type);
-  string constant_literal(t_type *type, t_const_value *value);
-  string constant_value(string name, t_type *type, t_const_value *value);
-  string function_signature(t_function *tfunction);
-  string argument_list(t_struct *tstruct);
-  string xception_list(t_struct *tstruct);
-  string declare_field(t_field *tfield, bool init=false, bool pointer=false, bool constant=false, bool reference=false);
-  void declare_local_variable(ofstream &out, t_type *ttype, string &base_name);
+  bool is_complex_type(t_type* ttype);
+  string type_name(t_type* ttype, bool in_typedef = false, bool is_const = false);
+  string property_type_name(t_type* ttype, bool in_typedef = false, bool is_const = false);
+  string base_type_name(t_base_type* type);
+  string type_to_enum(t_type* type);
+  string constant_literal(t_type* type, t_const_value* value);
+  string constant_value(string name, t_type* type, t_const_value* value);
+  string function_signature(t_function* tfunction);
+  string argument_list(t_struct* tstruct);
+  string xception_list(t_struct* tstruct);
+  string declare_field(t_field* tfield,
+                       bool init = false,
+                       bool pointer = false,
+                       bool constant = false,
+                       bool reference = false);
+  void declare_local_variable(ofstream& out, t_type* ttype, string& base_name);
 
   /* generation functions */
-  void generate_const_initializer(string name, t_type *type, t_const_value *value);
-  void generate_service_helpers(t_service *tservice);
-  void generate_service_client(t_service *tservice);
-  void generate_service_handler(t_service *tservice);
-  void generate_service_processor(t_service *tservice);
-  void generate_service_server(t_service *tservice);
-  void generate_object(t_struct *tstruct);
-  void generate_struct_writer(ofstream &out, t_struct *tstruct, string this_name, string this_get="", bool is_function=true);
-  void generate_struct_reader(ofstream &out, t_struct *tstruct, string this_name, string this_get="", bool is_function=true);
-
-  void generate_serialize_field(ofstream &out, t_field *tfield, string prefix, string suffix, int error_ret);
-  void generate_serialize_struct(ofstream &out, t_struct *tstruct, string prefix, int error_ret);
-  void generate_serialize_container(ofstream &out, t_type *ttype, string prefix, int error_ret);
-  void generate_serialize_map_element(ofstream &out, t_map *tmap, string key, string value, int error_ret);
-  void generate_serialize_set_element(ofstream &out, t_set *tset, string element, int error_ret);
-  void generate_serialize_list_element(ofstream &out, t_list *tlist, string list, string index, int error_ret);
-
-  void generate_deserialize_field(ofstream &out, t_field *tfield, string prefix, string suffix, int error_ret, bool allocate=true);
-  void generate_deserialize_struct(ofstream &out, t_struct *tstruct, string prefix, int error_ret, bool allocate=true);
-  void generate_deserialize_container(ofstream &out, t_type *ttype, string prefix, int error_ret);
-  void generate_deserialize_map_element(ofstream &out, t_map *tmap, string prefix, int error_ret);
-  void generate_deserialize_set_element(ofstream &out, t_set *tset, string prefix, int error_ret);
-  void generate_deserialize_list_element(ofstream &out, t_list *tlist, string prefix, string index, int error_ret);
-
-  string generate_new_hash_from_type(t_type * key, t_type * value);
-  string generate_new_array_from_type(t_type * ttype);
-
-  string generate_free_func_from_type(t_type * ttype);
-  string generate_hash_func_from_type(t_type * ttype);
-  string generate_cmp_func_from_type(t_type * ttype);
+  void generate_const_initializer(string name, t_type* type, t_const_value* value);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_handler(t_service* tservice);
+  void generate_service_processor(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_object(t_struct* tstruct);
+  void generate_struct_writer(ofstream& out,
+                              t_struct* tstruct,
+                              string this_name,
+                              string this_get = "",
+                              bool is_function = true);
+  void generate_struct_reader(ofstream& out,
+                              t_struct* tstruct,
+                              string this_name,
+                              string this_get = "",
+                              bool is_function = true);
+
+  void generate_serialize_field(ofstream& out,
+                                t_field* tfield,
+                                string prefix,
+                                string suffix,
+                                int error_ret);
+  void generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix, int error_ret);
+  void generate_serialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
+  void generate_serialize_map_element(ofstream& out,
+                                      t_map* tmap,
+                                      string key,
+                                      string value,
+                                      int error_ret);
+  void generate_serialize_set_element(ofstream& out, t_set* tset, string element, int error_ret);
+  void generate_serialize_list_element(ofstream& out,
+                                       t_list* tlist,
+                                       string list,
+                                       string index,
+                                       int error_ret);
+
+  void generate_deserialize_field(ofstream& out,
+                                  t_field* tfield,
+                                  string prefix,
+                                  string suffix,
+                                  int error_ret,
+                                  bool allocate = true);
+  void generate_deserialize_struct(ofstream& out,
+                                   t_struct* tstruct,
+                                   string prefix,
+                                   int error_ret,
+                                   bool allocate = true);
+  void generate_deserialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
+  void generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix, int error_ret);
+  void generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix, int error_ret);
+  void generate_deserialize_list_element(ofstream& out,
+                                         t_list* tlist,
+                                         string prefix,
+                                         string index,
+                                         int error_ret);
+
+  string generate_new_hash_from_type(t_type* key, t_type* value);
+  string generate_new_array_from_type(t_type* ttype);
+
+  string generate_free_func_from_type(t_type* ttype);
+  string generate_hash_func_from_type(t_type* ttype);
+  string generate_cmp_func_from_type(t_type* ttype);
 };
 
 /**
@@ -182,11 +217,9 @@ void t_c_glib_generator::init_generator() {
   string program_name_lc = to_lower_case(program_name_u);
 
   /* create output files */
-  string f_types_name = get_out_dir() + this->nspace_lc
-                        + program_name_lc + "_types.h";
+  string f_types_name = get_out_dir() + this->nspace_lc + program_name_lc + "_types.h";
   f_types_.open(f_types_name.c_str());
-  string f_types_impl_name = get_out_dir() + this->nspace_lc
-                             + program_name_lc + "_types.c";
+  string f_types_impl_name = get_out_dir() + this->nspace_lc + program_name_lc + "_types.c";
   f_types_impl_.open(f_types_impl_name.c_str());
 
   /* add thrift boilerplate headers */
@@ -194,70 +227,53 @@ void t_c_glib_generator::init_generator() {
   f_types_impl_ << autogen_comment();
 
   /* include inclusion guard */
-  f_types_ <<
-    "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
-    "#define " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl <<
-    endl;
+  f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << "#define "
+           << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << endl;
 
   /* include base types */
-  f_types_ <<
-    "/* base includes */" << endl <<
-    "#include <glib-object.h>" << endl <<
-    "#include <thrift/c_glib/thrift_struct.h>" << endl <<
-    "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
+  f_types_ << "/* base includes */" << endl << "#include <glib-object.h>" << endl
+           << "#include <thrift/c_glib/thrift_struct.h>" << endl
+           << "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
 
   /* include other thrift includes */
-  const vector<t_program *> &includes = program_->get_includes();
+  const vector<t_program*>& includes = program_->get_includes();
   for (size_t i = 0; i < includes.size(); ++i) {
-    f_types_ <<
-      "/* other thrift includes */" << endl <<
-      "#include \"" << this->nspace_lc << initial_caps_to_underscores(includes[i]->get_name()) <<
-          "_types.h\"" << endl;
+    f_types_ << "/* other thrift includes */" << endl << "#include \"" << this->nspace_lc
+             << initial_caps_to_underscores(includes[i]->get_name()) << "_types.h\"" << endl;
   }
   f_types_ << endl;
 
   /* include custom headers */
-  const vector<string> &c_includes = program_->get_c_includes();
+  const vector<string>& c_includes = program_->get_c_includes();
   f_types_ << "/* custom thrift includes */" << endl;
   for (size_t i = 0; i < c_includes.size(); ++i) {
     if (c_includes[i][0] == '<') {
-      f_types_ <<
-        "#include " << c_includes[i] << endl;
+      f_types_ << "#include " << c_includes[i] << endl;
     } else {
-      f_types_ <<
-        "#include \"" << c_includes[i] << "\"" << endl;
+      f_types_ << "#include \"" << c_includes[i] << "\"" << endl;
     }
   }
   f_types_ << endl;
 
   /* include math.h (for "INFINITY") in the implementation file, in case we
      encounter a struct with a member of type double */
-  f_types_impl_ <<
-    endl <<
-    "#include <math.h>" << endl;
+  f_types_impl_ << endl << "#include <math.h>" << endl;
 
   // include the types file
-  f_types_impl_ <<
-    endl <<
-    "#include \"" << this->nspace_lc << program_name_u <<
-        "_types.h\"" << endl <<
-    "#include <thrift/c_glib/thrift.h>" << endl <<
-    endl;
-
-  f_types_ <<
-    "/* begin types */" << endl << endl;
+  f_types_impl_ << endl << "#include \"" << this->nspace_lc << program_name_u << "_types.h\""
+                << endl << "#include <thrift/c_glib/thrift.h>" << endl << endl;
+
+  f_types_ << "/* begin types */" << endl << endl;
 }
 
 /**
  *  Finish up generation and close all file streams.
  */
 void t_c_glib_generator::close_generator() {
-  string program_name_uc = to_upper_case
-    (initial_caps_to_underscores(program_name_));
+  string program_name_uc = to_upper_case(initial_caps_to_underscores(program_name_));
 
   /* end the header inclusion guard */
-  f_types_ <<
-    "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl;
+  f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl;
 
   /* close output file */
   f_types_.close();
@@ -274,10 +290,8 @@ void t_c_glib_generator::close_generator() {
  * typedef GHashTable * ThriftSomeMap;
  */
 void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_ <<
-    indent() << "typedef " << type_name(ttypedef->get_type(), true) <<
-        " " << this->nspace << ttypedef->get_symbolic() << ";" << endl <<
-    endl;
+  f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << this->nspace
+           << ttypedef->get_symbolic() << ";" << endl << endl;
 }
 
 /**
@@ -296,17 +310,16 @@ void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
  * };
  * typedef enum _ThriftMyEnum ThriftMyEnum;
  */
-void t_c_glib_generator::generate_enum(t_enum *tenum) {
+void t_c_glib_generator::generate_enum(t_enum* tenum) {
   string name = tenum->get_name();
   string name_uc = to_upper_case(initial_caps_to_underscores(name));
 
-  f_types_ <<
-    indent() << "enum _" << this->nspace << name << " {" << endl;
+  f_types_ << indent() << "enum _" << this->nspace << name << " {" << endl;
 
   indent_up();
 
-  vector<t_enum_value *> constants = tenum->get_constants();
-  vector<t_enum_value *>::iterator c_iter;
+  vector<t_enum_value*> constants = tenum->get_constants();
+  vector<t_enum_value*>::iterator c_iter;
   bool first = true;
 
   /* output each of the enumeration elements */
@@ -317,32 +330,28 @@ void t_c_glib_generator::generate_enum(t_enum *tenum) {
       f_types_ << "," << endl;
     }
 
-    f_types_ <<
-      indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name();
-    f_types_ <<
-      " = " << (*c_iter)->get_value();
+    f_types_ << indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name();
+    f_types_ << " = " << (*c_iter)->get_value();
   }
 
   indent_down();
-  f_types_ <<
-    endl <<
-    "};" << endl <<
-    "typedef enum _" << this->nspace << name << " " << this->nspace << name << ";" << endl <<
-    endl;
+  f_types_ << endl << "};" << endl << "typedef enum _" << this->nspace << name << " "
+           << this->nspace << name << ";" << endl << endl;
 
   f_types_ << "/* return the name of the constant */" << endl;
   f_types_ << "const char *" << endl;
-  f_types_ << "toString_"<<name<<"(int value); "<<endl<<endl;;
+  f_types_ << "toString_" << name << "(int value); " << endl << endl;
+  ;
   f_types_impl_ << "/* return the name of the constant */" << endl;
   f_types_impl_ << "const char *" << endl;
-  f_types_impl_ << "toString_"<<name<<"(int value) "<<endl;
+  f_types_impl_ << "toString_" << name << "(int value) " << endl;
   f_types_impl_ << "{" << endl;
   f_types_impl_ << "  static __thread char buf[16] = {0};" << endl;
   f_types_impl_ << "  switch(value) {" << endl;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
-    f_types_impl_ << "  case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
-        << ":" << "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
-        << "\";"<<endl;
+    f_types_impl_ << "  case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name() << ":"
+                  << "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
+                  << "\";" << endl;
   }
   f_types_impl_ << "  default: g_snprintf(buf, 16, \"%d\", value); return buf;" << endl;
   f_types_impl_ << "  }" << endl;
@@ -352,23 +361,22 @@ void t_c_glib_generator::generate_enum(t_enum *tenum) {
 /**
  * Generates Thrift constants in C code.
  */
-void t_c_glib_generator::generate_consts (vector<t_const *> consts) {
+void t_c_glib_generator::generate_consts(vector<t_const*> consts) {
   f_types_ << "/* constants */" << endl;
   f_types_impl_ << "/* constants */" << endl;
 
-  vector<t_const *>::iterator c_iter;
+  vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     string name_uc = to_upper_case(name);
     string name_lc = to_lower_case(name);
-    t_type *type = (*c_iter)->get_type();
-    t_const_value *value = (*c_iter)->get_value();
+    t_type* type = (*c_iter)->get_type();
+    t_const_value* value = (*c_iter)->get_value();
 
-    f_types_ <<
-      indent() << "#define " << this->nspace_uc << name_uc << " " <<
-          constant_value (name_lc, type, value) << endl;
+    f_types_ << indent() << "#define " << this->nspace_uc << name_uc << " "
+             << constant_value(name_lc, type, value) << endl;
 
-    generate_const_initializer (name_lc, type, value);
+    generate_const_initializer(name_lc, type, value);
   }
 
   f_types_ << endl;
@@ -396,7 +404,7 @@ void t_c_glib_generator::generate_consts (vector<t_const *> consts) {
  * typedef struct _ThriftBonk ThriftBonk
  * // ... additional GObject boilerplate ...
  */
-void t_c_glib_generator::generate_struct (t_struct *tstruct) {
+void t_c_glib_generator::generate_struct(t_struct* tstruct) {
   f_types_ << "/* struct " << tstruct->get_name() << " */" << endl;
   generate_object(tstruct);
 }
@@ -405,7 +413,7 @@ void t_c_glib_generator::generate_struct (t_struct *tstruct) {
  * Generate C code to represent Thrift services.  Creates a new GObject
  * which can be used to access the service.
  */
-void t_c_glib_generator::generate_service (t_service *tservice) {
+void t_c_glib_generator::generate_service(t_service* tservice) {
   string svcname_u = initial_caps_to_underscores(tservice->get_name());
   string svcname_uc = this->nspace_uc + to_upper_case(svcname_u);
   string filename = this->nspace_lc + to_lower_case(svcname_u);
@@ -418,27 +426,22 @@ void t_c_glib_generator::generate_service (t_service *tservice) {
   string program_name_lc = to_lower_case(program_name_u);
 
   // add header file boilerplate
-  f_header_ <<
-    autogen_comment();
+  f_header_ << autogen_comment();
 
   // add an inclusion guard
-  f_header_ <<
-    "#ifndef " << svcname_uc << "_H" << endl <<
-    "#define " << svcname_uc << "_H" << endl <<
-    endl;
+  f_header_ << "#ifndef " << svcname_uc << "_H" << endl << "#define " << svcname_uc << "_H" << endl
+            << endl;
 
   // add standard includes
-  f_header_ <<
-    "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << endl <<
-    endl;
-  f_header_ <<
-    "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl;
+  f_header_ << "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << endl << endl;
+  f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl;
 
   // if we are inheriting from another service, include its header
-  t_service *extends_service = tservice->get_extends();
+  t_service* extends_service = tservice->get_extends();
   if (extends_service != NULL) {
-    f_header_ <<
-      "#include \"" << this->nspace_lc << to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\"" << endl;
+    f_header_ << "#include \"" << this->nspace_lc
+              << to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\""
+              << endl;
   }
   f_header_ << endl;
 
@@ -447,29 +450,24 @@ void t_c_glib_generator::generate_service (t_service *tservice) {
   f_service_.open(f_service_name.c_str());
 
   // add the boilerplace header
-  f_service_ <<
-    autogen_comment();
+  f_service_ << autogen_comment();
 
   // include the headers
-  f_service_ <<
-    "#include <string.h>" << endl <<
-    "#include <thrift/c_glib/thrift.h>" << endl <<
-    "#include <thrift/c_glib/thrift_application_exception.h>" << endl <<
-    "#include \"" << filename << ".h\"" << endl <<
-    endl;
+  f_service_ << "#include <string.h>" << endl << "#include <thrift/c_glib/thrift.h>" << endl
+             << "#include <thrift/c_glib/thrift_application_exception.h>" << endl << "#include \""
+             << filename << ".h\"" << endl << endl;
 
   // generate the service-helper classes
-  generate_service_helpers (tservice);
+  generate_service_helpers(tservice);
 
   // generate the client objects
-  generate_service_client (tservice);
+  generate_service_client(tservice);
 
   // generate the server objects
-  generate_service_server (tservice);
+  generate_service_server(tservice);
 
   // end the header inclusion guard
-  f_header_ <<
-    "#endif /* " << svcname_uc << "_H */" << endl;
+  f_header_ << "#endif /* " << svcname_uc << "_H */" << endl;
 
   // close the files
   f_service_.close();
@@ -479,7 +477,7 @@ void t_c_glib_generator::generate_service (t_service *tservice) {
 /**
  *
  */
-void t_c_glib_generator::generate_xception (t_struct *tstruct) {
+void t_c_glib_generator::generate_xception(t_struct* tstruct) {
   string name = tstruct->get_name();
   string name_u = initial_caps_to_underscores(name);
   string name_lc = to_lower_case(name_u);
@@ -487,29 +485,18 @@ void t_c_glib_generator::generate_xception (t_struct *tstruct) {
 
   generate_object(tstruct);
 
-  f_types_ << "/* exception */" << endl <<
-    "typedef enum" << endl <<
-    "{" << endl <<
-    "  " << this->nspace_uc << name_uc << "_ERROR_CODE," << endl <<
-    "} " << this->nspace << name << "Error;" << endl <<
-    endl <<
-    "GQuark " << this->nspace_lc << name_lc << "_error_quark (void);" << endl <<
-    "#define " << this->nspace_uc << name_uc << "_ERROR (" <<
-      this->nspace_lc << name_lc << "_error_quark())" << endl <<
-    endl <<
-    endl;
-
-  f_types_impl_ <<
-    "/* define the GError domain for exceptions */" << endl <<
-    "#define " << this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" <<
-        this->nspace_lc << name_lc << "_error_quark\"" << endl <<
-    "GQuark" << endl <<
-    this->nspace_lc << name_lc << "_error_quark (void)" << endl <<
-    "{" << endl <<
-    "  return g_quark_from_static_string (" << this->nspace_uc << name_uc <<
-        "_ERROR_DOMAIN);" << endl <<
-    "}" << endl <<
-    endl;
+  f_types_ << "/* exception */" << endl << "typedef enum" << endl << "{" << endl << "  "
+           << this->nspace_uc << name_uc << "_ERROR_CODE," << endl << "} " << this->nspace << name
+           << "Error;" << endl << endl << "GQuark " << this->nspace_lc << name_lc
+           << "_error_quark (void);" << endl << "#define " << this->nspace_uc << name_uc
+           << "_ERROR (" << this->nspace_lc << name_lc << "_error_quark())" << endl << endl << endl;
+
+  f_types_impl_ << "/* define the GError domain for exceptions */" << endl << "#define "
+                << this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" << this->nspace_lc << name_lc
+                << "_error_quark\"" << endl << "GQuark" << endl << this->nspace_lc << name_lc
+                << "_error_quark (void)" << endl << "{" << endl
+                << "  return g_quark_from_static_string (" << this->nspace_uc << name_uc
+                << "_ERROR_DOMAIN);" << endl << "}" << endl << endl;
 }
 
 /********************
@@ -519,22 +506,19 @@ void t_c_glib_generator::generate_xception (t_struct *tstruct) {
 /**
  * Returns true if ttype is not a primitive.
  */
-bool t_c_glib_generator::is_complex_type(t_type *ttype) {
-  ttype = get_true_type (ttype);
+bool t_c_glib_generator::is_complex_type(t_type* ttype) {
+  ttype = get_true_type(ttype);
 
-  return ttype->is_container()
-         || ttype->is_struct()
-         || ttype->is_xception();
+  return ttype->is_container() || ttype->is_struct() || ttype->is_xception();
 }
 
-
 /**
  * Maps a Thrift t_type to a C type.
  */
-string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_const) {
-  (void) in_typedef;
+string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_const) {
+  (void)in_typedef;
   if (ttype->is_base_type()) {
-    string bname = base_type_name ((t_base_type *) ttype);
+    string bname = base_type_name((t_base_type*)ttype);
 
     if (is_const) {
       return "const " + bname;
@@ -546,7 +530,7 @@ string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_co
   if (ttype->is_container()) {
     string cname;
 
-    t_container *tcontainer = (t_container *) ttype;
+    t_container* tcontainer = (t_container*)ttype;
     if (tcontainer->has_cpp_name()) {
       cname = tcontainer->get_cpp_name();
     } else if (ttype->is_map()) {
@@ -560,24 +544,24 @@ string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_co
     } else if (ttype->is_list()) {
       // TODO: investigate other implementations besides GPtrArray
       cname = "GPtrArray *";
-      t_type *etype = ((t_list *) ttype)->get_elem_type();
+      t_type* etype = ((t_list*)ttype)->get_elem_type();
       if (etype->is_base_type()) {
-        t_base_type::t_base tbase = ((t_base_type *) etype)->get_base();
+        t_base_type::t_base tbase = ((t_base_type*)etype)->get_base();
         switch (tbase) {
-          case t_base_type::TYPE_VOID:
-            throw "compiler error: cannot determine array type";
-          case t_base_type::TYPE_BOOL:
-          case t_base_type::TYPE_BYTE:
-          case t_base_type::TYPE_I16:
-          case t_base_type::TYPE_I32:
-          case t_base_type::TYPE_I64:
-          case t_base_type::TYPE_DOUBLE:
-            cname = "GArray *";
-            break;
-          case t_base_type::TYPE_STRING:
-            break;
-          default:
-            throw "compiler error: no array info for type";
+        case t_base_type::TYPE_VOID:
+          throw "compiler error: cannot determine array type";
+        case t_base_type::TYPE_BOOL:
+        case t_base_type::TYPE_BYTE:
+        case t_base_type::TYPE_I16:
+        case t_base_type::TYPE_I32:
+        case t_base_type::TYPE_I64:
+        case t_base_type::TYPE_DOUBLE:
+          cname = "GArray *";
+          break;
+        case t_base_type::TYPE_STRING:
+          break;
+        default:
+          throw "compiler error: no array info for type";
         }
       }
     }
@@ -592,7 +576,7 @@ string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_co
   // check for a namespace
   string pname = this->nspace + ttype->get_name();
 
-  if (is_complex_type (ttype)) {
+  if (is_complex_type(ttype)) {
     pname += " *";
   }
 
@@ -611,25 +595,23 @@ string t_c_glib_generator::type_name (t_type* ttype, bool in_typedef, bool is_co
  * bits map to the same type, gint, as opposed to their width-specific type
  * (gint8, gint16 or gint32).
  */
-string t_c_glib_generator::property_type_name (t_type* ttype,
-                                               bool in_typedef,
-                                               bool is_const) {
+string t_c_glib_generator::property_type_name(t_type* ttype, bool in_typedef, bool is_const) {
   string result;
 
   if (ttype->is_base_type()) {
-    switch (((t_base_type *) ttype)->get_base()) {
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-        if (is_const) {
-          result = "const gint";
-        } else {
-          result = "gint";
-        }
-        break;
+    switch (((t_base_type*)ttype)->get_base()) {
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+      if (is_const) {
+        result = "const gint";
+      } else {
+        result = "gint";
+      }
+      break;
 
-      default:
-        result = type_name(ttype, in_typedef, is_const);
+    default:
+      result = type_name(ttype, in_typedef, is_const);
     }
   } else {
     result = type_name(ttype, in_typedef, is_const);
@@ -641,33 +623,32 @@ string t_c_glib_generator::property_type_name (t_type* ttype,
 /**
  * Maps a Thrift primitive to a C primitive.
  */
-string t_c_glib_generator::base_type_name(t_base_type *type) {
+string t_c_glib_generator::base_type_name(t_base_type* type) {
   t_base_type::t_base tbase = type->get_base();
 
   switch (tbase) {
-    case t_base_type::TYPE_VOID:
-      return "void";
-    case t_base_type::TYPE_STRING:
-      if (type->is_binary()) {
-        return "GByteArray *";
-      } else {
-        return "gchar *";
-      }
-    case t_base_type::TYPE_BOOL:
-      return "gboolean";
-    case t_base_type::TYPE_BYTE:
-      return "gint8";
-    case t_base_type::TYPE_I16:
-      return "gint16";
-    case t_base_type::TYPE_I32:
-      return "gint32";
-    case t_base_type::TYPE_I64:
-      return "gint64";
-    case t_base_type::TYPE_DOUBLE:
-      return "gdouble";
-    default:
-      throw "compiler error: no C base type name for base type "
-            + t_base_type::t_base_name (tbase);
+  case t_base_type::TYPE_VOID:
+    return "void";
+  case t_base_type::TYPE_STRING:
+    if (type->is_binary()) {
+      return "GByteArray *";
+    } else {
+      return "gchar *";
+    }
+  case t_base_type::TYPE_BOOL:
+    return "gboolean";
+  case t_base_type::TYPE_BYTE:
+    return "gint8";
+  case t_base_type::TYPE_I16:
+    return "gint16";
+  case t_base_type::TYPE_I32:
+    return "gint32";
+  case t_base_type::TYPE_I64:
+    return "gint64";
+  case t_base_type::TYPE_DOUBLE:
+    return "gdouble";
+  default:
+    throw "compiler error: no C base type name for base type " + t_base_type::t_base_name(tbase);
   }
 }
 
@@ -675,29 +656,29 @@ string t_c_glib_generator::base_type_name(t_base_type *type) {
  * Returns a member of the ThriftType C enumeration in thrift_protocol.h
  * for a Thrift type.
  */
-string t_c_glib_generator::type_to_enum (t_type *type) {
-  type = get_true_type (type);
+string t_c_glib_generator::type_to_enum(t_type* type) {
+  type = get_true_type(type);
 
   if (type->is_base_type()) {
-    t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
 
     switch (tbase) {
-      case t_base_type::TYPE_VOID:
-        throw "NO T_VOID CONSTRUCT";
-      case t_base_type::TYPE_STRING:
-        return "T_STRING";
-      case t_base_type::TYPE_BOOL:
-        return "T_BOOL";
-      case t_base_type::TYPE_BYTE:
-        return "T_BYTE";
-      case t_base_type::TYPE_I16:
-        return "T_I16";
-      case t_base_type::TYPE_I32:
-        return "T_I32";
-      case t_base_type::TYPE_I64:
-        return "T_I64";
-      case t_base_type::TYPE_DOUBLE:
-        return "T_DOUBLE";
+    case t_base_type::TYPE_VOID:
+      throw "NO T_VOID CONSTRUCT";
+    case t_base_type::TYPE_STRING:
+      return "T_STRING";
+    case t_base_type::TYPE_BOOL:
+      return "T_BOOL";
+    case t_base_type::TYPE_BYTE:
+      return "T_BYTE";
+    case t_base_type::TYPE_I16:
+      return "T_I16";
+    case t_base_type::TYPE_I32:
+      return "T_I32";
+    case t_base_type::TYPE_I64:
+      return "T_I64";
+    case t_base_type::TYPE_DOUBLE:
+      return "T_DOUBLE";
     }
   } else if (type->is_enum()) {
     return "T_I32";
@@ -716,65 +697,63 @@ string t_c_glib_generator::type_to_enum (t_type *type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 /**
  * Returns a Thrift constant formatted as a literal for inclusion in C code.
  */
-string t_c_glib_generator::constant_literal(t_type *type, t_const_value *value) {
+string t_c_glib_generator::constant_literal(t_type* type, t_const_value* value) {
   ostringstream render;
 
   if (type->is_base_type()) {
     /* primitives */
-    t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
 
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        render << "\"" + value->get_string() + "\"";
-        break;
-      case t_base_type::TYPE_BOOL:
-        render << ((value->get_integer() != 0) ? "TRUE" : "FALSE");
-        break;
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-      case t_base_type::TYPE_I64:
-        render << value->get_integer();
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        render << value->get_double();
-        break;
-      default:
-        throw "compiler error: no const of base type "
-              + t_base_type::t_base_name (tbase);
+    case t_base_type::TYPE_STRING:
+      render << "\"" + value->get_string() + "\"";
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() != 0) ? "TRUE" : "FALSE");
+      break;
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      render << value->get_double();
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else {
     t_const_value::t_const_value_type value_type = value->get_type();
 
     switch (value_type) {
-      case t_const_value::CV_IDENTIFIER:
-        render << value->get_integer();
-        break;
-      case t_const_value::CV_LIST:
-        render << "{ ";
-        {
-          t_type *elem_type = ((t_list *) type)->get_elem_type();
-          const vector<t_const_value *> &list = value->get_list();
-          vector<t_const_value *>::const_iterator list_iter;
-
-          if (list.size() > 0) {
-            list_iter = list.begin();
-            render << constant_literal(elem_type, *list_iter);
-
-            while (++list_iter != list.end()) {
-              render << ", " << constant_literal(elem_type, *list_iter);
-            }
+    case t_const_value::CV_IDENTIFIER:
+      render << value->get_integer();
+      break;
+    case t_const_value::CV_LIST:
+      render << "{ ";
+      {
+        t_type* elem_type = ((t_list*)type)->get_elem_type();
+        const vector<t_const_value*>& list = value->get_list();
+        vector<t_const_value*>::const_iterator list_iter;
+
+        if (list.size() > 0) {
+          list_iter = list.begin();
+          render << constant_literal(elem_type, *list_iter);
+
+          while (++list_iter != list.end()) {
+            render << ", " << constant_literal(elem_type, *list_iter);
           }
         }
-        render << " }";
-        break;
-      case t_const_value::CV_MAP:
-      default:
-        render << "NULL /* not supported */";
+      }
+      render << " }";
+      break;
+    case t_const_value::CV_MAP:
+    default:
+      render << "NULL /* not supported */";
     }
   }
 
@@ -784,42 +763,40 @@ string t_c_glib_generator::constant_literal(t_type *type, t_const_value *value)
 /**
  * Returns C code that represents a Thrift constant.
  */
-string t_c_glib_generator::constant_value(string name, t_type *type, t_const_value *value) {
+string t_c_glib_generator::constant_value(string name, t_type* type, t_const_value* value) {
   ostringstream render;
 
   if (type->is_base_type()) {
     /* primitives */
-    t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        render << "g_strdup (\"" + value->get_string() + "\")";
-        break;
-      case t_base_type::TYPE_BOOL:
-        render << ((value->get_integer() != 0) ? 1 : 0);
-        break;
-      case t_base_type::TYPE_BYTE:
-      case t_base_type::TYPE_I16:
-      case t_base_type::TYPE_I32:
-      case t_base_type::TYPE_I64:
+    case t_base_type::TYPE_STRING:
+      render << "g_strdup (\"" + value->get_string() + "\")";
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() != 0) ? 1 : 0);
+      break;
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
         render << value->get_integer();
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        if (value->get_type() == t_const_value::CV_INTEGER) {
-          render << value->get_integer();
-        } else {
-          render << value->get_double();
-        }
-        break;
-      default:
-        throw "compiler error: no const of base type "
-              + t_base_type::t_base_name (tbase);
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
-    render << "(" << type_name (type) << ")" << value->get_integer();
-  } else if (type->is_struct() || type->is_xception() || type->is_list()
-             || type->is_set() || type->is_map()) {
-    render << "(" << this->nspace_lc <<
-      to_lower_case(name) << "_constant())";
+    render << "(" << type_name(type) << ")" << value->get_integer();
+  } else if (type->is_struct() || type->is_xception() || type->is_list() || type->is_set()
+             || type->is_map()) {
+    render << "(" << this->nspace_lc << to_lower_case(name) << "_constant())";
   } else {
     render << "NULL /* not supported */";
   }
@@ -842,13 +819,10 @@ string t_c_glib_generator::function_signature(t_function* tfunction) {
   bool has_return = !ttype->is_void();
   bool has_args = arglist->get_members().size() == 0;
   bool has_xceptions = xlist->get_members().size() == 0;
-  return
-    "gboolean " + this->nspace_lc + fname + " (" + this->nspace
-    + service_name_ + "If * iface"
-    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
-    + (has_args ? "" : (", " + argument_list (arglist)))
-    + (has_xceptions ? "" : (", " + xception_list (xlist)))
-    + ", GError ** error)";
+  return "gboolean " + this->nspace_lc + fname + " (" + this->nspace + service_name_ + "If * iface"
+         + (has_return ? ", " + type_name(ttype) + "* _return" : "")
+         + (has_args ? "" : (", " + argument_list(arglist)))
+         + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError ** error)";
 }
 
 /**
@@ -857,7 +831,7 @@ string t_c_glib_generator::function_signature(t_function* tfunction) {
  * @param tstruct The struct definition
  * @return Comma sepearated list of all field names in that struct
  */
-string t_c_glib_generator::argument_list (t_struct* tstruct) {
+string t_c_glib_generator::argument_list(t_struct* tstruct) {
   string result = "";
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -869,8 +843,7 @@ string t_c_glib_generator::argument_list (t_struct* tstruct) {
     } else {
       result += ", ";
     }
-    result += type_name((*f_iter)->get_type(), false, true) + " " +
-              (*f_iter)->get_name();
+    result += type_name((*f_iter)->get_type(), false, true) + " " + (*f_iter)->get_name();
   }
   return result;
 }
@@ -881,7 +854,7 @@ string t_c_glib_generator::argument_list (t_struct* tstruct) {
  * @param tstruct The struct definition
  * @return Comma sepearated list of all field names in that struct
  */
-string t_c_glib_generator::xception_list (t_struct* tstruct) {
+string t_c_glib_generator::xception_list(t_struct* tstruct) {
   string result = "";
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -893,17 +866,15 @@ string t_c_glib_generator::xception_list (t_struct* tstruct) {
     } else {
       result += ", ";
     }
-    result += type_name((*f_iter)->get_type(), false, false) + "* " +
-              (*f_iter)->get_name();
+    result += type_name((*f_iter)->get_type(), false, false) + "* " + (*f_iter)->get_name();
   }
   return result;
 }
 
-
 /**
  * Declares a field, including any necessary initialization.
  */
-string t_c_glib_generator::declare_field(t_field *tfield,
+string t_c_glib_generator::declare_field(t_field* tfield,
                                          bool init,
                                          bool pointer,
                                          bool constant,
@@ -924,29 +895,28 @@ string t_c_glib_generator::declare_field(t_field *tfield,
     t_type* type = get_true_type(tfield->get_type());
 
     if (type->is_base_type()) {
-      t_base_type::t_base tbase = ((t_base_type *) type)->get_base();
+      t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
-        case t_base_type::TYPE_VOID:
-          break;
-        case t_base_type::TYPE_BOOL:
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-          result += " = 0";
-          break;
-        case t_base_type::TYPE_DOUBLE:
-          result += " = (gdouble) 0";
-          break;
-        case t_base_type::TYPE_STRING:
-          result += " = NULL";
-          break;
-        default:
-          throw "compiler error: no C intializer for base type "
-                + t_base_type::t_base_name (tbase);
+      case t_base_type::TYPE_VOID:
+        break;
+      case t_base_type::TYPE_BOOL:
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+      case t_base_type::TYPE_I64:
+        result += " = 0";
+        break;
+      case t_base_type::TYPE_DOUBLE:
+        result += " = (gdouble) 0";
+        break;
+      case t_base_type::TYPE_STRING:
+        result += " = NULL";
+        break;
+      default:
+        throw "compiler error: no C intializer for base type " + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
-      result += " = (" + type_name (type) + ") 0";
+      result += " = (" + type_name(type) + ") 0";
     } else if (type->is_struct() || type->is_container()) {
       result += " = NULL";
     }
@@ -962,22 +932,24 @@ string t_c_glib_generator::declare_field(t_field *tfield,
 /**
  * Generates C code that initializes complex constants.
  */
-void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t_const_value *value) {
+void t_c_glib_generator::generate_const_initializer(string name,
+                                                    t_type* type,
+                                                    t_const_value* value) {
   string name_u = initial_caps_to_underscores(name);
   string name_lc = to_lower_case(name_u);
   string type_u = initial_caps_to_underscores(type->get_name());
   string type_uc = to_upper_case(type_u);
 
   if (type->is_struct() || type->is_xception()) {
-    const vector<t_field *> &fields = ((t_struct *) type)->get_members();
-    vector<t_field *>::const_iterator f_iter;
-    const map<t_const_value *, t_const_value *> &val = value->get_map();
-    map<t_const_value *, t_const_value *>::const_iterator v_iter;
+    const vector<t_field*>& fields = ((t_struct*)type)->get_members();
+    vector<t_field*>::const_iterator f_iter;
+    const map<t_const_value*, t_const_value*>& val = value->get_map();
+    map<t_const_value*, t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
     // initialize any constants that may be referenced by this initializer
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      t_type *field_type = NULL;
+      t_type* field_type = NULL;
       string field_name = "";
 
       for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -987,37 +959,25 @@ void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t
         }
       }
       if (field_type == NULL) {
-        throw "type error: " + type->get_name() + " has no field "
-              + v_iter->first->get_string();
+        throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
       }
-      field_name = tmp (field_name);
-
-      generate_const_initializer (name + "_constant_" + field_name,
-                                  field_type, v_iter->second);
-      initializers <<
-        "    constant->" << v_iter->first->get_string() << " = " <<
-        constant_value (name + "_constant_" + field_name,
-                        field_type, v_iter->second) << ";" << endl <<
-        "    constant->__isset_" << v_iter->first->get_string() <<
-        " = TRUE;" << endl;
+      field_name = tmp(field_name);
+
+      generate_const_initializer(name + "_constant_" + field_name, field_type, v_iter->second);
+      initializers << "    constant->" << v_iter->first->get_string() << " = "
+                   << constant_value(name + "_constant_" + field_name, field_type, v_iter->second)
+                   << ";" << endl << "    constant->__isset_" << v_iter->first->get_string()
+                   << " = TRUE;" << endl;
     }
 
     // implement the initializer
-    f_types_impl_ <<
-      "static " << this->nspace << type->get_name() << " *" << endl <<
-      this->nspace_lc << name_lc << "_constant (void)" << endl <<
-      "{" << endl <<
-      "  static " << this->nspace << type->get_name() <<
-          " *constant = NULL;" << endl <<
-      "  if (constant == NULL)" << endl <<
-      "  {" << endl <<
-      "    constant = g_object_new (" << this->nspace_uc << "TYPE_" <<
-          type_uc << ", NULL);" << endl <<
-      initializers.str() << endl <<
-      "  }" << endl <<
-      "  return constant;" << endl <<
-      "}" << endl <<
-      endl;
+    f_types_impl_ << "static " << this->nspace << type->get_name() << " *" << endl
+                  << this->nspace_lc << name_lc << "_constant (void)" << endl << "{" << endl
+                  << "  static " << this->nspace << type->get_name() << " *constant = NULL;" << endl
+                  << "  if (constant == NULL)" << endl << "  {" << endl
+                  << "    constant = g_object_new (" << this->nspace_uc << "TYPE_" << type_uc
+                  << ", NULL);" << endl << initializers.str() << endl << "  }" << endl
+                  << "  return constant;" << endl << "}" << endl << endl;
   } else if (type->is_list()) {
     string list_type = "GPtrArray *";
     // TODO: This initialization should contain a free function for container
@@ -1030,126 +990,99 @@ void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
-    list_initializer = generate_new_array_from_type (etype);
+    list_initializer = generate_new_array_from_type(etype);
     if (etype->is_base_type()) {
-      t_base_type::t_base tbase = ((t_base_type *) etype)->get_base();
+      t_base_type::t_base tbase = ((t_base_type*)etype)->get_base();
       switch (tbase) {
-        case t_base_type::TYPE_VOID:
-          throw "compiler error: cannot determine array type";
-        case t_base_type::TYPE_BOOL:
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-        case t_base_type::TYPE_DOUBLE:
-          list_type = "GArray *";
-          list_appender = "g_array_append_val";
-          list_variable = true;
-          break;
-        case t_base_type::TYPE_STRING:
-          break;
-        default:
-          throw "compiler error: no array info for type";
+      case t_base_type::TYPE_VOID:
+        throw "compiler error: cannot determine array type";
+      case t_base_type::TYPE_BOOL:
+      case t_base_type::TYPE_BYTE:
+      case t_base_type::TYPE_I16:
+      case t_base_type::TYPE_I32:
+      case t_base_type::TYPE_I64:
+      case t_base_type::TYPE_DOUBLE:
+        list_type = "GArray *";
+        list_appender = "g_array_append_val";
+        list_variable = true;
+        break;
+      case t_base_type::TYPE_STRING:
+        break;
+      default:
+        throw "compiler error: no array info for type";
       }
     }
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp (name);
+      string fname = tmp(name);
 
-      generate_const_initializer (fname, etype, (*v_iter));
+      generate_const_initializer(fname, etype, (*v_iter));
       if (list_variable) {
-        initializers <<
-          "    " << type_name (etype) << " " << fname << " = " <<
-            constant_value (fname, (t_type *) etype, (*v_iter)) << ";" <<
-                endl <<
-          "    " << list_appender << "(constant, " << fname << ");" << endl;
+        initializers << "    " << type_name(etype) << " " << fname << " = "
+                     << constant_value(fname, (t_type*)etype, (*v_iter)) << ";" << endl << "    "
+                     << list_appender << "(constant, " << fname << ");" << endl;
       } else {
-        initializers <<
-          "    " << list_appender << "(constant, " <<
-          constant_value (fname, (t_type *) etype, (*v_iter)) << ");" << endl;
+        initializers << "    " << list_appender << "(constant, "
+                     << constant_value(fname, (t_type*)etype, (*v_iter)) << ");" << endl;
       }
     }
 
-    f_types_impl_ <<
-      "static " << list_type << endl <<
-      this->nspace_lc << name_lc << "_constant (void)" << endl <<
-      "{" << endl <<
-      "  static " << list_type << " constant = NULL;" << endl <<
-      "  if (constant == NULL)" << endl <<
-      "  {" << endl <<
-      "    constant = " << list_initializer << endl <<
-      initializers.str() << endl <<
-      "  }" << endl <<
-      "  return constant;" << endl <<
-      "}" << endl <<
-    endl;
+    f_types_impl_ << "static " << list_type << endl << this->nspace_lc << name_lc
+                  << "_constant (void)" << endl << "{" << endl << "  static " << list_type
+                  << " constant = NULL;" << endl << "  if (constant == NULL)" << endl << "  {"
+                  << endl << "    constant = " << list_initializer << endl << initializers.str()
+                  << endl << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
   } else if (type->is_set()) {
-    t_type *etype = ((t_set *) type)->get_elem_type();
-    const vector<t_const_value *>& val = value->get_list();
+    t_type* etype = ((t_set*)type)->get_elem_type();
+    const vector<t_const_value*>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp (name);
-      generate_const_initializer (fname, etype, (*v_iter));
-      initializers <<
-        "    " << type_name (etype) << " " << fname << " = " <<
-          constant_value (fname, (t_type *) etype, (*v_iter)) << ";" << endl <<
-        "    g_hash_table_insert (constant, &" << fname << ", &" << fname <<
-        ");" << endl;
+      string fname = tmp(name);
+      generate_const_initializer(fname, etype, (*v_iter));
+      initializers << "    " << type_name(etype) << " " << fname << " = "
+                   << constant_value(fname, (t_type*)etype, (*v_iter)) << ";" << endl
+                   << "    g_hash_table_insert (constant, &" << fname << ", &" << fname << ");"
+                   << endl;
     }
 
-    f_types_impl_ <<
-      "static GHashTable *" << endl <<
-      this->nspace_lc << name_lc << "_constant (void)" << endl <<
-      "{" << endl <<
-      "  static GHashTable *constant = NULL;" << endl <<
-      "  if (constant == NULL)" << endl <<
-      "  {" << endl <<
-      // TODO: This initialization should contain a free function for elements
-      "    constant = g_hash_table_new (NULL, NULL);" << endl <<
-      initializers.str() << endl <<
-      "  }" << endl <<
-      "  return constant;" << endl <<
-      "}" << endl <<
-    endl;
+    f_types_impl_ << "static GHashTable *" << endl << this->nspace_lc << name_lc
+                  << "_constant (void)" << endl << "{" << endl
+                  << "  static GHashTable *constant = NULL;" << endl << "  if (constant == NULL)"
+                  << endl << "  {" << endl <<
+        // TODO: This initialization should contain a free function for elements
+        "    constant = g_hash_table_new (NULL, NULL);" << endl << initializers.str() << endl
+                  << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
   } else if (type->is_map()) {
-    t_type *ktype = ((t_map *) type)->get_key_type();
-    t_type *vtype = ((t_map *) type)->get_val_type();
-    const vector<t_const_value *>& val = value->get_list();
+    t_type* ktype = ((t_map*)type)->get_key_type();
+    t_type* vtype = ((t_map*)type)->get_val_type();
+    const vector<t_const_value*>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
     ostringstream initializers;
 
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string fname = tmp (name);
+      string fname = tmp(name);
       string kname = fname + "key";
       string vname = fname + "val";
-      generate_const_initializer (kname, ktype, (*v_iter));
-      generate_const_initializer (vname, vtype, (*v_iter));
-
-      initializers <<
-        "    " << type_name (ktype) << " " << kname << " = " <<
-          constant_value (kname, (t_type *) ktype, (*v_iter)) << ";" << endl <<
-        "    " << type_name (vtype) << " " << vname << " = " <<
-          constant_value (vname, (t_type *) vtype, (*v_iter)) << ";" << endl <<
-        "    g_hash_table_insert (constant, &" << fname << ", &" << fname <<
-        ");" << endl;
+      generate_const_initializer(kname, ktype, (*v_iter));
+      generate_const_initializer(vname, vtype, (*v_iter));
+
+      initializers << "    " << type_name(ktype) << " " << kname << " = "
+                   << constant_value(kname, (t_type*)ktype, (*v_iter)) << ";" << endl << "    "
+                   << type_name(vtype) << " " << vname << " = "
+                   << constant_value(vname, (t_type*)vtype, (*v_iter)) << ";" << endl
+                   << "    g_hash_table_insert (constant, &" << fname << ", &" << fname << ");"
+                   << endl;
     }
 
-    f_types_impl_ <<
-      "static GHashTable *" << endl <<
-      this->nspace_lc << name_lc << "_constant (void)" << endl <<
-      "{" << endl <<
-      "  static GHashTable *constant = NULL;" << endl <<
-      "  if (constant == NULL)" << endl <<
-      "  {" << endl <<
-      // TODO: This initialization should contain a free function for elements
-      "    constant = g_hash_table_new (NULL, NULL);" << endl <<
-      initializers.str() << endl <<
-      "  }" << endl <<
-      "  return constant;" << endl <<
-      "}" << endl <<
-    endl;
+    f_types_impl_ << "static GHashTable *" << endl << this->nspace_lc << name_lc
+                  << "_constant (void)" << endl << "{" << endl
+                  << "  static GHashTable *constant = NULL;" << endl << "  if (constant == NULL)"
+                  << endl << "  {" << endl <<
+        // TODO: This initialization should contain a free function for elements
+        "    constant = g_hash_table_new (NULL, NULL);" << endl << initializers.str() << endl
+                  << "  }" << endl << "  return constant;" << endl << "}" << endl << endl;
   }
 }
 
@@ -1159,22 +1092,18 @@ void t_c_glib_generator::generate_const_initializer(string name, t_type *type, t
  *
  * @param tservice The service for which to generate helper classes
  */
-void t_c_glib_generator::generate_service_helpers(t_service *tservice) {
+void t_c_glib_generator::generate_service_helpers(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator function_iter;
 
   // Iterate through the service's methods
-  for (function_iter = functions.begin();
-       function_iter != functions.end();
-       ++function_iter) {
+  for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
     string function_name = (*function_iter)->get_name();
-    t_struct *arg_list = (*function_iter)->get_arglist();
+    t_struct* arg_list = (*function_iter)->get_arglist();
     string arg_list_name_orig = arg_list->get_name();
 
     // Generate the arguments class
-    arg_list->set_name(tservice->get_name() +
-                       underscores_to_initial_caps(function_name) +
-                       "Args");
+    arg_list->set_name(tservice->get_name() + underscores_to_initial_caps(function_name) + "Args");
     generate_struct(arg_list);
 
     arg_list->set_name(arg_list_name_orig);
@@ -1182,9 +1111,7 @@ void t_c_glib_generator::generate_service_helpers(t_service *tservice) {
     // Generate the result class
     if (!(*function_iter)->is_oneway()) {
       t_struct result(program_,
-                      tservice->get_name() +
-                      underscores_to_initial_caps(function_name) +
-                      "Result");
+                      tservice->get_name() + underscores_to_initial_caps(function_name) + "Result");
       t_field success((*function_iter)->get_returntype(), "success", 0);
       success.set_req(t_field::T_OPTIONAL);
       if (!(*function_iter)->get_returntype()->is_void()) {
@@ -1194,9 +1121,7 @@ void t_c_glib_generator::generate_service_helpers(t_service *tservice) {
       t_struct* xs = (*function_iter)->get_xceptions();
       const vector<t_field*>& fields = xs->get_members();
       vector<t_field*>::const_iterator field_iter;
-      for (field_iter = fields.begin();
-           field_iter != fields.end();
-           ++field_iter) {
+      for (field_iter = fields.begin(); field_iter != fields.end(); ++field_iter) {
         (*field_iter)->set_req(t_field::T_OPTIONAL);
         result.append(*field_iter);
       }
@@ -1209,7 +1134,7 @@ void t_c_glib_generator::generate_service_helpers(t_service *tservice) {
 /**
  * Generates C code that represents a Thrift service client.
  */
-void t_c_glib_generator::generate_service_client(t_service *tservice) {
+void t_c_glib_generator::generate_service_client(t_service* tservice) {
   /* get some C friendly service names */
   string service_name_lc = to_lower_case(initial_caps_to_underscores(service_name_));
   string service_name_uc = to_upper_case(service_name_lc);
@@ -1223,47 +1148,38 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
 
   // The service this service extends, or NULL if it extends no
   // service
-  t_service *extends_service = tservice->get_extends();
+  t_service* extends_service = tservice->get_extends();
   if (extends_service) {
     // The name of the parent service
     parent_service_name = extends_service->get_name();
-    parent_service_name_lc =
-      to_lower_case(initial_caps_to_underscores(parent_service_name));
+    parent_service_name_lc = to_lower_case(initial_caps_to_underscores(parent_service_name));
     parent_service_name_uc = to_upper_case(parent_service_name_lc);
 
     // The names of the client class' parent class and type
     parent_class_name = this->nspace + parent_service_name + "Client";
-    parent_type_name =
-      this->nspace_uc + "TYPE_" + parent_service_name_uc + "_CLIENT";
+    parent_type_name = this->nspace_uc + "TYPE_" + parent_service_name_uc + "_CLIENT";
   }
 
   // The base service (the topmost in the "extends" hierarchy), on
   // whose client class the "input_protocol" and "output_protocol"
   // properties are defined
-  t_service *base_service = tservice;
+  t_service* base_service = tservice;
   while (base_service->get_extends()) {
     base_service = base_service->get_extends();
   }
 
   string base_service_name = base_service->get_name();
-  string base_service_name_lc =
-    to_lower_case(initial_caps_to_underscores(base_service_name));
+  string base_service_name_lc = to_lower_case(initial_caps_to_underscores(base_service_name));
   string base_service_name_uc = to_upper_case(base_service_name_lc);
 
   // Generate the client interface dummy object in the header.
-  f_header_ <<
-    "/* " << service_name_ << " service interface */" << endl <<
-    "typedef struct _" << this->nspace << service_name_ << "If " <<
-        this->nspace << service_name_ << "If; " <<
-        " /* dummy object */" << endl <<
-    endl;
+  f_header_ << "/* " << service_name_ << " service interface */" << endl << "typedef struct _"
+            << this->nspace << service_name_ << "If " << this->nspace << service_name_ << "If; "
+            << " /* dummy object */" << endl << endl;
 
   // Generate the client interface object in the header.
-  f_header_ <<
-    "struct _" << this->nspace << service_name_ << "IfInterface" << endl <<
-    "{" << endl <<
-    "  GTypeInterface parent;" << endl <<
-  endl;
+  f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << endl << "{" << endl
+            << "  GTypeInterface parent;" << endl << endl;
 
   /* write out the functions for this interface */
   indent_up();
@@ -1272,163 +1188,135 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type *ttype = (*f_iter)->get_returntype();
-    t_struct *arglist = (*f_iter)->get_arglist();
-    t_struct *xlist = (*f_iter)->get_xceptions();
+    t_type* ttype = (*f_iter)->get_returntype();
+    t_struct* arglist = (*f_iter)->get_arglist();
+    t_struct* xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list (arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
-                    + ", GError **error)";
+                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list(arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
 
-    indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" <<
-                          endl;
+    indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << endl;
   }
   indent_down();
 
-  f_header_ <<
-    "};" << endl <<
-    "typedef struct _" << this->nspace << service_name_ << "IfInterface " <<
-        this->nspace << service_name_ << "IfInterface;" << endl <<
-    endl;
+  f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "IfInterface "
+            << this->nspace << service_name_ << "IfInterface;" << endl << endl;
 
   // generate all the interface boilerplate
-  f_header_ <<
-    "GType " << this->nspace_lc << service_name_lc <<
-        "_if_get_type (void);" << endl <<
-    "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF " <<
-        "(" << this->nspace_lc << service_name_lc << "_if_get_type())" <<
-        endl <<
-    "#define " << this->nspace_uc << service_name_uc << "_IF(obj) " <<
-        "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " <<
-        this->nspace << service_name_ << "If))" << endl <<
-    "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) " <<
-        "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_IF))" << endl <<
-    "#define " << this->nspace_uc << service_name_uc <<
-        "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " <<
-        this->nspace << service_name_ << "IfInterface))" << endl <<
-    endl;
+  f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << endl
+            << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF "
+            << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << endl << "#define "
+            << this->nspace_uc << service_name_uc << "_IF(obj) "
+            << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
+            << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << endl
+            << "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) "
+            << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
+            << service_name_uc << "_IF))" << endl << "#define " << this->nspace_uc
+            << service_name_uc << "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), "
+            << this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " << this->nspace
+            << service_name_ << "IfInterface))" << endl << endl;
 
   // write out all the interface function prototypes
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type *ttype = (*f_iter)->get_returntype();
-    t_struct *arglist = (*f_iter)->get_arglist();
-    t_struct *xlist = (*f_iter)->get_xceptions();
+    t_type* ttype = (*f_iter)->get_returntype();
+    t_struct* arglist = (*f_iter)->get_arglist();
+    t_struct* xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list (arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
-                    + ", GError **error)";
+                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list(arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
 
-    f_header_ << "gboolean " << this->nspace_lc << service_name_lc <<
-                 "_if_" << funname << " " << params << ";" << endl;
+    f_header_ << "gboolean " << this->nspace_lc << service_name_lc << "_if_" << funname << " "
+              << params << ";" << endl;
   }
   f_header_ << endl;
 
   // Generate the client object instance definition in the header.
-  f_header_ <<
-    "/* " << service_name_ << " service client */" << endl <<
-    "struct _" << this->nspace << service_name_ << "Client" << endl <<
-    "{" << endl <<
-    "  " << parent_class_name << " parent;" << endl;
+  f_header_ << "/* " << service_name_ << " service client */" << endl << "struct _" << this->nspace
+            << service_name_ << "Client" << endl << "{" << endl << "  " << parent_class_name
+            << " parent;" << endl;
   if (!extends_service) {
     // Define "input_protocol" and "output_protocol" properties only
     // for base services; child service-client classes will inherit
     // these
-    f_header_ <<
-      endl <<
-      "  ThriftProtocol *input_protocol;" << endl <<
-      "  ThriftProtocol *output_protocol;" << endl;
+    f_header_ << endl << "  ThriftProtocol *input_protocol;" << endl
+              << "  ThriftProtocol *output_protocol;" << endl;
   }
-  f_header_ <<
-    "};" << endl <<
-    "typedef struct _" << this->nspace << service_name_ << "Client " <<
-      this->nspace << service_name_ << "Client;" << endl <<
-    endl;
+  f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "Client "
+            << this->nspace << service_name_ << "Client;" << endl << endl;
 
   // Generate the class definition in the header.
-  f_header_ <<
-    "struct _" << this->nspace << service_name_ << "ClientClass" << endl <<
-    "{" << endl <<
-    "  " << parent_class_name << "Class parent;" << endl <<
-    "};" << endl <<
-    "typedef struct _" << this->nspace << service_name_ << "ClientClass " <<
-      this->nspace << service_name_ << "ClientClass;" << endl <<
-    endl;
+  f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << endl << "{" << endl
+            << "  " << parent_class_name << "Class parent;" << endl << "};" << endl
+            << "typedef struct _" << this->nspace << service_name_ << "ClientClass " << this->nspace
+            << service_name_ << "ClientClass;" << endl << endl;
 
   // Create all the GObject boilerplate
-  f_header_ <<
-    "GType " << this->nspace_lc << service_name_lc <<
-        "_client_get_type (void);" << endl <<
-    "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT " <<
-        "(" << this->nspace_lc << service_name_lc << "_client_get_type())" <<
-        endl <<
-    "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) " <<
-        "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
-        this->nspace << service_name_ << "Client))" << endl <<
-    "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) " <<
-        "(G_TYPE_CHECK_CLASS_CAST ((c), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
-        this->nspace << service_name_ << "ClientClass))" << endl <<
-    "#define " << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) " <<
-        "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
-    "#define " << this->nspace_uc << service_name_uc <<
-        "_IS_CLIENT_CLASS(c) " << "(G_TYPE_CHECK_CLASS_TYPE ((c), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT))" << endl <<
-    "#define " << this->nspace_uc << service_name_uc <<
-        "_CLIENT_GET_CLASS(obj) " << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT, " <<
-        this->nspace << service_name_ << "ClientClass))" << endl <<
-    endl;
+  f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << endl
+            << "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT "
+            << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << endl
+            << "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) "
+            << "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
+            << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << endl
+            << "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) "
+            << "(G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
+            << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << endl << "#define "
+            << this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) "
+            << "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
+            << service_name_uc << "_CLIENT))" << endl << "#define " << this->nspace_uc
+            << service_name_uc << "_IS_CLIENT_CLASS(c) "
+            << "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
+            << "_CLIENT))" << endl << "#define " << this->nspace_uc << service_name_uc
+            << "_CLIENT_GET_CLASS(obj) "
+            << "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
+            << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))"
+            << endl << endl;
 
   /* write out the function prototypes */
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = to_lower_case(initial_caps_to_underscores((*f_iter)->get_name()));
 
-    t_function service_function ((*f_iter)->get_returntype(),
-                                 service_name_lc + string ("_client_")
-                                 + funname,
-                                 (*f_iter)->get_arglist(),
-                                 (*f_iter)->get_xceptions());
-    indent(f_header_) << function_signature (&service_function) << ";" << endl;
+    t_function service_function((*f_iter)->get_returntype(),
+                                service_name_lc + string("_client_") + funname,
+                                (*f_iter)->get_arglist(),
+                                (*f_iter)->get_xceptions());
+    indent(f_header_) << function_signature(&service_function) << ";" << endl;
 
-    t_function send_function (g_type_void,
-                              service_name_lc + string ("_client_send_")
-                              + funname,
-                              (*f_iter)->get_arglist());
-    indent(f_header_) << function_signature (&send_function) << ";" << endl;
+    t_function send_function(g_type_void,
+                             service_name_lc + string("_client_send_") + funname,
+                             (*f_iter)->get_arglist());
+    indent(f_header_) << function_signature(&send_function) << ";" << endl;
 
     // implement recv if not a oneway service
     if (!(*f_iter)->is_oneway()) {
-      t_struct noargs (program_);
-      t_function recv_function ((*f_iter)->get_returntype(),
-                                service_name_lc + string ("_client_recv_")
-                                + funname,
-                                &noargs,
-                                (*f_iter)->get_xceptions());
-      indent(f_header_) << function_signature (&recv_function) << ";" << endl;
+      t_struct noargs(program_);
+      t_function recv_function((*f_iter)->get_returntype(),
+                               service_name_lc + string("_client_recv_") + funname,
+                               &noargs,
+                               (*f_iter)->get_xceptions());
+      indent(f_header_) << function_signature(&recv_function) << ";" << endl;
     }
   }
 
   /* write out the get/set function prototypes */
-  f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);" << endl;
-  f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);" << endl;
+  f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint "
+                                           "property_id, const GValue *value, GParamSpec *pspec);"
+            << endl;
+  f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint "
+                                           "property_id, GValue *value, GParamSpec *pspec);"
+            << endl;
 
   f_header_ << endl;
   // end of header code
@@ -1437,164 +1325,104 @@ void t_c_glib_generator::generate_service_client(t_service *tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     /* make the function name C friendly */
     string funname = initial_caps_to_underscores((*f_iter)->get_name());
-    t_type *ttype = (*f_iter)->get_returntype();
-    t_struct *arglist = (*f_iter)->get_arglist();
-    t_struct *xlist = (*f_iter)->get_xceptions();
+    t_type* ttype = (*f_iter)->get_returntype();
+    t_struct* arglist = (*f_iter)->get_arglist();
+    t_struct* xlist = (*f_iter)->get_xceptions();
     bool has_return = !ttype->is_void();
     bool has_args = arglist->get_members().size() == 0;
     bool has_xceptions = xlist->get_members().size() == 0;
 
     string params = "(" + this->nspace + service_name_ + "If *iface"
-                    + (has_return ? ", " + type_name (ttype) + "* _return" : "")
-                    + (has_args ? "" : (", " + argument_list (arglist)))
-                    + (has_xceptions ? "" : (", " + xception_list (xlist)))
-                    + ", GError **error)";
+                    + (has_return ? ", " + type_name(ttype) + "* _return" : "")
+                    + (has_args ? "" : (", " + argument_list(arglist)))
+                    + (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
 
-    string params_without_type = string("iface, ")
-                                 + (has_return ? "_return, " : "");
+    string params_without_type = string("iface, ") + (has_return ? "_return, " : "");
 
-    const vector<t_field *>& fields = arglist->get_members();
-    vector<t_field *>::const_iterator f_iter_field;
+    const vector<t_field*>& fields = arglist->get_members();
+    vector<t_field*>::const_iterator f_iter_field;
     for (f_iter_field = fields.begin(); f_iter_field != fields.end(); ++f_iter_field) {
       params_without_type += (*f_iter_field)->get_name();
       params_without_type += ", ";
     }
 
-    const vector<t_field *>& xceptions = xlist->get_members();
-    vector<t_field *>::const_iterator x_iter;
+    const vector<t_field*>& xceptions = xlist->get_members();
+    vector<t_field*>::const_iterator x_iter;
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
       params_without_type += (*x_iter)->get_name();
       params_without_type += ", ";
     }
 
-    f_service_ <<
-      "gboolean" << endl <<
-      this->nspace_lc << service_name_lc << "_if_" << funname << " " <<
-          params << endl <<
-      "{" << endl <<
-      "  return " << this->nspace_uc << service_name_uc <<
-          "_IF_GET_INTERFACE (iface)->" << funname << " (" <<
-          params_without_type << "error);" << endl <<
-      "}" << endl <<
-      endl;
+    f_service_ << "gboolean" << endl << this->nspace_lc << service_name_lc << "_if_" << funname
+               << " " << params << endl << "{" << endl << "  return " << this->nspace_uc
+               << service_name_uc << "_IF_GET_INTERFACE (iface)->" << funname << " ("
+               << params_without_type << "error);" << endl << "}" << endl << endl;
   }
 
   // Generate interface boilerplate
-  f_service_ <<
-    "GType" << endl <<
-    this->nspace_lc << service_name_lc << "_if_get_type (void)" << endl <<
-    "{" << endl <<
-    "  static GType type = 0;" << endl <<
-    "  if (type == 0)" << endl <<
-    "  {" << endl <<
-    "    static const GTypeInfo type_info =" << endl <<
-    "    {" << endl <<
-    "      sizeof (" << this->nspace << service_name_ << "IfInterface)," <<
-        endl <<
-    "      NULL,  /* base_init */" << endl <<
-    "      NULL,  /* base_finalize */" << endl <<
-    "      NULL,  /* class_init */" << endl <<
-    "      NULL,  /* class_finalize */" << endl <<
-    "      NULL,  /* class_data */" << endl <<
-    "      0,     /* instance_size */" << endl <<
-    "      0,     /* n_preallocs */" << endl <<
-    "      NULL,  /* instance_init */" << endl <<
-    "      NULL   /* value_table */" << endl <<
-    "    };" << endl <<
-    "    type = g_type_register_static (G_TYPE_INTERFACE," << endl <<
-    "                                   \"" << this->nspace << service_name_ <<
-        "If\"," << endl <<
-    "                                   &type_info, 0);" << endl <<
-    "  }" << endl <<
-    "  return type;" << endl <<
-    "}" << endl <<
-    endl;
+  f_service_ << "GType" << endl << this->nspace_lc << service_name_lc << "_if_get_type (void)"
+             << endl << "{" << endl << "  static GType type = 0;" << endl << "  if (type == 0)"
+             << endl << "  {" << endl << "    static const GTypeInfo type_info =" << endl << "    {"
+             << endl << "      sizeof (" << this->nspace << service_name_ << "IfInterface)," << endl
+             << "      NULL,  /* base_init */" << endl << "      NULL,  /* base_finalize */" << endl
+             << "      NULL,  /* class_init */" << endl << "      NULL,  /* class_finalize */"
+             << endl << "      NULL,  /* class_data */" << endl
+             << "      0,     /* instance_size */" << endl << "      0,     /* n_preallocs */"
+             << endl << "      NULL,  /* instance_init */" << endl
+             << "      NULL   /* value_table */" << endl << "    };" << endl
+             << "    type = g_type_register_static (G_TYPE_INTERFACE," << endl
+             << "                                   \"" << this->nspace << service_name_ << "If\","
+             << endl << "                                   &type_info, 0);" << endl << "  }"
+             << endl << "  return type;" << endl << "}" << endl << endl;
 
   // Generate client boilerplate
-  f_service_ <<
-    "static void " << endl <<
-    this->nspace_lc << service_name_lc <<
-        "_if_interface_init (" << this->nspace << service_name_ <<
-        "IfInterface *iface);" << endl <<
-    endl <<
-    "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_ <<
-      "Client, " << this->nspace_lc << service_name_lc << "_client," << endl <<
-    "                         " << parent_type_name << ", " << endl <<
-    "                         G_IMPLEMENT_INTERFACE (" <<
-        this->nspace_uc << "TYPE_" << service_name_uc << "_IF," << endl <<
-    "                                                " <<
-        this->nspace_lc << service_name_lc << "_if_interface_init));" << endl <<
-    endl;
+  f_service_ << "static void " << endl << this->nspace_lc << service_name_lc
+             << "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);"
+             << endl << endl << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_
+             << "Client, " << this->nspace_lc << service_name_lc << "_client," << endl
+             << "                         " << parent_type_name << ", " << endl
+             << "                         G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_"
+             << service_name_uc << "_IF," << endl
+             << "                                                " << this->nspace_lc
+             << service_name_lc << "_if_interface_init));" << endl << endl;
 
   // Generate property-related code only for base services---child
   // service-client classes have only properties inherited from their
   // parent class
   if (!extends_service) {
     // Generate client properties
-    f_service_ <<
-      "enum _" << this->nspace << service_name_ << "ClientProperties" << endl <<
-      "{" << endl <<
-      "  PROP_0," << endl <<
-      "  PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_INPUT_PROTOCOL," <<
-          endl <<
-      "  PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_OUTPUT_PROTOCOL" <<
-          endl <<
-      "};" << endl <<
-    endl;
+    f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << endl << "{"
+               << endl << "  PROP_0," << endl << "  PROP_" << this->nspace_uc << service_name_uc
+               << "_CLIENT_INPUT_PROTOCOL," << endl << "  PROP_" << this->nspace_uc
+               << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << endl << "};" << endl << endl;
 
     // generate property setter
-    f_service_ <<
-      "void" << endl <<
-      this->nspace_lc << service_name_lc << "_client_set_property (" <<
-          "GObject *object, guint property_id, const GValue *value, " <<
-          "GParamSpec *pspec)" << endl <<
-      "{" << endl <<
-      "  " << this->nspace << service_name_ << "Client *client = " <<
-          this->nspace_uc << service_name_uc << "_CLIENT (object);" << endl <<
-      endl <<
-      "  THRIFT_UNUSED_VAR (pspec);" << endl <<
-      endl <<
-      "  switch (property_id)" << endl <<
-      "  {" << endl <<
-      "    case PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_INPUT_PROTOCOL:" << endl <<
-      "      client->input_protocol = g_value_get_object (value);" << endl <<
-      "      break;" << endl <<
-      "    case PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_OUTPUT_PROTOCOL:" << endl <<
-      "      client->output_protocol = g_value_get_object (value);" << endl <<
-      "      break;" << endl <<
-      "  }" << endl <<
-      "}" << endl <<
-    endl;
+    f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_set_property ("
+               << "GObject *object, guint property_id, const GValue *value, "
+               << "GParamSpec *pspec)" << endl << "{" << endl << "  " << this->nspace
+               << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
+               << "_CLIENT (object);" << endl << endl << "  THRIFT_UNUSED_VAR (pspec);" << endl
+               << endl << "  switch (property_id)" << endl << "  {" << endl << "    case PROP_"
+               << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
+               << "      client->input_protocol = g_value_get_object (value);" << endl
+               << "      break;" << endl << "    case PROP_" << this->nspace_uc << service_name_uc
+               << "_CLIENT_OUTPUT_PROTOCOL:" << endl
+               << "      client->output_protocol = g_value_get_object (value);" << endl
+               << "      break;" << endl << "  }" << endl << "}" << endl << endl;
 
     // generate property getter
-    f_service_ <<
-      "void" << endl <<
-      this->nspace_lc << service_name_lc << "_client_get_property (" <<
-          "GObject *object, guint property_id, GValue *value, " <<
-          "GParamSpec *pspec)" << endl <<
-      "{" << endl <<
-      "  " << this->nspace << service_name_ << "Client *client = " <<
-          this->nspace_uc << service_name_uc << "_CLIENT (object);" << endl <<
-      endl <<
-      "  THRIFT_UNUSED_VAR (pspec);" << endl <<
-      endl <<
-      "  switch (property_id)" << endl <<
-      "  {" << endl <<
-      "    case PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_INPUT_PROTOCOL:" << endl <<
-      "      g_value_set_object (value, client->input_protocol);" << endl <<
-      "      break;" << endl <<
-      "    case PROP_" << this->nspace_uc << service_name_uc <<
-          "_CLIENT_OUTPUT_PROTOCOL:" << endl <<
-      "      g_value_set_object (value, client->output_protocol);" << endl <<
-      "      break;" << endl <<
-      "  }" << endl <<
-      "}" << endl <<
-    endl;
+    f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_get_property ("
+               << "GObject *object, guint property_id, GValue *value, "
+               << "GParamSpec *pspec)" << endl << "{" << endl << "  " << this->nspace
+               << service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
+               << "_CLIENT (object);" << endl << endl << "  THRIFT_UNUSED_VAR (pspec);" << endl
+               << endl << "  switch (property_id)" << endl << "  {" << endl << "    case PROP_"
+               << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
+               << "      g_value_set_object (value, client->input_protocol);" << endl
+               << "      break;" << endl << "    case 

<TRUNCATED>

[14/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/main.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
old mode 100755
new mode 100644
index ed57596..57cd460
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -40,7 +40,7 @@
 #include <limits.h>
 
 #ifdef _WIN32
-# include <windows.h> /* for GetFullPathName */
+#include <windows.h> /* for GetFullPathName */
 #endif
 
 // Careful: must include globals first for extern definitions
@@ -150,8 +150,8 @@ int g_doctext_lineno;
  * The First doctext comment
  */
 char* g_program_doctext_candidate;
-int  g_program_doctext_lineno = 0;
-PROGDOCTEXT_STATUS  g_program_doctext_status = INVALID;
+int g_program_doctext_lineno = 0;
+PROGDOCTEXT_STATUS g_program_doctext_status = INVALID;
 
 /**
  * Whether or not negative field keys are accepted.
@@ -172,12 +172,12 @@ bool gen_recurse = false;
  * Win32 doesn't have realpath, so use fallback implementation in that case,
  * otherwise this just calls through to realpath
  */
-char *saferealpath(const char *path, char *resolved_path) {
+char* saferealpath(const char* path, char* resolved_path) {
 #ifdef _WIN32
   char buf[MAX_PATH];
   char* basename;
   DWORD len = GetFullPathName(path, MAX_PATH, buf, &basename);
-  if (len == 0 || len > MAX_PATH - 1){
+  if (len == 0 || len > MAX_PATH - 1) {
     strcpy(resolved_path, path);
   } else {
     strcpy(resolved_path, buf);
@@ -197,14 +197,17 @@ char *saferealpath(const char *path, char *resolved_path) {
 #endif
 }
 
-bool check_is_directory(const char *dir_name) {
+bool check_is_directory(const char* dir_name) {
 #ifdef _WIN32
   DWORD attributes = ::GetFileAttributesA(dir_name);
-  if(attributes == INVALID_FILE_ATTRIBUTES) {
-    fprintf(stderr, "Output directory %s is unusable: GetLastError() = %ld\n", dir_name, GetLastError());
+  if (attributes == INVALID_FILE_ATTRIBUTES) {
+    fprintf(stderr,
+            "Output directory %s is unusable: GetLastError() = %ld\n",
+            dir_name,
+            GetLastError());
     return false;
   }
-  if((attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
+  if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
     fprintf(stderr, "Output directory %s exists but is not a directory\n", dir_name);
     return false;
   }
@@ -215,7 +218,7 @@ bool check_is_directory(const char *dir_name) {
     fprintf(stderr, "Output directory %s is unusable: %s\n", dir_name, strerror(errno));
     return false;
   }
-  if (! S_ISDIR(sb.st_mode)) {
+  if (!S_ISDIR(sb.st_mode)) {
     fprintf(stderr, "Output directory %s exists but is not a directory\n", dir_name);
     return false;
   }
@@ -233,11 +236,7 @@ bool check_is_directory(const char *dir_name) {
  */
 void yyerror(const char* fmt, ...) {
   va_list args;
-  fprintf(stderr,
-          "[ERROR:%s:%d] (last token was '%s')\n",
-          g_curpath.c_str(),
-          yylineno,
-          yytext);
+  fprintf(stderr, "[ERROR:%s:%d] (last token was '%s')\n", g_curpath.c_str(), yylineno, yytext);
 
   va_start(args, fmt);
   vfprintf(stderr, fmt, args);
@@ -316,7 +315,7 @@ void failure(const char* fmt, ...) {
 string program_name(string filename) {
   string::size_type slash = filename.rfind("/");
   if (slash != string::npos) {
-    filename = filename.substr(slash+1);
+    filename = filename.substr(slash + 1);
   }
   string::size_type dot = filename.rfind(".");
   if (dot != string::npos) {
@@ -400,25 +399,25 @@ void clear_doctext() {
  * Reset program doctext information after processing a file
  */
 void reset_program_doctext_info() {
-  if(g_program_doctext_candidate != NULL) {
+  if (g_program_doctext_candidate != NULL) {
     free(g_program_doctext_candidate);
     g_program_doctext_candidate = NULL;
   }
   g_program_doctext_lineno = 0;
   g_program_doctext_status = INVALID;
-  pdebug("%s","program doctext set to INVALID");
+  pdebug("%s", "program doctext set to INVALID");
 }
 
 /**
  * We are sure the program doctext candidate is really the program doctext.
  */
 void declare_valid_program_doctext() {
-  if((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
+  if ((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
     g_program_doctext_status = ABSOLUTELY_SURE;
-    pdebug("%s","program doctext set to ABSOLUTELY_SURE");
+    pdebug("%s", "program doctext set to ABSOLUTELY_SURE");
   } else {
     g_program_doctext_status = NO_PROGRAM_DOCTEXT;
-    pdebug("%s","program doctext set to NO_PROGRAM_DOCTEXT");
+    pdebug("%s", "program doctext set to NO_PROGRAM_DOCTEXT");
   }
 }
 
@@ -431,16 +430,14 @@ void declare_valid_program_doctext() {
 char* clean_up_doctext(char* doctext) {
   // Convert to C++ string, and remove Windows's carriage returns.
   string docstring = doctext;
-  docstring.erase(
-      remove(docstring.begin(), docstring.end(), '\r'),
-      docstring.end());
+  docstring.erase(remove(docstring.begin(), docstring.end(), '\r'), docstring.end());
 
   // Separate into lines.
   vector<string> lines;
   string::size_type pos = string::npos;
   string::size_type last;
   while (true) {
-    last = (pos == string::npos) ? 0 : pos+1;
+    last = (pos == string::npos) ? 0 : pos + 1;
     pos = docstring.find('\n', last);
     if (pos == string::npos) {
       // First bit of cleaning.  If the last line is only whitespace, drop it.
@@ -450,7 +447,7 @@ char* clean_up_doctext(char* doctext) {
       }
       break;
     }
-    lines.push_back(docstring.substr(last, pos-last));
+    lines.push_back(docstring.substr(last, pos - last));
   }
 
   // A very profound docstring.
@@ -468,7 +465,7 @@ char* clean_up_doctext(char* doctext) {
   bool found_prefix = false;
   string::size_type prefix_len = 0;
   vector<string>::iterator l_iter;
-  for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
+  for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
     if (l_iter->empty()) {
       continue;
     }
@@ -487,9 +484,7 @@ char* clean_up_doctext(char* doctext) {
         // Whitespace-only line.  Truncate it.
         l_iter->clear();
       }
-    } else if (l_iter->size() > pos
-        && l_iter->at(pos) == '*'
-        && pos == prefix_len) {
+    } else if (l_iter->size() > pos && l_iter->at(pos) == '*' && pos == prefix_len) {
       // Business as usual.
     } else if (pos == string::npos) {
       // Whitespace-only line.  Let's truncate it for them.
@@ -505,27 +500,26 @@ char* clean_up_doctext(char* doctext) {
   if (have_prefix) {
     // Get the star too.
     prefix_len++;
-    for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
+    for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
       l_iter->erase(0, prefix_len);
     }
   }
 
   // Now delete the minimum amount of leading whitespace from each line.
   prefix_len = string::npos;
-  for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
+  for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
     if (l_iter->empty()) {
       continue;
     }
     pos = l_iter->find_first_not_of(" \t");
-    if (pos != string::npos
-        && (prefix_len == string::npos || pos < prefix_len)) {
+    if (pos != string::npos && (prefix_len == string::npos || pos < prefix_len)) {
       prefix_len = pos;
     }
   }
 
   // If our prefix survived, delete it from every line.
   if (prefix_len != string::npos) {
-    for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
+    for (l_iter = lines.begin() + 1; l_iter != lines.end(); ++l_iter) {
       l_iter->erase(0, prefix_len);
     }
   }
@@ -533,8 +527,8 @@ char* clean_up_doctext(char* doctext) {
   // Remove trailing whitespace from every line.
   for (l_iter = lines.begin(); l_iter != lines.end(); ++l_iter) {
     pos = l_iter->find_last_not_of(" \t");
-    if (pos != string::npos && pos != l_iter->length()-1) {
-      l_iter->erase(pos+1);
+    if (pos != string::npos && pos != l_iter->length() - 1) {
+      l_iter->erase(pos + 1);
     }
   }
 
@@ -551,11 +545,11 @@ char* clean_up_doctext(char* doctext) {
     docstring += '\n';
   }
 
-  //assert(docstring.length() <= strlen(doctext));  may happen, see THRIFT-1755
-  if(docstring.length() <= strlen(doctext)) {
+  // assert(docstring.length() <= strlen(doctext));  may happen, see THRIFT-1755
+  if (docstring.length() <= strlen(doctext)) {
     strcpy(doctext, docstring.c_str());
   } else {
-    free(doctext);  // too short
+    free(doctext); // too short
     doctext = strdup(docstring.c_str());
   }
   return doctext;
@@ -661,20 +655,18 @@ void generate_all_fingerprints(t_program* program) {
   */
 }
 
-
 /**
  * Emits a warning on list<byte>, binary type is typically a much better choice.
  */
 void check_for_list_of_bytes(t_type* list_elem_type) {
-  if((g_parse_mode == PROGRAM) && (list_elem_type != NULL) && list_elem_type->is_base_type()) {
+  if ((g_parse_mode == PROGRAM) && (list_elem_type != NULL) && list_elem_type->is_base_type()) {
     t_base_type* tbase = (t_base_type*)list_elem_type;
-    if(tbase->get_base() == t_base_type::TYPE_BYTE) {
-      pwarning(1,"Consider using the more efficient \"binary\" type instead of \"list<byte>\".");
+    if (tbase->get_base() == t_base_type::TYPE_BYTE) {
+      pwarning(1, "Consider using the more efficient \"binary\" type instead of \"list<byte>\".");
     }
   }
 }
 
-
 /**
  * Prints the version number
  */
@@ -701,7 +693,7 @@ void help() {
   fprintf(stderr, "  -o dir      Set the output directory for gen-* packages\n");
   fprintf(stderr, "               (default: current directory)\n");
   fprintf(stderr, "  -out dir    Set the ouput location for generated files.\n");
-  fprintf(stderr,"               (no gen-* folder will be created)\n");
+  fprintf(stderr, "               (no gen-* folder will be created)\n");
   fprintf(stderr, "  -I dir      Add a directory to the list of directories\n");
   fprintf(stderr, "                searched for include directives\n");
   fprintf(stderr, "  -nowarn     Suppress all compiler warnings (BAD!)\n");
@@ -709,7 +701,8 @@ void help() {
   fprintf(stderr, "  -v[erbose]  Verbose mode\n");
   fprintf(stderr, "  -r[ecurse]  Also generate included files\n");
   fprintf(stderr, "  -debug      Parse debug trace to stdout\n");
-  fprintf(stderr, "  --allow-neg-keys  Allow negative field keys (Used to "
+  fprintf(stderr,
+          "  --allow-neg-keys  Allow negative field keys (Used to "
           "preserve protocol\n");
   fprintf(stderr, "                compatibility with older .thrift files)\n");
   fprintf(stderr, "  --allow-64bit-consts  Do not print warnings about using 64-bit constants\n");
@@ -723,9 +716,10 @@ void help() {
   t_generator_registry::gen_map_t gen_map = t_generator_registry::get_generator_map();
   t_generator_registry::gen_map_t::iterator iter;
   for (iter = gen_map.begin(); iter != gen_map.end(); ++iter) {
-    fprintf(stderr, "  %s (%s):\n",
-        iter->second->get_short_name().c_str(),
-        iter->second->get_long_name().c_str());
+    fprintf(stderr,
+            "  %s (%s):\n",
+            iter->second->get_short_name().c_str(),
+            iter->second->get_long_name().c_str());
     fprintf(stderr, "%s", iter->second->get_documentation().c_str());
   }
   exit(1);
@@ -778,8 +772,8 @@ void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
       }
       break;
     case t_base_type::TYPE_DOUBLE:
-      if (value->get_type() != t_const_value::CV_INTEGER &&
-          value->get_type() != t_const_value::CV_DOUBLE) {
+      if (value->get_type() != t_const_value::CV_INTEGER
+          && value->get_type() != t_const_value::CV_DOUBLE) {
         throw "type error: const \"" + name + "\" was declared as double";
       }
       break;
@@ -805,9 +799,9 @@ void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
       }
     }
     if (!found) {
-      throw "type error: const " + name + " was declared as type "
-        + type->get_name() + " which is an enum, but "
-        + value->get_identifier() + " is not a valid value for that enum";
+      throw "type error: const " + name + " was declared as type " + type->get_name()
+          + " which is an enum, but " + value->get_identifier()
+          + " is not a valid value for that enum";
     }
   } else if (type->is_struct() || type->is_xception()) {
     if (value->get_type() != t_const_value::CV_MAP) {
@@ -863,8 +857,8 @@ void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
  * It's easier to do it this way instead of rewriting the whole grammar etc.
  */
 void validate_simple_identifier(const char* identifier) {
-  string name( identifier);
-  if( name.find(".") != string::npos) {
+  string name(identifier);
+  if (name.find(".") != string::npos) {
     yyerror("Identifier %s can't have a dot.", identifier);
     exit(1);
   }
@@ -904,9 +898,9 @@ bool validate_throws(t_struct* throws) {
 bool skip_utf8_bom(FILE* f) {
 
   // pretty straightforward, but works
-  if( fgetc(f) == 0xEF) {
-    if( fgetc(f) == 0xBB) {
-      if( fgetc(f) == 0xBF) {
+  if (fgetc(f) == 0xEF) {
+    if (fgetc(f) == 0xBB) {
+      if (fgetc(f) == 0xBF) {
         return true;
       }
     }
@@ -933,7 +927,7 @@ void parse(t_program* program, t_program* parent_program) {
   if (yyin == 0) {
     failure("Could not open input file: \"%s\"", path.c_str());
   }
-  if( skip_utf8_bom( yyin))
+  if (skip_utf8_bom(yyin))
     pverbose("Skipped UTF-8 BOM at %s\n", path.c_str());
 
   // Create new scope and scan for includes
@@ -975,7 +969,7 @@ void parse(t_program* program, t_program* parent_program) {
   if (yyin == 0) {
     failure("Could not open input file: \"%s\"", path.c_str());
   }
-  if( skip_utf8_bom( yyin))
+  if (skip_utf8_bom(yyin))
     pverbose("Skipped UTF-8 BOM at %s\n", path.c_str());
 
   pverbose("Parsing %s for types\n", path.c_str());
@@ -1010,7 +1004,7 @@ void generate(t_program* program, const vector<string>& generator_strings) {
     pverbose("Program: %s\n", program->get_path().c_str());
 
     // Compute fingerprints. - not anymore, we do it on the fly now
-    //generate_all_fingerprints(program);
+    // generate_all_fingerprints(program);
 
     if (dump_docs) {
       dump_docstrings(program);
@@ -1028,13 +1022,11 @@ void generate(t_program* program, const vector<string>& generator_strings) {
         delete generator;
       }
     }
-
   } catch (string s) {
     printf("Error: %s\n", s.c_str());
   } catch (const char* exc) {
     printf("Error: %s\n", exc);
   }
-
 }
 
 /**
@@ -1062,7 +1054,7 @@ int main(int argc, char** argv) {
   g_curpath = "arguments";
 
   // Hacky parameter handling... I didn't feel like using a library sorry!
-  for (i = 1; i < argc-1; i++) {
+  for (i = 1; i < argc - 1; i++) {
     char* arg;
 
     arg = strtok(argv[i], " ");
@@ -1084,9 +1076,9 @@ int main(int argc, char** argv) {
       } else if (strcmp(arg, "-strict") == 0) {
         g_strict = 255;
         g_warn = 2;
-      } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "-verbose") == 0 ) {
+      } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "-verbose") == 0) {
         g_verbose = 1;
-      } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-recurse") == 0 ) {
+      } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-recurse") == 0) {
         gen_recurse = true;
       } else if (strcmp(arg, "-allow-neg-keys") == 0) {
         g_allow_neg_field_keys = true;
@@ -1118,10 +1110,9 @@ int main(int argc, char** argv) {
         out_path = arg;
 
 #ifdef _WIN32
-        //strip out trailing \ on Windows
-        int last = out_path.length()-1;
-        if (out_path[last] == '\\')
-        {
+        // strip out trailing \ on Windows
+        int last = out_path.length() - 1;
+        if (out_path[last] == '\\') {
           out_path.erase(last);
         }
 #endif
@@ -1138,12 +1129,12 @@ int main(int argc, char** argv) {
   }
 
   // display help
-  if ((strcmp(argv[argc-1], "-help") == 0) || (strcmp(argv[argc-1], "--help") == 0)) {
+  if ((strcmp(argv[argc - 1], "-help") == 0) || (strcmp(argv[argc - 1], "--help") == 0)) {
     help();
   }
 
   // if you're asking for version, you have a right not to pass a file
-  if ((strcmp(argv[argc-1], "-version") == 0) || (strcmp(argv[argc-1], "--version") == 0)) {
+  if ((strcmp(argv[argc - 1], "-version") == 0) || (strcmp(argv[argc - 1], "--version") == 0)) {
     version();
     exit(0);
   }
@@ -1184,17 +1175,17 @@ int main(int argc, char** argv) {
   program->set_include_prefix(include_prefix);
 
   // Initialize global types
-  g_type_void   = new t_base_type("void",   t_base_type::TYPE_VOID);
+  g_type_void = new t_base_type("void", t_base_type::TYPE_VOID);
   g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
   g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
   ((t_base_type*)g_type_binary)->set_binary(true);
-  g_type_slist  = new t_base_type("string", t_base_type::TYPE_STRING);
+  g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
   ((t_base_type*)g_type_slist)->set_string_list(true);
-  g_type_bool   = new t_base_type("bool",   t_base_type::TYPE_BOOL);
-  g_type_byte   = new t_base_type("byte",   t_base_type::TYPE_BYTE);
-  g_type_i16    = new t_base_type("i16",    t_base_type::TYPE_I16);
-  g_type_i32    = new t_base_type("i32",    t_base_type::TYPE_I32);
-  g_type_i64    = new t_base_type("i64",    t_base_type::TYPE_I64);
+  g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
+  g_type_byte = new t_base_type("byte", t_base_type::TYPE_BYTE);
+  g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
+  g_type_i32 = new t_base_type("i32", t_base_type::TYPE_I32);
+  g_type_i64 = new t_base_type("i64", t_base_type::TYPE_I64);
   g_type_double = new t_base_type("double", t_base_type::TYPE_DOUBLE);
 
   // Parse it!

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/main.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/main.h b/compiler/cpp/src/main.h
index 9b0f3f3..a4f81b3 100644
--- a/compiler/cpp/src/main.h
+++ b/compiler/cpp/src/main.h
@@ -29,9 +29,7 @@
  * Defined in the flex library
  */
 
-extern "C" {
-  int yylex(void);
-}
+extern "C" { int yylex(void); }
 
 int yyparse(void);
 
@@ -99,8 +97,8 @@ void check_for_list_of_bytes(t_type* list_elem_type);
  * Flex utilities
  */
 
-extern int   yylineno;
-extern char  yytext[];
+extern int yylineno;
+extern char yytext[];
 extern FILE* yyin;
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/md5.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/md5.h b/compiler/cpp/src/md5.h
index 3baa4dc..3fbe498 100644
--- a/compiler/cpp/src/md5.h
+++ b/compiler/cpp/src/md5.h
@@ -27,7 +27,7 @@
 
   This code implements the MD5 Algorithm defined in RFC 1321, whose
   text is available at
-	http://www.ietf.org/rfc/rfc1321.txt
+    http://www.ietf.org/rfc/rfc1321.txt
   The code is derived from the text of the RFC, including the test suite
   (section A.5) but excluding the rest of Appendix A.  It does not include
   any code or documentation that is identified in the RFC as being
@@ -38,17 +38,17 @@
   that follows (in reverse chronological order):
 
   2002-04-13 lpd Removed support for non-ANSI compilers; removed
-	references to Ghostscript; clarified derivation from RFC 1321;
-	now handles byte order either statically or dynamically.
+    references to Ghostscript; clarified derivation from RFC 1321;
+    now handles byte order either statically or dynamically.
   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
-	added conditionalization for C++ compilation from Martin
-	Purschke <pu...@bnl.gov>.
+    added conditionalization for C++ compilation from Martin
+    Purschke <pu...@bnl.gov>.
   1999-05-03 lpd Original version.
  */
 
 #ifndef md5_INCLUDED
-#  define md5_INCLUDED
+#define md5_INCLUDED
 
 /*
  * This package supports both compile-time and run-time determination of CPU
@@ -61,31 +61,30 @@
  */
 
 typedef unsigned char md5_byte_t; /* 8-bit byte */
-typedef unsigned int md5_word_t; /* 32-bit word */
+typedef unsigned int md5_word_t;  /* 32-bit word */
 
 /* Define the state of the MD5 Algorithm. */
 typedef struct md5_state_s {
-    md5_word_t count[2];	/* message length in bits, lsw first */
-    md5_word_t abcd[4];		/* digest buffer */
-    md5_byte_t buf[64];		/* accumulate block */
+  md5_word_t count[2]; /* message length in bits, lsw first */
+  md5_word_t abcd[4];  /* digest buffer */
+  md5_byte_t buf[64];  /* accumulate block */
 } md5_state_t;
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
 /* Initialize the algorithm. */
-void md5_init(md5_state_t *pms);
+void md5_init(md5_state_t* pms);
 
 /* Append a string to the message. */
-void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes);
 
 /* Finish the message and return the digest. */
-void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+void md5_finish(md5_state_t* pms, md5_byte_t digest[16]);
 
 #ifdef __cplusplus
-}  /* end extern "C" */
+} /* end extern "C" */
 #endif
 
 #endif /* md5_INCLUDED */

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/parse.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/parse.cc b/compiler/cpp/src/parse/parse.cc
index 0a0c2c0..7f94bab 100644
--- a/compiler/cpp/src/parse/parse.cc
+++ b/compiler/cpp/src/parse/parse.cc
@@ -24,7 +24,7 @@
 #include "main.h"
 
 void t_type::generate_fingerprint() {
-  if (! has_fingerprint()) {
+  if (!has_fingerprint()) {
     pdebug("generating fingerprint for %s", get_name().c_str());
     std::string material = get_fingerprint_material();
     md5_state_t ctx;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_base_type.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_base_type.h b/compiler/cpp/src/parse/t_base_type.h
index d76772b..34ff961 100644
--- a/compiler/cpp/src/parse/t_base_type.h
+++ b/compiler/cpp/src/parse/t_base_type.h
@@ -29,7 +29,7 @@
  *
  */
 class t_base_type : public t_type {
- public:
+public:
   /**
    * Enumeration of thrift base types
    */
@@ -44,64 +44,34 @@ class t_base_type : public t_type {
     TYPE_DOUBLE
   };
 
-  t_base_type(std::string name, t_base base) :
-    t_type(name),
-    base_(base),
-    string_list_(false),
-    binary_(false),
-    string_enum_(false){}
+  t_base_type(std::string name, t_base base)
+    : t_type(name), base_(base), string_list_(false), binary_(false), string_enum_(false) {}
 
-  t_base get_base() const {
-    return base_;
-  }
+  t_base get_base() const { return base_; }
 
-  bool is_void() const {
-    return base_ == TYPE_VOID;
-  }
+  bool is_void() const { return base_ == TYPE_VOID; }
 
-  bool is_string() const {
-    return base_ == TYPE_STRING;
-  }
+  bool is_string() const { return base_ == TYPE_STRING; }
 
-  bool is_bool() const {
-    return base_ == TYPE_BOOL;
-  }
+  bool is_bool() const { return base_ == TYPE_BOOL; }
 
-  void set_string_list(bool val) {
-    string_list_ = val;
-  }
+  void set_string_list(bool val) { string_list_ = val; }
 
-  bool is_string_list() const {
-    return (base_ == TYPE_STRING) && string_list_;
-  }
+  bool is_string_list() const { return (base_ == TYPE_STRING) && string_list_; }
 
-  void set_binary(bool val) {
-    binary_ = val;
-  }
+  void set_binary(bool val) { binary_ = val; }
 
-  bool is_binary() const {
-    return (base_ == TYPE_STRING) && binary_;
-  }
+  bool is_binary() const { return (base_ == TYPE_STRING) && binary_; }
 
-  void set_string_enum(bool val) {
-    string_enum_ = val;
-  }
+  void set_string_enum(bool val) { string_enum_ = val; }
 
-  bool is_string_enum() const {
-    return base_ == TYPE_STRING && string_enum_;
-  }
+  bool is_string_enum() const { return base_ == TYPE_STRING && string_enum_; }
 
-  void add_string_enum_val(std::string val) {
-    string_enum_vals_.push_back(val);
-  }
+  void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }
 
-  const std::vector<std::string>& get_string_enum_vals() const {
-    return string_enum_vals_;
-  }
+  const std::vector<std::string>& get_string_enum_vals() const { return string_enum_vals_; }
 
-  bool is_base_type() const {
-    return true;
-  }
+  bool is_base_type() const { return true; }
 
   virtual std::string get_fingerprint_material() const {
     std::string rv = t_base_name(base_);
@@ -113,19 +83,37 @@ class t_base_type : public t_type {
 
   static std::string t_base_name(t_base tbase) {
     switch (tbase) {
-      case TYPE_VOID   : return      "void"; break;
-      case TYPE_STRING : return    "string"; break;
-      case TYPE_BOOL   : return      "bool"; break;
-      case TYPE_BYTE   : return      "byte"; break;
-      case TYPE_I16    : return       "i16"; break;
-      case TYPE_I32    : return       "i32"; break;
-      case TYPE_I64    : return       "i64"; break;
-      case TYPE_DOUBLE : return    "double"; break;
-      default          : return "(unknown)"; break;
+    case TYPE_VOID:
+      return "void";
+      break;
+    case TYPE_STRING:
+      return "string";
+      break;
+    case TYPE_BOOL:
+      return "bool";
+      break;
+    case TYPE_BYTE:
+      return "byte";
+      break;
+    case TYPE_I16:
+      return "i16";
+      break;
+    case TYPE_I32:
+      return "i32";
+      break;
+    case TYPE_I64:
+      return "i64";
+      break;
+    case TYPE_DOUBLE:
+      return "double";
+      break;
+    default:
+      return "(unknown)";
+      break;
     }
   }
 
- private:
+private:
   t_base base_;
 
   bool string_list_;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_const.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_const.h b/compiler/cpp/src/parse/t_const.h
index 7fd81bd..0f64bb1 100644
--- a/compiler/cpp/src/parse/t_const.h
+++ b/compiler/cpp/src/parse/t_const.h
@@ -31,29 +31,20 @@
  *
  */
 class t_const : public t_doc {
- public:
-  t_const(t_type* type, std::string name, t_const_value* value) :
-    type_(type),
-    name_(name),
-    value_(value) {}
+public:
+  t_const(t_type* type, std::string name, t_const_value* value)
+    : type_(type), name_(name), value_(value) {}
 
-  t_type* get_type() const {
-    return type_;
-  }
+  t_type* get_type() const { return type_; }
 
-  std::string get_name() const {
-    return name_;
-  }
+  std::string get_name() const { return name_; }
 
-  t_const_value* get_value() const {
-    return value_;
-  }
+  t_const_value* get_value() const { return value_; }
 
- private:
+private:
   t_type* type_;
   std::string name_;
   t_const_value* value_;
 };
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_const_value.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_const_value.h b/compiler/cpp/src/parse/t_const_value.h
index ff422ae..7e6e3f6 100644
--- a/compiler/cpp/src/parse/t_const_value.h
+++ b/compiler/cpp/src/parse/t_const_value.h
@@ -32,35 +32,21 @@
  *
  */
 class t_const_value {
- public:
-
-  enum t_const_value_type {
-    CV_INTEGER,
-    CV_DOUBLE,
-    CV_STRING,
-    CV_MAP,
-    CV_LIST,
-    CV_IDENTIFIER
-  };
+public:
+  enum t_const_value_type { CV_INTEGER, CV_DOUBLE, CV_STRING, CV_MAP, CV_LIST, CV_IDENTIFIER };
 
   t_const_value() {}
 
-  t_const_value(int64_t val) {
-    set_integer(val);
-  }
+  t_const_value(int64_t val) { set_integer(val); }
 
-  t_const_value(std::string val) {
-    set_string(val);
-  }
+  t_const_value(std::string val) { set_string(val); }
 
   void set_string(std::string val) {
     valType_ = CV_STRING;
     stringVal_ = val;
   }
 
-  std::string get_string() const {
-    return stringVal_;
-  }
+  std::string get_string() const { return stringVal_; }
 
   void set_integer(int64_t val) {
     valType_ = CV_INTEGER;
@@ -75,13 +61,12 @@ class t_const_value {
       std::string identifier = get_identifier();
       std::string::size_type dot = identifier.rfind('.');
       if (dot != std::string::npos) {
-        identifier = identifier.substr(dot+1);
+        identifier = identifier.substr(dot + 1);
       }
       t_enum_value* val = enum_->get_constant_by_name(identifier);
       if (val == NULL) {
-        throw
-          "Unable to find enum value \"" + identifier +
-          "\" in enum \"" + enum_->get_name() + "\"";
+        throw "Unable to find enum value \"" + identifier + "\" in enum \"" + enum_->get_name()
+            + "\"";
       }
       return val->get_value();
     } else {
@@ -94,42 +79,26 @@ class t_const_value {
     doubleVal_ = val;
   }
 
-  double get_double() const {
-    return doubleVal_;
-  }
+  double get_double() const { return doubleVal_; }
 
-  void set_map() {
-    valType_ = CV_MAP;
-  }
+  void set_map() { valType_ = CV_MAP; }
 
-  void add_map(t_const_value* key, t_const_value* val) {
-    mapVal_[key] = val;
-  }
+  void add_map(t_const_value* key, t_const_value* val) { mapVal_[key] = val; }
 
-  const std::map<t_const_value*, t_const_value*>& get_map() const {
-    return mapVal_;
-  }
+  const std::map<t_const_value*, t_const_value*>& get_map() const { return mapVal_; }
 
-  void set_list() {
-    valType_ = CV_LIST;
-  }
+  void set_list() { valType_ = CV_LIST; }
 
-  void add_list(t_const_value* val) {
-    listVal_.push_back(val);
-  }
+  void add_list(t_const_value* val) { listVal_.push_back(val); }
 
-  const std::vector<t_const_value*>& get_list() const {
-    return listVal_;
-  }
+  const std::vector<t_const_value*>& get_list() const { return listVal_; }
 
   void set_identifier(std::string val) {
     valType_ = CV_IDENTIFIER;
     identifierVal_ = val;
   }
 
-  std::string get_identifier() const {
-    return identifierVal_;
-  }
+  std::string get_identifier() const { return identifierVal_; }
 
   std::string get_identifier_name() const {
     std::string ret = get_identifier();
@@ -137,10 +106,10 @@ class t_const_value {
     if (s == std::string::npos) {
       throw "error: identifier " + ret + " is unqualified!";
     }
-    ret = ret.substr(s+1);
+    ret = ret.substr(s + 1);
     s = ret.find('.');
     if (s != std::string::npos) {
-      ret = ret.substr(s+1);
+      ret = ret.substr(s + 1);
     }
     return ret;
   }
@@ -151,22 +120,18 @@ class t_const_value {
     if (s == std::string::npos) {
       throw "error: identifier " + ret + " is unqualified!";
     }
-    size_t s2 = ret.find('.', s+1);
+    size_t s2 = ret.find('.', s + 1);
     if (s2 != std::string::npos) {
-      ret = ret.substr(s+1);
+      ret = ret.substr(s + 1);
     }
     return ret;
   }
 
-  void set_enum(t_enum* tenum) {
-    enum_ = tenum;
-  }
+  void set_enum(t_enum* tenum) { enum_ = tenum; }
 
-  t_const_value_type get_type() const {
-    return valType_;
-  }
+  t_const_value_type get_type() const { return valType_; }
 
- private:
+private:
   std::map<t_const_value*, t_const_value*> mapVal_;
   std::vector<t_const_value*> listVal_;
   std::string stringVal_;
@@ -176,8 +141,6 @@ class t_const_value {
   t_enum* enum_;
 
   t_const_value_type valType_;
-
 };
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_container.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_container.h b/compiler/cpp/src/parse/t_container.h
index 6753493..0d992b7 100644
--- a/compiler/cpp/src/parse/t_container.h
+++ b/compiler/cpp/src/parse/t_container.h
@@ -23,10 +23,8 @@
 #include "t_type.h"
 
 class t_container : public t_type {
- public:
-  t_container() :
-    cpp_name_(),
-    has_cpp_name_(false) {}
+public:
+  t_container() : cpp_name_(), has_cpp_name_(false) {}
 
   virtual ~t_container() {}
 
@@ -35,22 +33,15 @@ class t_container : public t_type {
     has_cpp_name_ = true;
   }
 
-  bool has_cpp_name() {
-    return has_cpp_name_;
-  }
+  bool has_cpp_name() { return has_cpp_name_; }
 
-  std::string get_cpp_name() {
-    return cpp_name_;
-  }
+  std::string get_cpp_name() { return cpp_name_; }
 
-  bool is_container() const {
-    return true;
-  }
+  bool is_container() const { return true; }
 
- private:
+private:
   std::string cpp_name_;
   bool has_cpp_name_;
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_doc.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_doc.h b/compiler/cpp/src/parse/t_doc.h
index 2c63b5a..9d310b7 100644
--- a/compiler/cpp/src/parse/t_doc.h
+++ b/compiler/cpp/src/parse/t_doc.h
@@ -29,30 +29,26 @@
  */
 class t_doc {
 
- public:
+public:
   t_doc() : has_doc_(false) {}
 
   void set_doc(const std::string& doc) {
     doc_ = doc;
     has_doc_ = true;
-    if( (g_program_doctext_lineno == g_doctext_lineno) &&  (g_program_doctext_status == STILL_CANDIDATE)) {
+    if ((g_program_doctext_lineno == g_doctext_lineno)
+        && (g_program_doctext_status == STILL_CANDIDATE)) {
       g_program_doctext_status = ALREADY_PROCESSED;
-      pdebug("%s","program doctext set to ALREADY_PROCESSED");
+      pdebug("%s", "program doctext set to ALREADY_PROCESSED");
     }
   }
 
-  const std::string& get_doc() const {
-    return doc_;
-  }
+  const std::string& get_doc() const { return doc_; }
 
-  bool has_doc() {
-    return has_doc_;
-  }
+  bool has_doc() { return has_doc_; }
 
- private:
+private:
   std::string doc_;
   bool has_doc_;
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_enum.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h
index 94cb26e..59941e3 100644
--- a/compiler/cpp/src/parse/t_enum.h
+++ b/compiler/cpp/src/parse/t_enum.h
@@ -28,21 +28,14 @@
  *
  */
 class t_enum : public t_type {
- public:
-  t_enum(t_program* program) :
-    t_type(program) {}
+public:
+  t_enum(t_program* program) : t_type(program) {}
 
-  void set_name(const std::string& name) {
-    name_ = name;
-  }
+  void set_name(const std::string& name) { name_ = name; }
 
-  void append(t_enum_value* constant) {
-    constants_.push_back(constant);
-  }
+  void append(t_enum_value* constant) { constants_.push_back(constant); }
 
-  const std::vector<t_enum_value*>& get_constants() {
-    return constants_;
-  }
+  const std::vector<t_enum_value*>& get_constants() { return constants_; }
 
   t_enum_value* get_constant_by_name(const std::string name) {
     const std::vector<t_enum_value*>& enum_values = get_constants();
@@ -72,8 +65,7 @@ class t_enum : public t_type {
     t_enum_value* min_value;
     if (enum_values.size() == 0) {
       min_value = NULL;
-    }
-    else {
+    } else {
       int min_value_value;
       min_value = enum_values.front();
       min_value_value = min_value->get_value();
@@ -93,8 +85,7 @@ class t_enum : public t_type {
     t_enum_value* max_value;
     if (enum_values.size() == 0) {
       max_value = NULL;
-    }
-    else {
+    } else {
       int max_value_value;
       max_value = enum_values.back();
       max_value_value = max_value->get_value();
@@ -108,16 +99,11 @@ class t_enum : public t_type {
     return max_value;
   }
 
-  bool is_enum() const {
-    return true;
-  }
-
-  virtual std::string get_fingerprint_material() const {
-    return "enum";
-  }
+  bool is_enum() const { return true; }
 
+  virtual std::string get_fingerprint_material() const { return "enum"; }
 
- private:
+private:
   std::vector<t_enum_value*> constants_;
 };
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_enum_value.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_enum_value.h b/compiler/cpp/src/parse/t_enum_value.h
index 26798d7..5979f06 100644
--- a/compiler/cpp/src/parse/t_enum_value.h
+++ b/compiler/cpp/src/parse/t_enum_value.h
@@ -30,24 +30,18 @@
  *
  */
 class t_enum_value : public t_doc {
- public:
-  t_enum_value(std::string name, int value) :
-    name_(name),
-    value_(value) {}
+public:
+  t_enum_value(std::string name, int value) : name_(name), value_(value) {}
 
   ~t_enum_value() {}
 
-  const std::string& get_name() const {
-    return name_;
-  }
+  const std::string& get_name() const { return name_; }
 
-  int get_value() const {
-    return value_;
-  }
+  int get_value() const { return value_; }
 
   std::map<std::string, std::string> annotations_;
 
- private:
+private:
   std::string name_;
   int value_;
 };

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_field.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
index c05fdf3..c4e30e3 100644
--- a/compiler/cpp/src/parse/t_field.h
+++ b/compiler/cpp/src/parse/t_field.h
@@ -34,96 +34,65 @@ class t_struct;
  *
  */
 class t_field : public t_doc {
- public:
-  t_field(t_type* type, std::string name) :
-    type_(type),
-    name_(name),
-    key_(0),
-    value_(NULL),
-    xsd_optional_(false),
-    xsd_nillable_(false),
-    xsd_attrs_(NULL),
-    reference_(false) {}
-
-  t_field(t_type* type, std::string name, int32_t key) :
-    type_(type),
-    name_(name),
-    key_(key),
-    req_(T_OPT_IN_REQ_OUT),
-    value_(NULL),
-    xsd_optional_(false),
-    xsd_nillable_(false),
-    xsd_attrs_(NULL),
-    reference_(false) {}
+public:
+  t_field(t_type* type, std::string name)
+    : type_(type),
+      name_(name),
+      key_(0),
+      value_(NULL),
+      xsd_optional_(false),
+      xsd_nillable_(false),
+      xsd_attrs_(NULL),
+      reference_(false) {}
+
+  t_field(t_type* type, std::string name, int32_t key)
+    : type_(type),
+      name_(name),
+      key_(key),
+      req_(T_OPT_IN_REQ_OUT),
+      value_(NULL),
+      xsd_optional_(false),
+      xsd_nillable_(false),
+      xsd_attrs_(NULL),
+      reference_(false) {}
 
   ~t_field() {}
 
-  t_type* get_type() const {
-    return type_;
-  }
+  t_type* get_type() const { return type_; }
 
-  const std::string& get_name() const {
-    return name_;
-  }
+  const std::string& get_name() const { return name_; }
 
-  int32_t get_key() const {
-    return key_;
-  }
+  int32_t get_key() const { return key_; }
 
-  enum e_req {
-    T_REQUIRED,
-    T_OPTIONAL,
-    T_OPT_IN_REQ_OUT
-  };
+  enum e_req { T_REQUIRED, T_OPTIONAL, T_OPT_IN_REQ_OUT };
 
-  void set_req(e_req req) {
-    req_ = req;
-  }
+  void set_req(e_req req) { req_ = req; }
 
-  e_req get_req() const {
-    return req_;
-  }
+  e_req get_req() const { return req_; }
 
-  void set_value(t_const_value* value) {
-    value_ = value;
-  }
+  void set_value(t_const_value* value) { value_ = value; }
 
-  t_const_value* get_value() {
-    return value_;
-  }
+  t_const_value* get_value() { return value_; }
 
-  void set_xsd_optional(bool xsd_optional) {
-    xsd_optional_ = xsd_optional;
-  }
+  void set_xsd_optional(bool xsd_optional) { xsd_optional_ = xsd_optional; }
 
-  bool get_xsd_optional() const {
-    return xsd_optional_;
-  }
+  bool get_xsd_optional() const { return xsd_optional_; }
 
-  void set_xsd_nillable(bool xsd_nillable) {
-    xsd_nillable_ = xsd_nillable;
-  }
+  void set_xsd_nillable(bool xsd_nillable) { xsd_nillable_ = xsd_nillable; }
 
-  bool get_xsd_nillable() const {
-    return xsd_nillable_;
-  }
+  bool get_xsd_nillable() const { return xsd_nillable_; }
 
-  void set_xsd_attrs(t_struct* xsd_attrs) {
-    xsd_attrs_ = xsd_attrs;
-  }
+  void set_xsd_attrs(t_struct* xsd_attrs) { xsd_attrs_ = xsd_attrs; }
 
-  t_struct* get_xsd_attrs() {
-    return xsd_attrs_;
-  }
+  t_struct* get_xsd_attrs() { return xsd_attrs_; }
 
   // This is not the same function as t_type::get_fingerprint_material,
   // but it does the same thing.
   std::string get_fingerprint_material() const {
     std::ostringstream keystm;
     keystm << key_;
-    return keystm.str() + ":" +
-      ((req_ == T_OPTIONAL) ? "opt-" : "") +
-      type_->get_fingerprint_material();
+    return keystm.str() + ":" + ((req_ == T_OPTIONAL) ? "opt-" : "")
+           + type_->get_fingerprint_material();
   }
 
   /**
@@ -132,22 +101,18 @@ class t_field : public t_doc {
    * The arguments are (const) references to const pointers to const t_fields.
    */
   struct key_compare {
-    bool operator()(t_field const * const & a, t_field const * const & b) {
+    bool operator()(t_field const* const& a, t_field const* const& b) {
       return a->get_key() < b->get_key();
     }
   };
 
   std::map<std::string, std::string> annotations_;
 
-  bool get_reference() {
-    return reference_;
-  }
+  bool get_reference() { return reference_; }
 
-  void set_reference(bool reference) {
-    reference_ = reference;
-  }
+  void set_reference(bool reference) { reference_ = reference; }
 
- private:
+private:
   t_type* type_;
   std::string name_;
   int32_t key_;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_function.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_function.h b/compiler/cpp/src/parse/t_function.h
index ae8c2f6..96886f3 100644
--- a/compiler/cpp/src/parse/t_function.h
+++ b/compiler/cpp/src/parse/t_function.h
@@ -32,17 +32,11 @@
  *
  */
 class t_function : public t_doc {
- public:
-  t_function(t_type* returntype,
-             std::string name,
-             t_struct* arglist,
-             bool oneway=false) :
-    returntype_(returntype),
-    name_(name),
-    arglist_(arglist),
-    oneway_(oneway) {
+public:
+  t_function(t_type* returntype, std::string name, t_struct* arglist, bool oneway = false)
+    : returntype_(returntype), name_(name), arglist_(arglist), oneway_(oneway) {
     xceptions_ = new t_struct(NULL);
-    if (oneway_ && (! returntype_->is_void())) {
+    if (oneway_ && (!returntype_->is_void())) {
       pwarning(1, "Oneway methods should return void.\n");
     }
   }
@@ -51,46 +45,35 @@ class t_function : public t_doc {
              std::string name,
              t_struct* arglist,
              t_struct* xceptions,
-             bool oneway=false) :
-    returntype_(returntype),
-    name_(name),
-    arglist_(arglist),
-    xceptions_(xceptions),
-    oneway_(oneway)
-  {
+             bool oneway = false)
+    : returntype_(returntype),
+      name_(name),
+      arglist_(arglist),
+      xceptions_(xceptions),
+      oneway_(oneway) {
     if (oneway_ && !xceptions_->get_members().empty()) {
       throw std::string("Oneway methods can't throw exceptions.");
     }
-    if (oneway_ && (! returntype_->is_void())) {
+    if (oneway_ && (!returntype_->is_void())) {
       pwarning(1, "Oneway methods should return void.\n");
     }
   }
 
   ~t_function() {}
 
-  t_type* get_returntype() const {
-    return returntype_;
-  }
+  t_type* get_returntype() const { return returntype_; }
 
-  const std::string& get_name() const {
-    return name_;
-  }
+  const std::string& get_name() const { return name_; }
 
-  t_struct* get_arglist() const {
-    return arglist_;
-  }
+  t_struct* get_arglist() const { return arglist_; }
 
-  t_struct* get_xceptions() const {
-    return xceptions_;
-  }
+  t_struct* get_xceptions() const { return xceptions_; }
 
-  bool is_oneway() const {
-    return oneway_;
-  }
+  bool is_oneway() const { return oneway_; }
 
   std::map<std::string, std::string> annotations_;
 
- private:
+private:
   t_type* returntype_;
   std::string name_;
   t_struct* arglist_;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_list.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_list.h b/compiler/cpp/src/parse/t_list.h
index 21a9625..e121d1d 100644
--- a/compiler/cpp/src/parse/t_list.h
+++ b/compiler/cpp/src/parse/t_list.h
@@ -27,17 +27,12 @@
  *
  */
 class t_list : public t_container {
- public:
-  t_list(t_type* elem_type) :
-    elem_type_(elem_type) {}
+public:
+  t_list(t_type* elem_type) : elem_type_(elem_type) {}
 
-  t_type* get_elem_type() const {
-    return elem_type_;
-  }
+  t_type* get_elem_type() const { return elem_type_; }
 
-  bool is_list() const {
-    return true;
-  }
+  bool is_list() const { return true; }
 
   virtual std::string get_fingerprint_material() const {
     return "list<" + elem_type_->get_fingerprint_material() + ">";
@@ -48,9 +43,8 @@ class t_list : public t_container {
     elem_type_->generate_fingerprint();
   }
 
- private:
+private:
   t_type* elem_type_;
 };
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_map.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_map.h b/compiler/cpp/src/parse/t_map.h
index c4e358f..4795147 100644
--- a/compiler/cpp/src/parse/t_map.h
+++ b/compiler/cpp/src/parse/t_map.h
@@ -28,26 +28,18 @@
  *
  */
 class t_map : public t_container {
- public:
-  t_map(t_type* key_type, t_type* val_type) :
-    key_type_(key_type),
-    val_type_(val_type) {}
+public:
+  t_map(t_type* key_type, t_type* val_type) : key_type_(key_type), val_type_(val_type) {}
 
-  t_type* get_key_type() const {
-    return key_type_;
-  }
+  t_type* get_key_type() const { return key_type_; }
 
-  t_type* get_val_type() const {
-    return val_type_;
-  }
+  t_type* get_val_type() const { return val_type_; }
 
-  bool is_map() const {
-    return true;
-  }
+  bool is_map() const { return true; }
 
   virtual std::string get_fingerprint_material() const {
-    return "map<" + key_type_->get_fingerprint_material() +
-      "," + val_type_->get_fingerprint_material() + ">";
+    return "map<" + key_type_->get_fingerprint_material() + ","
+           + val_type_->get_fingerprint_material() + ">";
   }
 
   virtual void generate_fingerprint() {
@@ -56,7 +48,7 @@ class t_map : public t_container {
     val_type_->generate_fingerprint();
   }
 
- private:
+private:
   t_type* key_type_;
   t_type* val_type_;
 };

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_program.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index d18cc5d..51157aa 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -56,30 +56,22 @@
  *
  */
 class t_program : public t_doc {
- public:
-  t_program(std::string path, std::string name) :
-    path_(path),
-    name_(name),
-    out_path_("./"),
-    out_path_is_absolute_(false) {
+public:
+  t_program(std::string path, std::string name)
+    : path_(path), name_(name), out_path_("./"), out_path_is_absolute_(false) {
     scope_ = new t_scope();
   }
 
-  t_program(std::string path) :
-    path_(path),
-    out_path_("./"),
-    out_path_is_absolute_(false) {
+  t_program(std::string path) : path_(path), out_path_("./"), out_path_is_absolute_(false) {
     name_ = program_name(path);
     scope_ = new t_scope();
   }
 
-  ~t_program()
-  {
-   if(scope_)
-   {
-     delete scope_;
-     scope_ = NULL;
-   }
+  ~t_program() {
+    if (scope_) {
+      delete scope_;
+      scope_ = NULL;
+    }
   }
 
   // Path accessor
@@ -101,23 +93,27 @@ class t_program : public t_doc {
   const std::string& get_include_prefix() const { return include_prefix_; }
 
   // Accessors for program elements
-  const std::vector<t_typedef*>& get_typedefs()  const { return typedefs_;  }
-  const std::vector<t_enum*>&    get_enums()     const { return enums_;     }
-  const std::vector<t_const*>&   get_consts()    const { return consts_;    }
-  const std::vector<t_struct*>&  get_structs()   const { return structs_;   }
-  const std::vector<t_struct*>&  get_xceptions() const { return xceptions_; }
-  const std::vector<t_struct*>&  get_objects()   const { return objects_;   }
-  const std::vector<t_service*>& get_services()  const { return services_;  }
+  const std::vector<t_typedef*>& get_typedefs() const { return typedefs_; }
+  const std::vector<t_enum*>& get_enums() const { return enums_; }
+  const std::vector<t_const*>& get_consts() const { return consts_; }
+  const std::vector<t_struct*>& get_structs() const { return structs_; }
+  const std::vector<t_struct*>& get_xceptions() const { return xceptions_; }
+  const std::vector<t_struct*>& get_objects() const { return objects_; }
+  const std::vector<t_service*>& get_services() const { return services_; }
 
   // Program elements
-  void add_typedef  (t_typedef* td) { typedefs_.push_back(td);  }
-  void add_enum     (t_enum*    te) { enums_.push_back(te);     }
-  void add_const    (t_const*   tc) { consts_.push_back(tc);    }
-  void add_struct   (t_struct*  ts) { objects_.push_back(ts);
-                                      structs_.push_back(ts);   }
-  void add_xception (t_struct*  tx) { objects_.push_back(tx);
-                                      xceptions_.push_back(tx); }
-  void add_service  (t_service* ts) { services_.push_back(ts);  }
+  void add_typedef(t_typedef* td) { typedefs_.push_back(td); }
+  void add_enum(t_enum* te) { enums_.push_back(te); }
+  void add_const(t_const* tc) { consts_.push_back(tc); }
+  void add_struct(t_struct* ts) {
+    objects_.push_back(ts);
+    structs_.push_back(ts);
+  }
+  void add_xception(t_struct* tx) {
+    objects_.push_back(tx);
+    xceptions_.push_back(tx);
+  }
+  void add_service(t_service* ts) { services_.push_back(ts); }
 
   // Programs to include
   const std::vector<t_program*>& get_includes() const { return includes_; }
@@ -138,10 +134,9 @@ class t_program : public t_doc {
    * @param t    the type to test for collisions
    * @return     true if a certain collision was found, otherwise false
    */
-  bool is_unique_typename(t_type * t) {
+  bool is_unique_typename(t_type* t) {
     int occurances = program_typename_count(this, t);
-    for (std::vector<t_program*>::iterator it = includes_.begin();
-         it != includes_.end(); ++it) {
+    for (std::vector<t_program*>::iterator it = includes_.begin(); it != includes_.end(); ++it) {
       occurances += program_typename_count(*it, t);
     }
     return 0 == occurances;
@@ -153,7 +148,7 @@ class t_program : public t_doc {
    * @param t    the type to test for collisions
    * @return     the number of certain typename collisions
    */
-  int program_typename_count(t_program * prog, t_type * t) {
+  int program_typename_count(t_program* prog, t_type* t) {
     int occurances = 0;
     occurances += collection_typename_count(prog, prog->typedefs_, t);
     occurances += collection_typename_count(prog, prog->enums_, t);
@@ -170,7 +165,7 @@ class t_program : public t_doc {
    * @return                the number of certain typename collisions
    */
   template <class T>
-  int collection_typename_count(t_program * prog, T type_collection, t_type * t) {
+  int collection_typename_count(t_program* prog, T type_collection, t_type* t) {
     int occurances = 0;
     for (typename T::iterator it = type_collection.begin(); it != type_collection.end(); ++it)
       if (t != *it && 0 == t->get_name().compare((*it)->get_name()) && is_common_namespace(prog, t))
@@ -190,54 +185,67 @@ class t_program : public t_doc {
    * @param t    the type containing the typename match
    * @return     true if a collision within namespaces is found, otherwise false
    */
-  bool is_common_namespace(t_program * prog, t_type * t) {
-    //Case 1: Typenames are in the same program [collision]
+  bool is_common_namespace(t_program* prog, t_type* t) {
+    // Case 1: Typenames are in the same program [collision]
     if (prog == t->get_program()) {
-      pwarning(1, "Duplicate typename %s found in %s",
-               t->get_name().c_str(), t->get_program()->get_name().c_str());
+      pwarning(1,
+               "Duplicate typename %s found in %s",
+               t->get_name().c_str(),
+               t->get_program()->get_name().c_str());
       return true;
     }
 
-    //Case 2: Both programs have identical namespace scope/name declarations [collision]
+    // Case 2: Both programs have identical namespace scope/name declarations [collision]
     bool match = true;
     for (std::map<std::string, std::string>::iterator it = prog->namespaces_.begin();
-         it != prog->namespaces_.end(); ++it) {
+         it != prog->namespaces_.end();
+         ++it) {
       if (0 == it->second.compare(t->get_program()->get_namespace(it->first))) {
-        pwarning(1, "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
+        pwarning(1,
+                 "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
                  t->get_name().c_str(),
-                 t->get_program()->get_name().c_str(), it->first.c_str(), it->second.c_str(),
-                 prog->get_name().c_str(), it->first.c_str(), it->second.c_str());
+                 t->get_program()->get_name().c_str(),
+                 it->first.c_str(),
+                 it->second.c_str(),
+                 prog->get_name().c_str(),
+                 it->first.c_str(),
+                 it->second.c_str());
       } else {
         match = false;
       }
     }
     for (std::map<std::string, std::string>::iterator it = t->get_program()->namespaces_.begin();
-         it != t->get_program()->namespaces_.end(); ++it) {
+         it != t->get_program()->namespaces_.end();
+         ++it) {
       if (0 == it->second.compare(prog->get_namespace(it->first))) {
-        pwarning(1, "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
+        pwarning(1,
+                 "Duplicate typename %s found in %s,%s,%s and %s,%s,%s [file,scope,ns]",
                  t->get_name().c_str(),
-                 t->get_program()->get_name().c_str(), it->first.c_str(), it->second.c_str(),
-                 prog->get_name().c_str(), it->first.c_str(), it->second.c_str());
+                 t->get_program()->get_name().c_str(),
+                 it->first.c_str(),
+                 it->second.c_str(),
+                 prog->get_name().c_str(),
+                 it->first.c_str(),
+                 it->second.c_str());
       } else {
         match = false;
       }
     }
     if (0 == prog->namespaces_.size() && 0 == t->get_program()->namespaces_.size()) {
-      pwarning(1, "Duplicate typename %s found in %s and %s",
-        t->get_name().c_str(), t->get_program()->get_name().c_str(),  prog->get_name().c_str());
+      pwarning(1,
+               "Duplicate typename %s found in %s and %s",
+               t->get_name().c_str(),
+               t->get_program()->get_name().c_str(),
+               prog->get_name().c_str());
     }
     return match;
   }
 
   // Scoping and namespacing
-  void set_namespace(std::string name) {
-    namespace_ = name;
-  }
+  void set_namespace(std::string name) { namespace_ = name; }
 
   // Scope accessor
-  t_scope* scope() const {
-    return scope_;
-  }
+  t_scope* scope() const { return scope_; }
 
   // Includes
 
@@ -256,9 +264,7 @@ class t_program : public t_doc {
     includes_.push_back(program);
   }
 
-  std::vector<t_program*>& get_includes() {
-    return includes_;
-  }
+  std::vector<t_program*>& get_includes() { return includes_; }
 
   void set_include_prefix(std::string include_prefix) {
     include_prefix_ = include_prefix;
@@ -277,7 +283,7 @@ class t_program : public t_doc {
       std::string base_language = language.substr(0, sub_index);
       std::string sub_namespace;
 
-      if(base_language == "smalltalk") {
+      if (base_language == "smalltalk") {
         pwarning(1, "Namespace 'smalltalk' is deprecated. Use 'st' instead");
         base_language = "st";
       }
@@ -285,16 +291,17 @@ class t_program : public t_doc {
       t_generator_registry::gen_map_t my_copy = t_generator_registry::get_generator_map();
 
       t_generator_registry::gen_map_t::iterator it;
-      it=my_copy.find(base_language);
+      it = my_copy.find(base_language);
 
       if (it == my_copy.end()) {
         std::string warning = "No generator named '" + base_language + "' could be found!";
         pwarning(1, warning.c_str());
       } else {
         if (sub_index != std::string::npos) {
-          std::string sub_namespace = language.substr(sub_index+1);
-          if ( ! it->second->is_valid_namespace(sub_namespace)) {
-            std::string warning = base_language + " generator does not accept '" + sub_namespace + "' as sub-namespace!";
+          std::string sub_namespace = language.substr(sub_index + 1);
+          if (!it->second->is_valid_namespace(sub_namespace)) {
+            std::string warning = base_language + " generator does not accept '" + sub_namespace
+                                  + "' as sub-namespace!";
             pwarning(1, warning.c_str());
           }
         }
@@ -306,8 +313,8 @@ class t_program : public t_doc {
 
   std::string get_namespace(std::string language) const {
     std::map<std::string, std::string>::const_iterator iter;
-    if ((iter = namespaces_.find(language)) != namespaces_.end() ||
-        (iter = namespaces_.find("*"     )) != namespaces_.end()) {
+    if ((iter = namespaces_.find(language)) != namespaces_.end()
+        || (iter = namespaces_.find("*")) != namespaces_.end()) {
       return iter->second;
     }
     return std::string();
@@ -315,24 +322,15 @@ class t_program : public t_doc {
 
   // Language specific namespace / packaging
 
-  void add_cpp_include(std::string path) {
-    cpp_includes_.push_back(path);
-  }
-
-  const std::vector<std::string>& get_cpp_includes() {
-    return cpp_includes_;
-  }
+  void add_cpp_include(std::string path) { cpp_includes_.push_back(path); }
 
-  void add_c_include(std::string path) {
-    c_includes_.push_back(path);
-  }
+  const std::vector<std::string>& get_cpp_includes() { return cpp_includes_; }
 
-  const std::vector<std::string>& get_c_includes() {
-    return c_includes_;
-  }
+  void add_c_include(std::string path) { c_includes_.push_back(path); }
 
- private:
+  const std::vector<std::string>& get_c_includes() { return c_includes_; }
 
+private:
   // File path
   std::string path_;
 
@@ -359,11 +357,11 @@ class t_program : public t_doc {
 
   // Components to generate code for
   std::vector<t_typedef*> typedefs_;
-  std::vector<t_enum*>    enums_;
-  std::vector<t_const*>   consts_;
-  std::vector<t_struct*>  objects_;
-  std::vector<t_struct*>  structs_;
-  std::vector<t_struct*>  xceptions_;
+  std::vector<t_enum*> enums_;
+  std::vector<t_const*> consts_;
+  std::vector<t_struct*> objects_;
+  std::vector<t_struct*> structs_;
+  std::vector<t_struct*> xceptions_;
   std::vector<t_service*> services_;
 
   // Dynamic namespaces
@@ -374,7 +372,6 @@ class t_program : public t_doc {
 
   // C extra includes
   std::vector<std::string> c_includes_;
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_scope.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h
index e73c0f3..c108fdd 100644
--- a/compiler/cpp/src/parse/t_scope.h
+++ b/compiler/cpp/src/parse/t_scope.h
@@ -40,24 +40,16 @@
  *
  */
 class t_scope {
- public:
+public:
   t_scope() {}
 
-  void add_type(std::string name, t_type* type) {
-    types_[name] = type;
-  }
+  void add_type(std::string name, t_type* type) { types_[name] = type; }
 
-  t_type* get_type(std::string name) {
-    return types_[name];
-  }
+  t_type* get_type(std::string name) { return types_[name]; }
 
-  void add_service(std::string name, t_service* service) {
-    services_[name] = service;
-  }
+  void add_service(std::string name, t_service* service) { services_[name] = service; }
 
-  t_service* get_service(std::string name) {
-    return services_[name];
-  }
+  t_service* get_service(std::string name) { return services_[name]; }
 
   void add_constant(std::string name, t_const* constant) {
     if (constants_.find(name) != constants_.end()) {
@@ -67,16 +59,12 @@ class t_scope {
     }
   }
 
-  t_const* get_constant(std::string name) {
-    return constants_[name];
-  }
+  t_const* get_constant(std::string name) { return constants_[name]; }
 
   void print() {
     std::map<std::string, t_type*>::iterator iter;
     for (iter = types_.begin(); iter != types_.end(); ++iter) {
-      printf("%s => %s\n",
-             iter->first.c_str(),
-             iter->second->get_name().c_str());
+      printf("%s => %s\n", iter->first.c_str(), iter->second->get_name().c_str());
     }
   }
 
@@ -101,7 +89,8 @@ class t_scope {
       for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
         t_field* field = tstruct->get_field_by_name(v_iter->first->get_string());
         if (field == NULL) {
-          throw "No field named \"" + v_iter->first->get_string() + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
+          throw "No field named \"" + v_iter->first->get_string()
+              + "\" was found in struct of type \"" + tstruct->get_name() + "\"";
         }
         resolve_const_value(v_iter->second, field->get_type());
       }
@@ -119,21 +108,21 @@ class t_scope {
 
         if (const_type->is_base_type()) {
           switch (((t_base_type*)const_type)->get_base()) {
-            case t_base_type::TYPE_I16:
-            case t_base_type::TYPE_I32:
-            case t_base_type::TYPE_I64:
-            case t_base_type::TYPE_BOOL:
-            case t_base_type::TYPE_BYTE:
-              const_val->set_integer(constant->get_value()->get_integer());
-              break;
-            case t_base_type::TYPE_STRING:
-              const_val->set_string(constant->get_value()->get_string());
-              break;
-            case t_base_type::TYPE_DOUBLE:
-              const_val->set_double(constant->get_value()->get_double());
-              break;
-            case t_base_type::TYPE_VOID:
-              throw "Constants cannot be of type VOID";
+          case t_base_type::TYPE_I16:
+          case t_base_type::TYPE_I32:
+          case t_base_type::TYPE_I64:
+          case t_base_type::TYPE_BOOL:
+          case t_base_type::TYPE_BYTE:
+            const_val->set_integer(constant->get_value()->get_integer());
+            break;
+          case t_base_type::TYPE_STRING:
+            const_val->set_string(constant->get_value()->get_string());
+            break;
+          case t_base_type::TYPE_DOUBLE:
+            const_val->set_double(constant->get_value()->get_double());
+            break;
+          case t_base_type::TYPE_VOID:
+            throw "Constants cannot be of type VOID";
           }
         } else if (const_type->is_map()) {
           const std::map<t_const_value*, t_const_value*>& map = constant->get_value()->get_map();
@@ -161,15 +150,15 @@ class t_scope {
       if (enum_value == NULL) {
         std::ostringstream valstm;
         valstm << const_val->get_integer();
-        throw "Couldn't find a named value in enum " + tenum->get_name() + " for value " + valstm.str();
+        throw "Couldn't find a named value in enum " + tenum->get_name() + " for value "
+            + valstm.str();
       }
       const_val->set_identifier(tenum->get_name() + "." + enum_value->get_name());
       const_val->set_enum(tenum);
     }
   }
 
- private:
-
+private:
   // Map of names to types
   std::map<std::string, t_type*> types_;
 
@@ -178,7 +167,6 @@ class t_scope {
 
   // Map of names to services
   std::map<std::string, t_service*> services_;
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_service.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_service.h b/compiler/cpp/src/parse/t_service.h
index 31e6924..091403d 100644
--- a/compiler/cpp/src/parse/t_service.h
+++ b/compiler/cpp/src/parse/t_service.h
@@ -30,18 +30,12 @@ class t_program;
  *
  */
 class t_service : public t_type {
- public:
-  t_service(t_program* program) :
-    t_type(program),
-    extends_(NULL) {}
+public:
+  t_service(t_program* program) : t_type(program), extends_(NULL) {}
 
-  bool is_service() const {
-    return true;
-  }
+  bool is_service() const { return true; }
 
-  void set_extends(t_service* extends) {
-    extends_ = extends;
-  }
+  void set_extends(t_service* extends) { extends_ = extends; }
 
   void add_function(t_function* func) {
     std::vector<t_function*>::const_iterator iter;
@@ -53,20 +47,16 @@ class t_service : public t_type {
     functions_.push_back(func);
   }
 
-  const std::vector<t_function*>& get_functions() const {
-    return functions_;
-  }
+  const std::vector<t_function*>& get_functions() const { return functions_; }
 
-  t_service* get_extends() {
-    return extends_;
-  }
+  t_service* get_extends() { return extends_; }
 
   virtual std::string get_fingerprint_material() const {
     // Services should never be used in fingerprints.
     throw "BUG: Can't get fingerprint material for service.";
   }
 
- private:
+private:
   std::vector<t_function*> functions_;
   t_service* extends_;
 };

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_set.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_set.h b/compiler/cpp/src/parse/t_set.h
index d198357..ccfc701 100644
--- a/compiler/cpp/src/parse/t_set.h
+++ b/compiler/cpp/src/parse/t_set.h
@@ -27,17 +27,12 @@
  *
  */
 class t_set : public t_container {
- public:
-  t_set(t_type* elem_type) :
-    elem_type_(elem_type) {}
+public:
+  t_set(t_type* elem_type) : elem_type_(elem_type) {}
 
-  t_type* get_elem_type() const {
-    return elem_type_;
-  }
+  t_type* get_elem_type() const { return elem_type_; }
 
-  bool is_set() const {
-    return true;
-  }
+  bool is_set() const { return true; }
 
   virtual std::string get_fingerprint_material() const {
     return "set<" + elem_type_->get_fingerprint_material() + ">";
@@ -48,7 +43,7 @@ class t_set : public t_container {
     elem_type_->generate_fingerprint();
   }
 
- private:
+private:
   t_type* elem_type_;
 };
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_struct.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
index 8dd4c73..2282676 100644
--- a/compiler/cpp/src/parse/t_struct.h
+++ b/compiler/cpp/src/parse/t_struct.h
@@ -37,58 +37,59 @@ class t_program;
  *
  */
 class t_struct : public t_type {
- public:
+public:
   typedef std::vector<t_field*> members_type;
 
-  t_struct(t_program* program) :
-    t_type(program),
-    is_xception_(false),
-    is_union_(false),
-    members_validated(false),
-    members_with_value(0),
-    xsd_all_(false) {}
-
-  t_struct(t_program* program, const std::string& name) :
-    t_type(program, name),
-    is_xception_(false),
-    is_union_(false),
-    members_validated(false),
-    members_with_value(0),
-    xsd_all_(false) {}
+  t_struct(t_program* program)
+    : t_type(program),
+      is_xception_(false),
+      is_union_(false),
+      members_validated(false),
+      members_with_value(0),
+      xsd_all_(false) {}
+
+  t_struct(t_program* program, const std::string& name)
+    : t_type(program, name),
+      is_xception_(false),
+      is_union_(false),
+      members_validated(false),
+      members_with_value(0),
+      xsd_all_(false) {}
 
   void set_name(const std::string& name) {
     name_ = name;
     validate_union_members();
   }
 
-  void set_xception(bool is_xception) {
-    is_xception_ = is_xception;
-  }
+  void set_xception(bool is_xception) { is_xception_ = is_xception; }
 
-  void validate_union_member( t_field * field) {
-    if( is_union_ && (! name_.empty())) {
+  void validate_union_member(t_field* field) {
+    if (is_union_ && (!name_.empty())) {
 
       // unions can't have required fields
-      if( field->get_req() == t_field::T_REQUIRED) {
-        pwarning(  1, "Required field %s of union %s set to optional.\n", field->get_name().c_str(), name_.c_str());
-        field->set_req( t_field::T_OPTIONAL);
+      if (field->get_req() == t_field::T_REQUIRED) {
+        pwarning(1,
+                 "Required field %s of union %s set to optional.\n",
+                 field->get_name().c_str(),
+                 name_.c_str());
+        field->set_req(t_field::T_OPTIONAL);
       }
 
       // unions may have up to one member defaulted, but not more
-      if( field->get_value() != NULL) {
-        if( 1 < ++members_with_value) {
-          throw "Error: Field "+field->get_name()+" provides another default value for union "+name_;
+      if (field->get_value() != NULL) {
+        if (1 < ++members_with_value) {
+          throw "Error: Field " + field->get_name() + " provides another default value for union "
+              + name_;
         }
       }
     }
-
   }
 
   void validate_union_members() {
-    if( is_union_ && (! name_.empty()) && (!members_validated)) {
+    if (is_union_ && (!name_.empty()) && (!members_validated)) {
       members_type::const_iterator m_iter;
       for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
-        validate_union_member( *m_iter);
+        validate_union_member(*m_iter);
       }
       members_validated = true;
     }
@@ -99,19 +100,16 @@ class t_struct : public t_type {
     validate_union_members();
   }
 
-  void set_xsd_all(bool xsd_all) {
-    xsd_all_ = xsd_all;
-  }
+  void set_xsd_all(bool xsd_all) { xsd_all_ = xsd_all; }
 
-  bool get_xsd_all() const {
-    return xsd_all_;
-  }
+  bool get_xsd_all() const { return xsd_all_; }
 
   bool append(t_field* elem) {
     typedef members_type::iterator iter_type;
-    std::pair<iter_type, iter_type> bounds = std::equal_range(
-            members_in_id_order_.begin(), members_in_id_order_.end(), elem, t_field::key_compare()
-        );
+    std::pair<iter_type, iter_type> bounds = std::equal_range(members_in_id_order_.begin(),
+                                                              members_in_id_order_.end(),
+                                                              elem,
+                                                              t_field::key_compare());
     if (bounds.first != bounds.second) {
       return false;
     }
@@ -121,29 +119,19 @@ class t_struct : public t_type {
     }
     members_.push_back(elem);
     members_in_id_order_.insert(bounds.second, elem);
-    validate_union_member( elem);
+    validate_union_member(elem);
     return true;
   }
 
-  const members_type& get_members() {
-    return members_;
-  }
+  const members_type& get_members() { return members_; }
 
-  const members_type& get_sorted_members() {
-    return members_in_id_order_;
-  }
+  const members_type& get_sorted_members() { return members_in_id_order_; }
 
-  bool is_struct() const {
-    return !is_xception_;
-  }
+  bool is_struct() const { return !is_xception_; }
 
-  bool is_xception() const {
-    return is_xception_;
-  }
+  bool is_xception() const { return is_xception_; }
 
-  bool is_union() const {
-    return is_union_;
-  }
+  bool is_union() const { return is_union_; }
 
   virtual std::string get_fingerprint_material() const {
     std::string rv = "{";
@@ -154,9 +142,9 @@ class t_struct : public t_type {
       rv += (*m_iter)->get_fingerprint_material();
       rv += ";";
 
-      if( do_reserve) {
+      if (do_reserve) {
         estimation = members_in_id_order_.size() * rv.size() + 16;
-        rv.reserve( estimation);
+        rv.reserve(estimation);
         do_reserve = false;
       }
     }
@@ -182,14 +170,13 @@ class t_struct : public t_type {
     return NULL;
   }
 
- private:
-
+private:
   members_type members_;
   members_type members_in_id_order_;
   bool is_xception_;
   bool is_union_;
   bool members_validated;
-  int  members_with_value;
+  int members_with_value;
 
   bool xsd_all_;
 };

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_type.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
index b85f2da..20409f3 100644
--- a/compiler/cpp/src/parse/t_type.h
+++ b/compiler/cpp/src/parse/t_type.h
@@ -37,38 +37,30 @@ class t_program;
  *
  */
 class t_type : public t_doc {
- public:
+public:
   virtual ~t_type() {}
 
-  virtual void set_name(const std::string& name) {
-    name_ = name;
-  }
+  virtual void set_name(const std::string& name) { name_ = name; }
 
-  virtual const std::string& get_name() const {
-    return name_;
-  }
+  virtual const std::string& get_name() const { return name_; }
 
-  virtual bool is_void()      const { return false; }
+  virtual bool is_void() const { return false; }
   virtual bool is_base_type() const { return false; }
-  virtual bool is_string()    const { return false; }
-  virtual bool is_bool()      const { return false; }
-  virtual bool is_typedef()   const { return false; }
-  virtual bool is_enum()      const { return false; }
-  virtual bool is_struct()    const { return false; }
-  virtual bool is_xception()  const { return false; }
+  virtual bool is_string() const { return false; }
+  virtual bool is_bool() const { return false; }
+  virtual bool is_typedef() const { return false; }
+  virtual bool is_enum() const { return false; }
+  virtual bool is_struct() const { return false; }
+  virtual bool is_xception() const { return false; }
   virtual bool is_container() const { return false; }
-  virtual bool is_list()      const { return false; }
-  virtual bool is_set()       const { return false; }
-  virtual bool is_map()       const { return false; }
-  virtual bool is_service()   const { return false; }
+  virtual bool is_list() const { return false; }
+  virtual bool is_set() const { return false; }
+  virtual bool is_map() const { return false; }
+  virtual bool is_service() const { return false; }
 
-  t_program* get_program() {
-    return program_;
-  }
+  t_program* get_program() { return program_; }
 
-  const t_program* get_program() const {
-    return program_;
-  }
+  const t_program* get_program() const { return program_; }
 
   t_type* get_true_type();
 
@@ -95,8 +87,9 @@ class t_type : public t_doc {
     return false;
   }
 
-  const uint8_t* get_binary_fingerprint()  {
-    if(! has_fingerprint())  // lazy fingerprint generation, right now only used with the c++ generator
+  const uint8_t* get_binary_fingerprint() {
+    if (!has_fingerprint()) // lazy fingerprint generation, right now only used with the c++
+                            // generator
       generate_fingerprint();
     return fingerprint_;
   }
@@ -128,30 +121,16 @@ class t_type : public t_doc {
 
   std::map<std::string, std::string> annotations_;
 
- protected:
-  t_type() :
-    program_(NULL)
-  {
-    memset(fingerprint_, 0, sizeof(fingerprint_));
-  }
+protected:
+  t_type() : program_(NULL) { memset(fingerprint_, 0, sizeof(fingerprint_)); }
 
-  t_type(t_program* program) :
-    program_(program)
-  {
-    memset(fingerprint_, 0, sizeof(fingerprint_));
-  }
+  t_type(t_program* program) : program_(program) { memset(fingerprint_, 0, sizeof(fingerprint_)); }
 
-  t_type(t_program* program, std::string name) :
-    program_(program),
-    name_(name)
-  {
+  t_type(t_program* program, std::string name) : program_(program), name_(name) {
     memset(fingerprint_, 0, sizeof(fingerprint_));
   }
 
-  t_type(std::string name) :
-    program_(NULL),
-    name_(name)
-  {
+  t_type(std::string name) : program_(NULL), name_(name) {
     memset(fingerprint_, 0, sizeof(fingerprint_));
   }
 
@@ -161,7 +140,6 @@ class t_type : public t_doc {
   uint8_t fingerprint_[fingerprint_len];
 };
 
-
 /**
  * Placeholder struct for returning the key and value of an annotation
  * during parsing.

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/parse/t_typedef.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/parse/t_typedef.h b/compiler/cpp/src/parse/t_typedef.h
index 57d8df5..1051909 100644
--- a/compiler/cpp/src/parse/t_typedef.h
+++ b/compiler/cpp/src/parse/t_typedef.h
@@ -31,41 +31,31 @@
  *
  */
 class t_typedef : public t_type {
- public:
-  t_typedef(t_program* program, t_type* type, const std::string& symbolic) :
-    t_type(program, symbolic),
-    type_(type),
-    symbolic_(symbolic),
-    forward_(false),
-    seen_(false) {}
+public:
+  t_typedef(t_program* program, t_type* type, const std::string& symbolic)
+    : t_type(program, symbolic), type_(type), symbolic_(symbolic), forward_(false), seen_(false) {}
 
   /**
    * This constructor is used to refer to a type that is lazily
    * resolved at a later time, like for forward declarations or
    * recursive types.
    */
-  t_typedef(t_program* program, const std::string& symbolic, bool forward) :
-    t_type(program, symbolic),
-    type_(NULL),
-    symbolic_(symbolic),
-    forward_(forward),
-    seen_(false) {}
+  t_typedef(t_program* program, const std::string& symbolic, bool forward)
+    : t_type(program, symbolic),
+      type_(NULL),
+      symbolic_(symbolic),
+      forward_(forward),
+      seen_(false) {}
 
   ~t_typedef() {}
 
   t_type* get_type() const;
 
-  const std::string& get_symbolic() const {
-    return symbolic_;
-  }
+  const std::string& get_symbolic() const { return symbolic_; }
 
-  bool is_forward_typedef() const {
-    return forward_;
-  }
+  bool is_forward_typedef() const { return forward_; }
 
-  bool is_typedef() const {
-    return true;
-  }
+  bool is_typedef() const { return true; }
 
   virtual std::string get_fingerprint_material() const {
     if (!seen_) {
@@ -84,7 +74,7 @@ class t_typedef : public t_type {
     }
   }
 
- private:
+private:
   t_type* type_;
   std::string symbolic_;
   bool forward_;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/windows/config.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/windows/config.h b/compiler/cpp/src/windows/config.h
index 4495672..a600080 100644
--- a/compiler/cpp/src/windows/config.h
+++ b/compiler/cpp/src/windows/config.h
@@ -38,9 +38,8 @@
 #define PRIi64 "I64d"
 
 // squelch deprecation warnings
-#pragma warning(disable:4996)
+#pragma warning(disable : 4996)
 // squelch bool conversion performance warning
-#pragma warning(disable:4800)
-
+#pragma warning(disable : 4800)
 
 #endif // _THRIFT_WINDOWS_CONFIG_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 04107be..fde0ad6 100755
--- a/configure.ac
+++ b/configure.ac
@@ -100,6 +100,9 @@ AC_PROG_RANLIB
 AC_LANG([C++])
 AX_CXX_COMPILE_STDCXX_11([noext])
 
+AM_EXTRA_RECURSIVE_TARGETS([style])
+AC_SUBST(CPPSTYLE_CMD, 'find . -type f \( -iname "*.h" -or -iname "*.cpp" -or -iname "*.cc" -or -iname "*.tcc" \) -printf "Reformatting: %h/%f\n" -exec clang-format -i {} \;')
+
 AC_ARG_ENABLE([libs],
   AS_HELP_STRING([--enable-libs], [build the Apache Thrift libraries [default=yes]]),
   [], enable_libs=yes

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am
index 5206db8..d0bfe62 100755
--- a/lib/cpp/Makefile.am
+++ b/lib/cpp/Makefile.am
@@ -243,3 +243,6 @@ EXTRA_DIST = \
              thrift-z.pc.in \
              thrift-qt.pc.in \
              $(WINDOWS_DIST)
+
+style-local:
+	$(CPPSTYLE_CMD)

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TApplicationException.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TApplicationException.cpp b/lib/cpp/src/thrift/TApplicationException.cpp
index 1110ba2..2f14653 100644
--- a/lib/cpp/src/thrift/TApplicationException.cpp
+++ b/lib/cpp/src/thrift/TApplicationException.cpp
@@ -20,7 +20,8 @@
 #include <thrift/TApplicationException.h>
 #include <thrift/protocol/TProtocol.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 uint32_t TApplicationException::read(apache::thrift::protocol::TProtocol* iprot) {
   uint32_t xfer = 0;
@@ -76,5 +77,5 @@ uint32_t TApplicationException::write(apache::thrift::protocol::TProtocol* oprot
   xfer += oprot->writeStructEnd();
   return xfer;
 }
-
-}} // apache::thrift
+}
+} // apache::thrift

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TApplicationException.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TApplicationException.h b/lib/cpp/src/thrift/TApplicationException.h
index d32a21d..0de5391 100644
--- a/lib/cpp/src/thrift/TApplicationException.h
+++ b/lib/cpp/src/thrift/TApplicationException.h
@@ -22,16 +22,15 @@
 
 #include <thrift/Thrift.h>
 
-
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 namespace protocol {
-  class TProtocol;
+class TProtocol;
 }
 
 class TApplicationException : public TException {
- public:
-
+public:
   /**
    * Error codes for the various types of exceptions.
    */
@@ -49,22 +48,14 @@ class TApplicationException : public TException {
     UNSUPPORTED_CLIENT_TYPE = 10
   };
 
-  TApplicationException() :
-    TException(),
-    type_(UNKNOWN) {}
+  TApplicationException() : TException(), type_(UNKNOWN) {}
 
-  TApplicationException(TApplicationExceptionType type) :
-    TException(),
-    type_(type) {}
+  TApplicationException(TApplicationExceptionType type) : TException(), type_(type) {}
 
-  TApplicationException(const std::string& message) :
-    TException(message),
-    type_(UNKNOWN) {}
+  TApplicationException(const std::string& message) : TException(message), type_(UNKNOWN) {}
 
-  TApplicationException(TApplicationExceptionType type,
-                        const std::string& message) :
-    TException(message),
-    type_(type) {}
+  TApplicationException(TApplicationExceptionType type, const std::string& message)
+    : TException(message), type_(type) {}
 
   virtual ~TApplicationException() throw() {}
 
@@ -74,25 +65,35 @@ class TApplicationException : public TException {
    *
    * @return Error code
    */
-  TApplicationExceptionType getType() {
-    return type_;
-  }
+  TApplicationExceptionType getType() { return type_; }
 
   virtual const char* what() const throw() {
     if (message_.empty()) {
       switch (type_) {
-        case UNKNOWN                 : return "TApplicationException: Unknown application exception";
-        case UNKNOWN_METHOD          : return "TApplicationException: Unknown method";
-        case INVALID_MESSAGE_TYPE    : return "TApplicationException: Invalid message type";
-        case WRONG_METHOD_NAME       : return "TApplicationException: Wrong method name";
-        case BAD_SEQUENCE_ID         : return "TApplicationException: Bad sequence identifier";
-        case MISSING_RESULT          : return "TApplicationException: Missing result";
-        case INTERNAL_ERROR          : return "TApplicationException: Internal error";
-        case PROTOCOL_ERROR          : return "TApplicationException: Protocol error";
-        case INVALID_TRANSFORM       : return "TApplicationException: Invalid transform";
-        case INVALID_PROTOCOL        : return "TApplicationException: Invalid protocol";
-        case UNSUPPORTED_CLIENT_TYPE : return "TApplicationException: Unsupported client type";
-        default                      : return "TApplicationException: (Invalid exception type)";
+      case UNKNOWN:
+        return "TApplicationException: Unknown application exception";
+      case UNKNOWN_METHOD:
+        return "TApplicationException: Unknown method";
+      case INVALID_MESSAGE_TYPE:
+        return "TApplicationException: Invalid message type";
+      case WRONG_METHOD_NAME:
+        return "TApplicationException: Wrong method name";
+      case BAD_SEQUENCE_ID:
+        return "TApplicationException: Bad sequence identifier";
+      case MISSING_RESULT:
+        return "TApplicationException: Missing result";
+      case INTERNAL_ERROR:
+        return "TApplicationException: Internal error";
+      case PROTOCOL_ERROR:
+        return "TApplicationException: Protocol error";
+      case INVALID_TRANSFORM:
+        return "TApplicationException: Invalid transform";
+      case INVALID_PROTOCOL:
+        return "TApplicationException: Invalid protocol";
+      case UNSUPPORTED_CLIENT_TYPE:
+        return "TApplicationException: Unsupported client type";
+      default:
+        return "TApplicationException: (Invalid exception type)";
       };
     } else {
       return message_.c_str();
@@ -102,14 +103,13 @@ class TApplicationException : public TException {
   uint32_t read(protocol::TProtocol* iprot);
   uint32_t write(protocol::TProtocol* oprot) const;
 
- protected:
+protected:
   /**
    * Error code
    */
   TApplicationExceptionType type_;
-
 };
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // #ifndef _THRIFT_TAPPLICATIONEXCEPTION_H_


[07/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TBufferTransports.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h
index 2ee9adf..da75052 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.h
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.h
@@ -35,8 +35,9 @@
 #define TDB_UNLIKELY(val) (val)
 #endif
 
-namespace apache { namespace thrift { namespace transport {
-
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Base class for all transports that use read/write buffers for performance.
@@ -50,8 +51,7 @@ namespace apache { namespace thrift { namespace transport {
  */
 class TBufferBase : public TVirtualTransport<TBufferBase> {
 
- public:
-
+public:
   /**
    * Fast-path read.
    *
@@ -122,13 +122,11 @@ class TBufferBase : public TVirtualTransport<TBufferBase> {
     if (TDB_LIKELY(static_cast<ptrdiff_t>(len) <= rBound_ - rBase_)) {
       rBase_ += len;
     } else {
-      throw TTransportException(TTransportException::BAD_ARGS,
-                                "consume did not follow a borrow.");
+      throw TTransportException(TTransportException::BAD_ARGS, "consume did not follow a borrow.");
     }
   }
 
- protected:
-
+protected:
   /// Slow path read.
   virtual uint32_t readSlow(uint8_t* buf, uint32_t len) = 0;
 
@@ -149,23 +147,18 @@ class TBufferBase : public TVirtualTransport<TBufferBase> {
    * performance-sensitive operation, so it is okay to just leave it to
    * the concrete class to set up pointers correctly.
    */
-  TBufferBase()
-    : rBase_(NULL)
-    , rBound_(NULL)
-    , wBase_(NULL)
-    , wBound_(NULL)
-  {}
+  TBufferBase() : rBase_(NULL), rBound_(NULL), wBase_(NULL), wBound_(NULL) {}
 
   /// Convenience mutator for setting the read buffer.
   void setReadBuffer(uint8_t* buf, uint32_t len) {
     rBase_ = buf;
-    rBound_ = buf+len;
+    rBound_ = buf + len;
   }
 
   /// Convenience mutator for setting the write buffer.
   void setWriteBuffer(uint8_t* buf, uint32_t len) {
     wBase_ = buf;
-    wBound_ = buf+len;
+    wBound_ = buf + len;
   }
 
   virtual ~TBufferBase() {}
@@ -181,59 +174,49 @@ class TBufferBase : public TVirtualTransport<TBufferBase> {
   uint8_t* wBound_;
 };
 
-
 /**
  * Buffered transport. For reads it will read more data than is requested
  * and will serve future data out of a local buffer. For writes, data is
  * stored to an in memory buffer before being written out.
  *
  */
-class TBufferedTransport
-  : public TVirtualTransport<TBufferedTransport, TBufferBase> {
- public:
-
+class TBufferedTransport : public TVirtualTransport<TBufferedTransport, TBufferBase> {
+public:
   static const int DEFAULT_BUFFER_SIZE = 512;
 
   /// Use default buffer sizes.
   TBufferedTransport(boost::shared_ptr<TTransport> transport)
-    : transport_(transport)
-    , rBufSize_(DEFAULT_BUFFER_SIZE)
-    , wBufSize_(DEFAULT_BUFFER_SIZE)
-    , rBuf_(new uint8_t[rBufSize_])
-    , wBuf_(new uint8_t[wBufSize_])
-  {
+    : transport_(transport),
+      rBufSize_(DEFAULT_BUFFER_SIZE),
+      wBufSize_(DEFAULT_BUFFER_SIZE),
+      rBuf_(new uint8_t[rBufSize_]),
+      wBuf_(new uint8_t[wBufSize_]) {
     initPointers();
   }
 
   /// Use specified buffer sizes.
   TBufferedTransport(boost::shared_ptr<TTransport> transport, uint32_t sz)
-    : transport_(transport)
-    , rBufSize_(sz)
-    , wBufSize_(sz)
-    , rBuf_(new uint8_t[rBufSize_])
-    , wBuf_(new uint8_t[wBufSize_])
-  {
+    : transport_(transport),
+      rBufSize_(sz),
+      wBufSize_(sz),
+      rBuf_(new uint8_t[rBufSize_]),
+      wBuf_(new uint8_t[wBufSize_]) {
     initPointers();
   }
 
   /// Use specified read and write buffer sizes.
   TBufferedTransport(boost::shared_ptr<TTransport> transport, uint32_t rsz, uint32_t wsz)
-    : transport_(transport)
-    , rBufSize_(rsz)
-    , wBufSize_(wsz)
-    , rBuf_(new uint8_t[rBufSize_])
-    , wBuf_(new uint8_t[wBufSize_])
-  {
+    : transport_(transport),
+      rBufSize_(rsz),
+      wBufSize_(wsz),
+      rBuf_(new uint8_t[rBufSize_]),
+      wBuf_(new uint8_t[wBufSize_]) {
     initPointers();
   }
 
-  void open() {
-    transport_->open();
-  }
+  void open() { transport_->open(); }
 
-  bool isOpen() {
-    return transport_->isOpen();
-  }
+  bool isOpen() { return transport_->isOpen(); }
 
   bool peek() {
     if (rBase_ == rBound_) {
@@ -256,9 +239,7 @@ class TBufferedTransport
   /**
    * Returns the origin of the underlying transport
    */
-  virtual const std::string getOrigin() {
-    return transport_->getOrigin();
-  }
+  virtual const std::string getOrigin() { return transport_->getOrigin(); }
 
   /**
    * The following behavior is currently implemented by TBufferedTransport,
@@ -273,19 +254,15 @@ class TBufferedTransport
    */
   virtual const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len);
 
-  boost::shared_ptr<TTransport> getUnderlyingTransport() {
-    return transport_;
-  }
+  boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; }
 
   /*
    * TVirtualTransport provides a default implementation of readAll().
    * We want to use the TBufferBase version instead.
    */
-  uint32_t readAll(uint8_t* buf, uint32_t len) {
-    return TBufferBase::readAll(buf, len);
-  }
+  uint32_t readAll(uint8_t* buf, uint32_t len) { return TBufferBase::readAll(buf, len); }
 
- protected:
+protected:
   void initPointers() {
     setReadBuffer(rBuf_.get(), 0);
     setWriteBuffer(wBuf_.get(), wBufSize_);
@@ -300,13 +277,12 @@ class TBufferedTransport
   boost::scoped_array<uint8_t> wBuf_;
 };
 
-
 /**
  * Wraps a transport into a buffered one.
  *
  */
 class TBufferedTransportFactory : public TTransportFactory {
- public:
+public:
   TBufferedTransportFactory() {}
 
   virtual ~TBufferedTransportFactory() {}
@@ -317,10 +293,8 @@ class TBufferedTransportFactory : public TTransportFactory {
   virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
     return boost::shared_ptr<TTransport>(new TBufferedTransport(trans));
   }
-
 };
 
-
 /**
  * Framed transport. All writes go into an in-memory buffer until flush is
  * called, at which point the transport writes the length of the entire
@@ -328,47 +302,38 @@ class TBufferedTransportFactory : public TTransportFactory {
  * other end to always do fixed-length reads.
  *
  */
-class TFramedTransport
-  : public TVirtualTransport<TFramedTransport, TBufferBase> {
- public:
-
+class TFramedTransport : public TVirtualTransport<TFramedTransport, TBufferBase> {
+public:
   static const int DEFAULT_BUFFER_SIZE = 512;
 
   /// Use default buffer sizes.
   TFramedTransport(boost::shared_ptr<TTransport> transport)
-    : transport_(transport)
-    , rBufSize_(0)
-    , wBufSize_(DEFAULT_BUFFER_SIZE)
-    , rBuf_()
-    , wBuf_(new uint8_t[wBufSize_])
-    , bufReclaimThresh_((std::numeric_limits<uint32_t>::max)())
-  {
+    : transport_(transport),
+      rBufSize_(0),
+      wBufSize_(DEFAULT_BUFFER_SIZE),
+      rBuf_(),
+      wBuf_(new uint8_t[wBufSize_]),
+      bufReclaimThresh_((std::numeric_limits<uint32_t>::max)()) {
     initPointers();
   }
 
-  TFramedTransport(boost::shared_ptr<TTransport> transport, uint32_t sz,
-          uint32_t bufReclaimThresh = (std::numeric_limits<uint32_t>::max)())
-    : transport_(transport)
-    , rBufSize_(0)
-    , wBufSize_(sz)
-    , rBuf_()
-    , wBuf_(new uint8_t[wBufSize_])
-    , bufReclaimThresh_(bufReclaimThresh)
-  {
+  TFramedTransport(boost::shared_ptr<TTransport> transport,
+                   uint32_t sz,
+                   uint32_t bufReclaimThresh = (std::numeric_limits<uint32_t>::max)())
+    : transport_(transport),
+      rBufSize_(0),
+      wBufSize_(sz),
+      rBuf_(),
+      wBuf_(new uint8_t[wBufSize_]),
+      bufReclaimThresh_(bufReclaimThresh) {
     initPointers();
   }
 
-  void open() {
-    transport_->open();
-  }
+  void open() { transport_->open(); }
 
-  bool isOpen() {
-    return transport_->isOpen();
-  }
+  bool isOpen() { return transport_->isOpen(); }
 
-  bool peek() {
-    return (rBase_ < rBound_) || transport_->peek();
-  }
+  bool peek() { return (rBase_ < rBound_) || transport_->peek(); }
 
   void close() {
     flush();
@@ -387,26 +352,20 @@ class TFramedTransport
 
   const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len);
 
-  boost::shared_ptr<TTransport> getUnderlyingTransport() {
-    return transport_;
-  }
+  boost::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; }
 
   /*
    * TVirtualTransport provides a default implementation of readAll().
    * We want to use the TBufferBase version instead.
    */
-  uint32_t readAll(uint8_t* buf, uint32_t len) {
-    return TBufferBase::readAll(buf,len);
-  }
+  uint32_t readAll(uint8_t* buf, uint32_t len) { return TBufferBase::readAll(buf, len); }
 
   /**
    * Returns the origin of the underlying transport
    */
-  virtual const std::string getOrigin() {
-    return transport_->getOrigin();
-  }
+  virtual const std::string getOrigin() { return transport_->getOrigin(); }
 
- protected:
+protected:
   /**
    * Reads a frame of input from the underlying stream.
    *
@@ -438,7 +397,7 @@ class TFramedTransport
  *
  */
 class TFramedTransportFactory : public TTransportFactory {
- public:
+public:
   TFramedTransportFactory() {}
 
   virtual ~TFramedTransportFactory() {}
@@ -449,10 +408,8 @@ class TFramedTransportFactory : public TTransportFactory {
   virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
     return boost::shared_ptr<TTransport>(new TFramedTransport(trans));
   }
-
 };
 
-
 /**
  * A memory buffer is a tranpsort that simply reads from and writes to an
  * in memory buffer. Anytime you call write on it, the data is simply placed
@@ -463,8 +420,7 @@ class TFramedTransportFactory : public TTransportFactory {
  *
  */
 class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
- private:
-
+private:
   // Common initialization done by all constructors.
   void initCommon(uint8_t* buf, uint32_t size, bool owner, uint32_t wPos) {
     if (buf == NULL && size != 0) {
@@ -490,7 +446,7 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
     // equal to wBase_.  We update it in a few places (computeRead, etc.).
   }
 
- public:
+public:
   static const uint32_t defaultSize = 1024;
 
   /**
@@ -513,19 +469,13 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
    *   and will be responsible for freeing it.
    *   The membory must have been allocated with malloc.
    */
-  enum MemoryPolicy
-  { OBSERVE = 1
-  , COPY = 2
-  , TAKE_OWNERSHIP = 3
-  };
+  enum MemoryPolicy { OBSERVE = 1, COPY = 2, TAKE_OWNERSHIP = 3 };
 
   /**
    * Construct a TMemoryBuffer with a default-sized buffer,
    * owned by the TMemoryBuffer object.
    */
-  TMemoryBuffer() {
-    initCommon(NULL, defaultSize, true, 0);
-  }
+  TMemoryBuffer() { initCommon(NULL, defaultSize, true, 0); }
 
   /**
    * Construct a TMemoryBuffer with a buffer of a specified size,
@@ -533,9 +483,7 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
    *
    * @param sz  The initial size of the buffer.
    */
-  TMemoryBuffer(uint32_t sz) {
-    initCommon(NULL, sz, true, 0);
-  }
+  TMemoryBuffer(uint32_t sz) { initCommon(NULL, sz, true, 0); }
 
   /**
    * Construct a TMemoryBuffer with buf as its initial contents.
@@ -554,17 +502,17 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
     }
 
     switch (policy) {
-      case OBSERVE:
-      case TAKE_OWNERSHIP:
-        initCommon(buf, sz, policy == TAKE_OWNERSHIP, sz);
-        break;
-      case COPY:
-        initCommon(NULL, sz, true, 0);
-        this->write(buf, sz);
-        break;
-      default:
-        throw TTransportException(TTransportException::BAD_ARGS,
-                                  "Invalid MemoryPolicy for TMemoryBuffer");
+    case OBSERVE:
+    case TAKE_OWNERSHIP:
+      initCommon(buf, sz, policy == TAKE_OWNERSHIP, sz);
+      break;
+    case COPY:
+      initCommon(NULL, sz, true, 0);
+      this->write(buf, sz);
+      break;
+    default:
+      throw TTransportException(TTransportException::BAD_ARGS,
+                                "Invalid MemoryPolicy for TMemoryBuffer");
     }
   }
 
@@ -574,13 +522,9 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
     }
   }
 
-  bool isOpen() {
-    return true;
-  }
+  bool isOpen() { return true; }
 
-  bool peek() {
-    return (rBase_ < wBase_);
-  }
+  bool peek() { return (rBase_ < wBase_); }
 
   void open() {}
 
@@ -663,7 +607,7 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
 
   // return number of bytes read
   uint32_t readEnd() {
-    //This cast should be safe, because buffer_'s size is a uint32_t
+    // This cast should be safe, because buffer_'s size is a uint32_t
     uint32_t bytes = static_cast<uint32_t>(rBase_ - buffer_);
     if (rBase_ == wBase_) {
       resetBuffer();
@@ -673,7 +617,7 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
 
   // Return number of bytes written
   uint32_t writeEnd() {
-    //This cast should be safe, because buffer_'s size is a uint32_t
+    // This cast should be safe, because buffer_'s size is a uint32_t
     return static_cast<uint32_t>(wBase_ - buffer_);
   }
 
@@ -682,9 +626,7 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
     return static_cast<uint32_t>(wBase_ - rBase_);
   }
 
-  uint32_t available_write() const {
-    return static_cast<uint32_t>(wBound_ - wBase_);
-  }
+  uint32_t available_write() const { return static_cast<uint32_t>(wBound_ - wBase_); }
 
   // Returns a pointer to where the client can write data to append to
   // the TMemoryBuffer, and ensures the buffer is big enough to accomodate a
@@ -704,22 +646,20 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
    * TVirtualTransport provides a default implementation of readAll().
    * We want to use the TBufferBase version instead.
    */
-  uint32_t readAll(uint8_t* buf, uint32_t len) {
-    return TBufferBase::readAll(buf,len);
-  }
+  uint32_t readAll(uint8_t* buf, uint32_t len) { return TBufferBase::readAll(buf, len); }
 
- protected:
+protected:
   void swap(TMemoryBuffer& that) {
     using std::swap;
-    swap(buffer_,     that.buffer_);
+    swap(buffer_, that.buffer_);
     swap(bufferSize_, that.bufferSize_);
 
-    swap(rBase_,      that.rBase_);
-    swap(rBound_,     that.rBound_);
-    swap(wBase_,      that.wBase_);
-    swap(wBound_,     that.wBound_);
+    swap(rBase_, that.rBase_);
+    swap(rBound_, that.rBound_);
+    swap(wBase_, that.wBase_);
+    swap(wBound_, that.wBound_);
 
-    swap(owner_,      that.owner_);
+    swap(owner_, that.owner_);
   }
 
   // Make sure there's at least 'len' bytes available for writing.
@@ -746,7 +686,8 @@ class TMemoryBuffer : public TVirtualTransport<TMemoryBuffer, TBufferBase> {
   // Don't forget to update constrctors, initCommon, and swap if
   // you add new members.
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TBUFFERTRANSPORTS_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TFDTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TFDTransport.cpp b/lib/cpp/src/thrift/transport/TFDTransport.cpp
index 26365f0..4bce3a8 100644
--- a/lib/cpp/src/thrift/transport/TFDTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFDTransport.cpp
@@ -33,7 +33,9 @@
 
 using namespace std;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 void TFDTransport::close() {
   if (!isOpen()) {
@@ -45,9 +47,7 @@ void TFDTransport::close() {
   fd_ = -1;
   // Have to check uncaught_exception because this is called in the destructor.
   if (rv < 0 && !std::uncaught_exception()) {
-    throw TTransportException(TTransportException::UNKNOWN,
-                              "TFDTransport::close()",
-                              errno_copy);
+    throw TTransportException(TTransportException::UNKNOWN, "TFDTransport::close()", errno_copy);
   }
 }
 
@@ -62,13 +62,11 @@ uint32_t TFDTransport::read(uint8_t* buf, uint32_t len) {
         ++retries;
         continue;
       }
-	  int errno_copy = THRIFT_ERRNO;
-      throw TTransportException(TTransportException::UNKNOWN,
-                                "TFDTransport::read()",
-                                errno_copy);
+      int errno_copy = THRIFT_ERRNO;
+      throw TTransportException(TTransportException::UNKNOWN, "TFDTransport::read()", errno_copy);
     }
-    //this should be fine, since we already checked for negative values,
-    //and ::read should only return a 32-bit value since len is 32-bit.
+    // this should be fine, since we already checked for negative values,
+    // and ::read should only return a 32-bit value since len is 32-bit.
     return static_cast<uint32_t>(rv);
   }
 }
@@ -78,20 +76,18 @@ void TFDTransport::write(const uint8_t* buf, uint32_t len) {
     THRIFT_SSIZET rv = ::THRIFT_WRITE(fd_, buf, len);
 
     if (rv < 0) {
-		int errno_copy = THRIFT_ERRNO;
-      throw TTransportException(TTransportException::UNKNOWN,
-                                "TFDTransport::write()",
-                                errno_copy);
+      int errno_copy = THRIFT_ERRNO;
+      throw TTransportException(TTransportException::UNKNOWN, "TFDTransport::write()", errno_copy);
     } else if (rv == 0) {
-      throw TTransportException(TTransportException::END_OF_FILE,
-                                "TFDTransport::write()");
+      throw TTransportException(TTransportException::END_OF_FILE, "TFDTransport::write()");
     }
 
     buf += rv;
-    //this should be fine, as we've already checked for negative values, and
+    // this should be fine, as we've already checked for negative values, and
     //::write shouldn't return more than a uint32_t since len is a uint32_t
     len -= static_cast<uint32_t>(rv);
   }
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TFDTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TFDTransport.h b/lib/cpp/src/thrift/transport/TFDTransport.h
index a337d8d..5593d43 100644
--- a/lib/cpp/src/thrift/transport/TFDTransport.h
+++ b/lib/cpp/src/thrift/transport/TFDTransport.h
@@ -28,31 +28,27 @@
 #include <thrift/transport/TTransport.h>
 #include <thrift/transport/TVirtualTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Dead-simple wrapper around a file descriptor.
  *
  */
 class TFDTransport : public TVirtualTransport<TFDTransport> {
- public:
-  enum ClosePolicy
-  { NO_CLOSE_ON_DESTROY = 0
-  , CLOSE_ON_DESTROY = 1
-  };
+public:
+  enum ClosePolicy { NO_CLOSE_ON_DESTROY = 0, CLOSE_ON_DESTROY = 1 };
 
   TFDTransport(int fd, ClosePolicy close_policy = NO_CLOSE_ON_DESTROY)
-    : fd_(fd)
-    , close_policy_(close_policy)
-  {}
+    : fd_(fd), close_policy_(close_policy) {}
 
   ~TFDTransport() {
     if (close_policy_ == CLOSE_ON_DESTROY) {
       try {
         close();
-      } catch(TTransportException& ex) {
-        GlobalOutput.printf("~TFDTransport TTransportException: '%s'",
-                            ex.what());
+      } catch (TTransportException& ex) {
+        GlobalOutput.printf("~TFDTransport TTransportException: '%s'", ex.what());
       }
     }
   }
@@ -70,11 +66,12 @@ class TFDTransport : public TVirtualTransport<TFDTransport> {
   void setFD(int fd) { fd_ = fd; }
   int getFD() { return fd_; }
 
- protected:
+protected:
   int fd_;
   ClosePolicy close_policy_;
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_TFDTRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TFileTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp
index 625c877..13e4471 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp
@@ -48,7 +48,9 @@
 #include <io.h>
 #endif
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using boost::scoped_ptr;
 using boost::shared_ptr;
@@ -57,35 +59,34 @@ using namespace apache::thrift::protocol;
 using namespace apache::thrift::concurrency;
 
 TFileTransport::TFileTransport(string path, bool readOnly)
-  : readState_()
-  , readBuff_(NULL)
-  , currentEvent_(NULL)
-  , readBuffSize_(DEFAULT_READ_BUFF_SIZE)
-  , readTimeout_(NO_TAIL_READ_TIMEOUT)
-  , chunkSize_(DEFAULT_CHUNK_SIZE)
-  , eventBufferSize_(DEFAULT_EVENT_BUFFER_SIZE)
-  , flushMaxUs_(DEFAULT_FLUSH_MAX_US)
-  , flushMaxBytes_(DEFAULT_FLUSH_MAX_BYTES)
-  , maxEventSize_(DEFAULT_MAX_EVENT_SIZE)
-  , maxCorruptedEvents_(DEFAULT_MAX_CORRUPTED_EVENTS)
-  , eofSleepTime_(DEFAULT_EOF_SLEEP_TIME_US)
-  , corruptedEventSleepTime_(DEFAULT_CORRUPTED_SLEEP_TIME_US)
-  , writerThreadIOErrorSleepTime_(DEFAULT_WRITER_THREAD_SLEEP_TIME_US)
-  , dequeueBuffer_(NULL)
-  , enqueueBuffer_(NULL)
-  , notFull_(&mutex_)
-  , notEmpty_(&mutex_)
-  , closing_(false)
-  , flushed_(&mutex_)
-  , forceFlush_(false)
-  , filename_(path)
-  , fd_(0)
-  , bufferAndThreadInitialized_(false)
-  , offset_(0)
-  , lastBadChunk_(0)
-  , numCorruptedEventsInChunk_(0)
-  , readOnly_(readOnly)
-{
+  : readState_(),
+    readBuff_(NULL),
+    currentEvent_(NULL),
+    readBuffSize_(DEFAULT_READ_BUFF_SIZE),
+    readTimeout_(NO_TAIL_READ_TIMEOUT),
+    chunkSize_(DEFAULT_CHUNK_SIZE),
+    eventBufferSize_(DEFAULT_EVENT_BUFFER_SIZE),
+    flushMaxUs_(DEFAULT_FLUSH_MAX_US),
+    flushMaxBytes_(DEFAULT_FLUSH_MAX_BYTES),
+    maxEventSize_(DEFAULT_MAX_EVENT_SIZE),
+    maxCorruptedEvents_(DEFAULT_MAX_CORRUPTED_EVENTS),
+    eofSleepTime_(DEFAULT_EOF_SLEEP_TIME_US),
+    corruptedEventSleepTime_(DEFAULT_CORRUPTED_SLEEP_TIME_US),
+    writerThreadIOErrorSleepTime_(DEFAULT_WRITER_THREAD_SLEEP_TIME_US),
+    dequeueBuffer_(NULL),
+    enqueueBuffer_(NULL),
+    notFull_(&mutex_),
+    notEmpty_(&mutex_),
+    closing_(false),
+    flushed_(&mutex_),
+    forceFlush_(false),
+    filename_(path),
+    fd_(0),
+    bufferAndThreadInitialized_(false),
+    offset_(0),
+    lastBadChunk_(0),
+    numCorruptedEventsInChunk_(0),
+    readOnly_(readOnly) {
   threadFactory_.setDetached(false);
   openLogFile();
 }
@@ -102,9 +103,11 @@ void TFileTransport::resetOutputFile(int fd, string filename, off_t offset) {
     if (-1 == ::THRIFT_CLOSE(fd_)) {
       int errno_copy = THRIFT_ERRNO;
       GlobalOutput.perror("TFileTransport: resetOutputFile() ::close() ", errno_copy);
-      throw TTransportException(TTransportException::UNKNOWN, "TFileTransport: error in file close", errno_copy);
+      throw TTransportException(TTransportException::UNKNOWN,
+                                "TFileTransport: error in file close",
+                                errno_copy);
     } else {
-      //successfully closed fd
+      // successfully closed fd
       fd_ = 0;
     }
   }
@@ -117,10 +120,9 @@ void TFileTransport::resetOutputFile(int fd, string filename, off_t offset) {
   }
 }
 
-
 TFileTransport::~TFileTransport() {
   // flush the buffer if a writer thread is active
-  if(writerThread_.get()) {
+  if (writerThread_.get()) {
     // set state to closing
     closing_ = true;
 
@@ -154,10 +156,10 @@ TFileTransport::~TFileTransport() {
 
   // close logfile
   if (fd_ > 0) {
-    if(-1 == ::THRIFT_CLOSE(fd_)) {
+    if (-1 == ::THRIFT_CLOSE(fd_)) {
       GlobalOutput.perror("TFileTransport: ~TFileTransport() ::close() ", THRIFT_ERRNO);
     } else {
-      //successfully closed fd
+      // successfully closed fd
       fd_ = 0;
     }
   }
@@ -169,9 +171,9 @@ bool TFileTransport::initBufferAndWriteThread() {
     return false;
   }
 
-  if(!writerThread_.get()) {
+  if (!writerThread_.get()) {
     writerThread_ = threadFactory_.newThread(
-      apache::thrift::concurrency::FunctionRunner::create(startWriterThread, this));
+        apache::thrift::concurrency::FunctionRunner::create(startWriterThread, this));
     writerThread_->start();
   }
 
@@ -197,7 +199,7 @@ void TFileTransport::enqueueEvent(const uint8_t* buf, uint32_t eventLen) {
   }
 
   // make sure that event size is valid
-  if ( (maxEventSize_ > 0) && (eventLen > maxEventSize_) ) {
+  if ((maxEventSize_ > 0) && (eventLen > maxEventSize_)) {
     T_ERROR("msg size is greater than max event size: %u > %u\n", eventLen, maxEventSize_);
     return;
   }
@@ -208,7 +210,7 @@ void TFileTransport::enqueueEvent(const uint8_t* buf, uint32_t eventLen) {
   }
 
   eventInfo* toEnqueue = new eventInfo();
-  toEnqueue->eventBuff_ = (uint8_t *)std::malloc((sizeof(uint8_t) * eventLen) + 4);
+  toEnqueue->eventBuff_ = (uint8_t*)std::malloc((sizeof(uint8_t) * eventLen) + 4);
   if (toEnqueue->eventBuff_ == NULL) {
     delete toEnqueue;
     throw std::bad_alloc();
@@ -232,7 +234,7 @@ void TFileTransport::enqueueEvent(const uint8_t* buf, uint32_t eventLen) {
 
   // Can't enqueue while buffer is full
   while (enqueueBuffer_->isFull()) {
-	  notFull_.wait();
+    notFull_.wait();
   }
 
   // We shouldn't be trying to enqueue new data while a forced flush is
@@ -278,25 +280,23 @@ bool TFileTransport::swapEventBuffers(struct timeval* deadline) {
   }
 
   if (swap) {
-    TFileTransportBuffer *temp = enqueueBuffer_;
+    TFileTransportBuffer* temp = enqueueBuffer_;
     enqueueBuffer_ = dequeueBuffer_;
     dequeueBuffer_ = temp;
   }
 
-
   if (swap) {
-	  notFull_.notify();
+    notFull_.notify();
   }
 
   return swap;
 }
 
-
 void TFileTransport::writerThread() {
   bool hasIOError = false;
 
   // open file if it is not open
-  if(!fd_) {
+  if (!fd_) {
     try {
       openLogFile();
     } catch (...) {
@@ -313,7 +313,7 @@ void TFileTransport::writerThread() {
       seekToEnd();
       // throw away any partial events
       offset_ += readState_.lastDispatchPtr_;
-	  THRIFT_FTRUNCATE(fd_, offset_);
+      THRIFT_FTRUNCATE(fd_, offset_);
       readState_.resetAllValues();
     } catch (...) {
       int errno_copy = THRIFT_ERRNO;
@@ -336,12 +336,12 @@ void TFileTransport::writerThread() {
 
       // Try to empty buffers before exit
       if (enqueueBuffer_->isEmpty() && dequeueBuffer_->isEmpty()) {
-		::THRIFT_FSYNC(fd_);
+        ::THRIFT_FSYNC(fd_);
         if (-1 == ::THRIFT_CLOSE(fd_)) {
           int errno_copy = THRIFT_ERRNO;
           GlobalOutput.perror("TFileTransport: writerThread() ::close() ", errno_copy);
         } else {
-          //fd successfully closed
+          // fd successfully closed
           fd_ = 0;
         }
         return;
@@ -351,13 +351,18 @@ void TFileTransport::writerThread() {
     if (swapEventBuffers(&ts_next_flush)) {
       eventInfo* outEvent;
       while (NULL != (outEvent = dequeueBuffer_->getNext())) {
-        // Remove an event from the buffer and write it out to disk. If there is any IO error, for instance,
-        // the output file is unmounted or deleted, then this event is dropped. However, the writer thread
-        // will: (1) sleep for a short while; (2) try to reopen the file; (3) if successful then start writing
+        // Remove an event from the buffer and write it out to disk. If there is any IO error, for
+        // instance,
+        // the output file is unmounted or deleted, then this event is dropped. However, the writer
+        // thread
+        // will: (1) sleep for a short while; (2) try to reopen the file; (3) if successful then
+        // start writing
         // from the end.
 
         while (hasIOError) {
-          T_ERROR("TFileTransport: writer thread going to sleep for %d microseconds due to IO errors", writerThreadIOErrorSleepTime_);
+          T_ERROR(
+              "TFileTransport: writer thread going to sleep for %d microseconds due to IO errors",
+              writerThreadIOErrorSleepTime_);
           THRIFT_SLEEP_USEC(writerThreadIOErrorSleepTime_);
           if (closing_) {
             return;
@@ -371,15 +376,20 @@ void TFileTransport::writerThread() {
             seekToEnd();
             unflushed = 0;
             hasIOError = false;
-            T_LOG_OPER("TFileTransport: log file %s reopened by writer thread during error recovery", filename_.c_str());
+            T_LOG_OPER(
+                "TFileTransport: log file %s reopened by writer thread during error recovery",
+                filename_.c_str());
           } catch (...) {
-            T_ERROR("TFileTransport: unable to reopen log file %s during error recovery", filename_.c_str());
+            T_ERROR("TFileTransport: unable to reopen log file %s during error recovery",
+                    filename_.c_str());
           }
         }
 
         // sanity check on event
         if ((maxEventSize_ > 0) && (outEvent->eventSize_ > maxEventSize_)) {
-          T_ERROR("msg size is greater than max event size: %u > %u\n", outEvent->eventSize_, maxEventSize_);
+          T_ERROR("msg size is greater than max event size: %u > %u\n",
+                  outEvent->eventSize_,
+                  maxEventSize_);
           continue;
         }
 
@@ -387,12 +397,14 @@ void TFileTransport::writerThread() {
         if ((outEvent->eventSize_ > 0) && (chunkSize_ != 0)) {
           // event size must be less than chunk size
           if (outEvent->eventSize_ > chunkSize_) {
-            T_ERROR("TFileTransport: event size(%u) > chunk size(%u): skipping event", outEvent->eventSize_, chunkSize_);
+            T_ERROR("TFileTransport: event size(%u) > chunk size(%u): skipping event",
+                    outEvent->eventSize_,
+                    chunkSize_);
             continue;
           }
 
-          int64_t chunk1 = offset_/chunkSize_;
-          int64_t chunk2 = (offset_ + outEvent->eventSize_ - 1)/chunkSize_;
+          int64_t chunk1 = offset_ / chunkSize_;
+          int64_t chunk2 = (offset_ + outEvent->eventSize_ - 1) / chunkSize_;
 
           // if adding this event will cross a chunk boundary, pad the chunk with zeros
           if (chunk1 != chunk2) {
@@ -405,7 +417,8 @@ void TFileTransport::writerThread() {
             boost::scoped_array<uint8_t> array(zeros);
             if (-1 == ::write(fd_, zeros, padding)) {
               int errno_copy = THRIFT_ERRNO;
-              GlobalOutput.perror("TFileTransport: writerThread() error while padding zeros ", errno_copy);
+              GlobalOutput.perror("TFileTransport: writerThread() error while padding zeros ",
+                                  errno_copy);
               hasIOError = true;
               continue;
             }
@@ -440,24 +453,24 @@ void TFileTransport::writerThread() {
     // time, it could have changed state in between.  This will result in us
     // making inconsistent decisions.
     bool forced_flush = false;
-	{
-    Guard g(mutex_);
-    if (forceFlush_) {
-      if (!enqueueBuffer_->isEmpty()) {
-        // If forceFlush_ is true, we need to flush all available data.
-        // If enqueueBuffer_ is not empty, go back to the start of the loop to
-        // write it out.
-        //
-        // We know the main thread is waiting on forceFlush_ to be cleared,
-        // so no new events will be added to enqueueBuffer_ until we clear
-        // forceFlush_.  Therefore the next time around the loop enqueueBuffer_
-        // is guaranteed to be empty.  (I.e., we're guaranteed to make progress
-        // and clear forceFlush_ the next time around the loop.)
-        continue;
+    {
+      Guard g(mutex_);
+      if (forceFlush_) {
+        if (!enqueueBuffer_->isEmpty()) {
+          // If forceFlush_ is true, we need to flush all available data.
+          // If enqueueBuffer_ is not empty, go back to the start of the loop to
+          // write it out.
+          //
+          // We know the main thread is waiting on forceFlush_ to be cleared,
+          // so no new events will be added to enqueueBuffer_ until we clear
+          // forceFlush_.  Therefore the next time around the loop enqueueBuffer_
+          // is guaranteed to be empty.  (I.e., we're guaranteed to make progress
+          // and clear forceFlush_ the next time around the loop.)
+          continue;
+        }
+        forced_flush = true;
       }
-      forced_flush = true;
-	}
-	}
+    }
 
     // determine if we need to perform an fsync
     bool flush = false;
@@ -466,9 +479,9 @@ void TFileTransport::writerThread() {
     } else {
       struct timeval current_time;
       THRIFT_GETTIMEOFDAY(&current_time, NULL);
-      if (current_time.tv_sec > ts_next_flush.tv_sec ||
-          (current_time.tv_sec == ts_next_flush.tv_sec &&
-           current_time.tv_usec > ts_next_flush.tv_usec)) {
+      if (current_time.tv_sec > ts_next_flush.tv_sec
+          || (current_time.tv_sec == ts_next_flush.tv_sec
+              && current_time.tv_usec > ts_next_flush.tv_usec)) {
         if (unflushed > 0) {
           flush = true;
         } else {
@@ -481,7 +494,7 @@ void TFileTransport::writerThread() {
 
     if (flush) {
       // sync (force flush) file to disk
-	  THRIFT_FSYNC(fd_);
+      THRIFT_FSYNC(fd_);
       unflushed = 0;
       getNextFlushTime(&ts_next_flush);
 
@@ -491,7 +504,7 @@ void TFileTransport::writerThread() {
         forceFlush_ = false;
         assert(enqueueBuffer_->isEmpty());
         assert(dequeueBuffer_->isEmpty());
-		flushed_.notifyAll();
+        flushed_.notifyAll();
       }
     }
   }
@@ -515,13 +528,12 @@ void TFileTransport::flush() {
   }
 }
 
-
 uint32_t TFileTransport::readAll(uint8_t* buf, uint32_t len) {
   uint32_t have = 0;
   uint32_t get = 0;
 
   while (have < len) {
-    get = read(buf+have, len-have);
+    get = read(buf + have, len - have);
     if (get <= 0) {
       throw TEOFException();
     }
@@ -564,11 +576,9 @@ uint32_t TFileTransport::read(uint8_t* buf, uint32_t len) {
   if (remaining <= (int32_t)len) {
     // copy over anything thats remaining
     if (remaining > 0) {
-      memcpy(buf,
-             currentEvent_->eventBuff_ + currentEvent_->eventBuffPos_,
-             remaining);
+      memcpy(buf, currentEvent_->eventBuff_ + currentEvent_->eventBuffPos_, remaining);
     }
-    delete(currentEvent_);
+    delete (currentEvent_);
     currentEvent_ = NULL;
     return remaining;
   }
@@ -592,7 +602,7 @@ eventInfo* TFileTransport::readEvent() {
     if (readState_.bufferPtr_ == readState_.bufferLen_) {
       // advance the offset pointer
       offset_ += readState_.bufferLen_;
-	  readState_.bufferLen_ = static_cast<uint32_t>(::THRIFT_READ(fd_, readBuff_, readBuffSize_));
+      readState_.bufferLen_ = static_cast<uint32_t>(::THRIFT_READ(fd_, readBuff_, readBuffSize_));
       //       if (readState_.bufferLen_) {
       //         T_DEBUG_L(1, "Amount read: %u (offset: %lu)", readState_.bufferLen_, offset_);
       //       }
@@ -604,7 +614,7 @@ eventInfo* TFileTransport::readEvent() {
         readState_.resetAllValues();
         GlobalOutput("TFileTransport: error while reading from file");
         throw TTransportException("TFileTransport: error while reading from file");
-      } else if (readState_.bufferLen_ == 0) {  // EOF
+      } else if (readState_.bufferLen_ == 0) { // EOF
         // wait indefinitely if there is no timeout
         if (readTimeout_ == TAIL_READ_TIMEOUT) {
           THRIFT_SLEEP_USEC(eofSleepTime_);
@@ -630,11 +640,11 @@ eventInfo* TFileTransport::readEvent() {
     readTries = 0;
 
     // attempt to read an event from the buffer
-    while(readState_.bufferPtr_ < readState_.bufferLen_) {
+    while (readState_.bufferPtr_ < readState_.bufferLen_) {
       if (readState_.readingSize_) {
-        if(readState_.eventSizeBuffPos_ == 0) {
-          if ( (offset_ + readState_.bufferPtr_)/chunkSize_ !=
-               ((offset_ + readState_.bufferPtr_ + 3)/chunkSize_)) {
+        if (readState_.eventSizeBuffPos_ == 0) {
+          if ((offset_ + readState_.bufferPtr_) / chunkSize_
+              != ((offset_ + readState_.bufferPtr_ + 3) / chunkSize_)) {
             // skip one byte towards chunk boundary
             //            T_DEBUG_L(1, "Skipping a byte");
             readState_.bufferPtr_++;
@@ -642,8 +652,8 @@ eventInfo* TFileTransport::readEvent() {
           }
         }
 
-        readState_.eventSizeBuff_[readState_.eventSizeBuffPos_++] =
-          readBuff_[readState_.bufferPtr_++];
+        readState_.eventSizeBuff_[readState_.eventSizeBuffPos_++]
+            = readBuff_[readState_.bufferPtr_++];
 
         if (readState_.eventSizeBuffPos_ == 4) {
           if (readState_.getEventSize() == 0) {
@@ -655,7 +665,7 @@ eventInfo* TFileTransport::readEvent() {
           // got a valid event
           readState_.readingSize_ = false;
           if (readState_.event_) {
-            delete(readState_.event_);
+            delete (readState_.event_);
           }
           readState_.event_ = new eventInfo();
           readState_.event_->eventSize_ = readState_.getEventSize();
@@ -699,24 +709,26 @@ eventInfo* TFileTransport::readEvent() {
         }
       }
     }
-
   }
 }
 
 bool TFileTransport::isEventCorrupted() {
   // an error is triggered if:
-  if ( (maxEventSize_ > 0) &&  (readState_.event_->eventSize_ > maxEventSize_)) {
+  if ((maxEventSize_ > 0) && (readState_.event_->eventSize_ > maxEventSize_)) {
     // 1. Event size is larger than user-speficied max-event size
     T_ERROR("Read corrupt event. Event size(%u) greater than max event size (%u)",
-            readState_.event_->eventSize_, maxEventSize_);
+            readState_.event_->eventSize_,
+            maxEventSize_);
     return true;
   } else if (readState_.event_->eventSize_ > chunkSize_) {
     // 2. Event size is larger than chunk size
     T_ERROR("Read corrupt event. Event size(%u) greater than chunk size (%u)",
-               readState_.event_->eventSize_, chunkSize_);
+            readState_.event_->eventSize_,
+            chunkSize_);
     return true;
-  } else if( ((offset_ + readState_.bufferPtr_ - 4)/chunkSize_) !=
-             ((offset_ + readState_.bufferPtr_ + readState_.event_->eventSize_ - 1)/chunkSize_) ) {
+  } else if (((offset_ + readState_.bufferPtr_ - 4) / chunkSize_)
+             != ((offset_ + readState_.bufferPtr_ + readState_.event_->eventSize_ - 1)
+                 / chunkSize_)) {
     // 3. size indicates that event crosses chunk boundary
     T_ERROR("Read corrupt event. Event crosses chunk boundary. Event size:%u  Offset:%lu",
             readState_.event_->eventSize_,
@@ -750,7 +762,7 @@ void TFileTransport::performRecovery() {
     } else if (readTimeout_ == TAIL_READ_TIMEOUT) {
       // if tailing the file, wait until there is enough data to start
       // the next chunk
-      while(curChunk == (getNumChunks() - 1)) {
+      while (curChunk == (getNumChunks() - 1)) {
         THRIFT_SLEEP_USEC(corruptedEventSleepTime_);
       }
       seekToChunk(curChunk + 1);
@@ -760,14 +772,14 @@ void TFileTransport::performRecovery() {
       readState_.resetState(readState_.lastDispatchPtr_);
       currentEvent_ = NULL;
       char errorMsg[1024];
-      sprintf(errorMsg, "TFileTransport: log file corrupted at offset: %lu",
+      sprintf(errorMsg,
+              "TFileTransport: log file corrupted at offset: %lu",
               static_cast<unsigned long>(offset_ + readState_.lastDispatchPtr_));
 
       GlobalOutput(errorMsg);
       throw TTransportException(errorMsg);
     }
   }
-
 }
 
 void TFileTransport::seekToChunk(int32_t chunk) {
@@ -827,7 +839,6 @@ void TFileTransport::seekToChunk(int32_t chunk) {
     }
     setReadTimeout(oldReadTimeout);
   }
-
 }
 
 void TFileTransport::seekToEnd() {
@@ -850,7 +861,7 @@ uint32_t TFileTransport::getNumChunks() {
   }
 
   if (f_info.st_size > 0) {
-    size_t numChunks = ((f_info.st_size)/chunkSize_) + 1;
+    size_t numChunks = ((f_info.st_size) / chunkSize_) + 1;
     if (numChunks > (std::numeric_limits<uint32_t>::max)())
       throw TTransportException("Too many chunks");
     return static_cast<uint32_t>(numChunks);
@@ -861,13 +872,13 @@ uint32_t TFileTransport::getNumChunks() {
 }
 
 uint32_t TFileTransport::getCurChunk() {
-  return static_cast<uint32_t>(offset_/chunkSize_);
+  return static_cast<uint32_t>(offset_ / chunkSize_);
 }
 
 // Utility Functions
 void TFileTransport::openLogFile() {
 #ifndef _WIN32
-  mode_t mode = readOnly_ ? S_IRUSR | S_IRGRP | S_IROTH : S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH;
+  mode_t mode = readOnly_ ? S_IRUSR | S_IRGRP | S_IROTH : S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
   int flags = readOnly_ ? O_RDONLY : O_RDWR | O_CREAT | O_APPEND;
 #else
   int mode = readOnly_ ? _S_IREAD : _S_IREAD | _S_IWRITE;
@@ -877,12 +888,11 @@ void TFileTransport::openLogFile() {
   offset_ = 0;
 
   // make sure open call was successful
-  if(fd_ == -1) {
+  if (fd_ == -1) {
     int errno_copy = THRIFT_ERRNO;
     GlobalOutput.perror("TFileTransport: openLogFile() ::open() file: " + filename_, errno_copy);
     throw TTransportException(TTransportException::NOT_OPEN, filename_, errno_copy);
   }
-
 }
 
 void TFileTransport::getNextFlushTime(struct timeval* ts_next_flush) {
@@ -897,12 +907,8 @@ void TFileTransport::getNextFlushTime(struct timeval* ts_next_flush) {
 }
 
 TFileTransportBuffer::TFileTransportBuffer(uint32_t size)
-  : bufferMode_(WRITE)
-  , writePoint_(0)
-  , readPoint_(0)
-  , size_(size)
-{
-  buffer_ = new eventInfo*[size];
+  : bufferMode_(WRITE), writePoint_(0), readPoint_(0), size_(size) {
+  buffer_ = new eventInfo* [size];
 }
 
 TFileTransportBuffer::~TFileTransportBuffer() {
@@ -915,7 +921,7 @@ TFileTransportBuffer::~TFileTransportBuffer() {
   }
 }
 
-bool TFileTransportBuffer::addEvent(eventInfo *event) {
+bool TFileTransportBuffer::addEvent(eventInfo* event) {
   if (bufferMode_ == READ) {
     GlobalOutput("Trying to write to a buffer in read mode");
   }
@@ -963,11 +969,11 @@ bool TFileTransportBuffer::isEmpty() {
 
 TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
                                shared_ptr<TProtocolFactory> protocolFactory,
-                               shared_ptr<TFileReaderTransport> inputTransport):
-  processor_(processor),
-  inputProtocolFactory_(protocolFactory),
-  outputProtocolFactory_(protocolFactory),
-  inputTransport_(inputTransport) {
+                               shared_ptr<TFileReaderTransport> inputTransport)
+  : processor_(processor),
+    inputProtocolFactory_(protocolFactory),
+    outputProtocolFactory_(protocolFactory),
+    inputTransport_(inputTransport) {
 
   // default the output transport to a null transport (common case)
   outputTransport_ = shared_ptr<TNullTransport>(new TNullTransport());
@@ -976,11 +982,11 @@ TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
 TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
                                shared_ptr<TProtocolFactory> inputProtocolFactory,
                                shared_ptr<TProtocolFactory> outputProtocolFactory,
-                               shared_ptr<TFileReaderTransport> inputTransport):
-  processor_(processor),
-  inputProtocolFactory_(inputProtocolFactory),
-  outputProtocolFactory_(outputProtocolFactory),
-  inputTransport_(inputTransport) {
+                               shared_ptr<TFileReaderTransport> inputTransport)
+  : processor_(processor),
+    inputProtocolFactory_(inputProtocolFactory),
+    outputProtocolFactory_(outputProtocolFactory),
+    inputTransport_(inputTransport) {
 
   // default the output transport to a null transport (common case)
   outputTransport_ = shared_ptr<TNullTransport>(new TNullTransport());
@@ -989,12 +995,13 @@ TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
 TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
                                shared_ptr<TProtocolFactory> protocolFactory,
                                shared_ptr<TFileReaderTransport> inputTransport,
-                               shared_ptr<TTransport> outputTransport):
-  processor_(processor),
-  inputProtocolFactory_(protocolFactory),
-  outputProtocolFactory_(protocolFactory),
-  inputTransport_(inputTransport),
-  outputTransport_(outputTransport) {}
+                               shared_ptr<TTransport> outputTransport)
+  : processor_(processor),
+    inputProtocolFactory_(protocolFactory),
+    outputProtocolFactory_(protocolFactory),
+    inputTransport_(inputTransport),
+    outputTransport_(outputTransport) {
+}
 
 void TFileProcessor::process(uint32_t numEvents, bool tail) {
   shared_ptr<TProtocol> inputProtocol = inputProtocolFactory_->getProtocol(inputTransport_);
@@ -1008,20 +1015,20 @@ void TFileProcessor::process(uint32_t numEvents, bool tail) {
   }
 
   uint32_t numProcessed = 0;
-  while(1) {
+  while (1) {
     // bad form to use exceptions for flow control but there is really
     // no other way around it
     try {
       processor_->process(inputProtocol, outputProtocol, NULL);
       numProcessed++;
-      if ( (numEvents > 0) && (numProcessed == numEvents)) {
+      if ((numEvents > 0) && (numProcessed == numEvents)) {
         return;
       }
     } catch (TEOFException&) {
       if (!tail) {
         break;
       }
-    } catch (TException &te) {
+    } catch (TException& te) {
       cerr << te.what() << endl;
       break;
     }
@@ -1031,7 +1038,6 @@ void TFileProcessor::process(uint32_t numEvents, bool tail) {
   if (tail) {
     inputTransport_->setReadTimeout(oldReadTimeout);
   }
-
 }
 
 void TFileProcessor::processChunk() {
@@ -1040,7 +1046,7 @@ void TFileProcessor::processChunk() {
 
   uint32_t curChunk = inputTransport_->getCurChunk();
 
-  while(1) {
+  while (1) {
     // bad form to use exceptions for flow control but there is really
     // no other way around it
     try {
@@ -1050,11 +1056,12 @@ void TFileProcessor::processChunk() {
       }
     } catch (TEOFException&) {
       break;
-    } catch (TException &te) {
+    } catch (TException& te) {
       cerr << te.what() << endl;
       break;
     }
   }
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TFileTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.h b/lib/cpp/src/thrift/transport/TFileTransport.h
index 75941cf..acd7bf9 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.h
+++ b/lib/cpp/src/thrift/transport/TFileTransport.h
@@ -35,7 +35,9 @@
 #include <thrift/concurrency/PlatformThreadFactory.h>
 #include <thrift/concurrency/Thread.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using apache::thrift::TProcessor;
 using apache::thrift::protocol::TProtocolFactory;
@@ -48,7 +50,7 @@ typedef struct eventInfo {
   uint32_t eventSize_;
   uint32_t eventBuffPos_;
 
-  eventInfo():eventBuff_(NULL), eventSize_(0), eventBuffPos_(0){};
+  eventInfo() : eventBuff_(NULL), eventSize_(0), eventBuffPos_(0){};
   ~eventInfo() {
     if (eventBuff_) {
       delete[] eventBuff_;
@@ -61,13 +63,13 @@ typedef struct readState {
   eventInfo* event_;
 
   // keep track of event size
-  uint8_t   eventSizeBuff_[4];
-  uint8_t   eventSizeBuffPos_;
-  bool      readingSize_;
+  uint8_t eventSizeBuff_[4];
+  uint8_t eventSizeBuffPos_;
+  bool readingSize_;
 
   // read buffer variables
-  int32_t  bufferPtr_;
-  int32_t  bufferLen_;
+  int32_t bufferPtr_;
+  int32_t bufferLen_;
 
   // last successful dispatch point
   int32_t lastDispatchPtr_;
@@ -83,24 +85,24 @@ typedef struct readState {
     bufferPtr_ = 0;
     bufferLen_ = 0;
     if (event_) {
-      delete(event_);
+      delete (event_);
     }
     event_ = 0;
   }
 
   inline uint32_t getEventSize() {
-  	  const void *buffer=reinterpret_cast<const void *>(eventSizeBuff_);
-	  return *reinterpret_cast<const uint32_t *>(buffer);
+    const void* buffer = reinterpret_cast<const void*>(eventSizeBuff_);
+    return *reinterpret_cast<const uint32_t*>(buffer);
   }
 
   readState() {
     event_ = 0;
-   resetAllValues();
+    resetAllValues();
   }
 
   ~readState() {
     if (event_) {
-      delete(event_);
+      delete (event_);
     }
   }
 
@@ -121,36 +123,33 @@ typedef struct readState {
  *
  */
 class TFileTransportBuffer {
-  public:
-    TFileTransportBuffer(uint32_t size);
-    ~TFileTransportBuffer();
-
-    bool addEvent(eventInfo *event);
-    eventInfo* getNext();
-    void reset();
-    bool isFull();
-    bool isEmpty();
-
-  private:
-    TFileTransportBuffer(); // should not be used
-
-    enum mode {
-      WRITE,
-      READ
-    };
-    mode bufferMode_;
-
-    uint32_t writePoint_;
-    uint32_t readPoint_;
-    uint32_t size_;
-    eventInfo** buffer_;
+public:
+  TFileTransportBuffer(uint32_t size);
+  ~TFileTransportBuffer();
+
+  bool addEvent(eventInfo* event);
+  eventInfo* getNext();
+  void reset();
+  bool isFull();
+  bool isEmpty();
+
+private:
+  TFileTransportBuffer(); // should not be used
+
+  enum mode { WRITE, READ };
+  mode bufferMode_;
+
+  uint32_t writePoint_;
+  uint32_t readPoint_;
+  uint32_t size_;
+  eventInfo** buffer_;
 };
 
 /**
  * Abstract interface for transports used to read files
  */
 class TFileReaderTransport : virtual public TTransport {
- public:
+public:
   virtual int32_t getReadTimeout() = 0;
   virtual void setReadTimeout(int32_t readTimeout) = 0;
 
@@ -164,7 +163,7 @@ class TFileReaderTransport : virtual public TTransport {
  * Abstract interface for transports used to write files
  */
 class TFileWriterTransport : virtual public TTransport {
- public:
+public:
   virtual uint32_t getChunkSize() = 0;
   virtual void setChunkSize(uint32_t chunkSize) = 0;
 };
@@ -174,17 +173,14 @@ class TFileWriterTransport : virtual public TTransport {
  * file on disk.
  *
  */
-class TFileTransport : public TFileReaderTransport,
-                       public TFileWriterTransport {
- public:
-  TFileTransport(std::string path, bool readOnly=false);
+class TFileTransport : public TFileReaderTransport, public TFileWriterTransport {
+public:
+  TFileTransport(std::string path, bool readOnly = false);
   ~TFileTransport();
 
   // TODO: what is the correct behaviour for this?
   // the log file is generally always open
-  bool isOpen() {
-    return true;
-  }
+  bool isOpen() { return true; }
 
   void write(const uint8_t* buf, uint32_t len);
   void flush();
@@ -208,27 +204,19 @@ class TFileTransport : public TFileReaderTransport,
       readBuffSize_ = readBuffSize;
     }
   }
-  uint32_t getReadBuffSize() {
-    return readBuffSize_;
-  }
+  uint32_t getReadBuffSize() { return readBuffSize_; }
 
   static const int32_t TAIL_READ_TIMEOUT = -1;
   static const int32_t NO_TAIL_READ_TIMEOUT = 0;
-  void setReadTimeout(int32_t readTimeout) {
-    readTimeout_ = readTimeout;
-  }
-  int32_t getReadTimeout() {
-    return readTimeout_;
-  }
+  void setReadTimeout(int32_t readTimeout) { readTimeout_ = readTimeout; }
+  int32_t getReadTimeout() { return readTimeout_; }
 
   void setChunkSize(uint32_t chunkSize) {
     if (chunkSize) {
       chunkSize_ = chunkSize;
     }
   }
-  uint32_t getChunkSize() {
-    return chunkSize_;
-  }
+  uint32_t getChunkSize() { return chunkSize_; }
 
   void setEventBufferSize(uint32_t bufferSize) {
     if (bufferAndThreadInitialized_) {
@@ -238,67 +226,47 @@ class TFileTransport : public TFileReaderTransport,
     eventBufferSize_ = bufferSize;
   }
 
-  uint32_t getEventBufferSize() {
-    return eventBufferSize_;
-  }
+  uint32_t getEventBufferSize() { return eventBufferSize_; }
 
   void setFlushMaxUs(uint32_t flushMaxUs) {
     if (flushMaxUs) {
       flushMaxUs_ = flushMaxUs;
     }
   }
-  uint32_t getFlushMaxUs() {
-    return flushMaxUs_;
-  }
+  uint32_t getFlushMaxUs() { return flushMaxUs_; }
 
   void setFlushMaxBytes(uint32_t flushMaxBytes) {
     if (flushMaxBytes) {
       flushMaxBytes_ = flushMaxBytes;
     }
   }
-  uint32_t getFlushMaxBytes() {
-    return flushMaxBytes_;
-  }
+  uint32_t getFlushMaxBytes() { return flushMaxBytes_; }
 
-  void setMaxEventSize(uint32_t maxEventSize) {
-    maxEventSize_ = maxEventSize;
-  }
-  uint32_t getMaxEventSize() {
-    return maxEventSize_;
-  }
+  void setMaxEventSize(uint32_t maxEventSize) { maxEventSize_ = maxEventSize; }
+  uint32_t getMaxEventSize() { return maxEventSize_; }
 
   void setMaxCorruptedEvents(uint32_t maxCorruptedEvents) {
     maxCorruptedEvents_ = maxCorruptedEvents;
   }
-  uint32_t getMaxCorruptedEvents() {
-    return maxCorruptedEvents_;
-  }
+  uint32_t getMaxCorruptedEvents() { return maxCorruptedEvents_; }
 
   void setEofSleepTimeUs(uint32_t eofSleepTime) {
     if (eofSleepTime) {
       eofSleepTime_ = eofSleepTime;
     }
   }
-  uint32_t getEofSleepTimeUs() {
-    return eofSleepTime_;
-  }
+  uint32_t getEofSleepTimeUs() { return eofSleepTime_; }
 
   /*
    * Override TTransport *_virt() functions to invoke our implementations.
    * We cannot use TVirtualTransport to provide these, since we need to inherit
    * virtually from TTransport.
    */
-  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) {
-    return this->read(buf, len);
-  }
-  virtual uint32_t readAll_virt(uint8_t* buf, uint32_t len) {
-    return this->readAll(buf, len);
-  }
-  virtual void write_virt(const uint8_t* buf, uint32_t len) {
-    this->write(buf, len);
-  }
+  virtual uint32_t read_virt(uint8_t* buf, uint32_t len) { return this->read(buf, len); }
+  virtual uint32_t readAll_virt(uint8_t* buf, uint32_t len) { return this->readAll(buf, len); }
+  virtual void write_virt(const uint8_t* buf, uint32_t len) { this->write(buf, len); }
 
- private:
+private:
   // helper functions for writing to a file
   void enqueueEvent(const uint8_t* buf, uint32_t eventLen);
   bool swapEventBuffers(struct timeval* deadline);
@@ -375,8 +343,8 @@ class TFileTransport : public TFileReaderTransport,
 
   // buffers to hold data before it is flushed. Each element of the buffer stores a msg that
   // needs to be written to the file.  The buffers are swapped by the writer thread.
-  TFileTransportBuffer *dequeueBuffer_;
-  TFileTransportBuffer *enqueueBuffer_;
+  TFileTransportBuffer* dequeueBuffer_;
+  TFileTransportBuffer* enqueueBuffer_;
 
   // conditions used to block when the buffer is full or empty
   Monitor notFull_, notEmpty_;
@@ -408,15 +376,13 @@ class TFileTransport : public TFileReaderTransport,
 
 // Exception thrown when EOF is hit
 class TEOFException : public TTransportException {
- public:
-  TEOFException():
-    TTransportException(TTransportException::END_OF_FILE) {};
+public:
+  TEOFException() : TTransportException(TTransportException::END_OF_FILE){};
 };
 
-
 // wrapper class to process events from a file containing thrift events
 class TFileProcessor {
- public:
+public:
   /**
    * Constructor that defaults output transport to null transport
    *
@@ -460,15 +426,15 @@ class TFileProcessor {
    */
   void processChunk();
 
- private:
+private:
   boost::shared_ptr<TProcessor> processor_;
   boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
   boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
   boost::shared_ptr<TFileReaderTransport> inputTransport_;
   boost::shared_ptr<TTransport> outputTransport_;
 };
-
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // _THRIFT_TRANSPORT_TFILETRANSPORT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpClient.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpClient.cpp b/lib/cpp/src/thrift/transport/THttpClient.cpp
index cb94d5e..c610636 100644
--- a/lib/cpp/src/thrift/transport/THttpClient.cpp
+++ b/lib/cpp/src/thrift/transport/THttpClient.cpp
@@ -25,26 +25,33 @@
 #include <thrift/transport/THttpClient.h>
 #include <thrift/transport/TSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
-THttpClient::THttpClient(boost::shared_ptr<TTransport> transport, std::string host, std::string path) :
-  THttpTransport(transport), host_(host), path_(path) {
+THttpClient::THttpClient(boost::shared_ptr<TTransport> transport,
+                         std::string host,
+                         std::string path)
+  : THttpTransport(transport), host_(host), path_(path) {
 }
 
-THttpClient::THttpClient(string host, int port, string path) :
-  THttpTransport(boost::shared_ptr<TTransport>(new TSocket(host, port))), host_(host), path_(path) {
+THttpClient::THttpClient(string host, int port, string path)
+  : THttpTransport(boost::shared_ptr<TTransport>(new TSocket(host, port))),
+    host_(host),
+    path_(path) {
 }
 
-THttpClient::~THttpClient() {}
+THttpClient::~THttpClient() {
+}
 
 void THttpClient::parseHeader(char* header) {
   char* colon = strchr(header, ':');
   if (colon == NULL) {
     return;
   }
-  char* value = colon+1;
+  char* value = colon + 1;
 
   if (boost::istarts_with(header, "Transfer-Encoding")) {
     if (boost::iends_with(value, "chunked")) {
@@ -65,7 +72,8 @@ bool THttpClient::parseStatusLine(char* status) {
   }
 
   *code = '\0';
-  while (*(code++) == ' ') {};
+  while (*(code++) == ' ') {
+  };
 
   char* msg = strchr(code, ' ');
   if (msg == NULL) {
@@ -92,17 +100,13 @@ void THttpClient::flush() {
 
   // Construct the HTTP header
   std::ostringstream h;
-  h <<
-    "POST " << path_ << " HTTP/1.1" << CRLF <<
-    "Host: " << host_ << CRLF <<
-    "Content-Type: application/x-thrift" << CRLF <<
-    "Content-Length: " << len << CRLF <<
-    "Accept: application/x-thrift" << CRLF <<
-    "User-Agent: Thrift/" << VERSION << " (C++/THttpClient)" << CRLF <<
-    CRLF;
+  h << "POST " << path_ << " HTTP/1.1" << CRLF << "Host: " << host_ << CRLF
+    << "Content-Type: application/x-thrift" << CRLF << "Content-Length: " << len << CRLF
+    << "Accept: application/x-thrift" << CRLF << "User-Agent: Thrift/" << VERSION
+    << " (C++/THttpClient)" << CRLF << CRLF;
   string header = h.str();
 
-  if(header.size() > (std::numeric_limits<uint32_t>::max)())
+  if (header.size() > (std::numeric_limits<uint32_t>::max)())
     throw TTransportException("Header too big");
   // Write the header, then the data, then flush
   transport_->write((const uint8_t*)header.c_str(), static_cast<uint32_t>(header.size()));
@@ -113,5 +117,6 @@ void THttpClient::flush() {
   writeBuffer_.resetBuffer();
   readHeaders_ = true;
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpClient.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpClient.h b/lib/cpp/src/thrift/transport/THttpClient.h
index 0898b11..64e7332 100644
--- a/lib/cpp/src/thrift/transport/THttpClient.h
+++ b/lib/cpp/src/thrift/transport/THttpClient.h
@@ -22,28 +22,29 @@
 
 #include <thrift/transport/THttpTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class THttpClient : public THttpTransport {
- public:
-  THttpClient(boost::shared_ptr<TTransport> transport, std::string host, std::string path="");
+public:
+  THttpClient(boost::shared_ptr<TTransport> transport, std::string host, std::string path = "");
 
-  THttpClient(std::string host, int port, std::string path="");
+  THttpClient(std::string host, int port, std::string path = "");
 
   virtual ~THttpClient();
 
   virtual void flush();
 
- protected:
-
+protected:
   std::string host_;
   std::string path_;
 
   virtual void parseHeader(char* header);
   virtual bool parseStatusLine(char* status);
-
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_THTTPCLIENT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp
index 620bbd2..12c55dc 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.cpp
+++ b/lib/cpp/src/thrift/transport/THttpServer.cpp
@@ -24,15 +24,17 @@
 #include <thrift/transport/THttpServer.h>
 #include <thrift/transport/TSocket.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
-THttpServer::THttpServer(boost::shared_ptr<TTransport> transport) :
-  THttpTransport(transport) {
+THttpServer::THttpServer(boost::shared_ptr<TTransport> transport) : THttpTransport(transport) {
 }
 
-THttpServer::~THttpServer() {}
+THttpServer::~THttpServer() {
+}
 
 void THttpServer::parseHeader(char* header) {
   char* colon = strchr(header, ':');
@@ -40,7 +42,7 @@ void THttpServer::parseHeader(char* header) {
     return;
   }
   size_t sz = colon - header;
-  char* value = colon+1;
+  char* value = colon + 1;
 
   if (strncmp(header, "Transfer-Encoding", sz) == 0) {
     if (strstr(value, "chunked") != NULL) {
@@ -63,7 +65,8 @@ bool THttpServer::parseStatusLine(char* status) {
   }
 
   *path = '\0';
-  while (*(++path) == ' ') {};
+  while (*(++path) == ' ') {
+  };
 
   char* http = strchr(path, ' ');
   if (http == NULL) {
@@ -74,8 +77,7 @@ bool THttpServer::parseStatusLine(char* status) {
   if (strcmp(method, "POST") == 0) {
     // POST method ok, looking for content.
     return true;
-  }
-  else if (strcmp(method, "OPTIONS") == 0) {
+  } else if (strcmp(method, "OPTIONS") == 0) {
     // preflight OPTIONS method, we don't need further content.
     // how to graciously close connection?
     uint8_t* buf;
@@ -84,13 +86,9 @@ bool THttpServer::parseStatusLine(char* status) {
 
     // Construct the HTTP header
     std::ostringstream h;
-    h <<
-      "HTTP/1.1 200 OK" << CRLF <<
-      "Date: " << getTimeRFC1123() << CRLF <<
-      "Access-Control-Allow-Origin: *" << CRLF <<
-      "Access-Control-Allow-Methods: POST, OPTIONS" << CRLF <<
-      "Access-Control-Allow-Headers: Content-Type" << CRLF <<
-      CRLF;
+    h << "HTTP/1.1 200 OK" << CRLF << "Date: " << getTimeRFC1123() << CRLF
+      << "Access-Control-Allow-Origin: *" << CRLF << "Access-Control-Allow-Methods: POST, OPTIONS"
+      << CRLF << "Access-Control-Allow-Headers: Content-Type" << CRLF << CRLF;
     string header = h.str();
 
     // Write the header, then the data, then flush
@@ -114,15 +112,10 @@ void THttpServer::flush() {
 
   // Construct the HTTP header
   std::ostringstream h;
-  h <<
-    "HTTP/1.1 200 OK" << CRLF <<
-    "Date: " << getTimeRFC1123() << CRLF <<
-    "Server: Thrift/" << VERSION << CRLF <<
-    "Access-Control-Allow-Origin: *" << CRLF <<
-    "Content-Type: application/x-thrift" << CRLF <<
-    "Content-Length: " << len << CRLF <<
-    "Connection: Keep-Alive" << CRLF <<
-    CRLF;
+  h << "HTTP/1.1 200 OK" << CRLF << "Date: " << getTimeRFC1123() << CRLF << "Server: Thrift/"
+    << VERSION << CRLF << "Access-Control-Allow-Origin: *" << CRLF
+    << "Content-Type: application/x-thrift" << CRLF << "Content-Length: " << len << CRLF
+    << "Connection: Keep-Alive" << CRLF << CRLF;
   string header = h.str();
 
   // Write the header, then the data, then flush
@@ -136,19 +129,25 @@ void THttpServer::flush() {
   readHeaders_ = true;
 }
 
-std::string THttpServer::getTimeRFC1123()
-{
-  static const char* Days[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
-  static const char* Months[] = {"Jan","Feb","Mar", "Apr", "May", "Jun", "Jul","Aug", "Sep", "Oct","Nov","Dec"};
+std::string THttpServer::getTimeRFC1123() {
+  static const char* Days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+  static const char* Months[]
+      = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
   char buff[128];
   time_t t = time(NULL);
   tm* broken_t = gmtime(&t);
 
-  sprintf(buff,"%s, %d %s %d %d:%d:%d GMT",
-          Days[broken_t->tm_wday], broken_t->tm_mday, Months[broken_t->tm_mon],
+  sprintf(buff,
+          "%s, %d %s %d %d:%d:%d GMT",
+          Days[broken_t->tm_wday],
+          broken_t->tm_mday,
+          Months[broken_t->tm_mon],
           broken_t->tm_year + 1900,
-          broken_t->tm_hour,broken_t->tm_min,broken_t->tm_sec);
+          broken_t->tm_hour,
+          broken_t->tm_min,
+          broken_t->tm_sec);
   return std::string(buff);
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpServer.h b/lib/cpp/src/thrift/transport/THttpServer.h
index bf69dbe..a7ab944 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.h
+++ b/lib/cpp/src/thrift/transport/THttpServer.h
@@ -22,30 +22,30 @@
 
 #include <thrift/transport/THttpTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 class THttpServer : public THttpTransport {
- public:
+public:
   THttpServer(boost::shared_ptr<TTransport> transport);
 
   virtual ~THttpServer();
 
   virtual void flush();
 
- protected:
-
+protected:
   void readHeaders();
   virtual void parseHeader(char* header);
   virtual bool parseStatusLine(char* status);
   std::string getTimeRFC1123();
-
 };
 
 /**
  * Wraps a transport into HTTP protocol
  */
 class THttpServerTransportFactory : public TTransportFactory {
- public:
+public:
   THttpServerTransportFactory() {}
 
   virtual ~THttpServerTransportFactory() {}
@@ -56,9 +56,9 @@ class THttpServerTransportFactory : public TTransportFactory {
   virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
     return boost::shared_ptr<TTransport>(new THttpServer(trans));
   }
-
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_THTTPSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpTransport.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpTransport.cpp b/lib/cpp/src/thrift/transport/THttpTransport.cpp
index 79ee7d5..eccac90 100644
--- a/lib/cpp/src/thrift/transport/THttpTransport.cpp
+++ b/lib/cpp/src/thrift/transport/THttpTransport.cpp
@@ -21,7 +21,9 @@
 
 #include <thrift/transport/THttpTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
@@ -29,23 +31,23 @@ using namespace std;
 const char* THttpTransport::CRLF = "\r\n";
 const int THttpTransport::CRLF_LEN = 2;
 
-THttpTransport::THttpTransport(boost::shared_ptr<TTransport> transport) :
-  transport_(transport),
-  origin_(""),
-  readHeaders_(true),
-  chunked_(false),
-  chunkedDone_(false),
-  chunkSize_(0),
-  contentLength_(0),
-  httpBuf_(NULL),
-  httpPos_(0),
-  httpBufLen_(0),
-  httpBufSize_(1024) {
+THttpTransport::THttpTransport(boost::shared_ptr<TTransport> transport)
+  : transport_(transport),
+    origin_(""),
+    readHeaders_(true),
+    chunked_(false),
+    chunkedDone_(false),
+    chunkSize_(0),
+    contentLength_(0),
+    httpBuf_(NULL),
+    httpPos_(0),
+    httpBufLen_(0),
+    httpBufSize_(1024) {
   init();
 }
 
 void THttpTransport::init() {
-  httpBuf_ = (char*)std::malloc(httpBufSize_+1);
+  httpBuf_ = (char*)std::malloc(httpBufSize_ + 1);
   if (httpBuf_ == NULL) {
     throw std::bad_alloc();
   }
@@ -152,7 +154,7 @@ uint32_t THttpTransport::readContent(uint32_t size) {
     if (need < give) {
       give = need;
     }
-    readBuffer_.write((uint8_t*)(httpBuf_+httpPos_), give);
+    readBuffer_.write((uint8_t*)(httpBuf_ + httpPos_), give);
     httpPos_ += give;
     need -= give;
   }
@@ -163,7 +165,7 @@ char* THttpTransport::readLine() {
   while (true) {
     char* eol = NULL;
 
-    eol = strstr(httpBuf_+httpPos_, CRLF);
+    eol = strstr(httpBuf_ + httpPos_, CRLF);
 
     // No CRLF yet?
     if (eol == NULL) {
@@ -173,19 +175,18 @@ char* THttpTransport::readLine() {
     } else {
       // Return pointer to next line
       *eol = '\0';
-      char* line = httpBuf_+httpPos_;
-      httpPos_ = static_cast<uint32_t>((eol-httpBuf_) + CRLF_LEN);
+      char* line = httpBuf_ + httpPos_;
+      httpPos_ = static_cast<uint32_t>((eol - httpBuf_) + CRLF_LEN);
       return line;
     }
   }
-
 }
 
 void THttpTransport::shift() {
   if (httpBufLen_ > httpPos_) {
     // Shift down remaining data and read more
     uint32_t length = httpBufLen_ - httpPos_;
-    memmove(httpBuf_, httpBuf_+httpPos_, length);
+    memmove(httpBuf_, httpBuf_ + httpPos_, length);
     httpBufLen_ = length;
   } else {
     httpBufLen_ = 0;
@@ -198,14 +199,14 @@ void THttpTransport::refill() {
   uint32_t avail = httpBufSize_ - httpBufLen_;
   if (avail <= (httpBufSize_ / 4)) {
     httpBufSize_ *= 2;
-    httpBuf_ = (char*)std::realloc(httpBuf_, httpBufSize_+1);
+    httpBuf_ = (char*)std::realloc(httpBuf_, httpBufSize_ + 1);
     if (httpBuf_ == NULL) {
       throw std::bad_alloc();
     }
   }
 
   // Read more data
-  uint32_t got = transport_->read((uint8_t*)(httpBuf_+httpBufLen_), httpBufSize_-httpBufLen_);
+  uint32_t got = transport_->read((uint8_t*)(httpBuf_ + httpBufLen_), httpBufSize_ - httpBufLen_);
   httpBufLen_ += got;
   httpBuf_[httpBufLen_] = '\0';
 
@@ -254,11 +255,12 @@ void THttpTransport::write(const uint8_t* buf, uint32_t len) {
 
 const std::string THttpTransport::getOrigin() {
   std::ostringstream oss;
-  if ( !origin_.empty()) {
+  if (!origin_.empty()) {
     oss << origin_ << ", ";
   }
   oss << transport_->getOrigin();
   return oss.str();
 }
-
-}}}
+}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/THttpTransport.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpTransport.h b/lib/cpp/src/thrift/transport/THttpTransport.h
index 8967c74..a9f564c 100644
--- a/lib/cpp/src/thrift/transport/THttpTransport.h
+++ b/lib/cpp/src/thrift/transport/THttpTransport.h
@@ -23,7 +23,9 @@
 #include <thrift/transport/TBufferTransports.h>
 #include <thrift/transport/TVirtualTransport.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * HTTP implementation of the thrift transport. This was irritating
@@ -33,26 +35,18 @@ namespace apache { namespace thrift { namespace transport {
  * chunked transfer encoding, keepalive, etc. Tested against Apache.
  */
 class THttpTransport : public TVirtualTransport<THttpTransport> {
- public:
+public:
   THttpTransport(boost::shared_ptr<TTransport> transport);
 
   virtual ~THttpTransport();
 
-  void open() {
-    transport_->open();
-  }
+  void open() { transport_->open(); }
 
-  bool isOpen() {
-    return transport_->isOpen();
-  }
+  bool isOpen() { return transport_->isOpen(); }
 
-  bool peek() {
-    return transport_->peek();
-  }
+  bool peek() { return transport_->peek(); }
 
-  void close() {
-    transport_->close();
-  }
+  void close() { transport_->close(); }
 
   uint32_t read(uint8_t* buf, uint32_t len);
 
@@ -64,8 +58,7 @@ class THttpTransport : public TVirtualTransport<THttpTransport> {
 
   virtual const std::string getOrigin();
 
- protected:
-
+protected:
   boost::shared_ptr<TTransport> transport_;
   std::string origin_;
 
@@ -104,7 +97,8 @@ class THttpTransport : public TVirtualTransport<THttpTransport> {
   static const char* CRLF;
   static const int CRLF_LEN;
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // #ifndef _THRIFT_TRANSPORT_THTTPCLIENT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TPipe.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TPipe.cpp b/lib/cpp/src/thrift/transport/TPipe.cpp
index 3bb3dac..15e4845 100644
--- a/lib/cpp/src/thrift/transport/TPipe.cpp
+++ b/lib/cpp/src/thrift/transport/TPipe.cpp
@@ -20,11 +20,13 @@
 #include <thrift/transport/TTransportException.h>
 #include <thrift/transport/TPipe.h>
 #ifdef _WIN32
-  #include <thrift/windows/OverlappedSubmissionThread.h>
-  #include <thrift/windows/Sync.h>
+#include <thrift/windows/OverlappedSubmissionThread.h>
+#include <thrift/windows/Sync.h>
 #endif
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 using namespace std;
 
@@ -46,9 +48,9 @@ public:
   virtual ~TPipeImpl() = 0 {}
   virtual uint32_t read(uint8_t* buf, uint32_t len) = 0;
   virtual void write(const uint8_t* buf, uint32_t len) = 0;
-  virtual HANDLE getPipeHandle() = 0; //doubles as the read handle for anon pipe
+  virtual HANDLE getPipeHandle() = 0; // doubles as the read handle for anon pipe
   virtual void setPipeHandle(HANDLE pipehandle) = 0;
-  virtual HANDLE getWrtPipeHandle() {return INVALID_HANDLE_VALUE;}
+  virtual HANDLE getWrtPipeHandle() { return INVALID_HANDLE_VALUE; }
   virtual void setWrtPipeHandle(HANDLE) {}
   virtual bool isBufferedDataAvailable() { return false; }
   virtual HANDLE getNativeWaitHandle() { return INVALID_HANDLE_VALUE; }
@@ -58,15 +60,16 @@ class TNamedPipeImpl : public TPipeImpl {
 public:
   explicit TNamedPipeImpl(HANDLE pipehandle) : Pipe_(pipehandle) {}
   virtual ~TNamedPipeImpl() {}
-  virtual uint32_t read(uint8_t* buf, uint32_t len)    {
-    return pseudo_sync_read (Pipe_.h, read_event_.h, buf, len);
+  virtual uint32_t read(uint8_t* buf, uint32_t len) {
+    return pseudo_sync_read(Pipe_.h, read_event_.h, buf, len);
   }
   virtual void write(const uint8_t* buf, uint32_t len) {
     pseudo_sync_write(Pipe_.h, write_event_.h, buf, len);
   }
 
-  virtual HANDLE getPipeHandle() {return Pipe_.h;}
-  virtual void setPipeHandle(HANDLE pipehandle) {Pipe_.reset(pipehandle);}
+  virtual HANDLE getPipeHandle() { return Pipe_.h; }
+  virtual void setPipeHandle(HANDLE pipehandle) { Pipe_.reset(pipehandle); }
+
 private:
   TManualResetEvent read_event_;
   TManualResetEvent write_event_;
@@ -77,13 +80,14 @@ class TAnonPipeImpl : public TPipeImpl {
 public:
   TAnonPipeImpl(HANDLE PipeRd, HANDLE PipeWrt) : PipeRd_(PipeRd), PipeWrt_(PipeWrt) {}
   virtual ~TAnonPipeImpl() {}
-  virtual uint32_t read(uint8_t* buf, uint32_t len)    {return pipe_read (PipeRd_.h,  buf, len);}
-  virtual void write(const uint8_t* buf, uint32_t len) {       pipe_write(PipeWrt_.h, buf, len);}
+  virtual uint32_t read(uint8_t* buf, uint32_t len) { return pipe_read(PipeRd_.h, buf, len); }
+  virtual void write(const uint8_t* buf, uint32_t len) { pipe_write(PipeWrt_.h, buf, len); }
+
+  virtual HANDLE getPipeHandle() { return PipeRd_.h; }
+  virtual void setPipeHandle(HANDLE PipeRd) { PipeRd_.reset(PipeRd); }
+  virtual HANDLE getWrtPipeHandle() { return PipeWrt_.h; }
+  virtual void setWrtPipeHandle(HANDLE PipeWrt) { PipeWrt_.reset(PipeWrt); }
 
-  virtual HANDLE getPipeHandle()                {return PipeRd_.h;}
-  virtual void setPipeHandle(HANDLE PipeRd)     {PipeRd_.reset(PipeRd);}
-  virtual HANDLE getWrtPipeHandle()             {return PipeWrt_.h;}
-  virtual void setWrtPipeHandle(HANDLE PipeWrt) {PipeWrt_.reset(PipeWrt);}
 private:
   TAutoHandle PipeRd_;
   TAutoHandle PipeWrt_;
@@ -94,11 +98,8 @@ private:
 // than using the regular named pipe implementation
 class TWaitableNamedPipeImpl : public TPipeImpl {
 public:
-  explicit TWaitableNamedPipeImpl(HANDLE pipehandle) :
-    Pipe_(pipehandle),
-    begin_unread_idx_(0),
-    end_unread_idx_(0)
-  {
+  explicit TWaitableNamedPipeImpl(HANDLE pipehandle)
+    : Pipe_(pipehandle), begin_unread_idx_(0), end_unread_idx_(0) {
     readOverlap_.action = TOverlappedWorkItem::READ;
     readOverlap_.h = Pipe_.h;
     cancelOverlap_.action = TOverlappedWorkItem::CANCELIO;
@@ -108,7 +109,7 @@ public:
   }
   virtual ~TWaitableNamedPipeImpl() {
     // see if there is an outstanding read request
-    if(begin_unread_idx_ == end_unread_idx_) {
+    if (begin_unread_idx_ == end_unread_idx_) {
       // if so, cancel it, and wait for the dead completion
       thread_->addWorkItem(&cancelOverlap_);
       readOverlap_.overlappedResults(false /*ignore errors*/);
@@ -119,10 +120,11 @@ public:
     pseudo_sync_write(Pipe_.h, write_event_.h, buf, len);
   }
 
-  virtual HANDLE getPipeHandle() {return Pipe_.h;}
-  virtual void setPipeHandle(HANDLE pipehandle) {Pipe_.reset(pipehandle);}
-  virtual bool isBufferedDataAvailable() {return begin_unread_idx_ < end_unread_idx_;}
+  virtual HANDLE getPipeHandle() { return Pipe_.h; }
+  virtual void setPipeHandle(HANDLE pipehandle) { Pipe_.reset(pipehandle); }
+  virtual bool isBufferedDataAvailable() { return begin_unread_idx_ < end_unread_idx_; }
   virtual HANDLE getNativeWaitHandle() { return ready_event_.h; }
+
 private:
   void beginAsyncRead(uint8_t* buf, uint32_t len);
   uint32_t endAsyncRead();
@@ -138,34 +140,29 @@ private:
   uint32_t end_unread_idx_;
 };
 
-void TWaitableNamedPipeImpl::beginAsyncRead(uint8_t* buf, uint32_t len)
-{
+void TWaitableNamedPipeImpl::beginAsyncRead(uint8_t* buf, uint32_t len) {
   begin_unread_idx_ = end_unread_idx_ = 0;
   readOverlap_.reset(buf, len, ready_event_.h);
   thread_->addWorkItem(&readOverlap_);
-  if(readOverlap_.success == FALSE && readOverlap_.last_error != ERROR_IO_PENDING)
-  {
+  if (readOverlap_.success == FALSE && readOverlap_.last_error != ERROR_IO_PENDING) {
     GlobalOutput.perror("TPipe ::ReadFile errored GLE=", readOverlap_.last_error);
     throw TTransportException(TTransportException::UNKNOWN, "TPipe: ReadFile failed");
   }
 }
 
-uint32_t TWaitableNamedPipeImpl::endAsyncRead()
-{
+uint32_t TWaitableNamedPipeImpl::endAsyncRead() {
   return readOverlap_.overlappedResults();
 }
 
-uint32_t TWaitableNamedPipeImpl::read(uint8_t* buf, uint32_t len)
-{
-  if(begin_unread_idx_ == end_unread_idx_) {
+uint32_t TWaitableNamedPipeImpl::read(uint8_t* buf, uint32_t len) {
+  if (begin_unread_idx_ == end_unread_idx_) {
     end_unread_idx_ = endAsyncRead();
   }
 
-  uint32_t bytes_to_copy = (std::min)(len, end_unread_idx_-begin_unread_idx_);
+  uint32_t bytes_to_copy = (std::min)(len, end_unread_idx_ - begin_unread_idx_);
   memcpy(buf, &buffer_[begin_unread_idx_], bytes_to_copy);
   begin_unread_idx_ += bytes_to_copy;
-  if(begin_unread_idx_ != end_unread_idx_)
-  {
+  if (begin_unread_idx_ != end_unread_idx_) {
     assert(len == bytes_to_copy);
     // we were able to fulfill the read with just the bytes in our
     // buffer, and we still have buffer left
@@ -173,33 +170,29 @@ uint32_t TWaitableNamedPipeImpl::read(uint8_t* buf, uint32_t len)
   }
   uint32_t bytes_copied = bytes_to_copy;
 
-  //all of the requested data has been read.  Kick off an async read for the next round.
+  // all of the requested data has been read.  Kick off an async read for the next round.
   beginAsyncRead(&buffer_[0], static_cast<uint32_t>(buffer_.size()));
 
   return bytes_copied;
 }
 
-void pseudo_sync_write(HANDLE pipe, HANDLE event, const uint8_t* buf, uint32_t len)
-{
+void pseudo_sync_write(HANDLE pipe, HANDLE event, const uint8_t* buf, uint32_t len) {
   OVERLAPPED tempOverlap;
-  memset( &tempOverlap, 0, sizeof(tempOverlap));
+  memset(&tempOverlap, 0, sizeof(tempOverlap));
   tempOverlap.hEvent = event;
 
   uint32_t written = 0;
-  while(written < len)
-  {
-    BOOL result = ::WriteFile(pipe, buf+written, len-written, NULL, &tempOverlap);
+  while (written < len) {
+    BOOL result = ::WriteFile(pipe, buf + written, len - written, NULL, &tempOverlap);
 
-    if(result == FALSE && ::GetLastError() != ERROR_IO_PENDING)
-    {
+    if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
       GlobalOutput.perror("TPipe ::WriteFile errored GLE=", ::GetLastError());
       throw TTransportException(TTransportException::UNKNOWN, "TPipe: write failed");
     }
 
     DWORD bytes = 0;
     result = ::GetOverlappedResult(pipe, &tempOverlap, &bytes, TRUE);
-    if(!result)
-    {
+    if (!result) {
       GlobalOutput.perror("TPipe ::GetOverlappedResult errored GLE=", ::GetLastError());
       throw TTransportException(TTransportException::UNKNOWN, "TPipe: GetOverlappedResult failed");
     }
@@ -207,24 +200,21 @@ void pseudo_sync_write(HANDLE pipe, HANDLE event, const uint8_t* buf, uint32_t l
   }
 }
 
-uint32_t pseudo_sync_read(HANDLE pipe, HANDLE event, uint8_t* buf, uint32_t len)
-{
+uint32_t pseudo_sync_read(HANDLE pipe, HANDLE event, uint8_t* buf, uint32_t len) {
   OVERLAPPED tempOverlap;
-  memset( &tempOverlap, 0, sizeof(tempOverlap));
+  memset(&tempOverlap, 0, sizeof(tempOverlap));
   tempOverlap.hEvent = event;
 
   BOOL result = ::ReadFile(pipe, buf, len, NULL, &tempOverlap);
 
-  if(result == FALSE && ::GetLastError() != ERROR_IO_PENDING)
-  {
+  if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
     GlobalOutput.perror("TPipe ::ReadFile errored GLE=", ::GetLastError());
     throw TTransportException(TTransportException::UNKNOWN, "TPipe: read failed");
   }
 
   DWORD bytes = 0;
   result = ::GetOverlappedResult(pipe, &tempOverlap, &bytes, TRUE);
-  if(!result)
-  {
+  if (!result) {
     GlobalOutput.perror("TPipe ::GetOverlappedResult errored GLE=", ::GetLastError());
     throw TTransportException(TTransportException::UNKNOWN, "TPipe: GetOverlappedResult failed");
   }
@@ -232,38 +222,27 @@ uint32_t pseudo_sync_read(HANDLE pipe, HANDLE event, uint8_t* buf, uint32_t len)
 }
 
 //---- Constructors ----
-TPipe::TPipe(HANDLE Pipe) :
-  impl_(new TWaitableNamedPipeImpl(Pipe)),
-  TimeoutSeconds_(3),
-  isAnonymous_(false)
-{}
-
-TPipe::TPipe(const char *pipename) :
-  TimeoutSeconds_(3),
-  isAnonymous_(false)
-{
+TPipe::TPipe(HANDLE Pipe)
+  : impl_(new TWaitableNamedPipeImpl(Pipe)), TimeoutSeconds_(3), isAnonymous_(false) {
+}
+
+TPipe::TPipe(const char* pipename) : TimeoutSeconds_(3), isAnonymous_(false) {
   setPipename(pipename);
 }
 
-TPipe::TPipe(const std::string &pipename) :
-  TimeoutSeconds_(3),
-  isAnonymous_(false)
-{
+TPipe::TPipe(const std::string& pipename) : TimeoutSeconds_(3), isAnonymous_(false) {
   setPipename(pipename);
 }
 
-TPipe::TPipe(HANDLE PipeRd, HANDLE PipeWrt) :
-  impl_(new TAnonPipeImpl(PipeRd, PipeWrt)),
-  TimeoutSeconds_(3),
-  isAnonymous_(true)
-{}
+TPipe::TPipe(HANDLE PipeRd, HANDLE PipeWrt)
+  : impl_(new TAnonPipeImpl(PipeRd, PipeWrt)), TimeoutSeconds_(3), isAnonymous_(true) {
+}
 
-TPipe::TPipe() :
-  TimeoutSeconds_(3),
-  isAnonymous_(false)
-{}
+TPipe::TPipe() : TimeoutSeconds_(3), isAnonymous_(false) {
+}
 
-TPipe::~TPipe() {}
+TPipe::~TPipe() {
+}
 
 //---------------------------------------------------------
 // Transport callbacks
@@ -283,27 +262,24 @@ void TPipe::open() {
   TAutoHandle hPipe;
   do {
     DWORD flags = FILE_FLAG_OVERLAPPED; // async mode, so we can do reads at the same time as writes
-    hPipe.reset(CreateFile(
-      pipename_.c_str(),
-      GENERIC_READ | GENERIC_WRITE,
-      0,                    // no sharing
-      NULL,                 // default security attributes
-      OPEN_EXISTING,        // opens existing pipe
-      flags,
-      NULL));               // no template file
+    hPipe.reset(CreateFile(pipename_.c_str(),
+                           GENERIC_READ | GENERIC_WRITE,
+                           0,             // no sharing
+                           NULL,          // default security attributes
+                           OPEN_EXISTING, // opens existing pipe
+                           flags,
+                           NULL)); // no template file
 
     if (hPipe.h != INVALID_HANDLE_VALUE)
-      break; //success!
+      break; // success!
 
-    if(::GetLastError() != ERROR_PIPE_BUSY)
-    {
+    if (::GetLastError() != ERROR_PIPE_BUSY) {
       GlobalOutput.perror("TPipe::open ::CreateFile errored GLE=", ::GetLastError());
       throw TTransportException(TTransportException::NOT_OPEN, "Unable to open pipe");
     }
-  } while( ::WaitNamedPipe(pipename_.c_str(), TimeoutSeconds_*1000) );
+  } while (::WaitNamedPipe(pipename_.c_str(), TimeoutSeconds_ * 1000));
 
-  if(hPipe.h == INVALID_HANDLE_VALUE)
-  {
+  if (hPipe.h == INVALID_HANDLE_VALUE) {
     GlobalOutput.perror("TPipe::open ::CreateFile errored GLE=", ::GetLastError());
     throw TTransportException(TTransportException::NOT_OPEN, "Unable to open pipe");
   }
@@ -312,7 +288,6 @@ void TPipe::open() {
   hPipe.release();
 }
 
-
 void TPipe::close() {
   impl_.reset();
 }
@@ -323,17 +298,15 @@ uint32_t TPipe::read(uint8_t* buf, uint32_t len) {
   return impl_->read(buf, len);
 }
 
-uint32_t pipe_read(HANDLE pipe, uint8_t* buf, uint32_t len)
-{
-  DWORD  cbRead;
-  int fSuccess = ReadFile(
-              pipe,     // pipe handle
-              buf,      // buffer to receive reply
-              len,      // size of buffer
-              &cbRead,  // number of bytes read
-              NULL);    // not overlapped
-
-  if ( !fSuccess && GetLastError() != ERROR_MORE_DATA )
+uint32_t pipe_read(HANDLE pipe, uint8_t* buf, uint32_t len) {
+  DWORD cbRead;
+  int fSuccess = ReadFile(pipe,    // pipe handle
+                          buf,     // buffer to receive reply
+                          len,     // size of buffer
+                          &cbRead, // number of bytes read
+                          NULL);   // not overlapped
+
+  if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
     return 0; // No more data, possibly because client disconnected.
 
   return cbRead;
@@ -345,17 +318,15 @@ void TPipe::write(const uint8_t* buf, uint32_t len) {
   impl_->write(buf, len);
 }
 
-void pipe_write(HANDLE pipe, const uint8_t* buf, uint32_t len)
-{
-  DWORD  cbWritten;
-  int fSuccess = WriteFile(
-              pipe,       // pipe handle
-              buf,        // message
-              len,        // message length
-              &cbWritten, // bytes written
-              NULL);      // not overlapped
-
-  if ( !fSuccess)
+void pipe_write(HANDLE pipe, const uint8_t* buf, uint32_t len) {
+  DWORD cbWritten;
+  int fSuccess = WriteFile(pipe,       // pipe handle
+                           buf,        // message
+                           len,        // message length
+                           &cbWritten, // bytes written
+                           NULL);      // not overlapped
+
+  if (!fSuccess)
     throw TTransportException(TTransportException::NOT_OPEN, "Write to pipe failed");
 }
 
@@ -367,36 +338,40 @@ string TPipe::getPipename() {
   return pipename_;
 }
 
-void TPipe::setPipename(const std::string &pipename) {
-  if(pipename.find("\\\\") == -1)
+void TPipe::setPipename(const std::string& pipename) {
+  if (pipename.find("\\\\") == -1)
     pipename_ = "\\\\.\\pipe\\" + pipename;
   else
     pipename_ = pipename;
 }
 
 HANDLE TPipe::getPipeHandle() {
-  if(impl_) return impl_->getPipeHandle();
+  if (impl_)
+    return impl_->getPipeHandle();
   return INVALID_HANDLE_VALUE;
 }
 
 void TPipe::setPipeHandle(HANDLE pipehandle) {
-  if(isAnonymous_)
+  if (isAnonymous_)
     impl_->setPipeHandle(pipehandle);
   else
     impl_.reset(new TNamedPipeImpl(pipehandle));
 }
 
 HANDLE TPipe::getWrtPipeHandle() {
-  if(impl_) return impl_->getWrtPipeHandle();
+  if (impl_)
+    return impl_->getWrtPipeHandle();
   return INVALID_HANDLE_VALUE;
 }
 
 void TPipe::setWrtPipeHandle(HANDLE pipehandle) {
-  if(impl_) impl_->setWrtPipeHandle(pipehandle);
+  if (impl_)
+    impl_->setWrtPipeHandle(pipehandle);
 }
 
 HANDLE TPipe::getNativeWaitHandle() {
-  if(impl_) return impl_->getNativeWaitHandle();
+  if (impl_)
+    return impl_->getNativeWaitHandle();
   return INVALID_HANDLE_VALUE;
 }
 
@@ -409,5 +384,6 @@ void TPipe::setConnectTimeout(long seconds) {
 }
 
 #endif //_WIN32
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport


[02/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/ProcessorTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp
index eee90c7..300b729 100644
--- a/lib/cpp/test/processor/ProcessorTest.cpp
+++ b/lib/cpp/test/processor/ProcessorTest.cpp
@@ -54,7 +54,7 @@ using namespace apache::thrift::test;
  */
 
 class TSimpleServerTraits {
- public:
+public:
   typedef TSimpleServer ServerType;
 
   boost::shared_ptr<TSimpleServer> createServer(
@@ -63,13 +63,13 @@ class TSimpleServerTraits {
       const boost::shared_ptr<TTransportFactory>& transportFactory,
       const boost::shared_ptr<TProtocolFactory>& protocolFactory) {
     boost::shared_ptr<TServerSocket> socket(new TServerSocket(port));
-    return boost::shared_ptr<TSimpleServer>(new TSimpleServer(
-          processor, socket, transportFactory, protocolFactory));
+    return boost::shared_ptr<TSimpleServer>(
+        new TSimpleServer(processor, socket, transportFactory, protocolFactory));
   }
 };
 
 class TThreadedServerTraits {
- public:
+public:
   typedef TThreadedServer ServerType;
 
   boost::shared_ptr<TThreadedServer> createServer(
@@ -78,13 +78,13 @@ class TThreadedServerTraits {
       const boost::shared_ptr<TTransportFactory>& transportFactory,
       const boost::shared_ptr<TProtocolFactory>& protocolFactory) {
     boost::shared_ptr<TServerSocket> socket(new TServerSocket(port));
-    return boost::shared_ptr<TThreadedServer>(new TThreadedServer(
-          processor, socket, transportFactory, protocolFactory));
+    return boost::shared_ptr<TThreadedServer>(
+        new TThreadedServer(processor, socket, transportFactory, protocolFactory));
   }
 };
 
 class TThreadPoolServerTraits {
- public:
+public:
   typedef TThreadPoolServer ServerType;
 
   boost::shared_ptr<TThreadPoolServer> createServer(
@@ -95,19 +95,17 @@ class TThreadPoolServerTraits {
     boost::shared_ptr<TServerSocket> socket(new TServerSocket(port));
 
     boost::shared_ptr<PosixThreadFactory> threadFactory(new PosixThreadFactory);
-    boost::shared_ptr<ThreadManager> threadManager =
-      ThreadManager::newSimpleThreadManager(8);
+    boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8);
     threadManager->threadFactory(threadFactory);
     threadManager->start();
 
-    return boost::shared_ptr<TThreadPoolServer>(new TThreadPoolServer(
-          processor, socket, transportFactory, protocolFactory,
-          threadManager));
+    return boost::shared_ptr<TThreadPoolServer>(
+        new TThreadPoolServer(processor, socket, transportFactory, protocolFactory, threadManager));
   }
 };
 
 class TNonblockingServerTraits {
- public:
+public:
   typedef TNonblockingServer ServerType;
 
   boost::shared_ptr<TNonblockingServer> createServer(
@@ -118,25 +116,24 @@ class TNonblockingServerTraits {
     // TNonblockingServer automatically uses TFramedTransport.
     // Raise an exception if the supplied transport factory is not a
     // TFramedTransportFactory
-    TFramedTransportFactory* framedFactory =
-      dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
+    TFramedTransportFactory* framedFactory
+        = dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
     if (framedFactory == NULL) {
       throw TException("TNonblockingServer must use TFramedTransport");
     }
 
     boost::shared_ptr<PosixThreadFactory> threadFactory(new PosixThreadFactory);
-    boost::shared_ptr<ThreadManager> threadManager =
-      ThreadManager::newSimpleThreadManager(8);
+    boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8);
     threadManager->threadFactory(threadFactory);
     threadManager->start();
 
-    return boost::shared_ptr<TNonblockingServer>(new TNonblockingServer(
-          processor, protocolFactory, port, threadManager));
+    return boost::shared_ptr<TNonblockingServer>(
+        new TNonblockingServer(processor, protocolFactory, port, threadManager));
   }
 };
 
 class TNonblockingServerNoThreadsTraits {
- public:
+public:
   typedef TNonblockingServer ServerType;
 
   boost::shared_ptr<TNonblockingServer> createServer(
@@ -147,16 +144,16 @@ class TNonblockingServerNoThreadsTraits {
     // TNonblockingServer automatically uses TFramedTransport.
     // Raise an exception if the supplied transport factory is not a
     // TFramedTransportFactory
-    TFramedTransportFactory* framedFactory =
-      dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
+    TFramedTransportFactory* framedFactory
+        = dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
     if (framedFactory == NULL) {
       throw TException("TNonblockingServer must use TFramedTransport");
     }
 
     // Use a NULL ThreadManager
     boost::shared_ptr<ThreadManager> threadManager;
-    return boost::shared_ptr<TNonblockingServer>(new TNonblockingServer(
-          processor, protocolFactory, port, threadManager));
+    return boost::shared_ptr<TNonblockingServer>(
+        new TNonblockingServer(processor, protocolFactory, port, threadManager));
   }
 };
 
@@ -173,7 +170,7 @@ class TNonblockingServerNoThreadsTraits {
  */
 
 class UntemplatedTraits {
- public:
+public:
   typedef TBinaryProtocolFactory ProtocolFactory;
   typedef TBinaryProtocol Protocol;
 
@@ -184,7 +181,7 @@ class UntemplatedTraits {
 };
 
 class TemplatedTraits {
- public:
+public:
   typedef TBinaryProtocolFactoryT<TBufferBase> ProtocolFactory;
   typedef TBinaryProtocolT<TBufferBase> Protocol;
 
@@ -194,10 +191,9 @@ class TemplatedTraits {
   typedef ChildServiceClientT<Protocol> ChildClient;
 };
 
-
-template<typename TemplateTraits_>
+template <typename TemplateTraits_>
 class ParentServiceTraits {
- public:
+public:
   typedef typename TemplateTraits_::ParentProcessor Processor;
   typedef typename TemplateTraits_::ParentClient Client;
   typedef ParentHandler Handler;
@@ -206,9 +202,9 @@ class ParentServiceTraits {
   typedef typename TemplateTraits_::Protocol Protocol;
 };
 
-template<typename TemplateTraits_>
+template <typename TemplateTraits_>
 class ChildServiceTraits {
- public:
+public:
   typedef typename TemplateTraits_::ChildProcessor Processor;
   typedef typename TemplateTraits_::ChildClient Client;
   typedef ChildHandler Handler;
@@ -224,17 +220,18 @@ class ChildServiceTraits {
 // It would also be niec if they used covariant return types.  Unfortunately,
 // since they return shared_ptr instead of raw pointers, covariant return types
 // won't work.
-template<typename ServerTraits_, typename ServiceTraits_,
-         typename TransportFactory_ = TFramedTransportFactory,
-         typename Transport_ = TFramedTransport>
+template <typename ServerTraits_,
+          typename ServiceTraits_,
+          typename TransportFactory_ = TFramedTransportFactory,
+          typename Transport_ = TFramedTransport>
 class ServiceState : public ServerState {
- public:
+public:
   typedef typename ServiceTraits_::Processor Processor;
   typedef typename ServiceTraits_::Client Client;
   typedef typename ServiceTraits_::Handler Handler;
 
-  ServiceState() :
-      port_(0),
+  ServiceState()
+    : port_(0),
       log_(new EventLog),
       handler_(new Handler(log_)),
       processor_(new Processor(handler_)),
@@ -247,29 +244,18 @@ class ServiceState : public ServerState {
 
   boost::shared_ptr<TServer> createServer(uint16_t port) {
     ServerTraits_ serverTraits;
-    return serverTraits.createServer(processor_, port, transportFactory_,
-                                     protocolFactory_);
+    return serverTraits.createServer(processor_, port, transportFactory_, protocolFactory_);
   }
 
-  boost::shared_ptr<TServerEventHandler> getServerEventHandler() {
-    return serverEventHandler_;
-  }
+  boost::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; }
 
-  void bindSuccessful(uint16_t port) {
-    port_ = port;
-  }
+  void bindSuccessful(uint16_t port) { port_ = port; }
 
-  uint16_t getPort() const {
-    return port_;
-  }
+  uint16_t getPort() const { return port_; }
 
-  const boost::shared_ptr<EventLog>& getLog() const {
-    return log_;
-  }
+  const boost::shared_ptr<EventLog>& getLog() const { return log_; }
 
-  const boost::shared_ptr<Handler>& getHandler() const {
-    return handler_;
-  }
+  const boost::shared_ptr<Handler>& getHandler() const { return handler_; }
 
   boost::shared_ptr<Client> createClient() {
     typedef typename ServiceTraits_::Protocol Protocol;
@@ -283,7 +269,7 @@ class ServiceState : public ServerState {
     return client;
   }
 
- private:
+private:
   uint16_t port_;
   boost::shared_ptr<EventLog> log_;
   boost::shared_ptr<Handler> handler_;
@@ -294,7 +280,6 @@ class ServiceState : public ServerState {
   boost::shared_ptr<TProcessorEventHandler> processorEventHandler_;
 };
 
-
 /**
  * Check that there are no more events in the log
  */
@@ -436,7 +421,7 @@ uint32_t checkCallEvents(const boost::shared_ptr<EventLog>& log,
  * Test functions
  */
 
-template<typename State_>
+template <typename State_>
 void testParentService(const boost::shared_ptr<State_>& state) {
   boost::shared_ptr<typename State_::Client> client = state->createClient();
 
@@ -458,7 +443,7 @@ void testParentService(const boost::shared_ptr<State_>& state) {
   BOOST_REQUIRE_EQUAL("asdf", strings[2]);
 }
 
-template<typename State_>
+template <typename State_>
 void testChildService(const boost::shared_ptr<State_>& state) {
   boost::shared_ptr<typename State_::Client> client = state->createClient();
 
@@ -476,10 +461,9 @@ void testChildService(const boost::shared_ptr<State_>& state) {
   BOOST_CHECK_EQUAL(99, client->getValue());
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testBasicService() {
-  typedef ServiceState< ServerTraits, ParentServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ParentServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -488,10 +472,9 @@ void testBasicService() {
   testParentService(state);
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testInheritedService() {
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -505,15 +488,16 @@ void testInheritedService() {
  * Test to make sure that the TServerEventHandler and TProcessorEventHandler
  * methods are invoked in the correct order with the actual events.
  */
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testEventSequencing() {
   // We use TBufferedTransport for this test, instead of TFramedTransport.
   // This way the server will start processing data as soon as it is received,
   // instead of waiting for the full request.  This is necessary so we can
   // separate the preRead() and postRead() events.
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits>,
-                        TBufferedTransportFactory, TBufferedTransport>
-    State;
+  typedef ServiceState<ServerTraits,
+                       ChildServiceTraits<TemplateTraits>,
+                       TBufferedTransportFactory,
+                       TBufferedTransport> State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -562,7 +546,7 @@ void testEventSequencing() {
   // Send the rest of the request
   protocol.writeStructBegin("ParentService_getDataNotified_pargs");
   protocol.writeFieldBegin("length", apache::thrift::protocol::T_I32, 1);
-  protocol.writeI32(8*1024*1024);
+  protocol.writeI32(8 * 1024 * 1024);
   protocol.writeFieldEnd();
   protocol.writeFieldStop();
   protocol.writeStructEnd();
@@ -644,10 +628,9 @@ void testEventSequencing() {
   checkNoEvents(log);
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testSeparateConnections() {
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -673,20 +656,19 @@ void testSeparateConnections() {
   // Make a call, and check for the proper events
   int32_t value = 5;
   client1->setValue(value);
-  uint32_t call1 = checkCallEvents(log, client1Id, EventLog::ET_CALL_SET_VALUE,
-                                     "ChildService.setValue");
+  uint32_t call1
+      = checkCallEvents(log, client1Id, EventLog::ET_CALL_SET_VALUE, "ChildService.setValue");
 
   // Make a call with client2
   int32_t v = client2->getValue();
   BOOST_CHECK_EQUAL(value, v);
-  checkCallEvents(log, client2Id, EventLog::ET_CALL_GET_VALUE,
-                  "ChildService.getValue");
+  checkCallEvents(log, client2Id, EventLog::ET_CALL_GET_VALUE, "ChildService.getValue");
 
   // Make another call with client1
   v = client1->getValue();
   BOOST_CHECK_EQUAL(value, v);
-  uint32_t call2 = checkCallEvents(log, client1Id, EventLog::ET_CALL_GET_VALUE,
-                                     "ChildService.getValue");
+  uint32_t call2
+      = checkCallEvents(log, client1Id, EventLog::ET_CALL_GET_VALUE, "ChildService.getValue");
   BOOST_CHECK_NE(call1, call2);
 
   // Close the second client, and check for the appropriate events
@@ -694,10 +676,9 @@ void testSeparateConnections() {
   checkCloseEvents(log, client2Id);
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testOnewayCall() {
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -715,9 +696,7 @@ void testOnewayCall() {
   state->getHandler()->prepareTriggeredCall();
   client->onewayWait();
   string callName = "ParentService.onewayWait";
-  uint32_t callId = checkCallHandlerEvents(log, connId,
-                                           EventLog::ET_CALL_ONEWAY_WAIT,
-                                           callName);
+  uint32_t callId = checkCallHandlerEvents(log, connId, EventLog::ET_CALL_ONEWAY_WAIT, callName);
 
   // There shouldn't be any more events
   checkNoEvents(log);
@@ -749,10 +728,9 @@ void testOnewayCall() {
   checkNoEvents(log);
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testExpectedError() {
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -769,9 +747,7 @@ void testExpectedError() {
   string message = "test 1234 test";
   client->send_exceptionWait(message);
   string callName = "ParentService.exceptionWait";
-  uint32_t callId = checkCallHandlerEvents(log, connId,
-                                           EventLog::ET_CALL_EXCEPTION_WAIT,
-                                           callName);
+  uint32_t callId = checkCallHandlerEvents(log, connId, EventLog::ET_CALL_EXCEPTION_WAIT, callName);
 
   // There shouldn't be any more events
   checkNoEvents(log);
@@ -804,10 +780,9 @@ void testExpectedError() {
   checkNoEvents(log);
 }
 
-template<typename ServerTraits, typename TemplateTraits>
+template <typename ServerTraits, typename TemplateTraits>
 void testUnexpectedError() {
-  typedef ServiceState< ServerTraits, ChildServiceTraits<TemplateTraits> >
-    State;
+  typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
 
   // Start the server
   boost::shared_ptr<State> state(new State);
@@ -824,8 +799,8 @@ void testUnexpectedError() {
   string message = "1234 test 5678";
   client->send_unexpectedExceptionWait(message);
   string callName = "ParentService.unexpectedExceptionWait";
-  uint32_t callId = checkCallHandlerEvents(
-      log, connId, EventLog::ET_CALL_UNEXPECTED_EXCEPTION_WAIT, callName);
+  uint32_t callId
+      = checkCallHandlerEvents(log, connId, EventLog::ET_CALL_UNEXPECTED_EXCEPTION_WAIT, callName);
 
   // There shouldn't be any more events
   checkNoEvents(log);
@@ -871,47 +846,46 @@ void testUnexpectedError() {
   checkNoEvents(log);
 }
 
-
 // Macro to define simple tests that can be used with all server types
-#define DEFINE_SIMPLE_TESTS(Server, Template) \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_basicService) { \
-    testBasicService<Server##Traits, Template##Traits>(); \
-  } \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_inheritedService) { \
-    testInheritedService<Server##Traits, Template##Traits>(); \
-  } \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_oneway) { \
-    testOnewayCall<Server##Traits, Template##Traits>(); \
-  } \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_exception) { \
-    testExpectedError<Server##Traits, Template##Traits>(); \
-  } \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_unexpectedException) { \
-    testUnexpectedError<Server##Traits, Template##Traits>(); \
+#define DEFINE_SIMPLE_TESTS(Server, Template)                                                      \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_basicService) {                                       \
+    testBasicService<Server##Traits, Template##Traits>();                                          \
+  }                                                                                                \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_inheritedService) {                                   \
+    testInheritedService<Server##Traits, Template##Traits>();                                      \
+  }                                                                                                \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_oneway) {                                             \
+    testOnewayCall<Server##Traits, Template##Traits>();                                            \
+  }                                                                                                \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_exception) {                                          \
+    testExpectedError<Server##Traits, Template##Traits>();                                         \
+  }                                                                                                \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_unexpectedException) {                                \
+    testUnexpectedError<Server##Traits, Template##Traits>();                                       \
   }
 
 // Tests that require the server to process multiple connections concurrently
 // (i.e., not TSimpleServer)
-#define DEFINE_CONCURRENT_SERVER_TESTS(Server, Template) \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_separateConnections) { \
-    testSeparateConnections<Server##Traits, Template##Traits>(); \
+#define DEFINE_CONCURRENT_SERVER_TESTS(Server, Template)                                           \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_separateConnections) {                                \
+    testSeparateConnections<Server##Traits, Template##Traits>();                                   \
   }
 
 // The testEventSequencing() test manually generates a request for the server,
 // and doesn't work with TFramedTransport.  Therefore we can't test it with
 // TNonblockingServer.
-#define DEFINE_NOFRAME_TESTS(Server, Template) \
-  BOOST_AUTO_TEST_CASE(Server##_##Template##_eventSequencing) { \
-    testEventSequencing<Server##Traits, Template##Traits>(); \
+#define DEFINE_NOFRAME_TESTS(Server, Template)                                                     \
+  BOOST_AUTO_TEST_CASE(Server##_##Template##_eventSequencing) {                                    \
+    testEventSequencing<Server##Traits, Template##Traits>();                                       \
   }
 
-#define DEFINE_TNONBLOCKINGSERVER_TESTS(Server, Template) \
-  DEFINE_SIMPLE_TESTS(Server, Template) \
+#define DEFINE_TNONBLOCKINGSERVER_TESTS(Server, Template)                                          \
+  DEFINE_SIMPLE_TESTS(Server, Template)                                                            \
   DEFINE_CONCURRENT_SERVER_TESTS(Server, Template)
 
-#define DEFINE_ALL_SERVER_TESTS(Server, Template) \
-  DEFINE_SIMPLE_TESTS(Server, Template) \
-  DEFINE_CONCURRENT_SERVER_TESTS(Server, Template) \
+#define DEFINE_ALL_SERVER_TESTS(Server, Template)                                                  \
+  DEFINE_SIMPLE_TESTS(Server, Template)                                                            \
+  DEFINE_CONCURRENT_SERVER_TESTS(Server, Template)                                                 \
   DEFINE_NOFRAME_TESTS(Server, Template)
 
 DEFINE_ALL_SERVER_TESTS(TThreadedServer, Templated)

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/ServerThread.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/ServerThread.cpp b/lib/cpp/test/processor/ServerThread.cpp
index 9f2087c..aa6fd7f 100644
--- a/lib/cpp/test/processor/ServerThread.cpp
+++ b/lib/cpp/test/processor/ServerThread.cpp
@@ -27,7 +27,9 @@
 #include <thrift/transport/TBufferTransports.h>
 #include <thrift/transport/TServerSocket.h>
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 void ServerThread::start() {
   assert(!running_);
@@ -48,9 +50,8 @@ void ServerThread::start() {
   }
 
   if (error_) {
-    throw transport::TTransportException(
-        transport::TTransportException::NOT_OPEN,
-        "failed to bind on server socket");
+    throw transport::TTransportException(transport::TTransportException::NOT_OPEN,
+                                         "failed to bind on server socket");
   }
 }
 
@@ -127,8 +128,8 @@ void ServerThread::preServe() {
   serverState_->bindSuccessful(port_);
 
   // Set the real server event handler (replacing ourself)
-  boost::shared_ptr<server::TServerEventHandler> serverEventHandler =
-    serverState_->getServerEventHandler();
+  boost::shared_ptr<server::TServerEventHandler> serverEventHandler
+      = serverState_->getServerEventHandler();
   server_->setServerEventHandler(serverEventHandler);
 
   // Notify the main thread that we have successfully started serving requests
@@ -142,7 +143,8 @@ void ServerThread::preServe() {
     serverEventHandler->preServe();
   }
 }
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_TEST_SERVERTHREAD_TCC_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/ServerThread.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/ServerThread.h b/lib/cpp/test/processor/ServerThread.h
index f7fa0d5..eed3469 100644
--- a/lib/cpp/test/processor/ServerThread.h
+++ b/lib/cpp/test/processor/ServerThread.h
@@ -26,13 +26,15 @@
 
 #include "EventLog.h"
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 /**
  * A helper class to tell ServerThread how to create the server
  */
 class ServerState {
- public:
+public:
   virtual ~ServerState() {}
 
   /**
@@ -50,8 +52,7 @@ class ServerState {
    * start serving traffic.  It is invoked from the server thread, rather than
    * the main thread.
    */
-  virtual boost::shared_ptr<server::TServerEventHandler>
-      getServerEventHandler() {
+  virtual boost::shared_ptr<server::TServerEventHandler> getServerEventHandler() {
     return boost::shared_ptr<server::TServerEventHandler>();
   }
 
@@ -61,17 +62,16 @@ class ServerState {
    * Subclasses may override this method if they wish to record the final
    * port that was used for the server.
    */
-  virtual void bindSuccessful(uint16_t /*port*/) {
-  }
+  virtual void bindSuccessful(uint16_t /*port*/) {}
 };
 
 /**
  * ServerThread starts a thrift server running in a separate thread.
  */
 class ServerThread {
- public:
-  ServerThread(const boost::shared_ptr<ServerState>& state, bool autoStart) :
-      helper_(new Helper(this)),
+public:
+  ServerThread(const boost::shared_ptr<ServerState>& state, bool autoStart)
+    : helper_(new Helper(this)),
       port_(0),
       running_(false),
       serving_(false),
@@ -85,9 +85,7 @@ class ServerThread {
   void start();
   void stop();
 
-  uint16_t getPort() const {
-    return port_;
-  }
+  uint16_t getPort() const { return port_; }
 
   ~ServerThread() {
     if (running_) {
@@ -99,26 +97,20 @@ class ServerThread {
     }
   }
 
- protected:
+protected:
   // Annoying.  thrift forces us to use shared_ptr, so we have to use
   // a helper class that we can allocate on the heap and give to thrift.
   // It would be simpler if we could just make Runnable and TServerEventHandler
   // private base classes of ServerThread.
-  class Helper : public concurrency::Runnable,
-                 public server::TServerEventHandler {
-   public:
-    Helper(ServerThread* serverThread)
-      : serverThread_(serverThread) {}
-
-    void run() {
-      serverThread_->run();
-    }
+  class Helper : public concurrency::Runnable, public server::TServerEventHandler {
+  public:
+    Helper(ServerThread* serverThread) : serverThread_(serverThread) {}
 
-    void preServe() {
-      serverThread_->preServe();
-    }
+    void run() { serverThread_->run(); }
+
+    void preServe() { serverThread_->preServe(); }
 
-   private:
+  private:
     ServerThread* serverThread_;
   };
 
@@ -137,7 +129,8 @@ class ServerThread {
   boost::shared_ptr<server::TServer> server_;
   boost::shared_ptr<concurrency::Thread> thread_;
 };
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_TEST_SERVERTHREAD_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index 33e71a3..b072440 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -104,6 +104,9 @@ AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS)
 clean-local:
 	$(RM) -r gen-cpp
 
+style-local:
+	$(CPPSTYLE_CMD)
+
 EXTRA_DIST = \
 	src/TestClient.cpp \
 	src/TestServer.cpp \

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/src/StressTest.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index dfe8350..fa468a4 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -40,7 +40,7 @@
 #include <sstream>
 #include <map>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -54,23 +54,18 @@ using namespace apache::thrift::concurrency;
 using namespace test::stress;
 
 struct eqstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) == 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
 };
 
 struct ltstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) < 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
 };
 
-
 // typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
 typedef map<const char*, int, ltstr> count_map;
 
 class Server : public ServiceIf {
- public:
+public:
   Server() {}
 
   void count(const char* method) {
@@ -89,43 +84,46 @@ class Server : public ServiceIf {
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) {return arg;}
-  int32_t echoI32(const int32_t arg) {return arg;}
-  int64_t echoI64(const int64_t arg) {return arg;}
-  void echoString(string& out, const string &arg) {
+  int8_t echoByte(const int8_t arg) { return arg; }
+  int32_t echoI32(const int32_t arg) { return arg; }
+  int64_t echoI64(const int64_t arg) { return arg; }
+  void echoString(string& out, const string& arg) {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t> &out, const vector<int8_t> &arg) { out = arg; }
-  void echoSet(set<int8_t> &out, const set<int8_t> &arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t> &out, const map<int8_t, int8_t> &arg) { out = arg; }
+  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
+  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
+  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
 
 private:
   count_map counts_;
   Mutex lock_;
-
 };
 
-class ClientThread: public Runnable {
+class ClientThread : public Runnable {
 public:
-
-  ClientThread(boost::shared_ptr<TTransport>transport, boost::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) :
-    _transport(transport),
-    _client(client),
-    _monitor(monitor),
-    _workerCount(workerCount),
-    _loopCount(loopCount),
-    _loopType(loopType)
-  {}
+  ClientThread(boost::shared_ptr<TTransport> transport,
+               boost::shared_ptr<ServiceClient> client,
+               Monitor& monitor,
+               size_t& workerCount,
+               size_t loopCount,
+               TType loopType)
+    : _transport(transport),
+      _client(client),
+      _monitor(monitor),
+      _workerCount(workerCount),
+      _loopCount(loopCount),
+      _loopType(loopType) {}
 
   void run() {
 
     // Wait for all worker threads to start
 
-    {Synchronized s(_monitor);
-      while(_workerCount == 0) {
+    {
+      Synchronized s(_monitor);
+      while (_workerCount == 0) {
         _monitor.wait();
       }
     }
@@ -134,13 +132,25 @@ public:
 
     _transport->open();
 
-    switch(_loopType) {
-    case T_VOID: loopEchoVoid(); break;
-    case T_BYTE: loopEchoByte(); break;
-    case T_I32: loopEchoI32(); break;
-    case T_I64: loopEchoI64(); break;
-    case T_STRING: loopEchoString(); break;
-    default: cerr << "Unexpected loop type" << _loopType << endl; break;
+    switch (_loopType) {
+    case T_VOID:
+      loopEchoVoid();
+      break;
+    case T_BYTE:
+      loopEchoByte();
+      break;
+    case T_I32:
+      loopEchoI32();
+      break;
+    case T_I64:
+      loopEchoI64();
+      break;
+    case T_STRING:
+      loopEchoString();
+      break;
+    default:
+      cerr << "Unexpected loop type" << _loopType << endl;
+      break;
     }
 
     _endTime = Util::currentTime();
@@ -149,7 +159,8 @@ public:
 
     _done = true;
 
-    {Synchronized s(_monitor);
+    {
+      Synchronized s(_monitor);
 
       _workerCount--;
 
@@ -170,7 +181,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int8_t arg = 1;
       int8_t result;
-      result =_client->echoByte(arg);
+      result = _client->echoByte(arg);
       (void)result;
       assert(result == arg);
     }
@@ -180,7 +191,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int32_t arg = 1;
       int32_t result;
-      result =_client->echoI32(arg);
+      result = _client->echoI32(arg);
       (void)result;
       assert(result == arg);
     }
@@ -190,7 +201,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int64_t arg = 1;
       int64_t result;
-      result =_client->echoI64(arg);
+      result = _client->echoI64(arg);
       (void)result;
       assert(result == arg);
     }
@@ -217,28 +228,26 @@ public:
   Monitor _sleep;
 };
 
-class TStartObserver : public apache::thrift::server::TServerEventHandler
-{
+class TStartObserver : public apache::thrift::server::TServerEventHandler {
 public:
-   TStartObserver() : awake_(false) {}
-   virtual void preServe()
-   {
-      apache::thrift::concurrency::Synchronized s(m_);
-      awake_ = true;
-      m_.notifyAll();
-   }
-   void waitForService()
-   {
-      apache::thrift::concurrency::Synchronized s(m_);
-      while(!awake_)
-         m_.waitForever();
-   }
- private:
-   apache::thrift::concurrency::Monitor m_;
-   bool awake_;
+  TStartObserver() : awake_(false) {}
+  virtual void preServe() {
+    apache::thrift::concurrency::Synchronized s(m_);
+    awake_ = true;
+    m_.notifyAll();
+  }
+  void waitForService() {
+    apache::thrift::concurrency::Synchronized s(m_);
+    while (!awake_)
+      m_.waitForever();
+  }
+
+private:
+  apache::thrift::concurrency::Monitor m_;
+  bool awake_;
 };
 
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -249,7 +258,7 @@ int main(int argc, char **argv) {
   size_t workerCount = 4;
   size_t clientCount = 20;
   size_t loopCount = 50000;
-  TType loopType  = T_VOID;
+  TType loopType = T_VOID;
   string callName = "echoVoid";
   bool runServer = true;
   bool logRequests = false;
@@ -258,28 +267,34 @@ int main(int argc, char **argv) {
 
   ostringstream usage;
 
-  usage <<
-    argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>] [--clients=<client-count>] [--loop=<loop-count>]" << endl <<
-    "\tclients        Number of client threads to create - 0 implies no clients, i.e. server only.  Default is " << clientCount << endl <<
-    "\thelp           Prints this help text." << endl <<
-    "\tcall           Service method to call.  Default is " << callName << endl <<
-    "\tloop           The number of remote thrift calls each client makes.  Default is " << loopCount << endl <<
-    "\tport           The port the server and clients should bind to for thrift network connections.  Default is " << port << endl <<
-    "\tserver         Run the Thrift server in this process.  Default is " << runServer << endl <<
-    "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is " << serverType << endl <<
-    "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is " << protocolType << endl <<
-    "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests << endl <<
-    "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl <<
-    "\tworkers        Number of thread pools workers.  Only valid for thread-pool server type.  Default is " << workerCount << endl;
-
-
-  map<string, string>  args;
+  usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
+                      "[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
+                      "[--clients=<client-count>] [--loop=<loop-count>]" << endl
+        << "\tclients        Number of client threads to create - 0 implies no clients, i.e. "
+           "server only.  Default is " << clientCount << endl
+        << "\thelp           Prints this help text." << endl
+        << "\tcall           Service method to call.  Default is " << callName << endl
+        << "\tloop           The number of remote thrift calls each client makes.  Default is "
+        << loopCount << endl << "\tport           The port the server and clients should bind to "
+                                "for thrift network connections.  Default is " << port << endl
+        << "\tserver         Run the Thrift server in this process.  Default is " << runServer
+        << endl << "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is "
+        << serverType << endl
+        << "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is "
+        << protocolType << endl
+        << "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests
+        << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
+        << replayRequests << endl << "\tworkers        Number of thread pools workers.  Only valid "
+                                     "for thread-pool server type.  Default is " << workerCount
+        << endl;
+
+  map<string, string> args;
 
   for (int ix = 1; ix < argc; ix++) {
 
     string arg(argv[ix]);
 
-    if (arg.compare(0,2, "--") == 0) {
+    if (arg.compare(0, 2, "--") == 0) {
 
       size_t end = arg.find_first_of("=", 2);
 
@@ -291,7 +306,7 @@ int main(int argc, char **argv) {
         args[key] = "true";
       }
     } else {
-      throw invalid_argument("Unexcepted command line token: "+arg);
+      throw invalid_argument("Unexcepted command line token: " + arg);
     }
   }
 
@@ -341,7 +356,7 @@ int main(int argc, char **argv) {
 
       } else {
 
-        throw invalid_argument("Unknown server type "+serverType);
+        throw invalid_argument("Unknown server type " + serverType);
       }
     }
 
@@ -349,12 +364,13 @@ int main(int argc, char **argv) {
       workerCount = atoi(args["workers"].c_str());
     }
 
-  } catch(std::exception& e) {
+  } catch (std::exception& e) {
     cerr << e.what() << endl;
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  boost::shared_ptr<PlatformThreadFactory> threadFactory
+      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
   boost::shared_ptr<Server> serviceHandler(new Server());
@@ -372,15 +388,12 @@ int main(int argc, char **argv) {
     // Protocol Factory
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    TFileProcessor fileProcessor(serviceProcessor,
-                                 protocolFactory,
-                                 fileTransport);
+    TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
     fileProcessor.process(0, true);
     exit(0);
   }
 
-
   if (runServer) {
 
     boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
@@ -400,27 +413,34 @@ int main(int argc, char **argv) {
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
-      transportFactory =
-        boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+      transportFactory
+          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
     boost::shared_ptr<TServer> server;
 
     if (serverType == "simple") {
 
-      server.reset(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(
+          new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "threaded") {
 
-      server.reset(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(
+          new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
+      boost::shared_ptr<ThreadManager> threadManager
+          = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
-      server.reset(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager));
+      server.reset(new TThreadPoolServer(serviceProcessor,
+                                         serverSocket,
+                                         transportFactory,
+                                         protocolFactory,
+                                         threadManager));
     }
 
     boost::shared_ptr<TStartObserver> observer(new TStartObserver);
@@ -446,12 +466,19 @@ int main(int argc, char **argv) {
 
     set<boost::shared_ptr<Thread> > clientThreads;
 
-    if (callName == "echoVoid") { loopType = T_VOID;}
-    else if (callName == "echoByte") { loopType = T_BYTE;}
-    else if (callName == "echoI32") { loopType = T_I32;}
-    else if (callName == "echoI64") { loopType = T_I64;}
-    else if (callName == "echoString") { loopType = T_STRING;}
-    else {throw invalid_argument("Unknown service call "+callName);}
+    if (callName == "echoVoid") {
+      loopType = T_VOID;
+    } else if (callName == "echoByte") {
+      loopType = T_BYTE;
+    } else if (callName == "echoI32") {
+      loopType = T_I32;
+    } else if (callName == "echoI64") {
+      loopType = T_I64;
+    } else if (callName == "echoString") {
+      loopType = T_STRING;
+    } else {
+      throw invalid_argument("Unknown service call " + callName);
+    }
 
     for (size_t ix = 0; ix < clientCount; ix++) {
 
@@ -460,30 +487,34 @@ int main(int argc, char **argv) {
       boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
       boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
+      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
+          new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) {
+    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+         thread != clientThreads.end();
+         thread++) {
       (*thread)->start();
     }
 
     int64_t time00;
     int64_t time01;
 
-    {Synchronized s(monitor);
+    {
+      Synchronized s(monitor);
       threadCount = clientCount;
 
-      cerr << "Launch "<< clientCount << " client threads" << endl;
+      cerr << "Launch " << clientCount << " client threads" << endl;
 
-      time00 =  Util::currentTime();
+      time00 = Util::currentTime();
 
       monitor.notifyAll();
 
-      while(threadCount > 0) {
+      while (threadCount > 0) {
         monitor.wait();
       }
 
-      time01 =  Util::currentTime();
+      time01 = Util::currentTime();
     }
 
     int64_t firstTime = 9223372036854775807LL;
@@ -493,9 +524,12 @@ int main(int argc, char **argv) {
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) {
+    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+         ix != clientThreads.end();
+         ix++) {
 
-      boost::shared_ptr<ClientThread> client = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      boost::shared_ptr<ClientThread> client
+          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
@@ -517,13 +551,13 @@ int main(int argc, char **argv) {
         maxTime = delta;
       }
 
-      averageTime+= delta;
+      averageTime += delta;
     }
 
     averageTime /= clientCount;
 
-
-    cout <<  "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+    cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
+         << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
 
     count_map count = serviceHandler->getCount();
     count_map::iterator iter;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/src/StressTestNonBlocking.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index 20320c7..8f161c0 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -43,7 +43,7 @@
 #include <sstream>
 #include <map>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -57,23 +57,18 @@ using namespace apache::thrift::concurrency;
 using namespace test::stress;
 
 struct eqstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) == 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
 };
 
 struct ltstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) < 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
 };
 
-
 // typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
 typedef map<const char*, int, ltstr> count_map;
 
 class Server : public ServiceIf {
- public:
+public:
   Server() {}
 
   void count(const char* method) {
@@ -94,58 +89,73 @@ class Server : public ServiceIf {
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) {return arg;}
-  int32_t echoI32(const int32_t arg) {return arg;}
-  int64_t echoI64(const int64_t arg) {return arg;}
-  void echoString(string& out, const string &arg) {
+  int8_t echoByte(const int8_t arg) { return arg; }
+  int32_t echoI32(const int32_t arg) { return arg; }
+  int64_t echoI64(const int64_t arg) { return arg; }
+  void echoString(string& out, const string& arg) {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t> &out, const vector<int8_t> &arg) { out = arg; }
-  void echoSet(set<int8_t> &out, const set<int8_t> &arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t> &out, const map<int8_t, int8_t> &arg) { out = arg; }
+  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
+  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
+  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
 
 private:
   count_map counts_;
   Mutex lock_;
-
 };
 
-class ClientThread: public Runnable {
+class ClientThread : public Runnable {
 public:
-
-  ClientThread(boost::shared_ptr<TTransport>transport, boost::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) :
-    _transport(transport),
-    _client(client),
-    _monitor(monitor),
-    _workerCount(workerCount),
-    _loopCount(loopCount),
-    _loopType(loopType)
-  {}
+  ClientThread(boost::shared_ptr<TTransport> transport,
+               boost::shared_ptr<ServiceClient> client,
+               Monitor& monitor,
+               size_t& workerCount,
+               size_t loopCount,
+               TType loopType)
+    : _transport(transport),
+      _client(client),
+      _monitor(monitor),
+      _workerCount(workerCount),
+      _loopCount(loopCount),
+      _loopType(loopType) {}
 
   void run() {
 
     // Wait for all worker threads to start
 
-    {Synchronized s(_monitor);
-        while(_workerCount == 0) {
-          _monitor.wait();
-        }
+    {
+      Synchronized s(_monitor);
+      while (_workerCount == 0) {
+        _monitor.wait();
+      }
     }
 
     _startTime = Util::currentTime();
 
     _transport->open();
 
-    switch(_loopType) {
-    case T_VOID: loopEchoVoid(); break;
-    case T_BYTE: loopEchoByte(); break;
-    case T_I32: loopEchoI32(); break;
-    case T_I64: loopEchoI64(); break;
-    case T_STRING: loopEchoString(); break;
-    default: cerr << "Unexpected loop type" << _loopType << endl; break;
+    switch (_loopType) {
+    case T_VOID:
+      loopEchoVoid();
+      break;
+    case T_BYTE:
+      loopEchoByte();
+      break;
+    case T_I32:
+      loopEchoI32();
+      break;
+    case T_I64:
+      loopEchoI64();
+      break;
+    case T_STRING:
+      loopEchoString();
+      break;
+    default:
+      cerr << "Unexpected loop type" << _loopType << endl;
+      break;
     }
 
     _endTime = Util::currentTime();
@@ -154,7 +164,8 @@ public:
 
     _done = true;
 
-    {Synchronized s(_monitor);
+    {
+      Synchronized s(_monitor);
 
       _workerCount--;
 
@@ -175,7 +186,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int8_t arg = 1;
       int8_t result;
-      result =_client->echoByte(arg);
+      result = _client->echoByte(arg);
       (void)result;
       assert(result == arg);
     }
@@ -185,7 +196,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int32_t arg = 1;
       int32_t result;
-      result =_client->echoI32(arg);
+      result = _client->echoI32(arg);
       (void)result;
       assert(result == arg);
     }
@@ -195,7 +206,7 @@ public:
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int64_t arg = 1;
       int64_t result;
-      result =_client->echoI64(arg);
+      result = _client->echoI64(arg);
       (void)result;
       assert(result == arg);
     }
@@ -222,8 +233,7 @@ public:
   Monitor _sleep;
 };
 
-
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -234,7 +244,7 @@ int main(int argc, char **argv) {
   uint32_t workerCount = 4;
   uint32_t clientCount = 20;
   uint32_t loopCount = 1000;
-  TType loopType  = T_VOID;
+  TType loopType = T_VOID;
   string callName = "echoVoid";
   bool runServer = true;
   bool logRequests = false;
@@ -243,28 +253,34 @@ int main(int argc, char **argv) {
 
   ostringstream usage;
 
-  usage <<
-    argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>] [--clients=<client-count>] [--loop=<loop-count>]" << endl <<
-    "\tclients        Number of client threads to create - 0 implies no clients, i.e. server only.  Default is " << clientCount << endl <<
-    "\thelp           Prints this help text." << endl <<
-    "\tcall           Service method to call.  Default is " << callName << endl <<
-    "\tloop           The number of remote thrift calls each client makes.  Default is " << loopCount << endl <<
-    "\tport           The port the server and clients should bind to for thrift network connections.  Default is " << port << endl <<
-    "\tserver         Run the Thrift server in this process.  Default is " << runServer << endl <<
-    "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is " << serverType << endl <<
-    "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is " << protocolType << endl <<
-    "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests << endl <<
-    "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl <<
-    "\tworkers        Number of thread pools workers.  Only valid for thread-pool server type.  Default is " << workerCount << endl;
-
-
-  map<string, string>  args;
+  usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
+                      "[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
+                      "[--clients=<client-count>] [--loop=<loop-count>]" << endl
+        << "\tclients        Number of client threads to create - 0 implies no clients, i.e. "
+           "server only.  Default is " << clientCount << endl
+        << "\thelp           Prints this help text." << endl
+        << "\tcall           Service method to call.  Default is " << callName << endl
+        << "\tloop           The number of remote thrift calls each client makes.  Default is "
+        << loopCount << endl << "\tport           The port the server and clients should bind to "
+                                "for thrift network connections.  Default is " << port << endl
+        << "\tserver         Run the Thrift server in this process.  Default is " << runServer
+        << endl << "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is "
+        << serverType << endl
+        << "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is "
+        << protocolType << endl
+        << "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests
+        << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
+        << replayRequests << endl << "\tworkers        Number of thread pools workers.  Only valid "
+                                     "for thread-pool server type.  Default is " << workerCount
+        << endl;
+
+  map<string, string> args;
 
   for (int ix = 1; ix < argc; ix++) {
 
     string arg(argv[ix]);
 
-    if (arg.compare(0,2, "--") == 0) {
+    if (arg.compare(0, 2, "--") == 0) {
 
       size_t end = arg.find_first_of("=", 2);
 
@@ -276,7 +292,7 @@ int main(int argc, char **argv) {
         args[key] = "true";
       }
     } else {
-      throw invalid_argument("Unexcepted command line token: "+arg);
+      throw invalid_argument("Unexcepted command line token: " + arg);
     }
   }
 
@@ -323,12 +339,13 @@ int main(int argc, char **argv) {
       workerCount = atoi(args["workers"].c_str());
     }
 
-  } catch(std::exception& e) {
+  } catch (std::exception& e) {
     cerr << e.what() << endl;
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  boost::shared_ptr<PlatformThreadFactory> threadFactory
+      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
   boost::shared_ptr<Server> serviceHandler(new Server());
@@ -346,15 +363,12 @@ int main(int argc, char **argv) {
     // Protocol Factory
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    TFileProcessor fileProcessor(serviceProcessor,
-                                 protocolFactory,
-                                 fileTransport);
+    TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
     fileProcessor.process(0, true);
     exit(0);
   }
 
-
   if (runServer) {
 
     boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
@@ -363,7 +377,7 @@ int main(int argc, char **argv) {
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     // Transport Factory
-    boost::shared_ptr<TTransportFactory>      transportFactory;
+    boost::shared_ptr<TTransportFactory> transportFactory;
 
     if (logRequests) {
       // initialize the log file
@@ -371,8 +385,8 @@ int main(int argc, char **argv) {
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
-      transportFactory =
-        boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+      transportFactory
+          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
     boost::shared_ptr<Thread> serverThread;
@@ -380,17 +394,22 @@ int main(int argc, char **argv) {
 
     if (serverType == "simple") {
 
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port)));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port+1)));
+      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
+          new TNonblockingServer(serviceProcessor, protocolFactory, port)));
+      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
+          new TNonblockingServer(serviceProcessor, protocolFactory, port + 1)));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
+      boost::shared_ptr<ThreadManager> threadManager
+          = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
-      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
-      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(new TNonblockingServer(serviceProcessor, protocolFactory, port+1, threadManager)));
+      serverThread = threadFactory->newThread(boost::shared_ptr<TServer>(
+          new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager)));
+      serverThread2 = threadFactory->newThread(boost::shared_ptr<TServer>(
+          new TNonblockingServer(serviceProcessor, protocolFactory, port + 1, threadManager)));
     }
 
     cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
@@ -414,12 +433,19 @@ int main(int argc, char **argv) {
 
     set<boost::shared_ptr<Thread> > clientThreads;
 
-    if (callName == "echoVoid") { loopType = T_VOID;}
-    else if (callName == "echoByte") { loopType = T_BYTE;}
-    else if (callName == "echoI32") { loopType = T_I32;}
-    else if (callName == "echoI64") { loopType = T_I64;}
-    else if (callName == "echoString") { loopType = T_STRING;}
-    else {throw invalid_argument("Unknown service call "+callName);}
+    if (callName == "echoVoid") {
+      loopType = T_VOID;
+    } else if (callName == "echoByte") {
+      loopType = T_BYTE;
+    } else if (callName == "echoI32") {
+      loopType = T_I32;
+    } else if (callName == "echoI64") {
+      loopType = T_I64;
+    } else if (callName == "echoString") {
+      loopType = T_STRING;
+    } else {
+      throw invalid_argument("Unknown service call " + callName);
+    }
 
     for (uint32_t ix = 0; ix < clientCount; ix++) {
 
@@ -428,30 +454,34 @@ int main(int argc, char **argv) {
       boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
       boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
+      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
+          new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) {
+    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+         thread != clientThreads.end();
+         thread++) {
       (*thread)->start();
     }
 
     int64_t time00;
     int64_t time01;
 
-    {Synchronized s(monitor);
+    {
+      Synchronized s(monitor);
       threadCount = clientCount;
 
-      cerr << "Launch "<< clientCount << " client threads" << endl;
+      cerr << "Launch " << clientCount << " client threads" << endl;
 
-      time00 =  Util::currentTime();
+      time00 = Util::currentTime();
 
       monitor.notifyAll();
 
-      while(threadCount > 0) {
+      while (threadCount > 0) {
         monitor.wait();
       }
 
-      time01 =  Util::currentTime();
+      time01 = Util::currentTime();
     }
 
     int64_t firstTime = 9223372036854775807LL;
@@ -461,9 +491,12 @@ int main(int argc, char **argv) {
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) {
+    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+         ix != clientThreads.end();
+         ix++) {
 
-      boost::shared_ptr<ClientThread> client = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      boost::shared_ptr<ClientThread> client
+          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
@@ -485,13 +518,13 @@ int main(int argc, char **argv) {
         maxTime = delta;
       }
 
-      averageTime+= delta;
+      averageTime += delta;
     }
 
     averageTime /= clientCount;
 
-
-    cout <<  "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+    cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
+         << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
 
     count_map count = serviceHandler->getCount();
     count_map::iterator iter;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/test/cpp/src/TestClient.cpp
----------------------------------------------------------------------
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
old mode 100755
new mode 100644
index 8c97dc0..a6069de
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -36,7 +36,7 @@
 #include <boost/filesystem.hpp>
 #include <thrift/cxxfunctional.h>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 #include "ThriftTest.h"
@@ -51,24 +51,27 @@ using namespace apache::thrift::async;
 // Length of argv[0] - Length of script dir
 #define EXECUTABLE_FILE_NAME_LENGTH 19
 
-//extern uint32_t g_socket_syscalls;
+// extern uint32_t g_socket_syscalls;
 
 // Current time, microseconds since the epoch
-uint64_t now()
-{
+uint64_t now() {
   int64_t ret;
   struct timeval tv;
 
   THRIFT_GETTIMEOFDAY(&tv, NULL);
   ret = tv.tv_sec;
-  ret = ret*1000*1000 + tv.tv_usec;
+  ret = ret * 1000 * 1000 + tv.tv_usec;
   return ret;
 }
 
-static void testString_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) {
-  (void) host;
-  (void) port;
-  (void) protocolFactory;
+static void testString_clientReturn(const char* host,
+                                    int port,
+                                    event_base* base,
+                                    TProtocolFactory* protocolFactory,
+                                    ThriftTestCobClient* client) {
+  (void)host;
+  (void)port;
+  (void)protocolFactory;
   try {
     string s;
     client->recv_testString(s);
@@ -80,7 +83,11 @@ static void testString_clientReturn(const char* host, int port, event_base *base
   event_base_loopbreak(base); // end test
 }
 
-static void testVoid_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) {
+static void testVoid_clientReturn(const char* host,
+                                  int port,
+                                  event_base* base,
+                                  TProtocolFactory* protocolFactory,
+                                  ThriftTestCobClient* client) {
   try {
     client->recv_testVoid();
     cout << "testVoid" << endl;
@@ -89,7 +96,13 @@ static void testVoid_clientReturn(const char* host, int port, event_base *base,
     delete client;
     boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host, "/", host, port, base));
     client = new ThriftTestCobClient(channel, protocolFactory);
-    client->testString(tcxx::bind(testString_clientReturn, host, port, base, protocolFactory, tcxx::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;
   }
@@ -97,7 +110,7 @@ static void testVoid_clientReturn(const char* host, int port, event_base *base,
 
 int main(int argc, char** argv) {
   string file_path = boost::filesystem::system_complete(argv[0]).string();
-  string dir_path = file_path.substr(0, file_path.size()-EXECUTABLE_FILE_NAME_LENGTH);
+  string dir_path = file_path.substr(0, file_path.size() - EXECUTABLE_FILE_NAME_LENGTH);
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -111,17 +124,26 @@ int main(int argc, char** argv) {
   bool noinsane = false;
 
   boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("host", boost::program_options::value<string>(&host)->default_value(host), "Host to connect")
-      ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to connect")
-	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket), "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")
-      ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type), "Transport: buffered, framed, http, evhttp")
-      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type), "Protocol: binary, compact, json")
-	  ("ssl", "Encrypted Transport using SSL")
-      ("testloops,n", boost::program_options::value<int>(&numTests)->default_value(numTests), "Number of Tests")
-      ("noinsane", "Do not run insanity test")
-  ;
+  desc.add_options()("help,h",
+                     "produce help message")("host",
+                                             boost::program_options::value<string>(&host)
+                                                 ->default_value(host),
+                                             "Host to connect")("port",
+                                                                boost::program_options::value<int>(
+                                                                    &port)->default_value(port),
+                                                                "Port number to connect")(
+      "domain-socket",
+      boost::program_options::value<string>(&domain_socket)->default_value(domain_socket),
+      "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")(
+      "transport",
+      boost::program_options::value<string>(&transport_type)->default_value(transport_type),
+      "Transport: buffered, framed, http, evhttp")(
+      "protocol",
+      boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
+      "Protocol: binary, compact, json")("ssl", "Encrypted Transport using SSL")(
+      "testloops,n",
+      boost::program_options::value<int>(&numTests)->default_value(numTests),
+      "Number of Tests")("noinsane", "Do not run insanity test");
 
   boost::program_options::variables_map vm;
   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
@@ -138,17 +160,17 @@ int main(int argc, char** argv) {
       } else if (protocol_type == "compact") {
       } else if (protocol_type == "json") {
       } else {
-          throw invalid_argument("Unknown protocol type "+protocol_type);
+        throw invalid_argument("Unknown protocol type " + protocol_type);
       }
     }
 
-	if (!transport_type.empty()) {
+    if (!transport_type.empty()) {
       if (transport_type == "buffered") {
       } else if (transport_type == "framed") {
       } else if (transport_type == "http") {
       } else if (transport_type == "evhttp") {
       } else {
-          throw invalid_argument("Unknown transport type "+transport_type);
+        throw invalid_argument("Unknown transport type " + transport_type);
       }
     }
 
@@ -182,8 +204,7 @@ int main(int argc, char** argv) {
     if (domain_socket != "") {
       socket = boost::shared_ptr<TSocket>(new TSocket(domain_socket));
       port = 0;
-    }
-    else {
+    } else {
       socket = boost::shared_ptr<TSocket>(new TSocket(host, port));
     }
   }
@@ -191,10 +212,10 @@ int main(int argc, char** argv) {
   if (transport_type.compare("http") == 0) {
     boost::shared_ptr<TTransport> httpSocket(new THttpClient(socket, host, "/service"));
     transport = httpSocket;
-  } else if (transport_type.compare("framed") == 0){
+  } else if (transport_type.compare("framed") == 0) {
     boost::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
     transport = framedSocket;
-  } else{
+  } else {
     boost::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket));
     transport = bufferedSocket;
   }
@@ -205,7 +226,7 @@ int main(int argc, char** argv) {
   } else if (protocol_type.compare("compact") == 0) {
     boost::shared_ptr<TProtocol> compactProtocol(new TCompactProtocol(transport));
     protocol = compactProtocol;
-  } else{
+  } else {
     boost::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport));
     protocol = binaryProtocol;
   }
@@ -218,7 +239,7 @@ int main(int argc, char** argv) {
   cout << endl;
 
   if (transport_type.compare("evhttp") == 0) {
-    event_base *base = event_base_new();
+    event_base* base = event_base_new();
     cout << "Libevent Version: " << event_get_version() << endl;
     cout << "Libevent Method: " << event_base_get_method(base) << endl;
 #if LIBEVENT_VERSION_NUMBER >= 0x02000000
@@ -227,15 +248,20 @@ int main(int argc, char** argv) {
 
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    boost::shared_ptr<TAsyncChannel> channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base));
+    boost::shared_ptr<TAsyncChannel> channel(
+        new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base));
     ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get());
-    client->testVoid(tcxx::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), tcxx::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;
   }
 
-
   ThriftTestClient testClient(protocol);
 
   uint64_t time_min = 0;
@@ -256,7 +282,7 @@ int main(int argc, char** argv) {
     /**
      * CONNECT TEST
      */
-    printf("Test #%d, connect %s:%d\n", test+1, host.c_str(), port);
+    printf("Test #%d, connect %s:%d\n", test + 1, host.c_str(), port);
 
     uint64_t start = now();
 
@@ -280,7 +306,7 @@ int main(int argc, char** argv) {
     testClient.testString(s, "Test");
     printf(" = \"%s\"\n", s.c_str());
     if (s != "Test")
-        failCount++;
+      failCount++;
 
     /**
      * BYTE TEST
@@ -289,7 +315,7 @@ int main(int argc, char** argv) {
     uint8_t u8 = testClient.testByte(1);
     printf(" = %d\n", (int)u8);
     if (u8 != 1)
-        failCount++;
+      failCount++;
 
     /**
      * I32 TEST
@@ -298,7 +324,7 @@ int main(int argc, char** argv) {
     int32_t i32 = testClient.testI32(-1);
     printf(" = %d\n", i32);
     if (i32 != -1)
-        failCount++;
+      failCount++;
 
     /**
      * I64 TEST
@@ -307,7 +333,7 @@ int main(int argc, char** argv) {
     int64_t i64 = testClient.testI64(-34359738368LL);
     printf(" = %" PRId64 "\n", i64);
     if (i64 != -34359738368LL)
-        failCount++;
+      failCount++;
     /**
      * DOUBLE TEST
      */
@@ -315,7 +341,7 @@ int main(int argc, char** argv) {
     double dub = testClient.testDouble(-5.2098523);
     printf(" = %f\n", dub);
     if ((dub - (-5.2098523)) > 0.001)
-        failCount++;
+      failCount++;
 
     /**
      * STRUCT TEST
@@ -334,7 +360,7 @@ int main(int argc, char** argv) {
            in.i32_thing,
            in.i64_thing);
     if (in != out)
-    	failCount++;
+      failCount++;
 
     /**
      * NESTED STRUCT TEST
@@ -355,14 +381,14 @@ int main(int argc, char** argv) {
            in.i64_thing,
            in2.i32_thing);
     if (in2 != out2)
-    	failCount++;
+      failCount++;
 
     /**
      * MAP TEST
      */
-    map<int32_t,int32_t> mapout;
+    map<int32_t, int32_t> mapout;
     for (int32_t i = 0; i < 5; ++i) {
-      mapout.insert(make_pair(i, i-10));
+      mapout.insert(make_pair(i, i - 10));
     }
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
@@ -376,7 +402,7 @@ int main(int argc, char** argv) {
       printf("%d => %d", m_iter->first, m_iter->second);
     }
     printf("})");
-    map<int32_t,int32_t> mapin;
+    map<int32_t, int32_t> mapin;
     testClient.testMap(mapin, mapout);
     printf(" = {");
     first = true;
@@ -390,7 +416,7 @@ int main(int argc, char** argv) {
     }
     printf("}\n");
     if (mapin != mapout)
-    	failCount++;
+      failCount++;
 
     /**
      * STRING MAP TEST
@@ -430,7 +456,7 @@ int main(int argc, char** argv) {
     }
     printf("}\n");
     if (setin != setout)
-    	failCount++;
+      failCount++;
 
     /**
      * LIST TEST
@@ -465,7 +491,7 @@ int main(int argc, char** argv) {
     }
     printf("}\n");
     if (listin != listout)
-    	failCount++;
+      failCount++;
 
     /**
      * ENUM TEST
@@ -474,31 +500,31 @@ int main(int argc, char** argv) {
     Numberz::type ret = testClient.testEnum(Numberz::ONE);
     printf(" = %d\n", ret);
     if (ret != Numberz::ONE)
-    	failCount++;
+      failCount++;
 
     printf("testEnum(TWO)");
     ret = testClient.testEnum(Numberz::TWO);
     printf(" = %d\n", ret);
     if (ret != Numberz::TWO)
-    	failCount++;
+      failCount++;
 
     printf("testEnum(THREE)");
     ret = testClient.testEnum(Numberz::THREE);
     printf(" = %d\n", ret);
     if (ret != Numberz::THREE)
-    	failCount++;
+      failCount++;
 
     printf("testEnum(FIVE)");
     ret = testClient.testEnum(Numberz::FIVE);
     printf(" = %d\n", ret);
     if (ret != Numberz::FIVE)
-    	failCount++;
+      failCount++;
 
     printf("testEnum(EIGHT)");
     ret = testClient.testEnum(Numberz::EIGHT);
     printf(" = %d\n", ret);
     if (ret != Numberz::EIGHT)
-    	failCount++;
+      failCount++;
 
     /**
      * TYPEDEF TEST
@@ -507,7 +533,7 @@ int main(int argc, char** argv) {
     UserId uid = testClient.testTypedef(309858235082523LL);
     printf(" = %" PRId64 "\n", uid);
     if (uid != 309858235082523LL)
-    	failCount++;
+      failCount++;
 
     /**
      * NESTED MAP TEST
@@ -540,16 +566,14 @@ int main(int argc, char** argv) {
       truck.i64_thing = 8;
       insane.xtructs.push_back(truck);
       printf("testInsanity()");
-      map<UserId, map<Numberz::type,Insanity> > whoa;
+      map<UserId, map<Numberz::type, Insanity> > whoa;
       testClient.testInsanity(whoa, insane);
       printf(" = {");
-      map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
+      map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
       for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
         printf("%" PRId64 " => {", i_iter->first);
-        map<Numberz::type,Insanity>::const_iterator i2_iter;
-        for (i2_iter = i_iter->second.begin();
-             i2_iter != i_iter->second.end();
-             ++i2_iter) {
+        map<Numberz::type, Insanity>::const_iterator i2_iter;
+        for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
           printf("%d => {", i2_iter->first);
           map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
           map<Numberz::type, UserId>::const_iterator um;
@@ -585,25 +609,25 @@ int main(int argc, char** argv) {
       printf("  void\nFAILURE\n");
       failCount++;
 
-    } catch(Xception& e) {
+    } catch (Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
     }
 
     try {
-        printf("testClient.testException(\"TException\") =>");
-        testClient.testException("TException");
-        printf("  void\nFAILURE\n");
-        failCount++;
+      printf("testClient.testException(\"TException\") =>");
+      testClient.testException("TException");
+      printf("  void\nFAILURE\n");
+      failCount++;
 
-      } catch(const TException&) {
-        printf("  Caught TException\n");
-      }
+    } catch (const TException&) {
+      printf("  Caught TException\n");
+    }
 
     try {
       printf("testClient.testException(\"success\") =>");
       testClient.testException("success");
       printf("  void\n");
-    } catch(...) {
+    } catch (...) {
       printf("  exception\nFAILURE\n");
       failCount++;
     }
@@ -616,7 +640,7 @@ int main(int argc, char** argv) {
       testClient.testMultiException(result, "Xception", "test 1");
       printf("  result\nFAILURE\n");
       failCount++;
-    } catch(Xception& e) {
+    } catch (Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
     }
 
@@ -627,7 +651,7 @@ int main(int argc, char** argv) {
       printf("  result\nFAILURE\n");
       failCount++;
 
-    } catch(Xception2& e) {
+    } catch (Xception2& e) {
       printf("  {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
     }
 
@@ -636,23 +660,23 @@ int main(int argc, char** argv) {
       Xtruct result;
       testClient.testMultiException(result, "success", "test 3");
       printf("  {{\"%s\"}}\n", result.string_thing.c_str());
-    } catch(...) {
+    } catch (...) {
       printf("  exception\nFAILURE\n");
       failCount++;
     }
 
     /* test oneway void */
     {
-        printf("testClient.testOneway(1) =>");
-        uint64_t startOneway = now();
-        testClient.testOneway(1);
-        uint64_t elapsed = now() - startOneway;
-        if (elapsed > 200 * 1000) { // 0.2 seconds
-            printf("  FAILURE - took %.2f ms\n", (double)elapsed/1000.0);
-            failCount++;
-        } else {
-            printf("  success - took %.2f ms\n", (double)elapsed/1000.0);
-        }
+      printf("testClient.testOneway(1) =>");
+      uint64_t startOneway = now();
+      testClient.testOneway(1);
+      uint64_t elapsed = now() - startOneway;
+      if (elapsed > 200 * 1000) { // 0.2 seconds
+        printf("  FAILURE - took %.2f ms\n", (double)elapsed / 1000.0);
+        failCount++;
+      } else {
+        printf("  success - took %.2f ms\n", (double)elapsed / 1000.0);
+      }
     }
 
     /**
@@ -670,13 +694,12 @@ int main(int argc, char** argv) {
     i32 = testClient.testI32(-1);
     printf(" = %d\n", i32);
     if (i32 != -1)
-        failCount++;
-
+      failCount++;
 
     uint64_t stop = now();
-    uint64_t tot = stop-start;
+    uint64_t tot = stop - start;
 
-    printf("Total time: %" PRIu64 " us\n", stop-start);
+    printf("Total time: %" PRIu64 " us\n", stop - start);
 
     time_tot += tot;
     if (time_min == 0 || tot < time_min) {


[21/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_js_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_js_generator.cc b/compiler/cpp/src/generate/t_js_generator.cc
index d753bbb..0fdde4d 100644
--- a/compiler/cpp/src/generate/t_js_generator.cc
+++ b/compiler/cpp/src/generate/t_js_generator.cc
@@ -37,7 +37,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 #include "t_oop_generator.h"
 
@@ -45,40 +45,40 @@ static const string endl = "\n";  // avoid ostream << std::endl flushes
  * JS code generator.
  */
 class t_js_generator : public t_oop_generator {
- public:
+public:
   t_js_generator(t_program* program,
-                const std::map<std::string, std::string>& parsed_options,
-                const std::string& option_string) :
-     t_oop_generator(program) {
-     (void) option_string;
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
 
-     std::map<std::string, std::string>::const_iterator iter;
+    std::map<std::string, std::string>::const_iterator iter;
 
-     iter = parsed_options.find("node");
-     gen_node_ = (iter != parsed_options.end());
+    iter = parsed_options.find("node");
+    gen_node_ = (iter != parsed_options.end());
 
-     iter = parsed_options.find("jquery");
-     gen_jquery_ = (iter != parsed_options.end());
+    iter = parsed_options.find("jquery");
+    gen_jquery_ = (iter != parsed_options.end());
 
-     if (!gen_node_) {
-       iter = parsed_options.find("ts");
-       gen_ts_ = (iter != parsed_options.end());
-     }
-     else {
-       gen_ts_ = false;
-     }
+    if (!gen_node_) {
+      iter = parsed_options.find("ts");
+      gen_ts_ = (iter != parsed_options.end());
+    } else {
+      gen_ts_ = false;
+    }
 
-     if (gen_node_ && gen_jquery_) {
-       throw "Invalid switch: [-gen js:node,jquery] options not compatible, try: [-gen js:node -gen js:jquery]";
-     }
+    if (gen_node_ && gen_jquery_) {
+      throw "Invalid switch: [-gen js:node,jquery] options not compatible, try: [-gen js:node -gen "
+            "js:jquery]";
+    }
 
-     if (gen_node_) {
-       out_dir_base_ = "gen-nodejs";
-     } else {
-       out_dir_base_ = "gen-js";
-     }
+    if (gen_node_) {
+      out_dir_base_ = "gen-nodejs";
+    } else {
+      out_dir_base_ = "gen-js";
+    }
 
-     escape_['\''] = "\\'";
+    escape_['\''] = "\\'";
   }
 
   /**
@@ -92,24 +92,26 @@ class t_js_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_recv_throw(std::string var);
   std::string render_recv_return(std::string var);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
-
   /**
    * Structs!
    */
   void generate_js_struct(t_struct* tstruct, bool is_exception);
-  void generate_js_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool is_exported=true);
+  void generate_js_struct_definition(std::ofstream& out,
+                                     t_struct* tstruct,
+                                     bool is_xception = false,
+                                     bool is_exported = true);
   void generate_js_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_js_struct_writer(std::ofstream& out, t_struct* tstruct);
   void generate_js_function_helpers(t_function* tfunction);
@@ -117,66 +119,48 @@ class t_js_generator : public t_oop_generator {
   /**
    * Service-level generation functions
    */
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_rest      (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_processor (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_rest(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_processor(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool inclass=false);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool inclass = false);
 
-  void generate_deserialize_struct       (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream &out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element    (std::ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
   /**
    * Helper rendering functions
@@ -184,38 +168,37 @@ class t_js_generator : public t_oop_generator {
 
   std::string js_includes();
   std::string render_includes();
-  std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="", bool include_callback=false);
-  std::string argument_list(t_struct* tstruct, bool include_callback=false);
+  std::string declare_field(t_field* tfield, bool init = false, bool obj = false);
+  std::string function_signature(t_function* tfunction,
+                                 std::string prefix = "",
+                                 bool include_callback = false);
+  std::string argument_list(t_struct* tstruct, bool include_callback = false);
   std::string type_to_enum(t_type* ttype);
 
   std::string autogen_comment() {
-    return
-      std::string("//\n") +
-      "// Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-      "//\n" +
-      "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-      "//\n";
+    return std::string("//\n") + "// Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           + "//\n" + "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+           + "//\n";
   }
 
   std::vector<std::string> js_namespace_pieces(t_program* p) {
-      std::string ns = p->get_namespace("js");
+    std::string ns = p->get_namespace("js");
 
-      std::string::size_type   loc;
-      std::vector<std::string> pieces;
+    std::string::size_type loc;
+    std::vector<std::string> pieces;
 
-      if (ns.size() > 0) {
-          while ((loc = ns.find(".")) != std::string::npos) {
-              pieces.push_back(ns.substr(0, loc));
-              ns = ns.substr(loc+1);
-          }
+    if (ns.size() > 0) {
+      while ((loc = ns.find(".")) != std::string::npos) {
+        pieces.push_back(ns.substr(0, loc));
+        ns = ns.substr(loc + 1);
       }
+    }
 
-      if (ns.size() > 0) {
-          pieces.push_back(ns);
-      }
+    if (ns.size() > 0) {
+      pieces.push_back(ns);
+    }
 
-      return pieces;
+    return pieces;
   }
 
   std::string js_type_namespace(t_program* p) {
@@ -236,13 +219,12 @@ class t_js_generator : public t_oop_generator {
   }
 
   std::string js_namespace(t_program* p) {
-      std::string ns = p->get_namespace("js");
-      if (ns.size() > 0) {
-          ns += ".";
-      }
-
+    std::string ns = p->get_namespace("js");
+    if (ns.size() > 0) {
+      ns += ".";
+    }
 
-      return ns;
+    return ns;
   }
 
   /**
@@ -257,26 +239,20 @@ class t_js_generator : public t_oop_generator {
    * Returns the normal indentation + "  " if a module was defined.
    * @return string
    */
-  string ts_indent() {
-    return indent() + (!ts_module_.empty() ? "  " : "");
-  }
+  string ts_indent() { return indent() + (!ts_module_.empty() ? "  " : ""); }
 
   /**
    * Returns "declare " if no module was defined.
    * @return string
    */
-  string ts_declare() {
-    return (ts_module_.empty() ? "declare " : "");
-  }
+  string ts_declare() { return (ts_module_.empty() ? "declare " : ""); }
 
   /**
    * Returns "?" if the given field is optional.
    * @param t_field The field to check
    * @return string
    */
-  string ts_get_req(t_field* field) {
-    return (field->get_req() == t_field::T_OPTIONAL ? "?" : "");
-  }
+  string ts_get_req(t_field* field) { return (field->get_req() == t_field::T_OPTIONAL ? "?" : ""); }
 
   /**
    * Returns the documentation, if the provided documentable object has one.
@@ -299,8 +275,7 @@ class t_js_generator : public t_oop_generator {
     return result;
   }
 
- private:
-
+private:
   /**
    * True if we should generate NodeJS-friendly RPC services.
    */
@@ -330,7 +305,6 @@ class t_js_generator : public t_oop_generator {
   std::ofstream f_service_ts_;
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -344,7 +318,7 @@ void t_js_generator::init_generator() {
   string outdir = get_out_dir();
 
   // Make output file(s)
-  string f_types_name = outdir+program_->get_name()+"_types.js";
+  string f_types_name = outdir + program_->get_name() + "_types.js";
   f_types_.open(f_types_name.c_str());
 
   if (gen_ts_) {
@@ -353,10 +327,7 @@ void t_js_generator::init_generator() {
   }
 
   // Print header
-  f_types_ <<
-    autogen_comment() <<
-    js_includes() << endl <<
-    render_includes() << endl;
+  f_types_ << autogen_comment() << js_includes() << endl << render_includes() << endl;
 
   if (gen_ts_) {
     f_types_ts_ << autogen_comment() << endl;
@@ -368,22 +339,21 @@ void t_js_generator::init_generator() {
 
   string pns;
 
-  //setup the namespace
+  // setup the namespace
   // TODO should the namespace just be in the directory structure for node?
-  vector<string> ns_pieces = js_namespace_pieces( program_ );
-  if( ns_pieces.size() > 0){
-    for(size_t i = 0; i < ns_pieces.size(); ++i) {
+  vector<string> ns_pieces = js_namespace_pieces(program_);
+  if (ns_pieces.size() > 0) {
+    for (size_t i = 0; i < ns_pieces.size(); ++i) {
       pns += ((i == 0) ? "" : ".") + ns_pieces[i];
       f_types_ << "if (typeof " << pns << " === 'undefined') {" << endl;
-        f_types_ << "  " << pns << " = {};" << endl;
-        f_types_ << "}" << endl;
+      f_types_ << "  " << pns << " = {};" << endl;
+      f_types_ << "}" << endl;
     }
     if (gen_ts_) {
       ts_module_ = pns;
       f_types_ts_ << "declare module " << ts_module_ << " {";
     }
   }
-
 }
 
 /**
@@ -391,9 +361,10 @@ void t_js_generator::init_generator() {
  */
 string t_js_generator::js_includes() {
   if (gen_node_) {
-    return string("var thrift = require('thrift');\n"
-      "var Thrift = thrift.Thrift;\n"
-      "var Q = thrift.Q;\n");
+    return string(
+        "var thrift = require('thrift');\n"
+        "var Thrift = thrift.Thrift;\n"
+        "var Q = thrift.Q;\n");
   }
 
   return "";
@@ -408,7 +379,8 @@ string t_js_generator::render_includes() {
   if (gen_node_) {
     const vector<t_program*>& includes = program_->get_includes();
     for (size_t i = 0; i < includes.size(); ++i) {
-      result += "var " + includes[i]->get_name() + "_ttypes = require('./" + includes[i]->get_name() + "_types')\n";
+      result += "var " + includes[i]->get_name() + "_ttypes = require('./" + includes[i]->get_name()
+                + "_types')\n";
     }
     if (includes.size() > 0) {
       result += "\n";
@@ -440,7 +412,7 @@ void t_js_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_js_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -450,12 +422,11 @@ void t_js_generator::generate_typedef(t_typedef* ttypedef) {
  * @param tenum The enumeration
  */
 void t_js_generator::generate_enum(t_enum* tenum) {
-  f_types_ << js_type_namespace(tenum->get_program())<<tenum->get_name()<<" = {"<<endl;
+  f_types_ << js_type_namespace(tenum->get_program()) << tenum->get_name() << " = {" << endl;
 
   if (gen_ts_) {
-    f_types_ts_ <<
-      ts_print_doc(tenum) <<
-      ts_indent() << ts_declare() << "enum " << tenum->get_name() << " {" << endl;
+    f_types_ts_ << ts_print_doc(tenum) << ts_indent() << ts_declare() << "enum "
+                << tenum->get_name() << " {" << endl;
   }
 
   indent_up();
@@ -466,19 +437,19 @@ void t_js_generator::generate_enum(t_enum* tenum) {
     int value = (*c_iter)->get_value();
     if (gen_ts_) {
       f_types_ts_ << ts_indent() << "'" << (*c_iter)->get_name() << "' = " << value << "," << endl;
-      //add 'value: key' in addition to 'key: value' for TypeScript enums
+      // add 'value: key' in addition to 'key: value' for TypeScript enums
       f_types_ << indent() << "'" << value << "' : '" << (*c_iter)->get_name() << "'," << endl;
     }
     f_types_ << indent() << "'" << (*c_iter)->get_name() << "' : " << value;
-    if (c_iter != constants.end()-1) {
-        f_types_ << ",";
+    if (c_iter != constants.end() - 1) {
+      f_types_ << ",";
     }
     f_types_ << endl;
   }
 
   indent_down();
 
-  f_types_ << "};"<<endl;
+  f_types_ << "};" << endl;
 
   if (gen_ts_) {
     f_types_ts_ << ts_indent() << "}" << endl;
@@ -493,13 +464,12 @@ void t_js_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
   t_const_value* value = tconst->get_value();
 
-  f_types_ << js_type_namespace(program_)  << name << " = ";
+  f_types_ << js_type_namespace(program_) << name << " = ";
   f_types_ << render_const_value(type, value) << ";" << endl;
 
   if (gen_ts_) {
-    f_types_ts_ <<
-      ts_print_doc(tconst) <<
-      ts_indent() << ts_declare() << "var " << name << ": " << ts_get_type(type) << ";" << endl;
+    f_types_ts_ << ts_print_doc(tconst) << ts_indent() << ts_declare() << "var " << name << ": "
+                << ts_get_type(type) << ";" << endl;
   }
 }
 
@@ -574,13 +544,13 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) {
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-        if (v_iter != val.begin())
-          out << "," << endl;
+      if (v_iter != val.begin())
+        out << "," << endl;
 
-        out << render_const_value(ktype, v_iter->first);
+      out << render_const_value(ktype, v_iter->first);
 
-        out << " : ";
-        out << render_const_value(vtype, v_iter->second);
+      out << " : ";
+      out << render_const_value(vtype, v_iter->second);
     }
 
     out << endl << "}";
@@ -624,8 +594,7 @@ void t_js_generator::generate_xception(t_struct* txception) {
 /**
  * Structs can be normal or exceptions.
  */
-void t_js_generator::generate_js_struct(t_struct* tstruct,
-                                            bool is_exception) {
+void t_js_generator::generate_js_struct(t_struct* tstruct, bool is_exception) {
   generate_js_struct_definition(f_types_, tstruct, is_exception);
 }
 
@@ -637,49 +606,52 @@ void t_js_generator::generate_js_struct(t_struct* tstruct,
  * @param tstruct The struct definition
  */
 void t_js_generator::generate_js_struct_definition(ofstream& out,
-                                                       t_struct* tstruct,
-                                                       bool is_exception,
-                                                       bool is_exported) {
+                                                   t_struct* tstruct,
+                                                   bool is_exception,
+                                                   bool is_exported) {
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
   if (gen_node_) {
     if (is_exported) {
-      out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = " <<
-        "module.exports." << tstruct->get_name() << " = function(args) {" << endl;
+      out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = "
+          << "module.exports." << tstruct->get_name() << " = function(args) {" << endl;
     } else {
-      out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = function(args) {" << endl;
+      out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = function(args) {"
+          << endl;
     }
   } else {
-    out << js_namespace(tstruct->get_program()) << tstruct->get_name() <<" = function(args) {" << endl;
+    out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = function(args) {"
+        << endl;
     if (gen_ts_) {
-      f_types_ts_ <<
-        ts_print_doc(tstruct) <<
-        ts_indent() << ts_declare() << "class " << tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "" ) << " {" << endl;
+      f_types_ts_ << ts_print_doc(tstruct) << ts_indent() << ts_declare() << "class "
+                  << tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "")
+                  << " {" << endl;
     }
   }
 
   indent_up();
 
   if (gen_node_ && is_exception) {
-      out << indent() << "Thrift.TException.call(this, \"" <<
-          js_namespace(tstruct->get_program()) << tstruct->get_name() << "\")" << endl;
-      out << indent() << "this.name = \"" <<
-          js_namespace(tstruct->get_program()) << tstruct->get_name() << "\"" << endl;
+    out << indent() << "Thrift.TException.call(this, \"" << js_namespace(tstruct->get_program())
+        << tstruct->get_name() << "\")" << endl;
+    out << indent() << "this.name = \"" << js_namespace(tstruct->get_program())
+        << tstruct->get_name() << "\"" << endl;
   }
 
-  //members with arguments
+  // members with arguments
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    string dval = declare_field(*m_iter,false,true);
+    string dval = declare_field(*m_iter, false, true);
     t_type* t = get_true_type((*m_iter)->get_type());
     if ((*m_iter)->get_value() != NULL && !(t->is_struct() || t->is_xception())) {
-        dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
-        out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << endl;
+      dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
+      out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << endl;
     } else {
-        out << indent() <<  dval << ";" << endl;
+      out << indent() << dval << ";" << endl;
     }
     if (gen_ts_) {
-      f_types_ts_ << ts_indent() << (*m_iter)->get_name() << ": " << ts_get_type((*m_iter)->get_type()) << ";" << endl;
+      f_types_ts_ << ts_indent() << (*m_iter)->get_name() << ": "
+                  << ts_get_type((*m_iter)->get_type()) << ";" << endl;
     }
   }
 
@@ -689,44 +661,47 @@ void t_js_generator::generate_js_struct_definition(ofstream& out,
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       t_type* t = get_true_type((*m_iter)->get_type());
       if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
-        indent(out) << "this." << (*m_iter)->get_name() << " = " << render_const_value(t, (*m_iter)->get_value())  << ";" << endl;
+        indent(out) << "this." << (*m_iter)->get_name() << " = "
+                    << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
       }
     }
 
     // Early returns for exceptions
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-       t_type* t = get_true_type((*m_iter)->get_type());
-       if (t->is_xception()) {
-                       out << indent() <<  "if (args instanceof " << js_type_namespace(t->get_program()) << t->get_name() << ") {" << endl
-                               << indent() << indent() << "this." << (*m_iter)->get_name() << " = args;" << endl
-                               << indent() << indent() << "return;" << endl
-                               << indent() << "}" << endl;
-       }
+      t_type* t = get_true_type((*m_iter)->get_type());
+      if (t->is_xception()) {
+        out << indent() << "if (args instanceof " << js_type_namespace(t->get_program())
+            << t->get_name() << ") {" << endl << indent() << indent() << "this."
+            << (*m_iter)->get_name() << " = args;" << endl << indent() << indent() << "return;"
+            << endl << indent() << "}" << endl;
+      }
     }
 
-    out << indent() <<  "if (args) {" << endl;
+    out << indent() << "if (args) {" << endl;
     if (gen_ts_) {
       f_types_ts_ << endl << ts_indent() << "constructor(args?: { ";
     }
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        out << indent() << indent() << "if (args." << (*m_iter)->get_name() << " !== undefined) {" << endl
-            << indent() << indent() << indent() << "this." << (*m_iter)->get_name() << " = args." << (*m_iter)->get_name()  << ";" << endl;
-        if (!(*m_iter)->get_req()) {
-          out << indent() << indent() << "} else {" << endl
-              << indent() << indent() << indent() << "throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field " << (*m_iter)->get_name() << " is unset!');" << endl;
-        }
-        out << indent() << indent() << "}" << endl;
-        if (gen_ts_) {
-          f_types_ts_ << (*m_iter)->get_name() << ts_get_req(*m_iter) << ": " << ts_get_type((*m_iter)->get_type()) << "; ";
-        }
+      out << indent() << indent() << "if (args." << (*m_iter)->get_name() << " !== undefined) {"
+          << endl << indent() << indent() << indent() << "this." << (*m_iter)->get_name()
+          << " = args." << (*m_iter)->get_name() << ";" << endl;
+      if (!(*m_iter)->get_req()) {
+        out << indent() << indent() << "} else {" << endl << indent() << indent() << indent()
+            << "throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, "
+               "'Required field " << (*m_iter)->get_name() << " is unset!');" << endl;
+      }
+      out << indent() << indent() << "}" << endl;
+      if (gen_ts_) {
+        f_types_ts_ << (*m_iter)->get_name() << ts_get_req(*m_iter) << ": "
+                    << ts_get_type((*m_iter)->get_type()) << "; ";
+      }
     }
 
-    out << indent() <<  "}" << endl;
+    out << indent() << "}" << endl;
     if (gen_ts_) {
       f_types_ts_ << "});" << endl;
     }
-
   }
 
   indent_down();
@@ -736,36 +711,34 @@ void t_js_generator::generate_js_struct_definition(ofstream& out,
   }
 
   if (is_exception) {
-    out << "Thrift.inherits(" <<
-        js_namespace(tstruct->get_program()) <<
-        tstruct->get_name() << ", Thrift.TException);" << endl;
-	out << js_namespace(tstruct->get_program())<<tstruct->get_name() <<".prototype.name = '" << tstruct->get_name() << "';" << endl;
+    out << "Thrift.inherits(" << js_namespace(tstruct->get_program()) << tstruct->get_name()
+        << ", Thrift.TException);" << endl;
+    out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype.name = '"
+        << tstruct->get_name() << "';" << endl;
   } else {
-    //init prototype
-    out << js_namespace(tstruct->get_program())<<tstruct->get_name() <<".prototype = {};" << endl;
+    // init prototype
+    out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype = {};"
+        << endl;
   }
 
-
   generate_js_struct_reader(out, tstruct);
   generate_js_struct_writer(out, tstruct);
-
 }
 
 /**
  * Generates the read() method for a struct
  */
-void t_js_generator::generate_js_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_js_generator::generate_js_struct_reader(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out <<  js_namespace(tstruct->get_program())<<tstruct->get_name() << ".prototype.read = function(input) {"<<endl;
+  out << js_namespace(tstruct->get_program()) << tstruct->get_name()
+      << ".prototype.read = function(input) {" << endl;
 
   indent_up();
 
   indent(out) << "input.readStructBegin();" << endl;
 
-
   // Loop over reading in fields
   indent(out) << "while (true)" << endl;
 
@@ -774,8 +747,7 @@ void t_js_generator::generate_js_struct_reader(ofstream& out,
   indent(out) << "var ret = input.readFieldBegin();" << endl;
   indent(out) << "var fname = ret.fname;" << endl;
   indent(out) << "var ftype = ret.ftype;" << endl;
-  indent(out) << "var fid = ret.fid;"   << endl;
-
+  indent(out) << "var fid = ret.fid;" << endl;
 
   // Check for field STOP marker and break
   indent(out) << "if (ftype == Thrift.Type.STOP) {" << endl;
@@ -801,22 +773,19 @@ void t_js_generator::generate_js_struct_reader(ofstream& out,
 
       indent(out) << "} else {" << endl;
 
-      indent(out) <<  "  input.skip(ftype);" << endl;
-
-      out <<
-        indent() << "}" << endl <<
-        indent() << "break;" << endl;
+      indent(out) << "  input.skip(ftype);" << endl;
 
+      out << indent() << "}" << endl << indent() << "break;" << endl;
     }
     if (fields.size() == 1) {
       // pseudo case to make jslint happy
-      indent(out) <<  "case 0:" << endl;
-      indent(out) <<  "  input.skip(ftype);" << endl;
-      indent(out) <<  "  break;" << endl;
+      indent(out) << "case 0:" << endl;
+      indent(out) << "  input.skip(ftype);" << endl;
+      indent(out) << "  break;" << endl;
     }
     // In the default case we skip the field
-    indent(out) <<  "default:" << endl;
-    indent(out) <<  "  input.skip(ftype);" << endl;
+    indent(out) << "default:" << endl;
+    indent(out) << "  input.skip(ftype);" << endl;
 
     scope_down(out);
   } else {
@@ -838,50 +807,43 @@ void t_js_generator::generate_js_struct_reader(ofstream& out,
 /**
  * Generates the write() method for a struct
  */
-void t_js_generator::generate_js_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_js_generator::generate_js_struct_writer(ofstream& out, t_struct* tstruct) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out << js_namespace(tstruct->get_program())<< tstruct->get_name() << ".prototype.write = function(output) {"<<endl;
+  out << js_namespace(tstruct->get_program()) << tstruct->get_name()
+      << ".prototype.write = function(output) {" << endl;
 
   indent_up();
 
   indent(out) << "output.writeStructBegin('" << name << "');" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    out << indent() << "if (this." << (*f_iter)->get_name() <<  " !== null && this." << (*f_iter)->get_name() << " !== undefined) {" << endl;
+    out << indent() << "if (this." << (*f_iter)->get_name() << " !== null && this."
+        << (*f_iter)->get_name() << " !== undefined) {" << endl;
     indent_up();
 
-    indent(out) <<
-      "output.writeFieldBegin(" <<
-      "'" << (*f_iter)->get_name() << "', " <<
-      type_to_enum((*f_iter)->get_type()) << ", " <<
-      (*f_iter)->get_key() << ");" << endl;
-
+    indent(out) << "output.writeFieldBegin("
+                << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
+                << ", " << (*f_iter)->get_key() << ");" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
-    indent(out) <<
-        "output.writeFieldEnd();" << endl;
+    indent(out) << "output.writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}" << endl;
   }
 
+  out << indent() << "output.writeFieldStop();" << endl << indent() << "output.writeStructEnd();"
+      << endl;
 
-  out <<
-    indent() << "output.writeFieldStop();" << endl <<
-    indent() << "output.writeStructEnd();" << endl;
-
-  out <<indent() << "return;" << endl;
+  out << indent() << "return;" << endl;
 
   indent_down();
-  out <<
-    indent() << "};" << endl <<
-    endl;
+  out << indent() << "};" << endl << endl;
 }
 
 /**
@@ -890,59 +852,55 @@ void t_js_generator::generate_js_struct_writer(ofstream& out,
  * @param tservice The service definition
  */
 void t_js_generator::generate_service(t_service* tservice) {
-    string f_service_name = get_out_dir()+service_name_+".js";
-    f_service_.open(f_service_name.c_str());
+  string f_service_name = get_out_dir() + service_name_ + ".js";
+  f_service_.open(f_service_name.c_str());
 
-    if (gen_ts_) {
-      string f_service_ts_name = get_out_dir() + service_name_ + ".d.ts";
-      f_service_ts_.open(f_service_ts_name.c_str());
-    }
+  if (gen_ts_) {
+    string f_service_ts_name = get_out_dir() + service_name_ + ".d.ts";
+    f_service_ts_.open(f_service_ts_name.c_str());
+  }
 
-    f_service_ <<
-      autogen_comment() <<
-      js_includes() << endl <<
-      render_includes() << endl;
+  f_service_ << autogen_comment() << js_includes() << endl << render_includes() << endl;
 
-    if (gen_ts_) {
-      if (tservice->get_extends() != NULL) {
-        f_service_ts_ << "/// <reference path=\"" << tservice->get_extends()->get_name() << ".d.ts\" />" << endl;
-      }
-      f_service_ts_ << autogen_comment() << endl;
-      if (!ts_module_.empty()) {
-        f_service_ts_ << "declare module " << ts_module_ << " {";
-      }
+  if (gen_ts_) {
+    if (tservice->get_extends() != NULL) {
+      f_service_ts_ << "/// <reference path=\"" << tservice->get_extends()->get_name()
+                    << ".d.ts\" />" << endl;
     }
+    f_service_ts_ << autogen_comment() << endl;
+    if (!ts_module_.empty()) {
+      f_service_ts_ << "declare module " << ts_module_ << " {";
+    }
+  }
 
-    if (gen_node_) {
-      if (tservice->get_extends() != NULL) {
-        f_service_ <<
-          "var " << tservice->get_extends()->get_name() <<
-          " = require('./" << tservice->get_extends()->get_name() << "')" << endl <<
-          "var " << tservice->get_extends()->get_name() << "Client = " <<
-          tservice->get_extends()->get_name() << ".Client" << endl <<
-          "var " << tservice->get_extends()->get_name() << "Processor = " <<
-          tservice->get_extends()->get_name() << ".Processor" << endl;
-      }
-
-      f_service_ <<
-        "var ttypes = require('./" + program_->get_name() + "_types');" << endl;
+  if (gen_node_) {
+    if (tservice->get_extends() != NULL) {
+      f_service_ << "var " << tservice->get_extends()->get_name() << " = require('./"
+                 << tservice->get_extends()->get_name() << "')" << endl << "var "
+                 << tservice->get_extends()->get_name()
+                 << "Client = " << tservice->get_extends()->get_name() << ".Client" << endl
+                 << "var " << tservice->get_extends()->get_name()
+                 << "Processor = " << tservice->get_extends()->get_name() << ".Processor" << endl;
     }
 
-    generate_service_helpers(tservice);
-    generate_service_interface(tservice);
-    generate_service_client(tservice);
+    f_service_ << "var ttypes = require('./" + program_->get_name() + "_types');" << endl;
+  }
 
-    if (gen_node_) {
-      generate_service_processor(tservice);
-    }
+  generate_service_helpers(tservice);
+  generate_service_interface(tservice);
+  generate_service_client(tservice);
 
-    f_service_.close();
-    if (gen_ts_) {
-      if (!ts_module_.empty()) {
-        f_service_ts_ << "}";
-      }
-      f_service_ts_.close();
+  if (gen_node_) {
+    generate_service_processor(tservice);
+  }
+
+  f_service_.close();
+  if (gen_ts_) {
+    if (!ts_module_.empty()) {
+      f_service_ts_ << "}";
     }
+    f_service_ts_.close();
+  }
 }
 
 /**
@@ -951,52 +909,50 @@ void t_js_generator::generate_service(t_service* tservice) {
  * @param tservice The service to generate a server for.
  */
 void t_js_generator::generate_service_processor(t_service* tservice) {
-    vector<t_function*> functions = tservice->get_functions();
-    vector<t_function*>::iterator f_iter;
+  vector<t_function*> functions = tservice->get_functions();
+  vector<t_function*>::iterator f_iter;
 
-    f_service_ <<
-        js_namespace(tservice->get_program()) << service_name_ << "Processor = " <<
-        "exports.Processor = function(handler) ";
+  f_service_ << js_namespace(tservice->get_program()) << service_name_ << "Processor = "
+             << "exports.Processor = function(handler) ";
 
-    scope_up(f_service_);
+  scope_up(f_service_);
 
-    f_service_ << indent() << "this._handler = handler" << endl;
+  f_service_ << indent() << "this._handler = handler" << endl;
 
-    scope_down(f_service_);
+  scope_down(f_service_);
 
-    if (tservice->get_extends() != NULL) {
-        indent(f_service_) << "Thrift.inherits(" <<
-            js_namespace(tservice->get_program()) <<
-            service_name_ << "Processor, " <<
-            tservice->get_extends()->get_name() << "Processor)" << endl;
-    }
-
-    // Generate the server implementation
-    indent(f_service_) <<
-        js_namespace(tservice->get_program()) << service_name_ << "Processor.prototype.process = function(input, output) ";
-
-    scope_up(f_service_);
-
-    f_service_ << indent() << "var r = input.readMessageBegin();" << endl
-               << indent() << "if (this['process_' + r.fname]) {" << endl
-               << indent() << "  return this['process_' + r.fname].call(this, r.rseqid, input, output);" << endl
-               << indent() << "} else {" << endl
-               << indent() << "  input.skip(Thrift.Type.STRUCT);" << endl
-               << indent() << "  input.readMessageEnd();" << endl
-               << indent() << "  var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);" << endl
-               << indent() << "  output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);" << endl
-               << indent() << "  x.write(output);" << endl
-               << indent() << "  output.writeMessageEnd();" << endl
-               << indent() << "  output.flush();" << endl
-               << indent() << "}" << endl;
-
-    scope_down(f_service_);
-    f_service_ << endl;
+  if (tservice->get_extends() != NULL) {
+    indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program())
+                       << service_name_ << "Processor, " << tservice->get_extends()->get_name()
+                       << "Processor)" << endl;
+  }
 
-    // Generate the process subfunctions
-    for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-        generate_process_function(tservice, *f_iter);
-    }
+  // Generate the server implementation
+  indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
+                     << "Processor.prototype.process = function(input, output) ";
+
+  scope_up(f_service_);
+
+  f_service_ << indent() << "var r = input.readMessageBegin();" << endl << indent()
+             << "if (this['process_' + r.fname]) {" << endl << indent()
+             << "  return this['process_' + r.fname].call(this, r.rseqid, input, output);" << endl
+             << indent() << "} else {" << endl << indent() << "  input.skip(Thrift.Type.STRUCT);"
+             << endl << indent() << "  input.readMessageEnd();" << endl << indent()
+             << "  var x = new "
+                "Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, "
+                "'Unknown function ' + r.fname);" << endl << indent()
+             << "  output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);"
+             << endl << indent() << "  x.write(output);" << endl << indent()
+             << "  output.writeMessageEnd();" << endl << indent() << "  output.flush();" << endl
+             << indent() << "}" << endl;
+
+  scope_down(f_service_);
+  f_service_ << endl;
+
+  // Generate the process subfunctions
+  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
+    generate_process_function(tservice, *f_iter);
+  }
 }
 
 /**
@@ -1004,105 +960,99 @@ void t_js_generator::generate_service_processor(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_js_generator::generate_process_function(t_service* tservice,
-                                                 t_function* tfunction) {
-    indent(f_service_) <<
-        js_namespace(tservice->get_program()) << service_name_ << "Processor.prototype.process_" + tfunction->get_name() + " = function(seqid, input, output) ";
+void t_js_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
+                     << "Processor.prototype.process_" + tfunction->get_name()
+                        + " = function(seqid, input, output) ";
 
-    scope_up(f_service_);
+  scope_up(f_service_);
 
-    string argsname =  js_namespace(program_)+ service_name_ + "_" + tfunction->get_name() + "_args";
-    string resultname =  js_namespace(program_)+ service_name_ + "_" + tfunction->get_name() + "_result";
+  string argsname = js_namespace(program_) + service_name_ + "_" + tfunction->get_name() + "_args";
+  string resultname = js_namespace(program_) + service_name_ + "_" + tfunction->get_name()
+                      + "_result";
 
-    f_service_ <<
-        indent() << "var args = new " << argsname << "();" << endl <<
-        indent() << "args.read(input);" << endl <<
-        indent() << "input.readMessageEnd();" << endl;
+  f_service_ << indent() << "var args = new " << argsname << "();" << endl << indent()
+             << "args.read(input);" << endl << indent() << "input.readMessageEnd();" << endl;
 
-    // Generate the function call
-    t_struct* arg_struct = tfunction->get_arglist();
-    const std::vector<t_field*>& fields = arg_struct->get_members();
-    vector<t_field*>::const_iterator f_iter;
+  // Generate the function call
+  t_struct* arg_struct = tfunction->get_arglist();
+  const std::vector<t_field*>& fields = arg_struct->get_members();
+  vector<t_field*>::const_iterator f_iter;
 
-    // Shortcut out here for oneway functions
-    if (tfunction->is_oneway()) {
-      indent(f_service_) << "this._handler." << tfunction->get_name() << "(";
+  // Shortcut out here for oneway functions
+  if (tfunction->is_oneway()) {
+    indent(f_service_) << "this._handler." << tfunction->get_name() << "(";
 
-      bool first = true;
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        if (first) {
-          first = false;
-        } else {
-          f_service_ << ", ";
-        }
-        f_service_ << "args." << (*f_iter)->get_name();
+    bool first = true;
+    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+      if (first) {
+        first = false;
+      } else {
+        f_service_ << ", ";
       }
-
-      f_service_ << ")" << endl;
-      scope_down(f_service_);
-      f_service_ << endl;
-      return;
+      f_service_ << "args." << (*f_iter)->get_name();
     }
 
-    f_service_ <<
-        indent() << "if (this._handler." << tfunction->get_name() << ".length === " << fields.size() <<") {" << endl;
-    indent_up();
-    indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name();
+    f_service_ << ")" << endl;
+    scope_down(f_service_);
+    f_service_ << endl;
+    return;
+  }
 
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      f_service_ << ", args." << (*f_iter)->get_name();
-    }
+  f_service_ << indent() << "if (this._handler." << tfunction->get_name()
+             << ".length === " << fields.size() << ") {" << endl;
+  indent_up();
+  indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name();
 
-    f_service_ << ")" << endl;
-    indent_up();
-    indent(f_service_) << ".then(function(result) {" << endl;
-    indent_up();
-    f_service_ <<
-        indent() << "var result = new " << resultname << "({success: result});" << endl <<
-        indent() << "output.writeMessageBegin(\"" << tfunction->get_name() <<
-        "\", Thrift.MessageType.REPLY, seqid);" << endl <<
-        indent() << "result.write(output);" << endl <<
-        indent() << "output.writeMessageEnd();" << endl <<
-        indent() << "output.flush();" << endl;
-    indent_down();
-    indent(f_service_) << "}, function (err) {" << endl;
-    indent_up();
-    f_service_ <<
-        indent() << "var result = new " << resultname << "(err);" << endl <<
-        indent() << "output.writeMessageBegin(\"" << tfunction->get_name() <<
-        "\", Thrift.MessageType.REPLY, seqid);" << endl <<
-        indent() << "result.write(output);" << endl <<
-        indent() << "output.writeMessageEnd();" << endl <<
-        indent() << "output.flush();" << endl;
-    indent_down();
-    indent(f_service_) << "});" << endl;
-    indent_down();
-    indent_down();
-    indent(f_service_) << "} else {" << endl;
-    indent_up();
-    indent(f_service_) << "this._handler." << tfunction->get_name() << "(";
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    f_service_ << ", args." << (*f_iter)->get_name();
+  }
 
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      f_service_ << "args." << (*f_iter)->get_name() << ", ";
-    }
+  f_service_ << ")" << endl;
+  indent_up();
+  indent(f_service_) << ".then(function(result) {" << endl;
+  indent_up();
+  f_service_ << indent() << "var result = new " << resultname << "({success: result});" << endl
+             << indent() << "output.writeMessageBegin(\"" << tfunction->get_name()
+             << "\", Thrift.MessageType.REPLY, seqid);" << endl << indent()
+             << "result.write(output);" << endl << indent() << "output.writeMessageEnd();" << endl
+             << indent() << "output.flush();" << endl;
+  indent_down();
+  indent(f_service_) << "}, function (err) {" << endl;
+  indent_up();
+  f_service_ << indent() << "var result = new " << resultname << "(err);" << endl << indent()
+             << "output.writeMessageBegin(\"" << tfunction->get_name()
+             << "\", Thrift.MessageType.REPLY, seqid);" << endl << indent()
+             << "result.write(output);" << endl << indent() << "output.writeMessageEnd();" << endl
+             << indent() << "output.flush();" << endl;
+  indent_down();
+  indent(f_service_) << "});" << endl;
+  indent_down();
+  indent_down();
+  indent(f_service_) << "} else {" << endl;
+  indent_up();
+  indent(f_service_) << "this._handler." << tfunction->get_name() << "(";
 
-    f_service_ << " function (err, result) {" << endl;
-    indent_up();
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    f_service_ << "args." << (*f_iter)->get_name() << ", ";
+  }
 
-    f_service_ <<
-        indent() << "var result = new " << resultname << "((err != null ? err : {success: result}));" << endl <<
-        indent() << "output.writeMessageBegin(\"" << tfunction->get_name() <<
-        "\", Thrift.MessageType.REPLY, seqid);" << endl <<
-        indent() << "result.write(output);" << endl <<
-        indent() << "output.writeMessageEnd();" << endl <<
-        indent() << "output.flush();" << endl;
+  f_service_ << " function (err, result) {" << endl;
+  indent_up();
 
-    indent_down();
-    indent(f_service_) << "});" << endl;
-    indent_down();
-    indent(f_service_) << "}" << endl;
-    scope_down(f_service_);
-    f_service_ << endl;
+  f_service_ << indent() << "var result = new " << resultname
+             << "((err != null ? err : {success: result}));" << endl << indent()
+             << "output.writeMessageBegin(\"" << tfunction->get_name()
+             << "\", Thrift.MessageType.REPLY, seqid);" << endl << indent()
+             << "result.write(output);" << endl << indent() << "output.writeMessageEnd();" << endl
+             << indent() << "output.flush();" << endl;
+
+  indent_down();
+  indent(f_service_) << "});" << endl;
+  indent_down();
+  indent(f_service_) << "}" << endl;
+  scope_down(f_service_);
+  f_service_ << endl;
 }
 
 /**
@@ -1111,26 +1061,25 @@ void t_js_generator::generate_process_function(t_service* tservice,
  * @param tservice The service to generate a header definition for
  */
 void t_js_generator::generate_service_helpers(t_service* tservice) {
-	  //Do not generate TS definitions for helper functions
-	  bool gen_ts_tmp = gen_ts_;
-	  gen_ts_ = false;
-
-    vector<t_function*> functions = tservice->get_functions();
-    vector<t_function*>::iterator f_iter;
-
-    f_service_ <<
-        "//HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
-
-    for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-        t_struct* ts = (*f_iter)->get_arglist();
-        string name = ts->get_name();
-        ts->set_name(service_name_ + "_" + name);
-        generate_js_struct_definition(f_service_, ts, false, false);
-        generate_js_function_helpers(*f_iter);
-        ts->set_name(name);
-    }
+  // Do not generate TS definitions for helper functions
+  bool gen_ts_tmp = gen_ts_;
+  gen_ts_ = false;
+
+  vector<t_function*> functions = tservice->get_functions();
+  vector<t_function*>::iterator f_iter;
+
+  f_service_ << "//HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
 
-	  gen_ts_ = gen_ts_tmp;
+  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
+    t_struct* ts = (*f_iter)->get_arglist();
+    string name = ts->get_name();
+    ts->set_name(service_name_ + "_" + name);
+    generate_js_struct_definition(f_service_, ts, false, false);
+    generate_js_function_helpers(*f_iter);
+    ts->set_name(name);
+  }
+
+  gen_ts_ = gen_ts_tmp;
 }
 
 /**
@@ -1139,20 +1088,20 @@ void t_js_generator::generate_service_helpers(t_service* tservice) {
  * @param tfunction The function
  */
 void t_js_generator::generate_js_function_helpers(t_function* tfunction) {
-    t_struct result(program_, service_name_ + "_" + tfunction->get_name() + "_result");
-    t_field success(tfunction->get_returntype(), "success", 0);
-    if (!tfunction->get_returntype()->is_void()) {
-        result.append(&success);
-    }
+  t_struct result(program_, service_name_ + "_" + tfunction->get_name() + "_result");
+  t_field success(tfunction->get_returntype(), "success", 0);
+  if (!tfunction->get_returntype()->is_void()) {
+    result.append(&success);
+  }
 
-    t_struct* xs = tfunction->get_xceptions();
-    const vector<t_field*>& fields = xs->get_members();
-    vector<t_field*>::const_iterator f_iter;
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        result.append(*f_iter);
-    }
+  t_struct* xs = tfunction->get_xceptions();
+  const vector<t_field*>& fields = xs->get_members();
+  vector<t_field*>::const_iterator f_iter;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    result.append(*f_iter);
+  }
 
-    generate_js_struct_definition(f_service_, &result, false, false);
+  generate_js_struct_definition(f_service_, &result, false, false);
 }
 
 /**
@@ -1161,14 +1110,14 @@ void t_js_generator::generate_js_function_helpers(t_function* tfunction) {
  * @param tservice The service to generate a header definition for
  */
 void t_js_generator::generate_service_interface(t_service* tservice) {
-  (void) tservice;
+  (void)tservice;
 }
 
 /**
  * Generates a REST interface
  */
 void t_js_generator::generate_service_rest(t_service* tservice) {
-  (void) tservice;
+  (void)tservice;
 }
 
 /**
@@ -1178,16 +1127,14 @@ void t_js_generator::generate_service_rest(t_service* tservice) {
  */
 void t_js_generator::generate_service_client(t_service* tservice) {
   if (gen_node_) {
-    f_service_ <<
-        js_namespace(tservice->get_program()) << service_name_ << "Client = " <<
-        "exports.Client = function(output, pClass) {"<<endl;
+    f_service_ << js_namespace(tservice->get_program()) << service_name_ << "Client = "
+               << "exports.Client = function(output, pClass) {" << endl;
   } else {
-    f_service_ <<
-        js_namespace(tservice->get_program()) << service_name_ << "Client = function(input, output) {"<<endl;
+    f_service_ << js_namespace(tservice->get_program()) << service_name_
+               << "Client = function(input, output) {" << endl;
     if (gen_ts_) {
-      f_service_ts_ <<
-        ts_print_doc(tservice) <<
-        ts_indent() << ts_declare() << "class " << service_name_ << "Client ";
+      f_service_ts_ << ts_print_doc(tservice) << ts_indent() << ts_declare() << "class "
+                    << service_name_ << "Client ";
       if (tservice->get_extends() != NULL) {
         f_service_ts_ << "extends " << tservice->get_extends()->get_name() << "Client ";
       }
@@ -1197,50 +1144,45 @@ void t_js_generator::generate_service_client(t_service* tservice) {
 
   indent_up();
 
-
   if (gen_node_) {
-    f_service_ <<
-      indent() << "  this.output = output;" << endl <<
-      indent() << "  this.pClass = pClass;" << endl <<
-      indent() << "  this._seqid = 0;" << endl <<
-      indent() << "  this._reqs = {};" << endl;
+    f_service_ << indent() << "  this.output = output;" << endl << indent()
+               << "  this.pClass = pClass;" << endl << indent() << "  this._seqid = 0;" << endl
+               << indent() << "  this._reqs = {};" << endl;
   } else {
-    f_service_ <<
-      indent() << "  this.input = input;" << endl <<
-      indent() << "  this.output = (!output) ? input : output;" << endl <<
-      indent() << "  this.seqid = 0;" << endl;
+    f_service_ << indent() << "  this.input = input;" << endl << indent()
+               << "  this.output = (!output) ? input : output;" << endl << indent()
+               << "  this.seqid = 0;" << endl;
     if (gen_ts_) {
-       f_service_ts_ <<
-         ts_indent() << "input: Thrift.TJSONProtocol;" << endl <<
-         ts_indent() << "output: Thrift.TJSONProtocol;" << endl <<
-         ts_indent() << "seqid: number;" << endl <<
-         endl <<
-         ts_indent() << "constructor(input: Thrift.TJSONProtocol, output?: Thrift.TJSONProtocol);" << endl;
+      f_service_ts_ << ts_indent() << "input: Thrift.TJSONProtocol;" << endl << ts_indent()
+                    << "output: Thrift.TJSONProtocol;" << endl << ts_indent() << "seqid: number;"
+                    << endl << endl << ts_indent()
+                    << "constructor(input: Thrift.TJSONProtocol, output?: Thrift.TJSONProtocol);"
+                    << endl;
     }
   }
 
-
   indent_down();
 
-  f_service_ <<
-      indent() << "};" << endl;
-
+  f_service_ << indent() << "};" << endl;
 
   if (tservice->get_extends() != NULL) {
-    indent(f_service_) << "Thrift.inherits(" <<
-        js_namespace(tservice->get_program()) <<
-        service_name_ << "Client, " <<
-        js_namespace(tservice->get_extends()->get_program()) <<
-        tservice->get_extends()->get_name() << "Client);" << endl;
+    indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program())
+                       << service_name_ << "Client, "
+                       << js_namespace(tservice->get_extends()->get_program())
+                       << tservice->get_extends()->get_name() << "Client);" << endl;
   } else {
-      //init prototype
-      indent(f_service_) <<  js_namespace(tservice->get_program())<<service_name_ << "Client.prototype = {};"<<endl;
+    // init prototype
+    indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
+                       << "Client.prototype = {};" << endl;
   }
 
   // utils for multiplexed services
   if (gen_node_) {
-    indent(f_service_) <<  js_namespace(tservice->get_program())<<service_name_ << "Client.prototype.seqid = function() { return this._seqid; }" << endl <<
-    js_namespace(tservice->get_program())<<service_name_ << "Client.prototype.new_seqid = function() { return this._seqid += 1; }" << endl;
+    indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
+                       << "Client.prototype.seqid = function() { return this._seqid; }" << endl
+                       << js_namespace(tservice->get_program()) << service_name_
+                       << "Client.prototype.new_seqid = function() { return this._seqid += 1; }"
+                       << endl;
   }
   // Generate client method implementations
   vector<t_function*> functions = tservice->get_functions();
@@ -1253,29 +1195,25 @@ void t_js_generator::generate_service_client(t_service* tservice) {
     string arglist = argument_list(arg_struct);
 
     // Open function
-    f_service_ <<  js_namespace(tservice->get_program())<<service_name_<<"Client.prototype." <<
-      function_signature(*f_iter, "", true) << " {" << endl;
+    f_service_ << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype."
+               << function_signature(*f_iter, "", true) << " {" << endl;
 
     indent_up();
 
     if (gen_ts_) {
-      f_service_ts_ <<
-      ts_print_doc(*f_iter) <<
-      //function definition without callback
-      ts_indent() << ts_function_signature(*f_iter, false) << endl <<
-      ts_print_doc(*f_iter) <<
-      //overload with callback
-      ts_indent() << ts_function_signature(*f_iter, true) << endl;
+      f_service_ts_ << ts_print_doc(*f_iter) <<
+          // function definition without callback
+          ts_indent() << ts_function_signature(*f_iter, false) << endl << ts_print_doc(*f_iter) <<
+          // overload with callback
+          ts_indent() << ts_function_signature(*f_iter, true) << endl;
     }
 
-    if (gen_node_) {          //Node.js output      ./gen-nodejs
-      f_service_ <<
-        indent() << "this._seqid = this.new_seqid();" << endl <<
-        indent() << "if (callback === undefined) {" << endl;
+    if (gen_node_) { // Node.js output      ./gen-nodejs
+      f_service_ << indent() << "this._seqid = this.new_seqid();" << endl << indent()
+                 << "if (callback === undefined) {" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "var _defer = Q.defer();" << endl <<
-        indent() << "this._reqs[this.seqid()] = function(error, result) {" << endl;
+      f_service_ << indent() << "var _defer = Q.defer();" << endl << indent()
+                 << "this._reqs[this.seqid()] = function(error, result) {" << endl;
       indent_up();
       indent(f_service_) << "if (error) {" << endl;
       indent_up();
@@ -1288,20 +1226,17 @@ void t_js_generator::generate_service_client(t_service* tservice) {
       indent(f_service_) << "}" << endl;
       indent_down();
       indent(f_service_) << "};" << endl;
-      f_service_ <<
-        indent() << "this.send_" << funname << "(" << arglist << ");" << endl <<
-        indent() << "return _defer.promise;" << endl;
+      f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl
+                 << indent() << "return _defer.promise;" << endl;
       indent_down();
       indent(f_service_) << "} else {" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "this._reqs[this.seqid()] = callback;" << endl <<
-        indent() << "this.send_" << funname << "(" << arglist << ");" << endl;
+      f_service_ << indent() << "this._reqs[this.seqid()] = callback;" << endl << indent()
+                 << "this.send_" << funname << "(" << arglist << ");" << endl;
       indent_down();
       indent(f_service_) << "}" << endl;
-    }
-    else if (gen_jquery_) {   //jQuery output       ./gen-js
-		  f_service_ << indent() << "if (callback === undefined) {" << endl;
+    } else if (gen_jquery_) { // jQuery output       ./gen-js
+      f_service_ << indent() << "if (callback === undefined) {" << endl;
       indent_up();
       f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl;
       if (!(*f_iter)->is_oneway()) {
@@ -1314,19 +1249,20 @@ void t_js_generator::generate_service_client(t_service* tservice) {
       indent_down();
       f_service_ << indent() << "} else {" << endl;
       indent_up();
-      f_service_ << indent() << "var postData = this.send_" << funname <<
-        "(" << arglist << (arglist.empty() ? "" : ", ") << "true);" << endl;
+      f_service_ << indent() << "var postData = this.send_" << funname << "(" << arglist
+                 << (arglist.empty() ? "" : ", ") << "true);" << endl;
       f_service_ << indent() << "return this.output.getTransport()" << endl;
       indent_up();
-      f_service_ << indent() << ".jqRequest(this, postData, arguments, this.recv_" << funname << ");" << endl;
+      f_service_ << indent() << ".jqRequest(this, postData, arguments, this.recv_" << funname
+                 << ");" << endl;
       indent_down();
       indent_down();
       f_service_ << indent() << "}" << endl;
-    } else {                  //Standard JavaScript ./gen-js
-      f_service_ << indent() <<
-        "this.send_" << funname << "(" << arglist << (arglist.empty() ? "" : ", ") << "callback); " << endl;
+    } else { // Standard JavaScript ./gen-js
+      f_service_ << indent() << "this.send_" << funname << "(" << arglist
+                 << (arglist.empty() ? "" : ", ") << "callback); " << endl;
       if (!(*f_iter)->is_oneway()) {
-		    f_service_ << indent() << "if (!callback) {" << endl;
+        f_service_ << indent() << "if (!callback) {" << endl;
         f_service_ << indent();
         if (!(*f_iter)->get_returntype()->is_void()) {
           f_service_ << "  return ";
@@ -1340,52 +1276,45 @@ void t_js_generator::generate_service_client(t_service* tservice) {
 
     f_service_ << "};" << endl << endl;
 
-
     // Send function
-    f_service_ <<  js_namespace(tservice->get_program())<<service_name_ <<
-      "Client.prototype.send_" << function_signature(*f_iter, "", !gen_node_) << " {" << endl;
+    f_service_ << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype.send_"
+               << function_signature(*f_iter, "", !gen_node_) << " {" << endl;
 
     indent_up();
 
     std::string outputVar;
     if (gen_node_) {
-      f_service_ <<
-        indent() << "var output = new this.pClass(this.output);" << endl;
+      f_service_ << indent() << "var output = new this.pClass(this.output);" << endl;
       outputVar = "output";
     } else {
       outputVar = "this.output";
     }
 
-    std::string argsname =  js_namespace(program_)+ service_name_ + "_" + (*f_iter)->get_name() + "_args";
+    std::string argsname = js_namespace(program_) + service_name_ + "_" + (*f_iter)->get_name()
+                           + "_args";
 
-    std::string messageType
-      = (*f_iter)->is_oneway() ? "Thrift.MessageType.ONEWAY" : "Thrift.MessageType.CALL";
+    std::string messageType = (*f_iter)->is_oneway() ? "Thrift.MessageType.ONEWAY"
+                                                     : "Thrift.MessageType.CALL";
 
     // Serialize the request header
     if (gen_node_) {
-       f_service_ <<
-         indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name()
-                  << "', " << messageType << ", this.seqid());" << endl;
-    }
-    else {
-       f_service_ <<
-         indent() << outputVar << ".writeMessageBegin('"
-                  << (*f_iter)->get_name() << "', "
-                  << messageType << ", this.seqid);" << endl;
+      f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name()
+                 << "', " << messageType << ", this.seqid());" << endl;
+    } else {
+      f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name()
+                 << "', " << messageType << ", this.seqid);" << endl;
     }
 
-    f_service_ <<
-      indent() << "var args = new " << argsname << "();" << endl;
+    f_service_ << indent() << "var args = new " << argsname << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args." << (*fld_iter)->get_name() << " = " << (*fld_iter)->get_name() << ";" << endl;
+      f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
+                 << (*fld_iter)->get_name() << ";" << endl;
     }
 
     // Write to the stream
-    f_service_ <<
-      indent() << "args.write(" << outputVar << ");" << endl <<
-      indent() << outputVar << ".writeMessageEnd();" << endl;
+    f_service_ << indent() << "args.write(" << outputVar << ");" << endl << indent() << outputVar
+               << ".writeMessageEnd();" << endl;
 
     if (gen_node_) {
       f_service_ << indent() << "return this.output.flush();" << endl;
@@ -1414,15 +1343,15 @@ void t_js_generator::generate_service_client(t_service* tservice) {
 
     f_service_ << "};" << endl;
 
-
     if (!(*f_iter)->is_oneway()) {
-      std::string resultname = js_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result";
+      std::string resultname = js_namespace(tservice->get_program()) + service_name_ + "_"
+                               + (*f_iter)->get_name() + "_result";
 
       if (gen_node_) {
         // Open function
-        f_service_ <<
-            endl <<  js_namespace(tservice->get_program())<<service_name_ <<
-            "Client.prototype.recv_" << (*f_iter)->get_name() << " = function(input,mtype,rseqid) {" << endl;
+        f_service_ << endl << js_namespace(tservice->get_program()) << service_name_
+                   << "Client.prototype.recv_" << (*f_iter)->get_name()
+                   << " = function(input,mtype,rseqid) {" << endl;
       } else {
         t_struct noargs(program_);
 
@@ -1430,9 +1359,8 @@ void t_js_generator::generate_service_client(t_service* tservice) {
                                  string("recv_") + (*f_iter)->get_name(),
                                  &noargs);
         // Open function
-        f_service_ <<
-            endl <<  js_namespace(tservice->get_program())<<service_name_ <<
-            "Client.prototype." << function_signature(&recv_function) << " {" << endl;
+        f_service_ << endl << js_namespace(tservice->get_program()) << service_name_
+                   << "Client.prototype." << function_signature(&recv_function) << " {" << endl;
       }
 
       indent_up();
@@ -1445,73 +1373,58 @@ void t_js_generator::generate_service_client(t_service* tservice) {
       }
 
       if (gen_node_) {
-        f_service_ <<
-          indent() << "var callback = this._reqs[rseqid] || function() {};" << endl <<
-          indent() << "delete this._reqs[rseqid];" << endl;
+        f_service_ << indent() << "var callback = this._reqs[rseqid] || function() {};" << endl
+                   << indent() << "delete this._reqs[rseqid];" << endl;
       } else {
-        f_service_ <<
-          indent() << "var ret = this.input.readMessageBegin();" << endl <<
-          indent() << "var fname = ret.fname;" << endl <<
-          indent() << "var mtype = ret.mtype;" << endl <<
-          indent() << "var rseqid = ret.rseqid;" <<endl;
+        f_service_ << indent() << "var ret = this.input.readMessageBegin();" << endl << indent()
+                   << "var fname = ret.fname;" << endl << indent() << "var mtype = ret.mtype;"
+                   << endl << indent() << "var rseqid = ret.rseqid;" << endl;
       }
 
-      f_service_ <<
-          indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << endl <<
-          indent() << "  var x = new Thrift.TApplicationException();" << endl <<
-          indent() << "  x.read(" << inputVar << ");" << endl <<
-          indent() << "  " << inputVar << ".readMessageEnd();" << endl <<
-          indent() << "  " << render_recv_throw("x") << endl <<
-          indent() << "}" << endl;
-
-
-      f_service_ <<
-        indent() << "var result = new " << resultname << "();" << endl <<
-        indent() << "result.read(" << inputVar << ");" << endl;
-
+      f_service_ << indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << endl << indent()
+                 << "  var x = new Thrift.TApplicationException();" << endl << indent()
+                 << "  x.read(" << inputVar << ");" << endl << indent() << "  " << inputVar
+                 << ".readMessageEnd();" << endl << indent() << "  " << render_recv_throw("x")
+                 << endl << indent() << "}" << endl;
 
-      f_service_ <<
-        indent() << inputVar << ".readMessageEnd();" << endl <<
-        endl;
+      f_service_ << indent() << "var result = new " << resultname << "();" << endl << indent()
+                 << "result.read(" << inputVar << ");" << endl;
 
+      f_service_ << indent() << inputVar << ".readMessageEnd();" << endl << endl;
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << endl <<
-          indent() << "  " << render_recv_throw("result." + (*x_iter)->get_name()) << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << endl
+                   << indent() << "  " << render_recv_throw("result." + (*x_iter)->get_name())
+                   << endl << indent() << "}" << endl;
       }
 
       // Careful, only return result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if (null !== result.success) {" << endl <<
-          indent() << "  " << render_recv_return("result.success") << endl <<
-          indent() << "}" << endl;
-        f_service_ <<
-          indent() << render_recv_throw("'" + (*f_iter)->get_name() + " failed: unknown result'") << endl;
+        f_service_ << indent() << "if (null !== result.success) {" << endl << indent() << "  "
+                   << render_recv_return("result.success") << endl << indent() << "}" << endl;
+        f_service_ << indent()
+                   << render_recv_throw("'" + (*f_iter)->get_name() + " failed: unknown result'")
+                   << endl;
       } else {
-          if (gen_node_) {
-            indent(f_service_) << "callback(null)" << endl;
-          } else {
-            indent(f_service_) << "return;" << endl;
-          }
+        if (gen_node_) {
+          indent(f_service_) << "callback(null)" << endl;
+        } else {
+          indent(f_service_) << "return;" << endl;
+        }
       }
 
       // Close function
       indent_down();
-      f_service_ << "};"<<endl;
-
+      f_service_ << "};" << endl;
     }
   }
 
   if (gen_ts_) {
-    f_service_ts_ << ts_indent() << "}" <<  endl;
+    f_service_ts_ << ts_indent() << "}" << endl;
   }
-
 }
 
 std::string t_js_generator::render_recv_throw(std::string var) {
@@ -1533,24 +1446,21 @@ std::string t_js_generator::render_recv_return(std::string var) {
 /**
  * Deserializes a field of any type.
  */
-void t_js_generator::generate_deserialize_field(ofstream &out,
-                                                  t_field* tfield,
-                                                  string prefix,
-                                                  bool inclass) {
-  (void) inclass;
+void t_js_generator::generate_deserialize_field(ofstream& out,
+                                                t_field* tfield,
+                                                string prefix,
+                                                bool inclass) {
+  (void)inclass;
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
-  string name = prefix+tfield->get_name();
+  string name = prefix + tfield->get_name();
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                 name);
+    generate_deserialize_struct(out, (t_struct*)type, name);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
@@ -1560,8 +1470,7 @@ void t_js_generator::generate_deserialize_field(ofstream &out,
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << (((t_base_type*)type)->is_binary() ? "readBinary()" : "readString()");
@@ -1592,13 +1501,14 @@ void t_js_generator::generate_deserialize_field(ofstream &out,
     }
 
     if (!gen_node_) {
-        out << ".value";
+      out << ".value";
     }
 
     out << ";" << endl;
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type->get_name().c_str());
+           tfield->get_name().c_str(),
+           type->get_name().c_str());
   }
 }
 
@@ -1608,18 +1518,12 @@ void t_js_generator::generate_deserialize_field(ofstream &out,
  * buffer for deserialization, and that there is a variable protocol which
  * is a reference to a TProtocol serialization object.
  */
-void t_js_generator::generate_deserialize_struct(ofstream &out,
-                                                   t_struct* tstruct,
-                                                   string prefix) {
-    out <<
-        indent() << prefix << " = new " <<  js_type_namespace(tstruct->get_program())<<tstruct->get_name() << "();" << endl <<
-        indent() << prefix << ".read(input);" << endl;
-
+void t_js_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  out << indent() << prefix << " = new " << js_type_namespace(tstruct->get_program())
+      << tstruct->get_name() << "();" << endl << indent() << prefix << ".read(input);" << endl;
 }
 
-void t_js_generator::generate_deserialize_container(ofstream &out,
-                                                      t_type* ttype,
-                                                      string prefix) {
+void t_js_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
   string size = tmp("_size");
   string ktype = tmp("_ktype");
   string vtype = tmp("_vtype");
@@ -1634,55 +1538,41 @@ void t_js_generator::generate_deserialize_container(ofstream &out,
   out << indent() << "var " << size << " = 0;" << endl;
   out << indent() << "var " << rtmp3 << ";" << endl;
 
-
   // Declare variables, read header
   if (ttype->is_map()) {
-      out <<
-          indent() << prefix << " = {};" << endl <<
-          indent() << "var " << ktype << " = 0;" << endl <<
-          indent() << "var " << vtype << " = 0;" << endl;
-
-      out << indent() << rtmp3 << " = input.readMapBegin();" << endl;
-      out << indent() << ktype << " = " << rtmp3 << ".ktype;" << endl;
-      out << indent() << vtype << " = " << rtmp3 << ".vtype;" << endl;
-      out << indent() << size  << " = " << rtmp3 << ".size;" << endl;
+    out << indent() << prefix << " = {};" << endl << indent() << "var " << ktype << " = 0;" << endl
+        << indent() << "var " << vtype << " = 0;" << endl;
 
+    out << indent() << rtmp3 << " = input.readMapBegin();" << endl;
+    out << indent() << ktype << " = " << rtmp3 << ".ktype;" << endl;
+    out << indent() << vtype << " = " << rtmp3 << ".vtype;" << endl;
+    out << indent() << size << " = " << rtmp3 << ".size;" << endl;
 
   } else if (ttype->is_set()) {
 
-    out <<
-        indent() << prefix << " = [];" << endl <<
-        indent() << "var " << etype << " = 0;" << endl <<
-        indent() << rtmp3 << " = input.readSetBegin();" << endl <<
-        indent() << etype << " = " << rtmp3 << ".etype;"<<endl<<
-        indent() << size << " = " << rtmp3 << ".size;"<<endl;
+    out << indent() << prefix << " = [];" << endl << indent() << "var " << etype << " = 0;" << endl
+        << indent() << rtmp3 << " = input.readSetBegin();" << endl << indent() << etype << " = "
+        << rtmp3 << ".etype;" << endl << indent() << size << " = " << rtmp3 << ".size;" << endl;
 
   } else if (ttype->is_list()) {
 
-    out <<
-        indent() << prefix << " = [];" << endl <<
-        indent() << "var " << etype << " = 0;" << endl <<
-        indent() << rtmp3 << " = input.readListBegin();" << endl <<
-        indent() << etype << " = " << rtmp3 << ".etype;"<<endl<<
-        indent() << size << " = " << rtmp3 << ".size;"<<endl;
+    out << indent() << prefix << " = [];" << endl << indent() << "var " << etype << " = 0;" << endl
+        << indent() << rtmp3 << " = input.readListBegin();" << endl << indent() << etype << " = "
+        << rtmp3 << ".etype;" << endl << indent() << size << " = " << rtmp3 << ".size;" << endl;
   }
 
   // For loop iterates over elements
   string i = tmp("_i");
-  indent(out) <<
-    "for (var " <<
-    i << " = 0; " << i << " < " << size << "; ++" << i << ")" << endl;
+  indent(out) << "for (var " << i << " = 0; " << i << " < " << size << "; ++" << i << ")" << endl;
 
   scope_up(out);
 
   if (ttype->is_map()) {
     if (!gen_node_) {
-      out <<
-      indent() << "if (" << i << " > 0 ) {" << endl <<
-      indent() << "  if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << endl <<
-      indent() << "    input.rstack.pop();" << endl <<
-      indent() << "  }" << endl <<
-      indent() << "}" << endl;
+      out << indent() << "if (" << i << " > 0 ) {" << endl << indent()
+          << "  if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << endl
+          << indent() << "    input.rstack.pop();" << endl << indent() << "  }" << endl << indent()
+          << "}" << endl;
     }
 
     generate_deserialize_map_element(out, (t_map*)ttype, prefix);
@@ -1694,7 +1584,6 @@ void t_js_generator::generate_deserialize_container(ofstream &out,
 
   scope_down(out);
 
-
   // Read container end
   if (ttype->is_map()) {
     indent(out) << "input.readMapEnd();" << endl;
@@ -1705,92 +1594,72 @@ void t_js_generator::generate_deserialize_container(ofstream &out,
   }
 }
 
-
 /**
  * Generates code to deserialize a map
  */
-void t_js_generator::generate_deserialize_map_element(ofstream &out,
-                                                        t_map* tmap,
-                                                        string prefix) {
+void t_js_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
   string key = tmp("key");
   string val = tmp("val");
   t_field fkey(tmap->get_key_type(), key);
   t_field fval(tmap->get_val_type(), val);
 
-  indent(out) <<
-    declare_field(&fkey, false, false) << ";" << endl;
-  indent(out) <<
-    declare_field(&fval, false, false) << ";" << endl;
+  indent(out) << declare_field(&fkey, false, false) << ";" << endl;
+  indent(out) << declare_field(&fval, false, false) << ";" << endl;
 
   generate_deserialize_field(out, &fkey);
   generate_deserialize_field(out, &fval);
 
-  indent(out) <<
-      prefix << "[" << key << "] = " << val << ";" << endl;
+  indent(out) << prefix << "[" << key << "] = " << val << ";" << endl;
 }
 
-void t_js_generator::generate_deserialize_set_element(ofstream &out,
-                                                        t_set* tset,
-                                                        string prefix) {
+void t_js_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
   string elem = tmp("elem");
   t_field felem(tset->get_elem_type(), elem);
 
-  indent(out) <<
-    "var " << elem << " = null;" << endl;
+  indent(out) << "var " << elem << " = null;" << endl;
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-      prefix << ".push(" << elem << ");" << endl;
+  indent(out) << prefix << ".push(" << elem << ");" << endl;
 }
 
-void t_js_generator::generate_deserialize_list_element(ofstream &out,
-                                                         t_list* tlist,
-                                                         string prefix) {
+void t_js_generator::generate_deserialize_list_element(ofstream& out,
+                                                       t_list* tlist,
+                                                       string prefix) {
   string elem = tmp("elem");
   t_field felem(tlist->get_elem_type(), elem);
 
-  indent(out) <<
-    "var " << elem << " = null;" << endl;
+  indent(out) << "var " << elem << " = null;" << endl;
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-      prefix << ".push(" << elem << ");" << endl;
+  indent(out) << prefix << ".push(" << elem << ");" << endl;
 }
 
-
 /**
  * Serializes a field of any type.
  *
  * @param tfield The field to serialize
  * @param prefix Name to prepend to field name
  */
-void t_js_generator::generate_serialize_field(ofstream &out,
-                                                t_field* tfield,
-                                                string prefix) {
+void t_js_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
 
   // Do nothing for void types
   if (type->is_void()) {
-    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_serialize_struct(out,
-                              (t_struct*)type,
-                               prefix +tfield->get_name() );
+    generate_serialize_struct(out, (t_struct*)type, prefix + tfield->get_name());
   } else if (type->is_container()) {
-    generate_serialize_container(out,
-                                 type,
-                                 prefix + tfield->get_name());
+    generate_serialize_container(out, type, prefix + tfield->get_name());
   } else if (type->is_base_type() || type->is_enum()) {
 
     string name = tfield->get_name();
 
-    //Hack for when prefix is defined (always a hash ref)
-    if(!prefix.empty())
+    // Hack for when prefix is defined (always a hash ref)
+    if (!prefix.empty())
       name = prefix + tfield->get_name();
 
     indent(out) << "output.";
@@ -1799,8 +1668,7 @@ void t_js_generator::generate_serialize_field(ofstream &out,
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << (((t_base_type*)type)->is_binary() ? "writeBinary(" : "writeString(") << name << ")";
@@ -1845,88 +1713,70 @@ void t_js_generator::generate_serialize_field(ofstream &out,
  * @param tstruct The struct to serialize
  * @param prefix  String prefix to attach to all fields
  */
-void t_js_generator::generate_serialize_struct(ofstream &out,
-                                                 t_struct* tstruct,
-                                                 string prefix) {
-  (void) tstruct;
+void t_js_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  (void)tstruct;
   indent(out) << prefix << ".write(output);" << endl;
 }
 
 /**
  * Writes out a container
  */
-void t_js_generator::generate_serialize_container(ofstream &out,
-                                                    t_type* ttype,
-                                                    string prefix) {
+void t_js_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   if (ttype->is_map()) {
-    indent(out) <<
-        "output.writeMapBegin(" <<
-        type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
-        type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
-        "Thrift.objectLength(" << prefix << "));" << endl;
+    indent(out) << "output.writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
+                << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
+                << "Thrift.objectLength(" << prefix << "));" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "output.writeSetBegin(" <<
-      type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
-        prefix << ".length);" << endl;
+    indent(out) << "output.writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
+                << prefix << ".length);" << endl;
 
   } else if (ttype->is_list()) {
 
-    indent(out) <<
-        "output.writeListBegin(" <<
-        type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
-        prefix << ".length);" << endl;
-
+    indent(out) << "output.writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
+                << ", " << prefix << ".length);" << endl;
   }
 
   if (ttype->is_map()) {
     string kiter = tmp("kiter");
     string viter = tmp("viter");
-    indent(out) << "for (var "<<kiter<<" in "<<prefix<<")" << endl;
+    indent(out) << "for (var " << kiter << " in " << prefix << ")" << endl;
     scope_up(out);
-    indent(out) << "if ("<<prefix<<".hasOwnProperty("<<kiter<<"))" <<endl;
+    indent(out) << "if (" << prefix << ".hasOwnProperty(" << kiter << "))" << endl;
     scope_up(out);
-    indent(out) << "var "<<viter<<" = "<<prefix<<"["<<kiter<<"];"<<endl;
+    indent(out) << "var " << viter << " = " << prefix << "[" << kiter << "];" << endl;
     generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
     scope_down(out);
     scope_down(out);
 
-
   } else if (ttype->is_set()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "for (var "<<iter<<" in " << prefix << ")" << endl;
+    indent(out) << "for (var " << iter << " in " << prefix << ")" << endl;
     scope_up(out);
-    indent(out) << "if ("<<prefix<<".hasOwnProperty("<<iter<<"))" <<endl;
+    indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << "))" << endl;
     scope_up(out);
-    indent(out) << iter << " = " << prefix << "[" << iter << "];"<< endl;
+    indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl;
     generate_serialize_set_element(out, (t_set*)ttype, iter);
     scope_down(out);
     scope_down(out);
 
-
   } else if (ttype->is_list()) {
     string iter = tmp("iter");
-    indent(out) <<
-        "for (var "<<iter<<" in "<< prefix << ")" << endl;
+    indent(out) << "for (var " << iter << " in " << prefix << ")" << endl;
     scope_up(out);
-    indent(out) << "if ("<<prefix<<".hasOwnProperty("<<iter<<"))" <<endl;
+    indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << "))" << endl;
     scope_up(out);
-    indent(out) << iter << " = " << prefix << "[" << iter << "];"<< endl;
+    indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl;
     generate_serialize_list_element(out, (t_list*)ttype, iter);
     scope_down(out);
     scope_down(out);
   }
 
   if (ttype->is_map()) {
-    indent(out) <<
-      "output.writeMapEnd();" << endl;
+    indent(out) << "output.writeMapEnd();" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "output.writeSetEnd();" << endl;
+    indent(out) << "output.writeSetEnd();" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "output.writeListEnd();" << endl;
+    indent(out) << "output.writeListEnd();" << endl;
   }
 }
 
@@ -1934,10 +1784,10 @@ void t_js_generator::generate_serialize_container(ofstream &out,
  * Serializes the members of a map.
  *
  */
-void t_js_generator::generate_serialize_map_element(ofstream &out,
-                                                      t_map* tmap,
-                                                      string kiter,
-                                                      string viter) {
+void t_js_generator::generate_serialize_map_element(ofstream& out,
+                                                    t_map* tmap,
+                                                    string kiter,
+                                                    string viter) {
   t_field kfield(tmap->get_key_type(), kiter);
   generate_serialize_field(out, &kfield);
 
@@ -1948,9 +1798,7 @@ void t_js_generator::generate_serialize_map_element(ofstream &out,
 /**
  * Serializes the members of a set.
  */
-void t_js_generator::generate_serialize_set_element(ofstream &out,
-                                                      t

<TRUNCATED>

[08/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TNonblockingServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index 532d4ae..7853d54 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -39,9 +39,9 @@
 #endif
 #include <event.h>
 
-
-
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::transport::TMemoryBuffer;
 using apache::thrift::transport::TSocket;
@@ -63,27 +63,28 @@ using apache::thrift::concurrency::Guard;
 #define LIBEVENT_VERSION_MAJOR 1
 #define LIBEVENT_VERSION_MINOR 14
 #define LIBEVENT_VERSION_REL 13
-#define LIBEVENT_VERSION_NUMBER ((LIBEVENT_VERSION_MAJOR << 24) | (LIBEVENT_VERSION_MINOR << 16) | (LIBEVENT_VERSION_REL << 8))
+#define LIBEVENT_VERSION_NUMBER                                                                    \
+  ((LIBEVENT_VERSION_MAJOR << 24) | (LIBEVENT_VERSION_MINOR << 16) | (LIBEVENT_VERSION_REL << 8))
 #endif
 
 #if LIBEVENT_VERSION_NUMBER < 0x02000000
- typedef THRIFT_SOCKET evutil_socket_t;
+typedef THRIFT_SOCKET evutil_socket_t;
 #endif
 
 #ifndef SOCKOPT_CAST_T
-#   ifndef _WIN32
-#       define SOCKOPT_CAST_T void
-#   else
-#       define SOCKOPT_CAST_T char
-#   endif // _WIN32
+#ifndef _WIN32
+#define SOCKOPT_CAST_T void
+#else
+#define SOCKOPT_CAST_T char
+#endif // _WIN32
 #endif
 
-template<class T>
+template <class T>
 inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) {
   return reinterpret_cast<const SOCKOPT_CAST_T*>(v);
 }
 
-template<class T>
+template <class T>
 inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
   return reinterpret_cast<SOCKOPT_CAST_T*>(v);
 }
@@ -99,22 +100,22 @@ inline SOCKOPT_CAST_T* cast_sockopt(T* v) {
  *
  */
 
-
 /// Overload condition actions.
 enum TOverloadAction {
-  T_OVERLOAD_NO_ACTION,        ///< Don't handle overload */
-  T_OVERLOAD_CLOSE_ON_ACCEPT,  ///< Drop new connections immediately */
-  T_OVERLOAD_DRAIN_TASK_QUEUE  ///< Drop some tasks from head of task queue */
+  T_OVERLOAD_NO_ACTION,       ///< Don't handle overload */
+  T_OVERLOAD_CLOSE_ON_ACCEPT, ///< Drop new connections immediately */
+  T_OVERLOAD_DRAIN_TASK_QUEUE ///< Drop some tasks from head of task queue */
 };
 
 class TNonblockingIOThread;
 
 class TNonblockingServer : public TServer {
- private:
+private:
   class TConnection;
 
   friend class TNonblockingIOThread;
- private:
+
+private:
   /// Listen backlog
   static const int LISTEN_BACKLOG = 1024;
 
@@ -299,33 +300,31 @@ class TNonblockingServer : public TServer {
     nTotalConnectionsDropped_ = 0;
   }
 
- public:
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      int port,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+public:
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     int port,
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
     init(port);
   }
 
-  template<typename Processor>
+  template <typename Processor>
   TNonblockingServer(const boost::shared_ptr<Processor>& processor,
                      int port,
-                     THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
     init(port);
   }
 
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
 
     init(port);
 
@@ -334,15 +333,14 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename Processor>
-  TNonblockingServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+  template <typename Processor>
+  TNonblockingServer(const boost::shared_ptr<Processor>& processor,
+                     const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
 
     init(port);
 
@@ -351,18 +349,17 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename ProcessorFactory>
-  TNonblockingServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory) {
+  template <typename ProcessorFactory>
+  TNonblockingServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                     const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                     const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                     const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                     const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory) {
 
     init(port);
 
@@ -373,18 +370,17 @@ class TNonblockingServer : public TServer {
     setThreadManager(threadManager);
   }
 
-  template<typename Processor>
-  TNonblockingServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      int port,
-      const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>(),
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor) {
+  template <typename Processor>
+  TNonblockingServer(const boost::shared_ptr<Processor>& processor,
+                     const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                     const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                     const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                     const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                     int port,
+                     const boost::shared_ptr<ThreadManager>& threadManager
+                     = boost::shared_ptr<ThreadManager>(),
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor) {
 
     init(port);
 
@@ -399,9 +395,7 @@ class TNonblockingServer : public TServer {
 
   void setThreadManager(boost::shared_ptr<ThreadManager> threadManager);
 
-  boost::shared_ptr<ThreadManager> getThreadManager() {
-    return threadManager_;
-  }
+  boost::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; }
 
   /**
    * Sets the number of IO threads used by this server. Can only be used before
@@ -409,46 +403,32 @@ class TNonblockingServer : public TServer {
    * PosixThreadFactory for the IO worker threads, because they must joinable
    * for clean shutdown.
    */
-  void setNumIOThreads(size_t numThreads) {
-    numIOThreads_ = numThreads;
-  }
+  void setNumIOThreads(size_t numThreads) { numIOThreads_ = numThreads; }
 
   /** Return whether the IO threads will get high scheduling priority */
-  bool useHighPriorityIOThreads() const {
-    return useHighPriorityIOThreads_;
-  }
+  bool useHighPriorityIOThreads() const { return useHighPriorityIOThreads_; }
 
   /** Set whether the IO threads will get high scheduling priority. */
-  void setUseHighPriorityIOThreads(bool val) {
-    useHighPriorityIOThreads_ = val;
-  }
+  void setUseHighPriorityIOThreads(bool val) { useHighPriorityIOThreads_ = val; }
 
   /** Return the number of IO threads used by this server. */
-  size_t getNumIOThreads() const {
-    return numIOThreads_;
-  }
+  size_t getNumIOThreads() const { return numIOThreads_; }
 
   /**
    * Get the maximum number of unused TConnection we will hold in reserve.
    *
    * @return the current limit on TConnection pool size.
    */
-  size_t getConnectionStackLimit() const {
-    return connectionStackLimit_;
-  }
+  size_t getConnectionStackLimit() const { return connectionStackLimit_; }
 
   /**
    * Set the maximum number of unused TConnection we will hold in reserve.
    *
    * @param sz the new limit for TConnection pool size.
    */
-  void setConnectionStackLimit(size_t sz) {
-    connectionStackLimit_ = sz;
-  }
+  void setConnectionStackLimit(size_t sz) { connectionStackLimit_ = sz; }
 
-  bool isThreadPoolProcessing() const {
-    return threadPoolProcessing_;
-  }
+  bool isThreadPoolProcessing() const { return threadPoolProcessing_; }
 
   void addTask(boost::shared_ptr<Runnable> task) {
     threadManager_->add(task, 0LL, taskExpireTime_);
@@ -459,27 +439,21 @@ class TNonblockingServer : public TServer {
    *
    * @return count of connected sockets.
    */
-  size_t getNumConnections() const {
-    return numTConnections_;
-  }
+  size_t getNumConnections() const { return numTConnections_; }
 
   /**
    * Return the count of sockets currently connected to.
    *
    * @return count of connected sockets.
    */
-  size_t getNumActiveConnections() const {
-    return getNumConnections() - getNumIdleConnections();
-  }
+  size_t getNumActiveConnections() const { return getNumConnections() - getNumIdleConnections(); }
 
   /**
    * Return the count of connection objects allocated but not in use.
    *
    * @return count of idle connection objects.
    */
-  size_t getNumIdleConnections() const {
-    return connectionStack_.size();
-  }
+  size_t getNumIdleConnections() const { return connectionStack_.size(); }
 
   /**
    * Return count of number of connections which are currently processing.
@@ -489,9 +463,7 @@ class TNonblockingServer : public TServer {
    *
    * @return # of connections currently processing.
    */
-  size_t getNumActiveProcessors() const {
-    return numActiveProcessors_;
-  }
+  size_t getNumActiveProcessors() const { return numActiveProcessors_; }
 
   /// Increment the count of connections currently processing.
   void incrementActiveProcessors() {
@@ -512,27 +484,21 @@ class TNonblockingServer : public TServer {
    *
    * @return current setting.
    */
-  size_t getMaxConnections() const {
-    return maxConnections_;
-  }
+  size_t getMaxConnections() const { return maxConnections_; }
 
   /**
    * Set the maximum # of connections allowed before overload.
    *
    * @param maxConnections new setting for maximum # of connections.
    */
-  void setMaxConnections(size_t maxConnections) {
-    maxConnections_ = maxConnections;
-  }
+  void setMaxConnections(size_t maxConnections) { maxConnections_ = maxConnections; }
 
   /**
    * Get the maximum # of connections waiting in handler/task before overload.
    *
    * @return current setting.
    */
-  size_t getMaxActiveProcessors() const {
-    return maxActiveProcessors_;
-  }
+  size_t getMaxActiveProcessors() const { return maxActiveProcessors_; }
 
   /**
    * Set the maximum # of connections waiting in handler/task before overload.
@@ -551,27 +517,21 @@ class TNonblockingServer : public TServer {
    *
    * @return Maxium frame size, in bytes.
    */
-  size_t getMaxFrameSize() const {
-    return maxFrameSize_;
-  }
+  size_t getMaxFrameSize() const { return maxFrameSize_; }
 
   /**
    * Set the maximum allowed frame size.
    *
    * @param maxFrameSize The new maximum frame size.
    */
-  void setMaxFrameSize(size_t maxFrameSize) {
-    maxFrameSize_ = maxFrameSize;
-  }
+  void setMaxFrameSize(size_t maxFrameSize) { maxFrameSize_ = maxFrameSize; }
 
   /**
    * Get fraction of maximum limits before an overload condition is cleared.
    *
    * @return hysteresis fraction
    */
-  double getOverloadHysteresis() const {
-    return overloadHysteresis_;
-  }
+  double getOverloadHysteresis() const { return overloadHysteresis_; }
 
   /**
    * Set fraction of maximum limits before an overload condition is cleared.
@@ -590,36 +550,28 @@ class TNonblockingServer : public TServer {
    *
    * @return a TOverloadAction enum value for the currently set action.
    */
-  TOverloadAction getOverloadAction() const {
-    return overloadAction_;
-  }
+  TOverloadAction getOverloadAction() const { return overloadAction_; }
 
   /**
    * Set the action the server is to take on overload.
    *
    * @param overloadAction a TOverloadAction enum value for the action.
    */
-  void setOverloadAction(TOverloadAction overloadAction) {
-    overloadAction_ = overloadAction;
-  }
+  void setOverloadAction(TOverloadAction overloadAction) { overloadAction_ = overloadAction; }
 
   /**
    * Get the time in milliseconds after which a task expires (0 == infinite).
    *
    * @return a 64-bit time in milliseconds.
    */
-  int64_t getTaskExpireTime() const {
-    return taskExpireTime_;
-  }
+  int64_t getTaskExpireTime() const { return taskExpireTime_; }
 
   /**
    * Set the time in milliseconds after which a task expires (0 == infinite).
    *
    * @param taskExpireTime a 64-bit time in milliseconds.
    */
-  void setTaskExpireTime(int64_t taskExpireTime) {
-    taskExpireTime_ = taskExpireTime;
-  }
+  void setTaskExpireTime(int64_t taskExpireTime) { taskExpireTime_ = taskExpireTime; }
 
   /**
    * Determine if the server is currently overloaded.
@@ -643,27 +595,21 @@ class TNonblockingServer : public TServer {
    *
    * @return # bytes we initialize a TConnection object's write buffer to.
    */
-  size_t getWriteBufferDefaultSize() const {
-    return writeBufferDefaultSize_;
-  }
+  size_t getWriteBufferDefaultSize() const { return writeBufferDefaultSize_; }
 
   /**
    * Set the starting size of a TConnection object's write buffer.
    *
    * @param size # bytes we initialize a TConnection object's write buffer to.
    */
-  void setWriteBufferDefaultSize(size_t size) {
-    writeBufferDefaultSize_ = size;
-  }
+  void setWriteBufferDefaultSize(size_t size) { writeBufferDefaultSize_ = size; }
 
   /**
    * Get the maximum size of read buffer allocated to idle TConnection objects.
    *
    * @return # bytes beyond which we will dealloc idle buffer.
    */
-  size_t getIdleReadBufferLimit() const {
-    return idleReadBufferLimit_;
-  }
+  size_t getIdleReadBufferLimit() const { return idleReadBufferLimit_; }
 
   /**
    * [NOTE: This is for backwards compatibility, use getIdleReadBufferLimit().]
@@ -671,9 +617,7 @@ class TNonblockingServer : public TServer {
    *
    * @return # bytes beyond which we will dealloc idle buffer.
    */
-  size_t getIdleBufferMemLimit() const {
-    return idleReadBufferLimit_;
-  }
+  size_t getIdleBufferMemLimit() const { return idleReadBufferLimit_; }
 
   /**
    * Set the maximum size read buffer allocated to idle TConnection objects.
@@ -684,9 +628,7 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when checked.
    */
-  void setIdleReadBufferLimit(size_t limit) {
-    idleReadBufferLimit_ = limit;
-  }
+  void setIdleReadBufferLimit(size_t limit) { idleReadBufferLimit_ = limit; }
 
   /**
    * [NOTE: This is for backwards compatibility, use setIdleReadBufferLimit().]
@@ -698,20 +640,14 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when checked.
    */
-  void setIdleBufferMemLimit(size_t limit) {
-    idleReadBufferLimit_ = limit;
-  }
-
-
+  void setIdleBufferMemLimit(size_t limit) { idleReadBufferLimit_ = limit; }
 
   /**
    * Get the maximum size of write buffer allocated to idle TConnection objects.
    *
    * @return # bytes beyond which we will reallocate buffers when checked.
    */
-  size_t getIdleWriteBufferLimit() const {
-    return idleWriteBufferLimit_;
-  }
+  size_t getIdleWriteBufferLimit() const { return idleWriteBufferLimit_; }
 
   /**
    * Set the maximum size write buffer allocated to idle TConnection objects.
@@ -722,18 +658,14 @@ class TNonblockingServer : public TServer {
    *
    * @param limit of bytes beyond which we will shrink buffers when idle.
    */
-  void setIdleWriteBufferLimit(size_t limit) {
-    idleWriteBufferLimit_ = limit;
-  }
+  void setIdleWriteBufferLimit(size_t limit) { idleWriteBufferLimit_ = limit; }
 
   /**
    * Get # of calls made between buffer size checks.  0 means disabled.
    *
    * @return # of calls between buffer size checks.
    */
-  int32_t getResizeBufferEveryN() const {
-    return resizeBufferEveryN_;
-  }
+  int32_t getResizeBufferEveryN() const { return resizeBufferEveryN_; }
 
   /**
    * Check buffer sizes every "count" calls.  This allows buffer limits
@@ -742,9 +674,7 @@ class TNonblockingServer : public TServer {
    *
    * @param count the number of calls between checks, or 0 to disable
    */
-  void setResizeBufferEveryN(int32_t count) {
-    resizeBufferEveryN_ = count;
-  }
+  void setResizeBufferEveryN(int32_t count) { resizeBufferEveryN_ = count; }
 
   /**
    * Main workhorse function, starts up the server listening on a port and
@@ -784,7 +714,7 @@ class TNonblockingServer : public TServer {
    */
   event_base* getUserEventBase() const { return userEventBase_; }
 
- private:
+private:
   /**
    * Callback function that the threadmanager calls when a task reaches
    * its expiration time.  It is needed to clean up the expired connection.
@@ -803,8 +733,7 @@ class TNonblockingServer : public TServer {
    * @param addrLen the length of addr
    * @return pointer to initialized TConnection object.
    */
-  TConnection* createConnection(THRIFT_SOCKET socket, const sockaddr* addr,
-                                            socklen_t addrLen);
+  TConnection* createConnection(THRIFT_SOCKET socket, const sockaddr* addr, socklen_t addrLen);
 
   /**
    * Returns a connection to pool or deletion.  If the connection pool
@@ -817,7 +746,7 @@ class TNonblockingServer : public TServer {
 };
 
 class TNonblockingIOThread : public Runnable {
- public:
+public:
   // Creates an IO thread and sets up the event base.  The listenSocket should
   // be a valid FD on which listen() has already been called.  If the
   // listenSocket is < 0, accepting will not be done.
@@ -868,7 +797,7 @@ class TNonblockingIOThread : public Runnable {
   /// Registers the events for the notification & listen sockets
   void registerEvents();
 
- private:
+private:
   /**
    * C-callable event handler for signaling task completion.  Provides a
    * callback that libevent can understand that will read a connection
@@ -903,7 +832,7 @@ class TNonblockingIOThread : public Runnable {
   /// Sets (or clears) high priority scheduling status for the current thread.
   void setCurrentThreadHighPriority(bool value);
 
- private:
+private:
   /// associated server
   TNonblockingServer* server_;
 
@@ -932,13 +861,14 @@ class TNonblockingIOThread : public Runnable {
   /// Used with eventBase_ for task completion notification
   struct event notificationEvent_;
 
- /// File descriptors for pipe used for task completion notification.
+  /// File descriptors for pipe used for task completion notification.
   evutil_socket_t notificationPipeFDs_[2];
 
   /// Actual IO Thread
   boost::shared_ptr<Thread> thread_;
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TNONBLOCKINGSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TServer.cpp b/lib/cpp/src/thrift/server/TServer.cpp
old mode 100755
new mode 100644
index 5e82ce6..df731c2
--- a/lib/cpp/src/thrift/server/TServer.cpp
+++ b/lib/cpp/src/thrift/server/TServer.cpp
@@ -30,20 +30,23 @@
 #include <unistd.h>
 #endif
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 #ifdef HAVE_SYS_RESOURCE_H
-int increase_max_fds(int max_fds=(1<<24))  {
+int increase_max_fds(int max_fds = (1 << 24)) {
   struct rlimit fdmaxrl;
 
-  for(fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
-      max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
-      fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
+  for (fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds;
+       max_fds && (setrlimit(RLIMIT_NOFILE, &fdmaxrl) < 0);
+       fdmaxrl.rlim_cur = max_fds, fdmaxrl.rlim_max = max_fds) {
     max_fds /= 2;
   }
 
   return static_cast<int>(fdmaxrl.rlim_cur);
 }
 #endif
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TServer.h b/lib/cpp/src/thrift/server/TServer.h
index 7f718da..c0b222f 100644
--- a/lib/cpp/src/thrift/server/TServer.h
+++ b/lib/cpp/src/thrift/server/TServer.h
@@ -27,7 +27,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::TProcessor;
 using apache::thrift::protocol::TBinaryProtocolFactory;
@@ -45,8 +47,7 @@ using apache::thrift::transport::TTransportFactory;
  * instance's state).
  */
 class TServerEventHandler {
- public:
-
+public:
   virtual ~TServerEventHandler() {}
 
   /**
@@ -69,8 +70,8 @@ class TServerEventHandler {
    * context.
    */
   virtual void deleteContext(void* serverContext,
-                             boost::shared_ptr<TProtocol>input,
-                             boost::shared_ptr<TProtocol>output) {
+                             boost::shared_ptr<TProtocol> input,
+                             boost::shared_ptr<TProtocol> output) {
     (void)serverContext;
     (void)input;
     (void)output;
@@ -79,19 +80,16 @@ class TServerEventHandler {
   /**
    * Called when a client is about to call the processor.
    */
-  virtual void processContext(void* serverContext,
-                              boost::shared_ptr<TTransport> transport) {
+  virtual void processContext(void* serverContext, boost::shared_ptr<TTransport> transport) {
     (void)serverContext;
     (void)transport;
-}
-
- protected:
+  }
 
+protected:
   /**
    * Prevent direct instantiation.
    */
   TServerEventHandler() {}
-
 };
 
 /**
@@ -99,8 +97,7 @@ class TServerEventHandler {
  *
  */
 class TServer : public concurrency::Runnable {
- public:
-
+public:
   virtual ~TServer() {}
 
   virtual void serve() = 0;
@@ -108,146 +105,122 @@ class TServer : public concurrency::Runnable {
   virtual void stop() {}
 
   // Allows running the server as a Runnable thread
-  virtual void run() {
-    serve();
-  }
+  virtual void run() { serve(); }
 
-  boost::shared_ptr<TProcessorFactory> getProcessorFactory() {
-    return processorFactory_;
-  }
+  boost::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; }
 
-  boost::shared_ptr<TServerTransport> getServerTransport() {
-    return serverTransport_;
-  }
+  boost::shared_ptr<TServerTransport> getServerTransport() { return serverTransport_; }
 
-  boost::shared_ptr<TTransportFactory> getInputTransportFactory() {
-    return inputTransportFactory_;
-  }
+  boost::shared_ptr<TTransportFactory> getInputTransportFactory() { return inputTransportFactory_; }
 
   boost::shared_ptr<TTransportFactory> getOutputTransportFactory() {
     return outputTransportFactory_;
   }
 
-  boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() {
-    return inputProtocolFactory_;
-  }
+  boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() { return inputProtocolFactory_; }
 
-  boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
-    return outputProtocolFactory_;
-  }
+  boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { return outputProtocolFactory_; }
 
-  boost::shared_ptr<TServerEventHandler> getEventHandler() {
-    return eventHandler_;
-  }
+  boost::shared_ptr<TServerEventHandler> getEventHandler() { return eventHandler_; }
 
 protected:
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory) {
-    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
-    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename Processor>
-  TServer(const boost::shared_ptr<Processor>& processor,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)) {
+  template <typename Processor>
+  TServer(const boost::shared_ptr<Processor>& processor, THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)) {
     setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
     setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport) {
-    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(
-          new TTransportFactory()));
-    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
-    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(
-          new TBinaryProtocolFactory()));
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory), serverTransport_(serverTransport) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename Processor>
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport) {
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport) {
     setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
     setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
     setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
   }
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& transportFactory,
           const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(transportFactory),
-    outputTransportFactory_(transportFactory),
-    inputProtocolFactory_(protocolFactory),
-    outputProtocolFactory_(protocolFactory) {}
-
-  template<typename Processor>
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(transportFactory),
+      outputTransportFactory_(transportFactory),
+      inputProtocolFactory_(protocolFactory),
+      outputProtocolFactory_(protocolFactory) {}
+
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& transportFactory,
           const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(transportFactory),
-    outputTransportFactory_(transportFactory),
-    inputProtocolFactory_(protocolFactory),
-    outputProtocolFactory_(protocolFactory) {}
-
-  template<typename ProcessorFactory>
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(transportFactory),
+      outputTransportFactory_(transportFactory),
+      inputProtocolFactory_(protocolFactory),
+      outputProtocolFactory_(protocolFactory) {}
+
+  template <typename ProcessorFactory>
   TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
           const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
           const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
           const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)):
-    processorFactory_(processorFactory),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(inputTransportFactory),
-    outputTransportFactory_(outputTransportFactory),
-    inputProtocolFactory_(inputProtocolFactory),
-    outputProtocolFactory_(outputProtocolFactory) {}
-
-  template<typename Processor>
+          THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : processorFactory_(processorFactory),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(inputTransportFactory),
+      outputTransportFactory_(outputTransportFactory),
+      inputProtocolFactory_(inputProtocolFactory),
+      outputProtocolFactory_(outputProtocolFactory) {}
+
+  template <typename Processor>
   TServer(const boost::shared_ptr<Processor>& processor,
           const boost::shared_ptr<TServerTransport>& serverTransport,
           const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
           const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
           const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
           const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-          THRIFT_OVERLOAD_IF(Processor, TProcessor)):
-    processorFactory_(new TSingletonProcessorFactory(processor)),
-    serverTransport_(serverTransport),
-    inputTransportFactory_(inputTransportFactory),
-    outputTransportFactory_(outputTransportFactory),
-    inputProtocolFactory_(inputProtocolFactory),
-    outputProtocolFactory_(outputProtocolFactory) {}
+          THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : processorFactory_(new TSingletonProcessorFactory(processor)),
+      serverTransport_(serverTransport),
+      inputTransportFactory_(inputTransportFactory),
+      outputTransportFactory_(outputTransportFactory),
+      inputProtocolFactory_(inputProtocolFactory),
+      outputProtocolFactory_(outputProtocolFactory) {}
 
   /**
    * Get a TProcessor to handle calls on a particular connection.
@@ -256,10 +229,9 @@ protected:
    * call).  This allows the TProcessorFactory to return a different processor
    * for each connection if it desires.
    */
-  boost::shared_ptr<TProcessor> getProcessor(
-      boost::shared_ptr<TProtocol> inputProtocol,
-      boost::shared_ptr<TProtocol> outputProtocol,
-      boost::shared_ptr<TTransport> transport) {
+  boost::shared_ptr<TProcessor> getProcessor(boost::shared_ptr<TProtocol> inputProtocol,
+                                             boost::shared_ptr<TProtocol> outputProtocol,
+                                             boost::shared_ptr<TTransport> transport) {
     TConnectionInfo connInfo;
     connInfo.input = inputProtocol;
     connInfo.output = outputProtocol;
@@ -299,7 +271,6 @@ public:
   void setServerEventHandler(boost::shared_ptr<TServerEventHandler> eventHandler) {
     eventHandler_ = eventHandler;
   }
-
 };
 
 /**
@@ -308,9 +279,10 @@ public:
  * By default, tries to increase it to as much as 2^24.
  */
 #ifdef HAVE_SYS_RESOURCE_H
- int increase_max_fds(int max_fds=(1<<24));
+int increase_max_fds(int max_fds = (1 << 24));
 #endif
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TSimpleServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp
index 5fc4c97..fa6bff5 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.cpp
+++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp
@@ -22,7 +22,9 @@
 #include <string>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using namespace std;
 using namespace apache::thrift;
@@ -59,33 +61,50 @@ void TSimpleServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
-          string errStr = string("TServerTransport died on accept: ") + ttx.what();
-          GlobalOutput(errStr.c_str());
+        string errStr = string("TServerTransport died on accept: ") + ttx.what();
+        GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("Some kind of accept exception: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("Some kind of accept exception: ") + s;
       GlobalOutput(errStr.c_str());
       break;
     }
 
     // Get the processor
-    shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                    outputProtocol, client);
+    shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
     void* connectionContext = NULL;
     if (eventHandler_) {
@@ -96,9 +115,8 @@ void TSimpleServer::serve() {
         if (eventHandler_) {
           eventHandler_->processContext(connectionContext, client);
         }
-        if (!processor->process(inputProtocol, outputProtocol,
-                                connectionContext) ||
-          // Peek ahead, is the remote side closed?
+        if (!processor->process(inputProtocol, outputProtocol, connectionContext) ||
+            // Peek ahead, is the remote side closed?
             !inputProtocol->getTransport()->peek()) {
           break;
         }
@@ -107,8 +125,7 @@ void TSimpleServer::serve() {
       string errStr = string("TSimpleServer client died: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     } catch (const std::exception& x) {
-      GlobalOutput.printf("TSimpleServer exception: %s: %s",
-                          typeid(x).name(), x.what());
+      GlobalOutput.printf("TSimpleServer exception: %s: %s", typeid(x).name(), x.what());
     } catch (...) {
       GlobalOutput("TSimpleServer uncaught exception.");
     }
@@ -119,22 +136,19 @@ void TSimpleServer::serve() {
     try {
       inputTransport->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer input close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer input close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     try {
       outputTransport->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer output close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer output close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     try {
       client->close();
     } catch (const TTransportException& ttx) {
-      string errStr = string("TSimpleServer client close failed: ")
-        + ttx.what();
+      string errStr = string("TSimpleServer client close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
   }
@@ -142,12 +156,13 @@ void TSimpleServer::serve() {
   if (stop_) {
     try {
       serverTransport_->close();
-    } catch (TTransportException &ttx) {
+    } catch (TTransportException& ttx) {
       string errStr = string("TServerTransport failed on close: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TSimpleServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h
index f9e0e2b..967f834 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.h
+++ b/lib/cpp/src/thrift/server/TSimpleServer.h
@@ -23,7 +23,9 @@
 #include <thrift/server/TServer.h>
 #include <thrift/transport/TServerTransport.h>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 /**
  * This is the most basic simple server. It is single-threaded and runs a
@@ -33,55 +35,54 @@ namespace apache { namespace thrift { namespace server {
  *
  */
 class TSimpleServer : public TServer {
- public:
-  template<typename ProcessorFactory>
-  TSimpleServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport, transportFactory,
-            protocolFactory),
-    stop_(false) {}
+public:
+  template <typename ProcessorFactory>
+  TSimpleServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& transportFactory,
+                const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory, serverTransport, transportFactory, protocolFactory), stop_(false) {}
 
-  template<typename Processor>
-  TSimpleServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport, transportFactory, protocolFactory),
-    stop_(false) {}
+  template <typename Processor>
+  TSimpleServer(const boost::shared_ptr<Processor>& processor,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& transportFactory,
+                const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor, serverTransport, transportFactory, protocolFactory), stop_(false) {}
 
-  template<typename ProcessorFactory>
-  TSimpleServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    stop_(false) {}
+  template <typename ProcessorFactory>
+  TSimpleServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      stop_(false) {}
 
-  template<typename Processor>
-  TSimpleServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    stop_(false) {}
+  template <typename Processor>
+  TSimpleServer(const boost::shared_ptr<Processor>& processor,
+                const boost::shared_ptr<TServerTransport>& serverTransport,
+                const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      stop_(false) {}
 
   ~TSimpleServer() {}
 
@@ -92,11 +93,11 @@ class TSimpleServer : public TServer {
     serverTransport_->interrupt();
   }
 
- protected:
+protected:
   bool stop_;
-
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
index da33ec2..0530d8d 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
@@ -26,7 +26,9 @@
 #include <string>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using boost::shared_ptr;
 using namespace std;
@@ -38,24 +40,21 @@ using namespace apache::thrift::transport;
 class TThreadPoolServer::Task : public Runnable {
 
 public:
-
-  Task(TThreadPoolServer &server,
+  Task(TThreadPoolServer& server,
        shared_ptr<TProcessor> processor,
        shared_ptr<TProtocol> input,
        shared_ptr<TProtocol> output,
-       shared_ptr<TTransport> transport) :
-    server_(server),
-    processor_(processor),
-    input_(input),
-    output_(output),
-    transport_(transport) {
-  }
+       shared_ptr<TTransport> transport)
+    : server_(server),
+      processor_(processor),
+      input_(input),
+      output_(output),
+      transport_(transport) {}
 
   ~Task() {}
 
   void run() {
-    boost::shared_ptr<TServerEventHandler> eventHandler =
-      server_.getEventHandler();
+    boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler();
     void* connectionContext = NULL;
     if (eventHandler) {
       connectionContext = eventHandler->createContext(input_, output_);
@@ -65,8 +64,8 @@ public:
         if (eventHandler) {
           eventHandler->processContext(connectionContext, transport_);
         }
-        if (!processor_->process(input_, output_, connectionContext) ||
-            !input_->getTransport()->peek()) {
+        if (!processor_->process(input_, output_, connectionContext)
+            || !input_->getTransport()->peek()) {
           break;
         }
       }
@@ -76,11 +75,11 @@ public:
       // string errStr = string("TThreadPoolServer client died: ") + ttx.what();
       // GlobalOutput(errStr.c_str());
     } catch (const std::exception& x) {
-      GlobalOutput.printf("TThreadPoolServer exception %s: %s",
-                          typeid(x).name(), x.what());
+      GlobalOutput.printf("TThreadPoolServer exception %s: %s", typeid(x).name(), x.what());
     } catch (...) {
-      GlobalOutput("TThreadPoolServer, unexpected exception in "
-                   "TThreadPoolServer::Task::run()");
+      GlobalOutput(
+          "TThreadPoolServer, unexpected exception in "
+          "TThreadPoolServer::Task::run()");
     }
 
     if (eventHandler) {
@@ -99,10 +98,9 @@ public:
       string errStr = string("TThreadPoolServer output close failed: ") + ttx.what();
       GlobalOutput(errStr.c_str());
     }
-
   }
 
- private:
+private:
   TServer& server_;
   shared_ptr<TProcessor> processor_;
   shared_ptr<TProtocol> input_;
@@ -110,7 +108,8 @@ public:
   shared_ptr<TTransport> transport_;
 };
 
-TThreadPoolServer::~TThreadPoolServer() {}
+TThreadPoolServer::~TThreadPoolServer() {
+}
 
 void TThreadPoolServer::serve() {
   shared_ptr<TTransport> client;
@@ -144,34 +143,51 @@ void TThreadPoolServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
 
-      shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                      outputProtocol, client);
+      shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
       // Add to threadmanager pool
-      shared_ptr<TThreadPoolServer::Task> task(new TThreadPoolServer::Task(
-            *this, processor, inputProtocol, outputProtocol, client));
+      shared_ptr<TThreadPoolServer::Task> task(
+          new TThreadPoolServer::Task(*this, processor, inputProtocol, outputProtocol, client));
       threadManager_->add(task, timeout_, taskExpiration_);
 
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
         string errStr = string("TThreadPoolServer: TServerTransport died on accept: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("TThreadPoolServer: Caught TException: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = "TThreadPoolServer: Unknown exception: " + s;
       GlobalOutput(errStr.c_str());
       break;
@@ -183,13 +199,12 @@ void TThreadPoolServer::serve() {
     try {
       serverTransport_->close();
       threadManager_->join();
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadPoolServer: Exception shutting down: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
-
 }
 
 int64_t TThreadPoolServer::getTimeout() const {
@@ -207,5 +222,6 @@ int64_t TThreadPoolServer::getTaskExpiration() const {
 void TThreadPoolServer::setTaskExpiration(int64_t value) {
   taskExpiration_ = value;
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadPoolServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.h b/lib/cpp/src/thrift/server/TThreadPoolServer.h
index 8a1fc16..ad7e7ef 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.h
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.h
@@ -26,7 +26,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::concurrency::ThreadManager;
 using apache::thrift::protocol::TProtocolFactory;
@@ -34,73 +36,74 @@ using apache::thrift::transport::TServerTransport;
 using apache::thrift::transport::TTransportFactory;
 
 class TThreadPoolServer : public TServer {
- public:
+public:
   class Task;
 
-  template<typename ProcessorFactory>
-  TThreadPoolServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport, transportFactory,
-            protocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename Processor>
-  TThreadPoolServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& transportFactory,
-      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport, transportFactory, protocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename ProcessorFactory>
-  TThreadPoolServer(
-      const boost::shared_ptr<ProcessorFactory>& processorFactory,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
-    TServer(processorFactory, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
-
-  template<typename Processor>
-  TThreadPoolServer(
-      const boost::shared_ptr<Processor>& processor,
-      const boost::shared_ptr<TServerTransport>& serverTransport,
-      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
-      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
-      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
-      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
-      const boost::shared_ptr<ThreadManager>& threadManager,
-      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
-    TServer(processor, serverTransport,
-            inputTransportFactory, outputTransportFactory,
-            inputProtocolFactory, outputProtocolFactory),
-    threadManager_(threadManager),
-    stop_(false),
-    timeout_(0),
-    taskExpiration_(0) {}
+  template <typename ProcessorFactory>
+  TThreadPoolServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& transportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory, serverTransport, transportFactory, protocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename Processor>
+  TThreadPoolServer(const boost::shared_ptr<Processor>& processor,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& transportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor, serverTransport, transportFactory, protocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename ProcessorFactory>
+  TThreadPoolServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                    const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                    const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory))
+    : TServer(processorFactory,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
+
+  template <typename Processor>
+  TThreadPoolServer(const boost::shared_ptr<Processor>& processor,
+                    const boost::shared_ptr<TServerTransport>& serverTransport,
+                    const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+                    const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+                    const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+                    const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+                    const boost::shared_ptr<ThreadManager>& threadManager,
+                    THRIFT_OVERLOAD_IF(Processor, TProcessor))
+    : TServer(processor,
+              serverTransport,
+              inputTransportFactory,
+              outputTransportFactory,
+              inputProtocolFactory,
+              outputProtocolFactory),
+      threadManager_(threadManager),
+      stop_(false),
+      timeout_(0),
+      taskExpiration_(0) {}
 
   virtual ~TThreadPoolServer();
 
@@ -119,8 +122,7 @@ class TThreadPoolServer : public TServer {
 
   virtual void setTaskExpiration(int64_t value);
 
- protected:
-
+protected:
   boost::shared_ptr<ThreadManager> threadManager_;
 
   volatile bool stop_;
@@ -128,9 +130,9 @@ class TThreadPoolServer : public TServer {
   volatile int64_t timeout_;
 
   volatile int64_t taskExpiration_;
-
 };
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TTHREADPOOLSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadedServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp
index 909c3ce..929ed86 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp
@@ -28,7 +28,9 @@
 #include <unistd.h>
 #endif
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using boost::shared_ptr;
 using namespace std;
@@ -37,27 +39,24 @@ using namespace apache::thrift::protocol;
 using namespace apache::thrift::transport;
 using namespace apache::thrift::concurrency;
 
-class TThreadedServer::Task: public Runnable {
+class TThreadedServer::Task : public Runnable {
 
 public:
-
   Task(TThreadedServer& server,
        shared_ptr<TProcessor> processor,
        shared_ptr<TProtocol> input,
        shared_ptr<TProtocol> output,
-       shared_ptr<TTransport> transport) :
-    server_(server),
-    processor_(processor),
-    input_(input),
-    output_(output),
-    transport_(transport) {
-  }
+       shared_ptr<TTransport> transport)
+    : server_(server),
+      processor_(processor),
+      input_(input),
+      output_(output),
+      transport_(transport) {}
 
   ~Task() {}
 
   void run() {
-    boost::shared_ptr<TServerEventHandler> eventHandler =
-      server_.getEventHandler();
+    boost::shared_ptr<TServerEventHandler> eventHandler = server_.getEventHandler();
     void* connectionContext = NULL;
     if (eventHandler) {
       connectionContext = eventHandler->createContext(input_, output_);
@@ -67,8 +66,8 @@ public:
         if (eventHandler) {
           eventHandler->processContext(connectionContext, transport_);
         }
-        if (!processor_->process(input_, output_, connectionContext) ||
-            !input_->getTransport()->peek()) {
+        if (!processor_->process(input_, output_, connectionContext)
+            || !input_->getTransport()->peek()) {
           break;
         }
       }
@@ -77,9 +76,8 @@ public:
         string errStr = string("TThreadedServer client died: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
-    } catch (const std::exception &x) {
-      GlobalOutput.printf("TThreadedServer exception: %s: %s",
-                          typeid(x).name(), x.what());
+    } catch (const std::exception& x) {
+      GlobalOutput.printf("TThreadedServer exception: %s: %s", typeid(x).name(), x.what());
     } catch (...) {
       GlobalOutput("TThreadedServer uncaught exception.");
     }
@@ -108,10 +106,9 @@ public:
         server_.tasksMonitor_.notify();
       }
     }
-
   }
 
- private:
+private:
   TThreadedServer& server_;
   friend class TThreadedServer;
 
@@ -129,7 +126,8 @@ void TThreadedServer::init() {
   }
 }
 
-TThreadedServer::~TThreadedServer() {}
+TThreadedServer::~TThreadedServer() {
+}
 
 void TThreadedServer::serve() {
 
@@ -164,22 +162,16 @@ void TThreadedServer::serve() {
       inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
       outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
 
-      shared_ptr<TProcessor> processor = getProcessor(inputProtocol,
-                                                      outputProtocol, client);
+      shared_ptr<TProcessor> processor = getProcessor(inputProtocol, outputProtocol, client);
 
-      TThreadedServer::Task* task = new TThreadedServer::Task(*this,
-                                                              processor,
-                                                              inputProtocol,
-                                                              outputProtocol,
-                                                              client);
+      TThreadedServer::Task* task
+          = new TThreadedServer::Task(*this, processor, inputProtocol, outputProtocol, client);
 
       // Create a task
-      shared_ptr<Runnable> runnable =
-        shared_ptr<Runnable>(task);
+      shared_ptr<Runnable> runnable = shared_ptr<Runnable>(task);
 
       // Create a thread for this task
-      shared_ptr<Thread> thread =
-        shared_ptr<Thread>(threadFactory_->newThread(runnable));
+      shared_ptr<Thread> thread = shared_ptr<Thread>(threadFactory_->newThread(runnable));
 
       // Insert thread into the set of threads
       {
@@ -191,25 +183,43 @@ void TThreadedServer::serve() {
       thread->start();
 
     } catch (TTransportException& ttx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
         string errStr = string("TThreadedServer: TServerTransport died on accept: ") + ttx.what();
         GlobalOutput(errStr.c_str());
       }
       continue;
     } catch (TException& tx) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = string("TThreadedServer: Caught TException: ") + tx.what();
       GlobalOutput(errStr.c_str());
       continue;
     } catch (string s) {
-      if (inputTransport) { inputTransport->close(); }
-      if (outputTransport) { outputTransport->close(); }
-      if (client) { client->close(); }
+      if (inputTransport) {
+        inputTransport->close();
+      }
+      if (outputTransport) {
+        outputTransport->close();
+      }
+      if (client) {
+        client->close();
+      }
       string errStr = "TThreadedServer: Unknown exception: " + s;
       GlobalOutput(errStr.c_str());
       break;
@@ -220,7 +230,7 @@ void TThreadedServer::serve() {
   if (stop_) {
     try {
       serverTransport_->close();
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadedServer: Exception shutting down: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
@@ -229,13 +239,13 @@ void TThreadedServer::serve() {
       while (!tasks_.empty()) {
         tasksMonitor_.wait();
       }
-    } catch (TException &tx) {
+    } catch (TException& tx) {
       string errStr = string("TThreadedServer: Exception joining workers: ") + tx.what();
       GlobalOutput(errStr.c_str());
     }
     stop_ = false;
   }
-
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/server/TThreadedServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h
index f965fcd..2b1f757 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.h
+++ b/lib/cpp/src/thrift/server/TThreadedServer.h
@@ -27,7 +27,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace server {
+namespace apache {
+namespace thrift {
+namespace server {
 
 using apache::thrift::TProcessor;
 using apache::thrift::transport::TServerTransport;
@@ -37,17 +39,17 @@ using apache::thrift::concurrency::ThreadFactory;
 
 class TThreadedServer : public TServer {
 
- public:
+public:
   class Task;
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
                   const boost::shared_ptr<TProtocolFactory>& protocolFactory,
                   THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory));
 
-  template<typename ProcessorFactory>
+  template <typename ProcessorFactory>
   TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
@@ -55,14 +57,14 @@ class TThreadedServer : public TServer {
                   const boost::shared_ptr<ThreadFactory>& threadFactory,
                   THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory));
 
-  template<typename Processor>
+  template <typename Processor>
   TThreadedServer(const boost::shared_ptr<Processor>& processor,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
                   const boost::shared_ptr<TProtocolFactory>& protocolFactory,
                   THRIFT_OVERLOAD_IF(Processor, TProcessor));
 
-  template<typename Processor>
+  template <typename Processor>
   TThreadedServer(const boost::shared_ptr<Processor>& processor,
                   const boost::shared_ptr<TServerTransport>& serverTransport,
                   const boost::shared_ptr<TTransportFactory>& transportFactory,
@@ -79,7 +81,7 @@ class TThreadedServer : public TServer {
     serverTransport_->interrupt();
   }
 
- protected:
+protected:
   void init();
 
   boost::shared_ptr<ThreadFactory> threadFactory_;
@@ -87,59 +89,53 @@ class TThreadedServer : public TServer {
 
   Monitor tasksMonitor_;
   std::set<Task*> tasks_;
-
 };
 
-template<typename ProcessorFactory>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<ProcessorFactory>& processorFactory,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory)) :
-  TServer(processorFactory, serverTransport, transportFactory,
-          protocolFactory) {
+template <typename ProcessorFactory>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory))
+  : TServer(processorFactory, serverTransport, transportFactory, protocolFactory) {
   init();
 }
 
-template<typename ProcessorFactory>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<ProcessorFactory>& processorFactory,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    const boost::shared_ptr<ThreadFactory>& threadFactory,
-    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory)) :
-  TServer(processorFactory, serverTransport, transportFactory,
-          protocolFactory),
-  threadFactory_(threadFactory) {
+template <typename ProcessorFactory>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 const boost::shared_ptr<ThreadFactory>& threadFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory))
+  : TServer(processorFactory, serverTransport, transportFactory, protocolFactory),
+    threadFactory_(threadFactory) {
   init();
 }
 
-template<typename Processor>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<Processor>& processor,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
-  TServer(processor, serverTransport, transportFactory, protocolFactory) {
+template <typename Processor>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor))
+  : TServer(processor, serverTransport, transportFactory, protocolFactory) {
   init();
 }
 
-template<typename Processor>
-TThreadedServer::TThreadedServer(
-    const boost::shared_ptr<Processor>& processor,
-    const boost::shared_ptr<TServerTransport>& serverTransport,
-    const boost::shared_ptr<TTransportFactory>& transportFactory,
-    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
-    const boost::shared_ptr<ThreadFactory>& threadFactory,
-    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
-  TServer(processor, serverTransport, transportFactory, protocolFactory),
-  threadFactory_(threadFactory) {
+template <typename Processor>
+TThreadedServer::TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                                 const boost::shared_ptr<TServerTransport>& serverTransport,
+                                 const boost::shared_ptr<TTransportFactory>& transportFactory,
+                                 const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                                 const boost::shared_ptr<ThreadFactory>& threadFactory,
+                                 THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor))
+  : TServer(processor, serverTransport, transportFactory, protocolFactory),
+    threadFactory_(threadFactory) {
   init();
 }
-
-}}} // apache::thrift::server
+}
+}
+} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TTHREADEDSERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/thrift-config.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/thrift-config.h b/lib/cpp/src/thrift/thrift-config.h
old mode 100755
new mode 100644
index b1bcccb..d648706
--- a/lib/cpp/src/thrift/thrift-config.h
+++ b/lib/cpp/src/thrift/thrift-config.h
@@ -18,7 +18,7 @@
  */
 
 #ifdef _WIN32
-# include <thrift/windows/config.h>
+#include <thrift/windows/config.h>
 #else
-# include <thrift/config.h>
+#include <thrift/config.h>
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/PlatformSocket.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/PlatformSocket.h b/lib/cpp/src/thrift/transport/PlatformSocket.h
index d28978e..96a3da3 100644
--- a/lib/cpp/src/thrift/transport/PlatformSocket.h
+++ b/lib/cpp/src/thrift/transport/PlatformSocket.h
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+// clang-format off
+
 #ifndef _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
 #  define _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/transport/TBufferTransports.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 15d8f59..25adb23 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -24,8 +24,9 @@
 
 using std::string;
 
-namespace apache { namespace thrift { namespace transport {
-
+namespace apache {
+namespace thrift {
+namespace transport {
 
 uint32_t TBufferedTransport::readSlow(uint8_t* buf, uint32_t len) {
   uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
@@ -85,7 +86,7 @@ void TBufferedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   // The case where we have to do two syscalls.
   // This case also covers the case where the buffer is empty,
   // but it is clearer (I think) to think of it as two separate cases.
-  if ((have_bytes + len >= 2*wBufSize_) || (have_bytes == 0)) {
+  if ((have_bytes + len >= 2 * wBufSize_) || (have_bytes == 0)) {
     // TODO(dreiss): writev
     if (have_bytes > 0) {
       transport_->write(wBuf_.get(), have_bytes);
@@ -109,14 +110,14 @@ void TBufferedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
 }
 
 const uint8_t* TBufferedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
-  (void) len;
+  (void)buf;
+  (void)len;
   // Simply return NULL.  We don't know if there is actually data available on
   // the underlying transport, so calling read() might block.
   return NULL;
 }
 
-void TBufferedTransport::flush()  {
+void TBufferedTransport::flush() {
   // Write out any data waiting in the write buffer.
   uint32_t have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
   if (have_bytes > 0) {
@@ -131,7 +132,6 @@ void TBufferedTransport::flush()  {
   transport_->flush();
 }
 
-
 uint32_t TFramedTransport::readSlow(uint8_t* buf, uint32_t len) {
   uint32_t want = len;
   uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
@@ -179,9 +179,8 @@ bool TFramedTransport::readFrame() {
   uint32_t size_bytes_read = 0;
   while (size_bytes_read < sizeof(sz)) {
     uint8_t* szp = reinterpret_cast<uint8_t*>(&sz) + size_bytes_read;
-    uint32_t bytes_read = transport_->read(
-      szp,
-      static_cast<uint32_t>(sizeof(sz)) - size_bytes_read);
+    uint32_t bytes_read
+        = transport_->read(szp, static_cast<uint32_t>(sizeof(sz)) - size_bytes_read);
     if (bytes_read == 0) {
       if (size_bytes_read == 0) {
         // EOF before any data was read.
@@ -218,7 +217,7 @@ void TFramedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   uint32_t new_size = wBufSize_;
   if (len + have < have /* overflow */ || len + have > 0x7fffffff) {
     throw TTransportException(TTransportException::BAD_ARGS,
-        "Attempted to write over 2 GB to TFramedTransport.");
+                              "Attempted to write over 2 GB to TFramedTransport.");
   }
   while (new_size < len + have) {
     new_size = new_size > 0 ? new_size * 2 : 1;
@@ -244,7 +243,7 @@ void TFramedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
   wBase_ += len;
 }
 
-void TFramedTransport::flush()  {
+void TFramedTransport::flush() {
   int32_t sz_hbo, sz_nbo;
   assert(wBufSize_ > sizeof(sz_nbo));
 
@@ -261,9 +260,7 @@ void TFramedTransport::flush()  {
     wBase_ = wBuf_.get() + sizeof(sz_nbo);
 
     // Write size and frame body.
-    transport_->write(
-      wBuf_.get(),
-      static_cast<uint32_t>(sizeof(sz_nbo))+sz_hbo);
+    transport_->write(wBuf_.get(), static_cast<uint32_t>(sizeof(sz_nbo)) + sz_hbo);
   }
 
   // Flush the underlying transport.
@@ -286,8 +283,8 @@ uint32_t TFramedTransport::writeEnd() {
 }
 
 const uint8_t* TFramedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
-  (void) len;
+  (void)buf;
+  (void)len;
   // Don't try to be clever with shifting buffers.
   // If the fast path failed let the protocol use its slow path.
   // Besides, who is going to try to borrow across messages?
@@ -299,9 +296,9 @@ uint32_t TFramedTransport::readEnd() {
   uint32_t bytes_read = static_cast<uint32_t>(rBound_ - rBuf_.get() + sizeof(uint32_t));
 
   if (rBufSize_ > bufReclaimThresh_) {
-      rBufSize_ = 0;
-      rBuf_.reset();
-      setReadBuffer(rBuf_.get(), rBufSize_);
+    rBufSize_ = 0;
+    rBuf_.reset();
+    setReadBuffer(rBuf_.get(), rBufSize_);
   }
 
   return bytes_read;
@@ -398,7 +395,7 @@ void TMemoryBuffer::wroteBytes(uint32_t len) {
 }
 
 const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
-  (void) buf;
+  (void)buf;
   rBound_ = wBase_;
   if (available_read() >= *len) {
     *len = available_read();
@@ -406,5 +403,6 @@ const uint8_t* TMemoryBuffer::borrowSlow(uint8_t* buf, uint32_t* len) {
   }
   return NULL;
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport


[18/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_perl_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_perl_generator.cc b/compiler/cpp/src/generate/t_perl_generator.cc
index 5a5c080..6c823c0 100644
--- a/compiler/cpp/src/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/generate/t_perl_generator.cc
@@ -37,22 +37,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * PERL code generator.
  *
  */
 class t_perl_generator : public t_oop_generator {
- public:
-  t_perl_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_perl_generator(t_program* program,
+                   const std::map<std::string, std::string>& parsed_options,
+                   const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-perl";
     escape_['$'] = "\\$";
     escape_['@'] = "\\@";
@@ -69,12 +67,12 @@ class t_perl_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
@@ -83,7 +81,9 @@ class t_perl_generator : public t_oop_generator {
    */
 
   void generate_perl_struct(t_struct* tstruct, bool is_exception);
-  void generate_perl_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false);
+  void generate_perl_struct_definition(std::ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_xception = false);
   void generate_perl_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_perl_struct_writer(std::ofstream& out, t_struct* tstruct);
   void generate_perl_function_helpers(t_function* tfunction);
@@ -92,84 +92,62 @@ class t_perl_generator : public t_oop_generator {
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_rest      (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_processor (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_rest(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_processor(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool inclass=false);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool inclass = false);
 
-  void generate_deserialize_struct       (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream &out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element    (std::ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
   /**
    * Helper rendering functions
    */
 
   std::string perl_includes();
-  std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string declare_field(t_field* tfield, bool init = false, bool obj = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
 
   std::string autogen_comment() {
-    return
-      std::string("#\n") +
-      "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-      "#\n" +
-      "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-      "#\n";
+    return std::string("#\n") + "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           + "#\n" + "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "#\n";
   }
 
   void perl_namespace_dirs(t_program* p, std::list<std::string>& dirs) {
@@ -179,7 +157,7 @@ class t_perl_generator : public t_oop_generator {
     if (ns.size() > 0) {
       while ((loc = ns.find(".")) != std::string::npos) {
         dirs.push_back(ns.substr(0, loc));
-        ns = ns.substr(loc+1);
+        ns = ns.substr(loc + 1);
       }
     }
 
@@ -197,7 +175,7 @@ class t_perl_generator : public t_oop_generator {
       while ((loc = ns.find(".")) != std::string::npos) {
         result += ns.substr(0, loc);
         result += "::";
-        ns = ns.substr(loc+1);
+        ns = ns.substr(loc + 1);
       }
 
       if (ns.size() > 0) {
@@ -219,8 +197,7 @@ class t_perl_generator : public t_oop_generator {
     return outdir;
   }
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -228,10 +205,8 @@ class t_perl_generator : public t_oop_generator {
   std::ofstream f_consts_;
   std::ofstream f_helpers_;
   std::ofstream f_service_;
-
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -247,27 +222,22 @@ void t_perl_generator::init_generator() {
   perl_namespace_dirs(program_, dirs);
   std::list<std::string>::iterator it;
   for (it = dirs.begin(); it != dirs.end(); it++) {
-      outdir += *it + "/";
-      MKDIR(outdir.c_str());
+    outdir += *it + "/";
+    MKDIR(outdir.c_str());
   }
 
   // Make output file
-  string f_types_name = outdir+"Types.pm";
+  string f_types_name = outdir + "Types.pm";
   f_types_.open(f_types_name.c_str());
-  string f_consts_name = outdir+"Constants.pm";
+  string f_consts_name = outdir + "Constants.pm";
   f_consts_.open(f_consts_name.c_str());
 
   // Print header
-  f_types_ <<
-    autogen_comment() <<
-    perl_includes();
+  f_types_ << autogen_comment() << perl_includes();
 
   // Print header
-  f_consts_ <<
-    autogen_comment() <<
-    "package "<< perl_namespace(program_) <<"Constants;"<<endl<<
-    perl_includes() <<
-    endl;
+  f_consts_ << autogen_comment() << "package " << perl_namespace(program_) << "Constants;" << endl
+            << perl_includes() << endl;
 }
 
 /**
@@ -276,7 +246,7 @@ void t_perl_generator::init_generator() {
 string t_perl_generator::perl_includes() {
   string inc;
 
-  inc  = "require 5.6.0;\n";
+  inc = "require 5.6.0;\n";
   inc += "use strict;\n";
   inc += "use warnings;\n";
   inc += "use Thrift;\n\n";
@@ -302,7 +272,7 @@ void t_perl_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_perl_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -312,13 +282,13 @@ void t_perl_generator::generate_typedef(t_typedef* ttypedef) {
  * @param tenum The enumeration
  */
 void t_perl_generator::generate_enum(t_enum* tenum) {
-  f_types_ << "package " << perl_namespace(program_) <<tenum->get_name()<<";"<<endl;
+  f_types_ << "package " << perl_namespace(program_) << tenum->get_name() << ";" << endl;
 
   vector<t_enum_value*> constants = tenum->get_constants();
   vector<t_enum_value*>::iterator c_iter;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
-    f_types_ << "use constant "<< (*c_iter)->get_name() << " => " << value << ";" << endl;
+    f_types_ << "use constant " << (*c_iter)->get_name() << " => " << value << ";" << endl;
   }
 }
 
@@ -455,8 +425,7 @@ void t_perl_generator::generate_xception(t_struct* txception) {
 /**
  * Structs can be normal or exceptions.
  */
-void t_perl_generator::generate_perl_struct(t_struct* tstruct,
-                                            bool is_exception) {
+void t_perl_generator::generate_perl_struct(t_struct* tstruct, bool is_exception) {
   generate_perl_struct_definition(f_types_, tstruct, is_exception);
 }
 
@@ -473,36 +442,32 @@ void t_perl_generator::generate_perl_struct_definition(ofstream& out,
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  out <<
-      "package " << perl_namespace(tstruct->get_program()) << tstruct->get_name() <<";\n";
+  out << "package " << perl_namespace(tstruct->get_program()) << tstruct->get_name() << ";\n";
   if (is_exception) {
     out << "use base qw(Thrift::TException);\n";
   }
 
-  //Create simple acessor methods
+  // Create simple acessor methods
   out << "use base qw(Class::Accessor);\n";
 
   if (members.size() > 0) {
-      out << perl_namespace(tstruct->get_program()) << tstruct->get_name() <<"->mk_accessors( qw( ";
-      for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-          t_type* t = get_true_type((*m_iter)->get_type());
-          if (!t->is_xception()) {
-              out << (*m_iter)->get_name() << " ";
-          }
+    out << perl_namespace(tstruct->get_program()) << tstruct->get_name() << "->mk_accessors( qw( ";
+    for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
+      t_type* t = get_true_type((*m_iter)->get_type());
+      if (!t->is_xception()) {
+        out << (*m_iter)->get_name() << " ";
       }
+    }
 
-      out << ") );\n";
+    out << ") );\n";
   }
 
   out << endl;
 
   // new()
   indent_up();
-  out <<
-    "sub new {" << endl <<
-    indent() << "my $classname = shift;" << endl <<
-    indent() << "my $self      = {};" << endl <<
-    indent() << "my $vals      = shift || {};" << endl;
+  out << "sub new {" << endl << indent() << "my $classname = shift;" << endl << indent()
+      << "my $self      = {};" << endl << indent() << "my $vals      = shift || {};" << endl;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     string dval = "undef";
@@ -510,8 +475,7 @@ void t_perl_generator::generate_perl_struct_definition(ofstream& out,
     if ((*m_iter)->get_value() != NULL && !(t->is_struct() || t->is_xception())) {
       dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
     }
-    out <<
-      indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << endl;
+    out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << endl;
   }
 
   // Generate constructor from array
@@ -520,61 +484,50 @@ void t_perl_generator::generate_perl_struct_definition(ofstream& out,
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       t_type* t = get_true_type((*m_iter)->get_type());
       if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
-        indent(out) << "$self->{" << (*m_iter)->get_name() << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
+        indent(out) << "$self->{" << (*m_iter)->get_name()
+                    << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
       }
     }
 
     out << indent() << "if (UNIVERSAL::isa($vals,'HASH')) {" << endl;
     indent_up();
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-      out <<
-        indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << endl <<
-        indent() << "  $self->{" << (*m_iter)->get_name() << "} = $vals->{" << (*m_iter)->get_name() << "};" << endl <<
-        indent() << "}" << endl;
+      out << indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << endl
+          << indent() << "  $self->{" << (*m_iter)->get_name() << "} = $vals->{"
+          << (*m_iter)->get_name() << "};" << endl << indent() << "}" << endl;
     }
     indent_down();
-    out <<
-      indent() << "}" << endl;
-
+    out << indent() << "}" << endl;
   }
 
   out << indent() << "return bless ($self, $classname);" << endl;
   indent_down();
   out << "}\n\n";
 
-  out <<
-    "sub getName {" << endl <<
-    indent() << "  return '" << tstruct->get_name() << "';" << endl <<
-    indent() << "}" << endl <<
-    endl;
+  out << "sub getName {" << endl << indent() << "  return '" << tstruct->get_name() << "';" << endl
+      << indent() << "}" << endl << endl;
 
   generate_perl_struct_reader(out, tstruct);
   generate_perl_struct_writer(out, tstruct);
-
 }
 
 /**
  * Generates the read() method for a struct
  */
-void t_perl_generator::generate_perl_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_perl_generator::generate_perl_struct_reader(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out << "sub read {" <<endl;
+  out << "sub read {" << endl;
 
   indent_up();
 
-  out <<
-    indent() << "my ($self, $input) = @_;" << endl <<
-    indent() << "my $xfer  = 0;" << endl <<
-    indent() << "my $fname;"     << endl <<
-    indent() << "my $ftype = 0;" << endl <<
-    indent() << "my $fid   = 0;" << endl;
+  out << indent() << "my ($self, $input) = @_;" << endl << indent() << "my $xfer  = 0;" << endl
+      << indent() << "my $fname;" << endl << indent() << "my $ftype = 0;" << endl << indent()
+      << "my $fid   = 0;" << endl;
 
   indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << endl;
 
-
   // Loop over reading in fields
   indent(out) << "while (1) " << endl;
 
@@ -606,16 +559,13 @@ void t_perl_generator::generate_perl_struct_reader(ofstream& out,
 
     indent(out) << "} else {" << endl;
 
-    indent(out) <<  "  $xfer += $input->skip($ftype);" << endl;
-
-    out <<
-      indent() << "}" << endl <<
-      indent() << "last; };" << endl;
+    indent(out) << "  $xfer += $input->skip($ftype);" << endl;
 
+    out << indent() << "}" << endl << indent() << "last; };" << endl;
   }
   // In the default case we skip the field
 
-  indent(out) <<  "  $xfer += $input->skip($ftype);" << endl;
+  indent(out) << "  $xfer += $input->skip($ftype);" << endl;
 
   scope_down(out);
 
@@ -634,8 +584,7 @@ void t_perl_generator::generate_perl_struct_reader(ofstream& out,
 /**
  * Generates the write() method for a struct
  */
-void t_perl_generator::generate_perl_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_perl_generator::generate_perl_struct_writer(ofstream& out, t_struct* tstruct) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
@@ -652,34 +601,26 @@ void t_perl_generator::generate_perl_struct_writer(ofstream& out,
     out << indent() << "if (defined $self->{" << (*f_iter)->get_name() << "}) {" << endl;
     indent_up();
 
-    indent(out) <<
-      "$xfer += $output->writeFieldBegin(" <<
-      "'" << (*f_iter)->get_name() << "', " <<
-      type_to_enum((*f_iter)->get_type()) << ", " <<
-      (*f_iter)->get_key() << ");" << endl;
-
+    indent(out) << "$xfer += $output->writeFieldBegin("
+                << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
+                << ", " << (*f_iter)->get_key() << ");" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "self->");
 
-    indent(out) <<
-        "$xfer += $output->writeFieldEnd();" << endl;
+    indent(out) << "$xfer += $output->writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}" << endl;
   }
 
+  out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent()
+      << "$xfer += $output->writeStructEnd();" << endl;
 
-  out <<
-    indent() << "$xfer += $output->writeFieldStop();" << endl <<
-    indent() << "$xfer += $output->writeStructEnd();" << endl;
-
-  out <<indent() << "return $xfer;" << endl;
+  out << indent() << "return $xfer;" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -688,25 +629,22 @@ void t_perl_generator::generate_perl_struct_writer(ofstream& out,
  * @param tservice The service definition
  */
 void t_perl_generator::generate_service(t_service* tservice) {
-  string f_service_name = get_namespace_out_dir()+service_name_+".pm";
+  string f_service_name = get_namespace_out_dir() + service_name_ + ".pm";
   f_service_.open(f_service_name.c_str());
 
   f_service_ <<
-    ///      "package "<<service_name_<<";"<<endl<<
-    autogen_comment() <<
-    perl_includes();
+      ///      "package "<<service_name_<<";"<<endl<<
+      autogen_comment() << perl_includes();
 
-  f_service_ <<
-    "use " << perl_namespace(tservice->get_program()) << "Types;" << endl;
+  f_service_ << "use " << perl_namespace(tservice->get_program()) << "Types;" << endl;
 
   t_service* extends_s = tservice->get_extends();
   if (extends_s != NULL) {
-    f_service_ <<
-      "use " << perl_namespace(extends_s->get_program()) << extends_s->get_name() << ";" << endl;
+    f_service_ << "use " << perl_namespace(extends_s->get_program()) << extends_s->get_name() << ";"
+               << endl;
   }
 
-  f_service_ <<
-    endl;
+  f_service_ << endl;
 
   // Generate the three main parts of the service (well, two for now in PERL)
   generate_service_helpers(tservice);
@@ -741,74 +679,59 @@ void t_perl_generator::generate_service_processor(t_service* tservice) {
   indent_up();
 
   // Generate the header portion
-  f_service_ <<
-    "package " << perl_namespace(program_) << service_name_ << "Processor;" << endl << endl <<
-    "use strict;" << endl <<
-    extends_processor << endl << endl;
-
+  f_service_ << "package " << perl_namespace(program_) << service_name_ << "Processor;" << endl
+             << endl << "use strict;" << endl << extends_processor << endl << endl;
 
   if (extends.empty()) {
     f_service_ << "sub new {" << endl;
 
     indent_up();
 
-    f_service_ <<
-      indent() << "my ($classname, $handler) = @_;"<< endl <<
-      indent() << "my $self      = {};"   << endl;
+    f_service_ << indent() << "my ($classname, $handler) = @_;" << endl << indent()
+               << "my $self      = {};" << endl;
 
-    f_service_ <<
-      indent() << "$self->{handler} = $handler;" << endl;
+    f_service_ << indent() << "$self->{handler} = $handler;" << endl;
 
-    f_service_ <<
-      indent() << "return bless ($self, $classname);"<<endl;
+    f_service_ << indent() << "return bless ($self, $classname);" << endl;
 
     indent_down();
 
-    f_service_ <<
-      "}" << endl << endl;
+    f_service_ << "}" << endl << endl;
   }
 
   // Generate the server implementation
   f_service_ << "sub process {" << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "my ($self, $input, $output) = @_;" << endl;
+  f_service_ << indent() << "my ($self, $input, $output) = @_;" << endl;
 
-  f_service_ <<
-    indent() << "my $rseqid = 0;" << endl <<
-    indent() << "my $fname  = undef;" << endl <<
-    indent() << "my $mtype  = 0;" << endl << endl;
+  f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname  = undef;" << endl
+             << indent() << "my $mtype  = 0;" << endl << endl;
 
-  f_service_ <<
-    indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << endl;
+  f_service_ << indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << endl;
 
   // HOT: check for method implementation
-  f_service_ <<
-    indent() << "my $methodname = 'process_'.$fname;" << endl <<
-    indent() << "if (!$self->can($methodname)) {" << endl;
+  f_service_ << indent() << "my $methodname = 'process_'.$fname;" << endl << indent()
+             << "if (!$self->can($methodname)) {" << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "$input->skip(TType::STRUCT);" << endl <<
-    indent() << "$input->readMessageEnd();" << endl <<
-    indent() << "my $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD);" << endl <<
-    indent() << "$output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid);" << endl <<
-    indent() << "$x->write($output);" << endl <<
-    indent() << "$output->writeMessageEnd();" << endl <<
-    indent() << "$output->getTransport()->flush();" << endl <<
-    indent() << "return;" << endl;
+  f_service_ << indent() << "$input->skip(TType::STRUCT);" << endl << indent()
+             << "$input->readMessageEnd();" << endl << indent()
+             << "my $x = new TApplicationException('Function '.$fname.' not implemented.', "
+                "TApplicationException::UNKNOWN_METHOD);" << endl << indent()
+             << "$output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid);" << endl
+             << indent() << "$x->write($output);" << endl << indent()
+             << "$output->writeMessageEnd();" << endl << indent()
+             << "$output->getTransport()->flush();" << endl << indent() << "return;" << endl;
 
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl <<
-    indent() << "$self->$methodname($rseqid, $input, $output);" << endl <<
-    indent() << "return 1;" << endl;
+  f_service_ << indent() << "}" << endl << indent()
+             << "$self->$methodname($rseqid, $input, $output);" << endl << indent() << "return 1;"
+             << endl;
 
   indent_down();
 
-  f_service_ <<
-    "}" << endl <<endl;
+  f_service_ << "}" << endl << endl;
 
   // Generate the process subfunctions
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -821,26 +744,23 @@ void t_perl_generator::generate_service_processor(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_perl_generator::generate_process_function(t_service* tservice,
-                                                 t_function* tfunction) {
+void t_perl_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
   // Open function
-  f_service_ <<
-    "sub process_" << tfunction->get_name() << " {"<<endl;
+  f_service_ << "sub process_" << tfunction->get_name() << " {" << endl;
 
   indent_up();
 
-  f_service_ <<
-    indent() << "my ($self, $seqid, $input, $output) = @_;" << endl;
+  f_service_ << indent() << "my ($self, $seqid, $input, $output) = @_;" << endl;
 
-  string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_args";
-  string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_" + tfunction->get_name() + "_result";
+  string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+                    + tfunction->get_name() + "_args";
+  string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+                      + tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << "my $args = new " << argsname << "();" << endl <<
-    indent() << "$args->read($input);" << endl;
+  f_service_ << indent() << "my $args = new " << argsname << "();" << endl << indent()
+             << "$args->read($input);" << endl;
 
-  f_service_ <<
-    indent() << "$input->readMessageEnd();" << endl;
+  f_service_ << indent() << "$input->readMessageEnd();" << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
@@ -848,14 +768,12 @@ void t_perl_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "my $result = new " << resultname << "();" << endl;
+    f_service_ << indent() << "my $result = new " << resultname << "();" << endl;
   }
 
   // Try block for a function with exceptions
   if (xceptions.size() > 0) {
-    f_service_ <<
-      indent() << "eval {" << endl;
+    f_service_ << indent() << "eval {" << endl;
     indent_up();
   }
 
@@ -868,8 +786,7 @@ void t_perl_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << "$result->{success} = ";
   }
-  f_service_ <<
-    "$self->{handler}->" << tfunction->get_name() << "(";
+  f_service_ << "$self->{handler}->" << tfunction->get_name() << "(";
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
@@ -884,16 +801,13 @@ void t_perl_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && xceptions.size() > 0) {
     indent_down();
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_ <<
-        indent() << "}; if( UNIVERSAL::isa($@,'" <<
-          perl_namespace((*x_iter)->get_type()->get_program()) <<
-          (*x_iter)->get_type()->get_name() <<
-          "') ){ " << endl;
+      f_service_ << indent() << "}; if( UNIVERSAL::isa($@,'"
+                 << perl_namespace((*x_iter)->get_type()->get_program())
+                 << (*x_iter)->get_type()->get_name() << "') ){ " << endl;
 
       if (!tfunction->is_oneway()) {
         indent_up();
-        f_service_ <<
-          indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << endl;
+        f_service_ << indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << endl;
         indent_down();
         f_service_ << indent();
       }
@@ -903,24 +817,20 @@ void t_perl_generator::generate_process_function(t_service* tservice,
 
   // Shortcut out here for oneway functions
   if (tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "return;" << endl;
+    f_service_ << indent() << "return;" << endl;
     indent_down();
-    f_service_ <<
-      "}" << endl;
+    f_service_ << "}" << endl;
     return;
   }
   // Serialize the request header
-  f_service_ <<
-    indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', TMessageType::REPLY, $seqid);" << endl <<
-    indent() << "$result->write($output);" << endl <<
-    indent() << "$output->writeMessageEnd();" << endl <<
-    indent() << "$output->getTransport()->flush();" << endl;
+  f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name()
+             << "', TMessageType::REPLY, $seqid);" << endl << indent() << "$result->write($output);"
+             << endl << indent() << "$output->writeMessageEnd();" << endl << indent()
+             << "$output->getTransport()->flush();" << endl;
 
   // Close function
   indent_down();
-  f_service_ <<
-    "}" << endl << endl;
+  f_service_ << "}" << endl << endl;
 }
 
 /**
@@ -932,8 +842,7 @@ void t_perl_generator::generate_service_helpers(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
-  f_service_ <<
-    "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+  f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_struct* ts = (*f_iter)->get_arglist();
@@ -976,24 +885,21 @@ void t_perl_generator::generate_service_interface(t_service* tservice) {
   string extends_if = "";
   t_service* extends_s = tservice->get_extends();
   if (extends_s != NULL) {
-    extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name() + "If);";
+    extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name()
+                 + "If);";
   }
 
-  f_service_ <<
-    "package " << perl_namespace(program_) << service_name_ << "If;" << endl << endl <<
-    "use strict;" << endl <<
-    extends_if << endl << endl;
-
+  f_service_ << "package " << perl_namespace(program_) << service_name_ << "If;" << endl << endl
+             << "use strict;" << endl << extends_if << endl << endl;
 
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      "sub " << function_signature(*f_iter) <<endl<< "  die 'implement interface';\n}" << endl << endl;
+    f_service_ << "sub " << function_signature(*f_iter) << endl << "  die 'implement interface';\n}"
+               << endl << endl;
   }
   indent_down();
-
 }
 
 /**
@@ -1004,65 +910,54 @@ void t_perl_generator::generate_service_rest(t_service* tservice) {
   string extends_if = "";
   t_service* extends_s = tservice->get_extends();
   if (extends_s != NULL) {
-    extends    =  extends_s->get_name();
-    extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name() + "Rest);";
+    extends = extends_s->get_name();
+    extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name()
+                 + "Rest);";
   }
-  f_service_ <<
-    "package " << perl_namespace(program_) << service_name_ << "Rest;" << endl << endl <<
-    "use strict;" << endl <<
-    extends_if << endl << endl;
-
+  f_service_ << "package " << perl_namespace(program_) << service_name_ << "Rest;" << endl << endl
+             << "use strict;" << endl << extends_if << endl << endl;
 
   if (extends.empty()) {
     f_service_ << "sub new {" << endl;
 
     indent_up();
 
-    f_service_ <<
-      indent() << "my ($classname, $impl) = @_;" << endl <<
-      indent() << "my $self     ={ impl => $impl };" << endl << endl <<
-      indent() << "return bless($self,$classname);" << endl;
-
+    f_service_ << indent() << "my ($classname, $impl) = @_;" << endl << indent()
+               << "my $self     ={ impl => $impl };" << endl << endl << indent()
+               << "return bless($self,$classname);" << endl;
 
     indent_down();
 
-    f_service_  <<
-      "}" << endl << endl;
+    f_service_ << "}" << endl << endl;
   }
 
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      "sub " << (*f_iter)->get_name() <<
-      "{"    <<endl;
+    f_service_ << "sub " << (*f_iter)->get_name() << "{" << endl;
 
     indent_up();
 
-    f_service_ <<
-      indent() << "my ($self, $request) = @_;" << endl << endl;
-
+    f_service_ << indent() << "my ($self, $request) = @_;" << endl << endl;
 
     const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
     vector<t_field*>::const_iterator a_iter;
     for (a_iter = args.begin(); a_iter != args.end(); ++a_iter) {
       t_type* atype = get_true_type((*a_iter)->get_type());
       string req = "$request->{'" + (*a_iter)->get_name() + "'}";
-      f_service_ <<
-        indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req << " : undef;" << endl;
-      if (atype->is_string() &&
-          ((t_base_type*)atype)->is_string_list()) {
-        f_service_ <<
-          indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $" << (*a_iter)->get_name() << ");" << endl <<
-          indent()     << "$"<<(*a_iter)->get_name() <<" = \\@"<<(*a_iter)->get_name()<<endl;
+      f_service_ << indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req
+                 << " : undef;" << endl;
+      if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
+        f_service_ << indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $"
+                   << (*a_iter)->get_name() << ");" << endl << indent() << "$"
+                   << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << endl;
       }
     }
-    f_service_ <<
-      indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "(" << argument_list((*f_iter)->get_arglist()) << ");" << endl;
+    f_service_ << indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "("
+               << argument_list((*f_iter)->get_arglist()) << ");" << endl;
     indent_down();
-    indent(f_service_) << "}" << endl <<endl;
+    indent(f_service_) << "}" << endl << endl;
   }
-
 }
 
 /**
@@ -1079,37 +974,31 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
     extends_client = "use base qw(" + extends + "Client);";
   }
 
-  f_service_ <<
-      "package " << perl_namespace(program_) << service_name_ << "Client;" << endl << endl <<
-      extends_client << endl <<
-      "use base qw(" << perl_namespace(program_) << service_name_ << "If);" << endl;
+  f_service_ << "package " << perl_namespace(program_) << service_name_ << "Client;" << endl << endl
+             << extends_client << endl << "use base qw(" << perl_namespace(program_)
+             << service_name_ << "If);" << endl;
 
   // Constructor function
-  f_service_ << "sub new {"<<endl;
+  f_service_ << "sub new {" << endl;
 
   indent_up();
 
-  f_service_ <<
-    indent() << "my ($classname, $input, $output) = @_;" << endl <<
-    indent() << "my $self      = {};"   <<endl;
+  f_service_ << indent() << "my ($classname, $input, $output) = @_;" << endl << indent()
+             << "my $self      = {};" << endl;
 
   if (!extends.empty()) {
-    f_service_ <<
-      indent() << "$self = $classname->SUPER::new($input, $output);" << endl;
+    f_service_ << indent() << "$self = $classname->SUPER::new($input, $output);" << endl;
   } else {
-    f_service_ <<
-      indent() << "$self->{input}  = $input;" << endl <<
-      indent() << "$self->{output} = defined $output ? $output : $input;" << endl <<
-      indent() << "$self->{seqid}  = 0;" << endl;
+    f_service_ << indent() << "$self->{input}  = $input;" << endl << indent()
+               << "$self->{output} = defined $output ? $output : $input;" << endl << indent()
+               << "$self->{seqid}  = 0;" << endl;
   }
 
-  f_service_ <<
-    indent() << "return bless($self,$classname);"<<endl;
+  f_service_ << indent() << "return bless($self,$classname);" << endl;
 
   indent_down();
 
-  f_service_ <<
-    "}" << endl << endl;
+  f_service_ << "}" << endl << endl;
 
   // Generate client method implementations
   vector<t_function*> functions = tservice->get_functions();
@@ -1125,8 +1014,7 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
 
     indent_up();
 
-    indent(f_service_) << indent() <<
-      "$self->send_" << funname << "(";
+    indent(f_service_) << indent() << "$self->send_" << funname << "(";
 
     bool first = true;
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -1144,161 +1032,132 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void()) {
         f_service_ << "return ";
       }
-      f_service_ <<
-        "$self->recv_" << funname << "();" << endl;
+      f_service_ << "$self->recv_" << funname << "();" << endl;
     }
 
     indent_down();
 
     f_service_ << "}" << endl << endl;
 
-    f_service_ <<
-      "sub send_" << function_signature(*f_iter) << endl;
+    f_service_ << "sub send_" << function_signature(*f_iter) << endl;
 
     indent_up();
 
-    std::string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_args";
+    std::string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+                           + (*f_iter)->get_name() + "_args";
 
     // Serialize the request header
-    f_service_ <<
-      indent() << "$self->{output}->writeMessageBegin('" << (*f_iter)->get_name() << "', " <<
-      ((*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL") <<
-      ", $self->{seqid});" << endl;
+    f_service_ << indent() << "$self->{output}->writeMessageBegin('" << (*f_iter)->get_name()
+               << "', " << ((*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL")
+               << ", $self->{seqid});" << endl;
 
-    f_service_ <<
-      indent() << "my $args = new " << argsname << "();" << endl;
+    f_service_ << indent() << "my $args = new " << argsname << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "$args->{" << (*fld_iter)->get_name() << "} = $" << (*fld_iter)->get_name() << ";" << endl;
+      f_service_ << indent() << "$args->{" << (*fld_iter)->get_name() << "} = $"
+                 << (*fld_iter)->get_name() << ";" << endl;
     }
 
     // Write to the stream
-    f_service_ <<
-      indent() << "$args->write($self->{output});" << endl <<
-      indent() << "$self->{output}->writeMessageEnd();" << endl <<
-      indent() << "$self->{output}->getTransport()->flush();" << endl;
-
+    f_service_ << indent() << "$args->write($self->{output});" << endl << indent()
+               << "$self->{output}->writeMessageEnd();" << endl << indent()
+               << "$self->{output}->getTransport()->flush();" << endl;
 
     indent_down();
 
     f_service_ << "}" << endl;
 
-
     if (!(*f_iter)->is_oneway()) {
-      std::string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result";
+      std::string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+                               + (*f_iter)->get_name() + "_result";
       t_struct noargs(program_);
 
       t_function recv_function((*f_iter)->get_returntype(),
                                string("recv_") + (*f_iter)->get_name(),
                                &noargs);
       // Open function
-      f_service_ <<
-        endl <<
-        "sub " << function_signature(&recv_function) << endl;
+      f_service_ << endl << "sub " << function_signature(&recv_function) << endl;
 
       indent_up();
 
-      f_service_ <<
-        indent() << "my $rseqid = 0;" << endl <<
-        indent() << "my $fname;" << endl <<
-        indent() << "my $mtype = 0;" << endl <<
-        endl;
-
-      f_service_ <<
-        indent() << "$self->{input}->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << endl <<
-        indent() << "if ($mtype == TMessageType::EXCEPTION) {" << endl <<
-        indent() << "  my $x = new TApplicationException();" << endl <<
-        indent() << "  $x->read($self->{input});" << endl <<
-        indent() << "  $self->{input}->readMessageEnd();" << endl <<
-        indent() << "  die $x;" << endl <<
-        indent() << "}" << endl;
-
+      f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname;" << endl
+                 << indent() << "my $mtype = 0;" << endl << endl;
 
-      f_service_ <<
-        indent() << "my $result = new " << resultname << "();" << endl <<
-        indent() << "$result->read($self->{input});" << endl;
+      f_service_ << indent() << "$self->{input}->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);"
+                 << endl << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << endl
+                 << indent() << "  my $x = new TApplicationException();" << endl << indent()
+                 << "  $x->read($self->{input});" << endl << indent()
+                 << "  $self->{input}->readMessageEnd();" << endl << indent() << "  die $x;" << endl
+                 << indent() << "}" << endl;
 
+      f_service_ << indent() << "my $result = new " << resultname << "();" << endl << indent()
+                 << "$result->read($self->{input});" << endl;
 
-      f_service_ <<
-        indent() << "$self->{input}->readMessageEnd();" << endl <<
-        endl;
-
+      f_service_ << indent() << "$self->{input}->readMessageEnd();" << endl << endl;
 
       // Careful, only return result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if (defined $result->{success} ) {" << endl <<
-          indent() << "  return $result->{success};" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (defined $result->{success} ) {" << endl << indent()
+                   << "  return $result->{success};" << endl << indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if (defined $result->{" << (*x_iter)->get_name() << "}) {" << endl <<
-          indent() << "  die $result->{" << (*x_iter)->get_name() << "};" << endl <<
-          indent() << "}" << endl;
+        f_service_ << indent() << "if (defined $result->{" << (*x_iter)->get_name() << "}) {"
+                   << endl << indent() << "  die $result->{" << (*x_iter)->get_name() << "};"
+                   << endl << indent() << "}" << endl;
       }
 
       // Careful, only return _result if not a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) <<
-          "return;" << endl;
+        indent(f_service_) << "return;" << endl;
       } else {
-        f_service_ <<
-          indent() << "die \"" << (*f_iter)->get_name() << " failed: unknown result\";" << endl;
+        f_service_ << indent() << "die \"" << (*f_iter)->get_name() << " failed: unknown result\";"
+                   << endl;
       }
 
       // Close function
       indent_down();
-      f_service_ << "}"<<endl;
-
+      f_service_ << "}" << endl;
     }
   }
-
 }
 
 /**
  * Deserializes a field of any type.
  */
-void t_perl_generator::generate_deserialize_field(ofstream &out,
+void t_perl_generator::generate_deserialize_field(ofstream& out,
                                                   t_field* tfield,
                                                   string prefix,
                                                   bool inclass) {
-  (void) inclass;
+  (void)inclass;
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = tfield->get_name();
 
-  //Hack for when prefix is defined (always a hash ref)
+  // Hack for when prefix is defined (always a hash ref)
   if (!prefix.empty()) {
     name = prefix + "{" + tfield->get_name() + "}";
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                 name);
+    generate_deserialize_struct(out, (t_struct*)type, name);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      "$xfer += $input->";
+    indent(out) << "$xfer += $input->";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "readString(\\$" << name << ");";
@@ -1331,7 +1190,8 @@ void t_perl_generator::generate_deserialize_field(ofstream &out,
 
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type->get_name().c_str());
+           tfield->get_name().c_str(),
+           type->get_name().c_str());
   }
 }
 
@@ -1341,17 +1201,15 @@ void t_perl_generator::generate_deserialize_field(ofstream &out,
  * buffer for deserialization, and that there is a variable protocol which
  * is a reference to a TProtocol serialization object.
  */
-void t_perl_generator::generate_deserialize_struct(ofstream &out,
+void t_perl_generator::generate_deserialize_struct(ofstream& out,
                                                    t_struct* tstruct,
                                                    string prefix) {
-  out <<
-    indent() << "$" << prefix << " = new " << perl_namespace(tstruct->get_program()) << tstruct->get_name() << "();" << endl <<
-    indent() << "$xfer += $" << prefix << "->read($input);" << endl;
+  out << indent() << "$" << prefix << " = new " << perl_namespace(tstruct->get_program())
+      << tstruct->get_name() << "();" << endl << indent() << "$xfer += $" << prefix
+      << "->read($input);" << endl;
 }
 
-void t_perl_generator::generate_deserialize_container(ofstream &out,
-                                                      t_type* ttype,
-                                                      string prefix) {
+void t_perl_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
   scope_up(out);
 
   string size = tmp("_size");
@@ -1364,43 +1222,33 @@ void t_perl_generator::generate_deserialize_container(ofstream &out,
   t_field fvtype(g_type_byte, vtype);
   t_field fetype(g_type_byte, etype);
 
-  out <<
-    indent() << "my $" << size << " = 0;" << endl;
+  out << indent() << "my $" << size << " = 0;" << endl;
 
   // Declare variables, read header
   if (ttype->is_map()) {
-    out <<
-      indent() << "$" << prefix << " = {};" << endl <<
-      indent() << "my $" << ktype << " = 0;" << endl <<
-      indent() << "my $" << vtype << " = 0;" << endl;
+    out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << ktype << " = 0;"
+        << endl << indent() << "my $" << vtype << " = 0;" << endl;
 
-    out <<
-      indent() << "$xfer += $input->readMapBegin(" <<
-      "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << endl;
+    out << indent() << "$xfer += $input->readMapBegin("
+        << "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << endl;
 
   } else if (ttype->is_set()) {
 
-    out <<
-      indent() << "$" << prefix << " = {};" << endl <<
-      indent() << "my $" << etype << " = 0;" << endl <<
-      indent() << "$xfer += $input->readSetBegin(" <<
-      "\\$" << etype << ", \\$" << size << ");" << endl;
+    out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << etype << " = 0;"
+        << endl << indent() << "$xfer += $input->readSetBegin("
+        << "\\$" << etype << ", \\$" << size << ");" << endl;
 
   } else if (ttype->is_list()) {
 
-    out <<
-      indent() << "$" << prefix << " = [];" << endl <<
-      indent() << "my $" << etype << " = 0;" << endl <<
-      indent() << "$xfer += $input->readListBegin(" <<
-      "\\$" << etype << ", \\$" << size << ");" << endl;
-
+    out << indent() << "$" << prefix << " = [];" << endl << indent() << "my $" << etype << " = 0;"
+        << endl << indent() << "$xfer += $input->readListBegin("
+        << "\\$" << etype << ", \\$" << size << ");" << endl;
   }
 
   // For loop iterates over elements
   string i = tmp("_i");
-  indent(out) <<
-    "for (my $" <<
-    i << " = 0; $" << i << " < $" << size << "; ++$" << i << ")" << endl;
+  indent(out) << "for (my $" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ")"
+              << endl;
 
   scope_up(out);
 
@@ -1414,7 +1262,6 @@ void t_perl_generator::generate_deserialize_container(ofstream &out,
 
   scope_down(out);
 
-
   // Read container end
   if (ttype->is_map()) {
     indent(out) << "$xfer += $input->readMapEnd();" << endl;
@@ -1427,103 +1274,81 @@ void t_perl_generator::generate_deserialize_container(ofstream &out,
   scope_down(out);
 }
 
-
 /**
  * Generates code to deserialize a map
  */
-void t_perl_generator::generate_deserialize_map_element(ofstream &out,
-                                                        t_map* tmap,
-                                                        string prefix) {
+void t_perl_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
   string key = tmp("key");
   string val = tmp("val");
   t_field fkey(tmap->get_key_type(), key);
   t_field fval(tmap->get_val_type(), val);
 
-  indent(out) <<
-    declare_field(&fkey, true, true) << endl;
-  indent(out) <<
-    declare_field(&fval, true, true) << endl;
+  indent(out) << declare_field(&fkey, true, true) << endl;
+  indent(out) << declare_field(&fval, true, true) << endl;
 
   generate_deserialize_field(out, &fkey);
   generate_deserialize_field(out, &fval);
 
-  indent(out) <<
-    "$" << prefix << "->{$" << key << "} = $" << val << ";" << endl;
+  indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << endl;
 }
 
-void t_perl_generator::generate_deserialize_set_element(ofstream &out,
-                                                        t_set* tset,
-                                                        string prefix) {
+void t_perl_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
   string elem = tmp("elem");
   t_field felem(tset->get_elem_type(), elem);
 
-  indent(out) <<
-    "my $" << elem << " = undef;" << endl;
+  indent(out) << "my $" << elem << " = undef;" << endl;
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-    "$" << prefix << "->{$" << elem << "} = 1;" << endl;
+  indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << endl;
 }
 
-void t_perl_generator::generate_deserialize_list_element(ofstream &out,
+void t_perl_generator::generate_deserialize_list_element(ofstream& out,
                                                          t_list* tlist,
                                                          string prefix) {
   string elem = tmp("elem");
   t_field felem(tlist->get_elem_type(), elem);
 
-  indent(out) <<
-    "my $" << elem << " = undef;" << endl;
+  indent(out) << "my $" << elem << " = undef;" << endl;
 
   generate_deserialize_field(out, &felem);
 
-  indent(out) <<
-    "push(@{$" << prefix << "},$" << elem << ");" << endl;
+  indent(out) << "push(@{$" << prefix << "},$" << elem << ");" << endl;
 }
 
-
 /**
  * Serializes a field of any type.
  *
  * @param tfield The field to serialize
  * @param prefix Name to prepend to field name
  */
-void t_perl_generator::generate_serialize_field(ofstream &out,
-                                                t_field* tfield,
-                                                string prefix) {
+void t_perl_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
   t_type* type = get_true_type(tfield->get_type());
 
   // Do nothing for void types
   if (type->is_void()) {
-    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   if (type->is_struct() || type->is_xception()) {
-    generate_serialize_struct(out,
-                              (t_struct*)type,
-                               prefix + "{"+tfield->get_name()+"}" );
+    generate_serialize_struct(out, (t_struct*)type, prefix + "{" + tfield->get_name() + "}");
   } else if (type->is_container()) {
-    generate_serialize_container(out,
-                                 type,
-                                 prefix + "{" + tfield->get_name()+"}");
+    generate_serialize_container(out, type, prefix + "{" + tfield->get_name() + "}");
   } else if (type->is_base_type() || type->is_enum()) {
 
     string name = tfield->get_name();
 
-    //Hack for when prefix is defined (always a hash ref)
-    if(!prefix.empty())
+    // Hack for when prefix is defined (always a hash ref)
+    if (!prefix.empty())
       name = prefix + "{" + tfield->get_name() + "}";
 
-    indent(out) <<
-      "$xfer += $output->";
+    indent(out) << "$xfer += $output->";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw
-          "compiler error: cannot serialize void field in a struct: " + name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         out << "writeString($" << name << ");";
@@ -1568,41 +1393,32 @@ void t_perl_generator::generate_serialize_field(ofstream &out,
  * @param tstruct The struct to serialize
  * @param prefix  String prefix to attach to all fields
  */
-void t_perl_generator::generate_serialize_struct(ofstream &out,
-                                                 t_struct* tstruct,
-                                                 string prefix) {
-  (void) tstruct;
-  indent(out) <<
-      "$xfer += $" << prefix << "->write($output);" << endl;
+void t_perl_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  (void)tstruct;
+  indent(out) << "$xfer += $" << prefix << "->write($output);" << endl;
 }
 
 /**
  * Writes out a container
  */
-void t_perl_generator::generate_serialize_container(ofstream &out,
-                                                    t_type* ttype,
-                                                    string prefix) {
+void t_perl_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   scope_up(out);
 
   if (ttype->is_map()) {
-    indent(out) <<
-      "$xfer += $output->writeMapBegin(" <<
-      type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
-      type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
-      "scalar(keys %{$" << prefix << "}));" << endl;
+    indent(out) << "$xfer += $output->writeMapBegin("
+                << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
+                << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
+                << "scalar(keys %{$" << prefix << "}));" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "$xfer += $output->writeSetBegin(" <<
-      type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
-      "scalar(@{$" << prefix << "}));" << endl;
+    indent(out) << "$xfer += $output->writeSetBegin("
+                << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
+                << "scalar(@{$" << prefix << "}));" << endl;
 
   } else if (ttype->is_list()) {
 
-    indent(out) <<
-      "$xfer += $output->writeListBegin(" <<
-      type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
-      "scalar(@{$" << prefix << "}));" << endl;
-
+    indent(out) << "$xfer += $output->writeListBegin("
+                << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
+                << "scalar(@{$" << prefix << "}));" << endl;
   }
 
   scope_up(out);
@@ -1610,8 +1426,8 @@ void t_perl_generator::generate_serialize_container(ofstream &out,
   if (ttype->is_map()) {
     string kiter = tmp("kiter");
     string viter = tmp("viter");
-    indent(out) <<
-      "while( my ($"<<kiter<<",$"<<viter<<") = each %{$" << prefix << "}) " << endl;
+    indent(out) << "while( my ($" << kiter << ",$" << viter << ") = each %{$" << prefix << "}) "
+                << endl;
 
     scope_up(out);
     generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
@@ -1619,17 +1435,14 @@ void t_perl_generator::generate_serialize_container(ofstream &out,
 
   } else if (ttype->is_set()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "foreach my $"<<iter<<" (@{$" << prefix << "})" << endl;
+    indent(out) << "foreach my $" << iter << " (@{$" << prefix << "})" << endl;
     scope_up(out);
     generate_serialize_set_element(out, (t_set*)ttype, iter);
     scope_down(out);
 
-
   } else if (ttype->is_list()) {
     string iter = tmp("iter");
-    indent(out) <<
-      "foreach my $"<<iter<<" (@{$" << prefix << "}) " << endl;
+    indent(out) << "foreach my $" << iter << " (@{$" << prefix << "}) " << endl;
     scope_up(out);
     generate_serialize_list_element(out, (t_list*)ttype, iter);
     scope_down(out);
@@ -1638,14 +1451,11 @@ void t_perl_generator::generate_serialize_container(ofstream &out,
   scope_down(out);
 
   if (ttype->is_map()) {
-    indent(out) <<
-      "$xfer += $output->writeMapEnd();" << endl;
+    indent(out) << "$xfer += $output->writeMapEnd();" << endl;
   } else if (ttype->is_set()) {
-    indent(out) <<
-      "$xfer += $output->writeSetEnd();" << endl;
+    indent(out) << "$xfer += $output->writeSetEnd();" << endl;
   } else if (ttype->is_list()) {
-    indent(out) <<
-      "$xfer += $output->writeListEnd();" << endl;
+    indent(out) << "$xfer += $output->writeListEnd();" << endl;
   }
 
   scope_down(out);
@@ -1655,7 +1465,7 @@ void t_perl_generator::generate_serialize_container(ofstream &out,
  * Serializes the members of a map.
  *
  */
-void t_perl_generator::generate_serialize_map_element(ofstream &out,
+void t_perl_generator::generate_serialize_map_element(ofstream& out,
                                                       t_map* tmap,
                                                       string kiter,
                                                       string viter) {
@@ -1669,9 +1479,7 @@ void t_perl_generator::generate_serialize_map_element(ofstream &out,
 /**
  * Serializes the members of a set.
  */
-void t_perl_generator::generate_serialize_set_element(ofstream &out,
-                                                      t_set* tset,
-                                                      string iter) {
+void t_perl_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
   t_field efield(tset->get_elem_type(), iter);
   generate_serialize_field(out, &efield);
 }
@@ -1679,9 +1487,7 @@ void t_perl_generator::generate_serialize_set_element(ofstream &out,
 /**
  * Serializes the members of a list.
  */
-void t_perl_generator::generate_serialize_list_element(ofstream &out,
-                                                       t_list* tlist,
-                                                       string iter) {
+void t_perl_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
   t_field efield(tlist->get_elem_type(), iter);
   generate_serialize_field(out, &efield);
 }
@@ -1716,7 +1522,8 @@ string t_perl_generator::declare_field(t_field* tfield, bool init, bool obj) {
         result += " = 0.0";
         break;
       default:
-        throw "compiler error: no PERL initializer for base type " + t_base_type::t_base_name(tbase);
+        throw "compiler error: no PERL initializer for base type "
+            + t_base_type::t_base_name(tbase);
       }
     } else if (type->is_enum()) {
       result += " = 0";
@@ -1739,16 +1546,15 @@ string t_perl_generator::declare_field(t_field* tfield, bool init, bool obj) {
  * @param tfunction Function definition
  * @return String of rendered function definition
  */
-string t_perl_generator::function_signature(t_function* tfunction,
-                                            string prefix) {
+string t_perl_generator::function_signature(t_function* tfunction, string prefix) {
 
   string str;
 
-  str  = prefix + tfunction->get_name() + "{\n";
+  str = prefix + tfunction->get_name() + "{\n";
   str += "  my $self = shift;\n";
 
-  //Need to create perl function arg inputs
-  const vector<t_field*> &fields = tfunction->get_arglist()->get_members();
+  // Need to create perl function arg inputs
+  const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1781,7 +1587,7 @@ string t_perl_generator::argument_list(t_struct* tstruct) {
 /**
  * Converts the parse type to a C++ enum string for the given type.
  */
-string t_perl_generator ::type_to_enum(t_type* type) {
+string t_perl_generator::type_to_enum(t_type* type) {
   type = get_true_type(type);
 
   if (type->is_base_type()) {
@@ -1820,4 +1626,3 @@ string t_perl_generator ::type_to_enum(t_type* type) {
 }
 
 THRIFT_REGISTER_GENERATOR(perl, "Perl", "")
-


[23/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 4e2046f..4e5b3ef 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -40,7 +40,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Java code generator.
@@ -48,19 +48,17 @@ static const string endl = "\n";  // avoid ostream << std::endl flushes
  */
 class t_java_generator : public t_oop_generator {
 public:
-  t_java_generator(
-                   t_program* program,
+  t_java_generator(t_program* program,
                    const std::map<std::string, std::string>& parsed_options,
                    const std::string& option_string)
-  : t_oop_generator(program)
-  {
-    (void) option_string;
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("beans");
     bean_style_ = (iter != parsed_options.end());
 
-	iter = parsed_options.find("android");
+    iter = parsed_options.find("android");
     android_style_ = (iter != parsed_options.end());
 
     iter = parsed_options.find("private-members");
@@ -103,14 +101,19 @@ public:
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_union   (t_struct*   tunion);
-  void generate_xception(t_struct*   txception);
-  void generate_service (t_service*  tservice);
-
-  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_union(t_struct* tunion);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  void print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool in_static,
+                         bool defval = false);
   std::string render_const_value(std::ofstream& out, t_type* type, t_const_value* value);
 
   /**
@@ -119,7 +122,11 @@ public:
 
   void generate_java_struct(t_struct* tstruct, bool is_exception);
 
-  void generate_java_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
+  void generate_java_struct_definition(std::ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_xception = false,
+                                       bool in_class = false,
+                                       bool is_result = false);
   void generate_java_struct_parcelable(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_equality(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_compare_to(std::ofstream& out, t_struct* tstruct);
@@ -135,14 +142,20 @@ public:
   void generate_field_value_meta_data(std::ofstream& out, t_type* type);
   std::string get_java_type_string(t_type* type);
   void generate_java_struct_field_by_id(ofstream& out, t_struct* tstruct);
-  void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
-  void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
+  void generate_reflection_setters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
+  void generate_reflection_getters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
   void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
   void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
   void generate_java_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
 
   void generate_function_helpers(t_function* tfunction);
-  std::string as_camel_case(std::string name, bool ucfirst=true);
+  std::string as_camel_case(std::string name, bool ucfirst = true);
   std::string get_rpc_method_name(std::string name);
   std::string get_cap_name(std::string name);
   std::string generate_isset_check(t_field* field);
@@ -150,16 +163,15 @@ public:
   void generate_isset_set(ofstream& out, t_field* field, std::string prefix);
   std::string isset_field_id(t_field* field);
 
-  void generate_service_interface (t_service* tservice);
+  void generate_service_interface(t_service* tservice);
   void generate_service_async_interface(t_service* tservice);
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
   void generate_service_async_client(t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_service_async_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
-  void generate_process_async_function  (t_service* tservice, t_function* tfunction);
-
+  void generate_service_server(t_service* tservice);
+  void generate_service_async_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
+  void generate_process_async_function(t_service* tservice, t_function* tfunction);
 
   void generate_java_union(t_struct* tstruct);
   void generate_union_constructor(ofstream& out, t_struct* tstruct);
@@ -192,73 +204,76 @@ public:
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool has_metadata = true);
-
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
-
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="",
-                                          bool has_metadata = true);
-
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="",
-                                          std::string obj="",
-                                          bool has_metadata = true);
-
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="",
-                                          std::string obj="",
-                                          bool has_metadata = true);
-
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix="",
-                                          std::string obj="",
-                                          bool has_metadata = true);
-
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool has_metadata = true);
-
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
-
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="",
-                                          bool has_metadata = true);
-
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter,
-                                          std::string map,
-                                          bool has_metadata = true);
-
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter,
-                                          bool has_metadata = true);
-
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string iter,
-                                          bool has_metadata = true);
-
-  void generate_deep_copy_container(std::ofstream& out, std::string source_name_p1, std::string source_name_p2, std::string result_name, t_type* type);
-  void generate_deep_copy_non_container(std::ofstream& out, std::string source_name, std::string dest_name, t_type* type);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool has_metadata = true);
+
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+
+  void generate_deserialize_container(std::ofstream& out,
+                                      t_type* ttype,
+                                      std::string prefix = "",
+                                      bool has_metadata = true);
+
+  void generate_deserialize_set_element(std::ofstream& out,
+                                        t_set* tset,
+                                        std::string prefix = "",
+                                        std::string obj = "",
+                                        bool has_metadata = true);
+
+  void generate_deserialize_map_element(std::ofstream& out,
+                                        t_map* tmap,
+                                        std::string prefix = "",
+                                        std::string obj = "",
+                                        bool has_metadata = true);
+
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "",
+                                         std::string obj = "",
+                                         bool has_metadata = true);
+
+  void generate_serialize_field(std::ofstream& out,
+                                t_field* tfield,
+                                std::string prefix = "",
+                                bool has_metadata = true);
+
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+
+  void generate_serialize_container(std::ofstream& out,
+                                    t_type* ttype,
+                                    std::string prefix = "",
+                                    bool has_metadata = true);
+
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map,
+                                      bool has_metadata = true);
+
+  void generate_serialize_set_element(std::ofstream& out,
+                                      t_set* tmap,
+                                      std::string iter,
+                                      bool has_metadata = true);
+
+  void generate_serialize_list_element(std::ofstream& out,
+                                       t_list* tlist,
+                                       std::string iter,
+                                       bool has_metadata = true);
+
+  void generate_deep_copy_container(std::ofstream& out,
+                                    std::string source_name_p1,
+                                    std::string source_name_p2,
+                                    std::string result_name,
+                                    t_type* type);
+  void generate_deep_copy_non_container(std::ofstream& out,
+                                        std::string source_name,
+                                        std::string dest_name,
+                                        t_type* type);
 
   enum isset_type { ISSET_NONE, ISSET_PRIMITIVE, ISSET_BITSET };
-  isset_type needs_isset(t_struct* tstruct, std::string *outPrimitiveType = NULL);
+  isset_type needs_isset(t_struct* tstruct, std::string* outPrimitiveType = NULL);
 
   /**
    * Helper rendering functions
@@ -267,37 +282,43 @@ public:
   std::string java_package();
   std::string java_type_imports();
   std::string java_suppressions();
-  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false, bool force_namespace = false);
-  std::string base_type_name(t_base_type* tbase, bool in_container=false);
-  std::string declare_field(t_field* tfield, bool init=false, bool comment=false);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
-  std::string function_signature_async(t_function* tfunction, bool use_base_method = false, std::string prefix="");
+  std::string type_name(t_type* ttype,
+                        bool in_container = false,
+                        bool in_init = false,
+                        bool skip_generic = false,
+                        bool force_namespace = false);
+  std::string base_type_name(t_base_type* tbase, bool in_container = false);
+  std::string declare_field(t_field* tfield, bool init = false, bool comment = false);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string function_signature_async(t_function* tfunction,
+                                       bool use_base_method = false,
+                                       std::string prefix = "");
   std::string argument_list(t_struct* tstruct, bool include_types = true);
-  std::string async_function_call_arglist(t_function* tfunc, bool use_base_method = true, bool include_types = true);
-  std::string async_argument_list(t_function* tfunct, t_struct* tstruct, t_type* ttype, bool include_types=false);
+  std::string async_function_call_arglist(t_function* tfunc,
+                                          bool use_base_method = true,
+                                          bool include_types = true);
+  std::string async_argument_list(t_function* tfunct,
+                                  t_struct* tstruct,
+                                  t_type* ttype,
+                                  bool include_types = false);
   std::string type_to_enum(t_type* ttype);
   void generate_struct_desc(ofstream& out, t_struct* tstruct);
   void generate_field_descs(ofstream& out, t_struct* tstruct);
   void generate_field_name_constants(ofstream& out, t_struct* tstruct);
 
-  std::string make_valid_java_filename( std::string const & fromName);
-  std::string make_valid_java_identifier( std::string const & fromName);
+  std::string make_valid_java_filename(std::string const& fromName);
+  std::string make_valid_java_identifier(std::string const& fromName);
 
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return
-      ttype->is_container() ||
-      ttype->is_struct() ||
-      ttype->is_xception() ||
-      ttype->is_string() ||
-      ttype->is_enum();
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception() || ttype->is_string()
+           || ttype->is_enum();
   }
 
   std::string constant_name(std::string name);
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -317,7 +338,6 @@ public:
   bool reuse_objects_;
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -335,7 +355,7 @@ void t_java_generator::init_generator() {
   while ((loc = dir.find(".")) != string::npos) {
     subdir = subdir + "/" + dir.substr(0, loc);
     MKDIR(subdir.c_str());
-    dir = dir.substr(loc+1);
+    dir = dir.substr(loc + 1);
   }
   if (dir.size() > 0) {
     subdir = subdir + "/" + dir;
@@ -366,40 +386,25 @@ string t_java_generator::java_type_imports() {
   string hash_builder;
   string tree_set_and_map;
   if (sorted_containers_) {
-    tree_set_and_map = string() +
-      "import java.util.TreeSet;\n" +
-      "import java.util.TreeMap;\n";
-  }
-
-  return
-    string() +
-    hash_builder +
-    "import org.apache.thrift.scheme.IScheme;\n" +
-    "import org.apache.thrift.scheme.SchemeFactory;\n" +
-    "import org.apache.thrift.scheme.StandardScheme;\n\n" +
-    "import org.apache.thrift.scheme.TupleScheme;\n" +
-    "import org.apache.thrift.protocol.TTupleProtocol;\n" +
-    "import org.apache.thrift.protocol.TProtocolException;\n" +
-    "import org.apache.thrift.EncodingUtils;\n" +
-    "import org.apache.thrift.TException;\n" +
-    "import org.apache.thrift.async.AsyncMethodCallback;\n"+
-    "import org.apache.thrift.server.AbstractNonblockingServer.*;\n"+
-    "import java.util.List;\n" +
-    "import java.util.ArrayList;\n" +
-    "import java.util.Map;\n" +
-    "import java.util.HashMap;\n" +
-    "import java.util.EnumMap;\n" +
-    "import java.util.Set;\n" +
-    "import java.util.HashSet;\n" +
-    "import java.util.EnumSet;\n" +
-    tree_set_and_map +
-    "import java.util.Collections;\n" +
-    "import java.util.BitSet;\n" +
-    "import java.nio.ByteBuffer;\n"
-    "import java.util.Arrays;\n" +
-    "import javax.annotation.Generated;\n" +
-    "import org.slf4j.Logger;\n" +
-    "import org.slf4j.LoggerFactory;\n\n";
+    tree_set_and_map = string() + "import java.util.TreeSet;\n" + "import java.util.TreeMap;\n";
+  }
+
+  return string() + hash_builder + "import org.apache.thrift.scheme.IScheme;\n"
+         + "import org.apache.thrift.scheme.SchemeFactory;\n"
+         + "import org.apache.thrift.scheme.StandardScheme;\n\n"
+         + "import org.apache.thrift.scheme.TupleScheme;\n"
+         + "import org.apache.thrift.protocol.TTupleProtocol;\n"
+         + "import org.apache.thrift.protocol.TProtocolException;\n"
+         + "import org.apache.thrift.EncodingUtils;\n" + "import org.apache.thrift.TException;\n"
+         + "import org.apache.thrift.async.AsyncMethodCallback;\n"
+         + "import org.apache.thrift.server.AbstractNonblockingServer.*;\n"
+         + "import java.util.List;\n" + "import java.util.ArrayList;\n" + "import java.util.Map;\n"
+         + "import java.util.HashMap;\n" + "import java.util.EnumMap;\n" + "import java.util.Set;\n"
+         + "import java.util.HashSet;\n" + "import java.util.EnumSet;\n" + tree_set_and_map
+         + "import java.util.Collections;\n" + "import java.util.BitSet;\n"
+         + "import java.nio.ByteBuffer;\n"
+           "import java.util.Arrays;\n" + "import javax.annotation.Generated;\n"
+         + "import org.slf4j.Logger;\n" + "import org.slf4j.LoggerFactory;\n\n";
 }
 
 string t_java_generator::java_suppressions() {
@@ -409,7 +414,8 @@ string t_java_generator::java_suppressions() {
 /**
  * Nothing in Java
  */
-void t_java_generator::close_generator() {}
+void t_java_generator::close_generator() {
+}
 
 /**
  * Generates a typedef. This is not done in Java, since it does
@@ -419,7 +425,7 @@ void t_java_generator::close_generator() {}
  * @param ttypedef The type definition
  */
 void t_java_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -429,24 +435,19 @@ void t_java_generator::generate_typedef(t_typedef* ttypedef) {
  */
 void t_java_generator::generate_enum(t_enum* tenum) {
   // Make output file
-  string f_enum_name = package_dir_+"/"+make_valid_java_filename(tenum->get_name())+".java";
+  string f_enum_name = package_dir_ + "/" + make_valid_java_filename(tenum->get_name()) + ".java";
   ofstream f_enum;
   f_enum.open(f_enum_name.c_str());
 
   // Comment and package it
-  f_enum <<
-    autogen_comment() <<
-    java_package() << endl;
+  f_enum << autogen_comment() << java_package() << endl;
 
   // Add java imports
-  f_enum << string() +
-    "import java.util.Map;\n" +
-    "import java.util.HashMap;\n" +
-    "import org.apache.thrift.TEnum;" << endl << endl;
+  f_enum << string() + "import java.util.Map;\n" + "import java.util.HashMap;\n"
+            + "import org.apache.thrift.TEnum;" << endl << endl;
 
   generate_java_doc(f_enum, tenum);
-  indent(f_enum) <<
-    "public enum " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
+  indent(f_enum) << "public enum " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
   scope_up(f_enum);
 
   vector<t_enum_value*> constants = tenum->get_constants();
@@ -470,21 +471,23 @@ void t_java_generator::generate_enum(t_enum* tenum) {
   indent(f_enum) << "private final int value;" << endl << endl;
 
   indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl;
-  indent(f_enum) << "  this.value = value;" <<endl;
+  indent(f_enum) << "  this.value = value;" << endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL." << endl;
+  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL."
+                 << endl;
   indent(f_enum) << " */" << endl;
   indent(f_enum) << "public int getValue() {" << endl;
-  indent(f_enum) << "  return value;" <<endl;
+  indent(f_enum) << "  return value;" << endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL." << endl;
+  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL."
+                 << endl;
   indent(f_enum) << " * @return null if the value is not found." << endl;
   indent(f_enum) << " */" << endl;
-  indent(f_enum) << "public static "+ tenum->get_name() + " findByValue(int value) { " << endl;
+  indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl;
 
   indent_up();
 
@@ -521,20 +524,16 @@ void t_java_generator::generate_consts(std::vector<t_const*> consts) {
     return;
   }
 
-  string f_consts_name = package_dir_+ '/' + make_valid_java_filename(program_name_) + "Constants.java";
+  string f_consts_name = package_dir_ + '/' + make_valid_java_filename(program_name_)
+                         + "Constants.java";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
   // Print header
-  f_consts <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_suppressions();
-
-  f_consts <<
-    "public class " << make_valid_java_identifier(program_name_) << "Constants {" << endl <<
-    endl;
+  f_consts << autogen_comment() << java_package() << java_type_imports() << java_suppressions();
+
+  f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << endl
+           << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -550,20 +549,22 @@ void t_java_generator::generate_consts(std::vector<t_const*> consts) {
   f_consts.close();
 }
 
-
 /**
  * Prints the value of a constant with the given type. Note that type checking
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-void t_java_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
+void t_java_generator::print_const_value(std::ofstream& out,
+                                         string name,
+                                         t_type* type,
+                                         t_const_value* value,
+                                         bool in_static,
+                                         bool defval) {
   type = get_true_type(type);
 
   indent(out);
   if (!defval) {
-    out <<
-      (in_static ? "" : "public static final ") <<
-      type_name(type) << " ";
+    out << (in_static ? "" : "public static final ") << type_name(type) << " ";
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, type, value);
@@ -655,36 +656,37 @@ string t_java_generator::render_const_value(ofstream& out, t_type* type, t_const
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        render << '"' << get_escaped_string(value) << '"';
-        break;
-      case t_base_type::TYPE_BOOL:
-        render << ((value->get_integer() > 0) ? "true" : "false");
-        break;
-      case t_base_type::TYPE_BYTE:
-        render << "(byte)" << value->get_integer();
-        break;
-      case t_base_type::TYPE_I16:
-        render << "(short)" << value->get_integer();
-        break;
-      case t_base_type::TYPE_I32:
-        render << value->get_integer();
-        break;
-      case t_base_type::TYPE_I64:
-        render << value->get_integer() << "L";
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        if (value->get_type() == t_const_value::CV_INTEGER) {
-          render << "(double)" << value->get_integer();
-        } else {
-          render << value->get_double();
-        }
-        break;
-      default:
-        throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    case t_base_type::TYPE_STRING:
+      render << '"' << get_escaped_string(value) << '"';
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() > 0) ? "true" : "false");
+      break;
+    case t_base_type::TYPE_BYTE:
+      render << "(byte)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I16:
+      render << "(short)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I32:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_I64:
+      render << value->get_integer() << "L";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        render << "(double)" << value->get_integer();
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
-    render << type->get_program()->get_namespace("java") << "." << value->get_identifier_with_parent();
+    render << type->get_program()->get_namespace("java") << "."
+           << value->get_identifier_with_parent();
   } else {
     string t = tmp("tmp");
     print_const_value(out, t, type, value, true);
@@ -717,28 +719,21 @@ void t_java_generator::generate_xception(t_struct* txception) {
   generate_java_struct(txception, true);
 }
 
-
 /**
  * Java struct definition.
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_struct(t_struct* tstruct,
-                                            bool is_exception) {
+void t_java_generator::generate_java_struct(t_struct* tstruct, bool is_exception) {
   // Make output file
-  string f_struct_name = package_dir_+"/"+make_valid_java_filename(tstruct->get_name())+".java";
+  string f_struct_name = package_dir_ + "/" + make_valid_java_filename(tstruct->get_name())
+                         + ".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_suppressions();
+  f_struct << autogen_comment() << java_package() << java_type_imports() << java_suppressions();
 
-  generate_java_struct_definition(f_struct,
-                                  tstruct,
-                                  is_exception);
+  generate_java_struct_definition(f_struct, tstruct, is_exception);
   f_struct.close();
 }
 
@@ -749,23 +744,20 @@ void t_java_generator::generate_java_struct(t_struct* tstruct,
  */
 void t_java_generator::generate_java_union(t_struct* tstruct) {
   // Make output file
-  string f_struct_name = package_dir_+"/"+make_valid_java_filename(tstruct->get_name())+".java";
+  string f_struct_name = package_dir_ + "/" + make_valid_java_filename(tstruct->get_name())
+                         + ".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-    java_package() <<
-    java_type_imports() <<
-    java_suppressions();
+  f_struct << autogen_comment() << java_package() << java_type_imports() << java_suppressions();
 
   generate_java_doc(f_struct, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(f_struct) <<
-    "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
-    << " extends org.apache.thrift.TUnion<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields> ";
+  indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
+                   << " extends org.apache.thrift.TUnion<" << tstruct->get_name() << ", "
+                   << tstruct->get_name() << "._Fields> ";
 
   scope_up(f_struct);
 
@@ -831,7 +823,8 @@ void t_java_generator::generate_union_constructor(ofstream& out, t_struct* tstru
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* type = get_true_type((*m_iter)->get_type());
     if ((*m_iter)->get_value() != NULL) {
-      indent(out) << "super(_Fields." << constant_name((*m_iter)->get_name()) << ", " << render_const_value(out, type, (*m_iter)->get_value()) << ");" << endl;
+      indent(out) << "super(_Fields." << constant_name((*m_iter)->get_name()) << ", "
+                  << render_const_value(out, type, (*m_iter)->get_value()) << ");" << endl;
       default_value = true;
       break;
     }
@@ -846,7 +839,8 @@ void t_java_generator::generate_union_constructor(ofstream& out, t_struct* tstru
   indent(out) << "  super(setField, value);" << endl;
   indent(out) << "}" << endl << endl;
 
-  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" << endl;
+  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {"
+              << endl;
   indent(out) << "  super(other);" << endl;
   indent(out) << "}" << endl;
 
@@ -857,16 +851,20 @@ void t_java_generator::generate_union_constructor(ofstream& out, t_struct* tstru
   // generate "constructors" for each field
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* type = (*m_iter)->get_type();
-    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(" << type_name(type) << " value) {" << endl;
+    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "("
+                << type_name(type) << " value) {" << endl;
     indent(out) << "  " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
     indent(out) << "  x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl;
     indent(out) << "  return x;" << endl;
     indent(out) << "}" << endl << endl;
 
     if (type->is_base_type() && ((t_base_type*)type)->is_binary()) {
-      indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(byte[] value) {" << endl;
-      indent(out) << "  " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
-      indent(out) << "  x.set" << get_cap_name((*m_iter)->get_name()) << "(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));" << endl;
+      indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name()
+                  << "(byte[] value) {" << endl;
+      indent(out) << "  " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();"
+                  << endl;
+      indent(out) << "  x.set" << get_cap_name((*m_iter)->get_name())
+                  << "(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));" << endl;
       indent(out) << "  return x;" << endl;
       indent(out) << "}" << endl << endl;
     }
@@ -892,28 +890,38 @@ void t_java_generator::generate_union_getters_and_setters(ofstream& out, t_struc
     generate_java_doc(out, field);
     if (type->is_base_type() && ((t_base_type*)type)->is_binary()) {
       indent(out) << "public byte[] get" << cap_name << "() {" << endl;
-      indent(out) << "  set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(buffer" << get_cap_name("for") << cap_name << "()));" << endl;
+      indent(out) << "  set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(buffer"
+                  << get_cap_name("for") << cap_name << "()));" << endl;
       indent(out) << "  ByteBuffer b = buffer" << get_cap_name("for") << cap_name << "();" << endl;
       indent(out) << "  return b == null ? null : b.array();" << endl;
       indent(out) << "}" << endl;
 
       out << endl;
 
-      indent(out) << "public ByteBuffer buffer" << get_cap_name("for") << get_cap_name(field->get_name()) << "() {" << endl;
-      indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" << endl;
-      indent(out) << "    return org.apache.thrift.TBaseHelper.copyBinary((ByteBuffer)getFieldValue());" << endl;
+      indent(out) << "public ByteBuffer buffer" << get_cap_name("for")
+                  << get_cap_name(field->get_name()) << "() {" << endl;
+      indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
+                  << endl;
+      indent(out)
+          << "    return org.apache.thrift.TBaseHelper.copyBinary((ByteBuffer)getFieldValue());"
+          << endl;
       indent(out) << "  } else {" << endl;
       indent(out) << "    throw new RuntimeException(\"Cannot get field '" << field->get_name()
-        << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" << endl;
+                  << "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
+                  << endl;
       indent(out) << "  }" << endl;
       indent(out) << "}" << endl;
     } else {
-      indent(out) << "public " << type_name(field->get_type()) << " get" << get_cap_name(field->get_name()) << "() {" << endl;
-      indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" << endl;
-      indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();" << endl;
+      indent(out) << "public " << type_name(field->get_type()) << " get"
+                  << get_cap_name(field->get_name()) << "() {" << endl;
+      indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
+                  << endl;
+      indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();"
+                  << endl;
       indent(out) << "  } else {" << endl;
       indent(out) << "    throw new RuntimeException(\"Cannot get field '" << field->get_name()
-        << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" << endl;
+                  << "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
+                  << endl;
       indent(out) << "  }" << endl;
       indent(out) << "}" << endl;
     }
@@ -922,13 +930,16 @@ void t_java_generator::generate_union_getters_and_setters(ofstream& out, t_struc
 
     generate_java_doc(out, field);
     if (type->is_base_type() && ((t_base_type*)type)->is_binary()) {
-      indent(out) << "public void set" << get_cap_name(field->get_name()) << "(byte[] value) {" << endl;
-      indent(out) << "  set" << get_cap_name(field->get_name()) << "(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));" << endl;
+      indent(out) << "public void set" << get_cap_name(field->get_name()) << "(byte[] value) {"
+                  << endl;
+      indent(out) << "  set" << get_cap_name(field->get_name())
+                  << "(ByteBuffer.wrap(Arrays.copyOf(value, value.length)));" << endl;
       indent(out) << "}" << endl;
 
       out << endl;
     }
-    indent(out) << "public void set" << get_cap_name(field->get_name()) << "(" << type_name(field->get_type()) << " value) {" << endl;
+    indent(out) << "public void set" << get_cap_name(field->get_name()) << "("
+                << type_name(field->get_type()) << " value) {" << endl;
     if (type_can_be_null(field->get_type())) {
       indent(out) << "  if (value == null) throw new NullPointerException();" << endl;
     }
@@ -952,7 +963,8 @@ void t_java_generator::generate_union_is_set_methods(ofstream& out, t_struct* ts
 
     std::string field_name = (*m_iter)->get_name();
 
-    indent(out) << "public boolean is" << get_cap_name("set") << get_cap_name(field_name) << "() {" << endl;
+    indent(out) << "public boolean is" << get_cap_name("set") << get_cap_name(field_name) << "() {"
+                << endl;
     indent_up();
     indent(out) << "return setField_ == _Fields." << constant_name(field_name) << ";" << endl;
     indent_down();
@@ -983,7 +995,9 @@ void t_java_generator::generate_union_abstract_methods(ofstream& out, t_struct*
 
 void t_java_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected void checkType(_Fields setField, Object value) throws ClassCastException {" << endl;
+  indent(out)
+      << "protected void checkType(_Fields setField, Object value) throws ClassCastException {"
+      << endl;
   indent_up();
 
   indent(out) << "switch (setField) {" << endl;
@@ -996,12 +1010,13 @@ void t_java_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
     t_field* field = (*m_iter);
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
-    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true) << ") {" << endl;
+    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true)
+                << ") {" << endl;
     indent(out) << "    break;" << endl;
     indent(out) << "  }" << endl;
     indent(out) << "  throw new ClassCastException(\"Was expecting value of type "
-      << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
-      << "', but got \" + value.getClass().getSimpleName());" << endl;
+                << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
+                << "', but got \" + value.getClass().getSimpleName());" << endl;
     // do the real check here
   }
 
@@ -1017,7 +1032,9 @@ void t_java_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
 
 void t_java_generator::generate_standard_scheme_read_value(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {" << endl;
+  indent(out) << "protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol "
+                 "iprot, org.apache.thrift.protocol.TField field) throws "
+                 "org.apache.thrift.TException {" << endl;
 
   indent_up();
 
@@ -1035,9 +1052,11 @@ void t_java_generator::generate_standard_scheme_read_value(ofstream& out, t_stru
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {" << endl;
+    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {"
+                << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
+                << endl;
     generate_deserialize_field(out, field, "");
     indent(out) << "return " << field->get_name() << ";" << endl;
     indent_down();
@@ -1049,7 +1068,8 @@ void t_java_generator::generate_standard_scheme_read_value(ofstream& out, t_stru
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any of the case statements!\");" << endl;
+  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any "
+                 "of the case statements!\");" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -1068,7 +1088,8 @@ void t_java_generator::generate_standard_scheme_read_value(ofstream& out, t_stru
 
 void t_java_generator::generate_standard_scheme_write_value(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl;
+  indent(out) << "protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol "
+                 "oprot) throws org.apache.thrift.TException {" << endl;
 
   indent_up();
 
@@ -1083,15 +1104,16 @@ void t_java_generator::generate_standard_scheme_write_value(ofstream& out, t_str
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name()
-      << " = (" <<  type_name(field->get_type(), true, false) << ")value_;" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
+                << type_name(field->get_type(), true, false) << ")value_;" << endl;
     generate_serialize_field(out, field, "");
     indent(out) << "return;" << endl;
     indent_down();
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField_);" << endl;
+  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + "
+                 "setField_);" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -1103,7 +1125,8 @@ void t_java_generator::generate_standard_scheme_write_value(ofstream& out, t_str
 
 void t_java_generator::generate_tuple_scheme_read_value(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {" << endl;
+  indent(out) << "protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol "
+                 "iprot, short fieldID) throws org.apache.thrift.TException {" << endl;
 
   indent_up();
 
@@ -1121,14 +1144,16 @@ void t_java_generator::generate_tuple_scheme_read_value(ofstream& out, t_struct*
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
+                << endl;
     generate_deserialize_field(out, field, "");
     indent(out) << "return " << field->get_name() << ";" << endl;
     indent_down();
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any of the case statements!\");" << endl;
+  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any "
+                 "of the case statements!\");" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -1136,7 +1161,8 @@ void t_java_generator::generate_tuple_scheme_read_value(ofstream& out, t_struct*
   indent_down();
   indent(out) << "} else {" << endl;
   indent_up();
-  indent(out) << "throw new TProtocolException(\"Couldn't find a field with field id \" + fieldID);" << endl;
+  indent(out) << "throw new TProtocolException(\"Couldn't find a field with field id \" + fieldID);"
+              << endl;
   indent_down();
   indent(out) << "}" << endl;
   indent_down();
@@ -1145,7 +1171,8 @@ void t_java_generator::generate_tuple_scheme_read_value(ofstream& out, t_struct*
 
 void t_java_generator::generate_tuple_scheme_write_value(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl;
+  indent(out) << "protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) "
+                 "throws org.apache.thrift.TException {" << endl;
 
   indent_up();
 
@@ -1160,15 +1187,16 @@ void t_java_generator::generate_tuple_scheme_write_value(ofstream& out, t_struct
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name()
-    << " = (" <<  type_name(field->get_type(), true, false) << ")value_;" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
+                << type_name(field->get_type(), true, false) << ")value_;" << endl;
     generate_serialize_field(out, field, "");
     indent(out) << "return;" << endl;
     indent_down();
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField_);" << endl;
+  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + "
+                 "setField_);" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -1180,7 +1208,8 @@ void t_java_generator::generate_tuple_scheme_write_value(ofstream& out, t_struct
 
 void t_java_generator::generate_get_field_desc(ofstream& out, t_struct* tstruct) {
   indent(out) << "@Override" << endl;
-  indent(out) << "protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {" << endl;
+  indent(out) << "protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {"
+              << endl;
   indent_up();
 
   const vector<t_field*>& members = tstruct->get_members();
@@ -1206,7 +1235,7 @@ void t_java_generator::generate_get_field_desc(ofstream& out, t_struct* tstruct)
 }
 
 void t_java_generator::generate_get_struct_desc(ofstream& out, t_struct* tstruct) {
-  (void) tstruct;
+  (void)tstruct;
   indent(out) << "@Override" << endl;
   indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << endl;
   indent(out) << "  return STRUCT_DESC;" << endl;
@@ -1226,15 +1255,18 @@ void t_java_generator::generate_union_comparisons(ofstream& out, t_struct* tstru
   out << endl;
 
   indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << endl;
-  indent(out) << "  return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());" << endl;
+  indent(out) << "  return other != null && getSetField() == other.getSetField() && "
+                 "getFieldValue().equals(other.getFieldValue());" << endl;
   indent(out) << "}" << endl;
   out << endl;
 
   indent(out) << "@Override" << endl;
   indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
-  indent(out) << "  int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());" << endl;
+  indent(out) << "  int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), "
+                 "other.getSetField());" << endl;
   indent(out) << "  if (lastComparison == 0) {" << endl;
-  indent(out) << "    return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" << endl;
+  indent(out) << "    return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), "
+                 "other.getFieldValue());" << endl;
   indent(out) << "  }" << endl;
   indent(out) << "  return lastComparison;" << endl;
   indent(out) << "}" << endl;
@@ -1242,7 +1274,7 @@ void t_java_generator::generate_union_comparisons(ofstream& out, t_struct* tstru
 }
 
 void t_java_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct) {
-  (void) tstruct;
+  (void)tstruct;
   indent(out) << "@Override" << endl;
   indent(out) << "public int hashCode() {" << endl;
   indent(out) << "  List<Object> list = new ArrayList<Object>();" << endl;
@@ -1271,7 +1303,7 @@ void t_java_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct)
  * @param in_class     If inside a class, needs to be static class
  * @param is_result    If this is a result it needs a different writer
  */
-void t_java_generator::generate_java_struct_definition(ofstream &out,
+void t_java_generator::generate_java_struct_definition(ofstream& out,
                                                        t_struct* tstruct,
                                                        bool is_exception,
                                                        bool in_class,
@@ -1284,14 +1316,14 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
     generate_javax_generated_annotation(out);
   }
 
-  indent(out) <<
-    "public " << (is_final ? "final " : "") <<
-    (in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
+  indent(out) << "public " << (is_final ? "final " : "") << (in_class ? "static " : "") << "class "
+              << tstruct->get_name() << " ";
 
   if (is_exception) {
     out << "extends TException ";
   }
-  out << "implements org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable, Comparable<" << tstruct->get_name() << ">";
+  out << "implements org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name()
+      << "._Fields>, java.io.Serializable, Cloneable, Comparable<" << tstruct->get_name() << ">";
 
   if (android_style_) {
     out << ", android.os.Parcelable";
@@ -1329,7 +1361,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
 
   out << endl;
 
-  if(android_style_) {
+  if (android_style_) {
     generate_java_struct_parcelable(out, tstruct);
   }
 
@@ -1348,14 +1380,14 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
         optionals++;
       }
       if (!type_can_be_null((*m_iter)->get_type())) {
-        indent(out) << "private static final int " << isset_field_id(*m_iter)
-          << " = " << i << ";" <<  endl;
+        indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";"
+                    << endl;
         i++;
       }
     }
 
     std::string primitiveType;
-    switch(needs_isset(tstruct, &primitiveType)) {
+    switch (needs_isset(tstruct, &primitiveType)) {
     case ISSET_NONE:
       break;
     case ISSET_PRIMITIVE:
@@ -1373,7 +1405,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
           output_string = output_string + "_Fields." + constant_name((*m_iter)->get_name()) + ",";
         }
       }
-      indent(out) << output_string.substr(0, output_string.length() - 1) <<  "};" << endl;
+      indent(out) << output_string.substr(0, output_string.length() - 1) << "};" << endl;
     }
   }
 
@@ -1382,13 +1414,17 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
   bool all_optional_members = true;
 
   // Default constructor
-  indent(out) <<
-    "public " << tstruct->get_name() << "() {" << endl;
+  indent(out) << "public " << tstruct->get_name() << "() {" << endl;
   indent_up();
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* t = get_true_type((*m_iter)->get_type());
     if ((*m_iter)->get_value() != NULL) {
-      print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
+      print_const_value(out,
+                        "this." + (*m_iter)->get_name(),
+                        t,
+                        (*m_iter)->get_value(),
+                        true,
+                        true);
     }
     if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
       all_optional_members = false;
@@ -1399,8 +1435,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
 
   if (!members.empty() && !all_optional_members) {
     // Full constructor for all fields
-    indent(out) <<
-      "public " << tstruct->get_name() << "(" << endl;
+    indent(out) << "public " << tstruct->get_name() << "(" << endl;
     indent_up();
     bool first = true;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1409,8 +1444,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
           out << "," << endl;
         }
         first = false;
-        indent(out) << type_name((*m_iter)->get_type()) << " " <<
-          (*m_iter)->get_name();
+        indent(out) << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name();
       }
     }
     out << ")" << endl;
@@ -1423,11 +1457,11 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
         t_type* type = get_true_type((*m_iter)->get_type());
         if (type->is_base_type() && ((t_base_type*)type)->is_binary()) {
           indent(out) << "this." << (*m_iter)->get_name()
-            << " = org.apache.thrift.TBaseHelper.copyBinary("
-            << (*m_iter)->get_name() << ");" << endl;
+                      << " = org.apache.thrift.TBaseHelper.copyBinary(" << (*m_iter)->get_name()
+                      << ");" << endl;
         } else {
-          indent(out) << "this." << (*m_iter)->get_name() << " = "
-            << (*m_iter)->get_name() << ";" << endl;
+          indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << ";"
+                      << endl;
         }
         generate_isset_set(out, (*m_iter), "");
       }
@@ -1441,10 +1475,11 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
   indent(out) << "/**" << endl;
   indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
   indent(out) << " */" << endl;
-  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {" << endl;
+  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {"
+              << endl;
   indent_up();
 
-  switch(needs_isset(tstruct)) {
+  switch (needs_isset(tstruct)) {
   case ISSET_NONE:
     break;
   case ISSET_PRIMITIVE:
@@ -1490,8 +1525,6 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
   indent(out) << "  return new " << tstruct->get_name() << "(this);" << endl;
   indent(out) << "}" << endl << endl;
 
-
-
   generate_java_struct_clear(out, tstruct);
 
   generate_java_bean_boilerplate(out, tstruct);
@@ -1524,206 +1557,208 @@ void t_java_generator::generate_java_struct_definition(ofstream &out,
 /**
  * generates parcelable interface implementation
  */
-void t_java_generator::generate_java_struct_parcelable(ofstream& out,
-                                                     t_struct* tstruct) {
+void t_java_generator::generate_java_struct_parcelable(ofstream& out, t_struct* tstruct) {
   string tname = tstruct->get_name();
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  out << indent() << "@Override" << endl <<
-		  indent() << "public void writeToParcel(android.os.Parcel out, int flags) {" << endl;
+  out << indent() << "@Override" << endl << indent()
+      << "public void writeToParcel(android.os.Parcel out, int flags) {" << endl;
   indent_up();
   string bitsetPrimitiveType = "";
-  switch(needs_isset(tstruct, &bitsetPrimitiveType)) {
+  switch (needs_isset(tstruct, &bitsetPrimitiveType)) {
   case ISSET_NONE:
-	  break;
+    break;
   case ISSET_PRIMITIVE:
-	  indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
-	  if(bitsetPrimitiveType=="byte") {
-		  indent(out) << "out.writeByte(__isset_bitfield);" << endl;
-	  } else if(bitsetPrimitiveType=="short") {
-		  indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << endl;
-	  } else if(bitsetPrimitiveType=="int") {
-		  indent(out) << "out.writeInt(__isset_bitfield);" << endl;
-	  } else if(bitsetPrimitiveType=="long") {
-		  indent(out) << "out.writeLong(__isset_bitfield);" << endl;
-	  }
-	  out << endl;
-	  break;
+    indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
+    if (bitsetPrimitiveType == "byte") {
+      indent(out) << "out.writeByte(__isset_bitfield);" << endl;
+    } else if (bitsetPrimitiveType == "short") {
+      indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << endl;
+    } else if (bitsetPrimitiveType == "int") {
+      indent(out) << "out.writeInt(__isset_bitfield);" << endl;
+    } else if (bitsetPrimitiveType == "long") {
+      indent(out) << "out.writeLong(__isset_bitfield);" << endl;
+    }
+    out << endl;
+    break;
   case ISSET_BITSET:
-	  indent(out) << "//BitSet" << endl;
-	  indent(out) << "out.writeSerializable(__isset_bit_vector);" << endl;
-	  out << endl;
-	  break;
+    indent(out) << "//BitSet" << endl;
+    indent(out) << "out.writeSerializable(__isset_bit_vector);" << endl;
+    out << endl;
+    break;
   }
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-	  t_type* t = get_true_type((*m_iter)->get_type());
-	  string name = (*m_iter)->get_name();
-
-	  if(t->is_struct()) {
-		  indent(out) << "out.writeParcelable(" << name << ", flags);" << endl;
-	  } else if(type_name(t)=="float") {
-		  indent(out) << "out.writeFloat(" << name << ");" << endl;
-	  } else if(t->is_enum()) {
-		  indent(out) << "out.writeInt(" << name << ".getValue());" << endl;
-	  } else if(t->is_list()) {
-		  if(((t_list*)t)->get_elem_type()->get_true_type()->is_struct()) {
-			  indent(out) << "out.writeTypedList(" << name << ");" << endl;
-		  }else {
-			  indent(out) << "out.writeList(" << name << ");" << endl;
-		  }
-	  } else if(t->is_map()) {
-		  indent(out) << "out.writeMap(" << name << ");" << endl;
-	  } else if(t->is_base_type()) {
-		  if (((t_base_type*)t)->is_binary()) {
-			  indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << endl;
-			  indent(out) << "if(" << name << " != null) { " << endl;
-			  indent_up();
-			  indent(out) << "out.writeByteArray(" << name << ".array(), "
-					  << name << ".position() + " << name << ".arrayOffset(), "
-					  << name << ".limit() - " << name << ".position() );" << endl;
-			  scope_down(out);
-		  } else {
-			  switch(((t_base_type*)t)->get_base()) {
-			  case t_base_type::TYPE_I16:
-				  indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << endl;
-				  break;
-			  case t_base_type::TYPE_I32:
-				  indent(out) << "out.writeInt(" << name << ");" << endl;
-				  break;
-			  case t_base_type::TYPE_I64:
-				  indent(out) << "out.writeLong(" << name << ");" << endl;
-				  break;
-			  case t_base_type::TYPE_BOOL:
-				  indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << endl;
-				  break;
-			  case t_base_type::TYPE_BYTE:
-				  indent(out) << "out.writeByte(" << name << ");" << endl;
-				  break;
-			  case t_base_type::TYPE_DOUBLE:
-				  indent(out) << "out.writeDouble(" << name << ");" << endl;
-				  break;
-			  case t_base_type::TYPE_STRING:
-				  indent(out) << "out.writeString(" << name << ");" << endl;
-				  break;
-			  case t_base_type::TYPE_VOID:
-				  break;
-			  }
-		  }
-	  }
+    t_type* t = get_true_type((*m_iter)->get_type());
+    string name = (*m_iter)->get_name();
+
+    if (t->is_struct()) {
+      indent(out) << "out.writeParcelable(" << name << ", flags);" << endl;
+    } else if (type_name(t) == "float") {
+      indent(out) << "out.writeFloat(" << name << ");" << endl;
+    } else if (t->is_enum()) {
+      indent(out) << "out.writeInt(" << name << ".getValue());" << endl;
+    } else if (t->is_list()) {
+      if (((t_list*)t)->get_elem_type()->get_true_type()->is_struct()) {
+        indent(out) << "out.writeTypedList(" << name << ");" << endl;
+      } else {
+        indent(out) << "out.writeList(" << name << ");" << endl;
+      }
+    } else if (t->is_map()) {
+      indent(out) << "out.writeMap(" << name << ");" << endl;
+    } else if (t->is_base_type()) {
+      if (((t_base_type*)t)->is_binary()) {
+        indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << endl;
+        indent(out) << "if(" << name << " != null) { " << endl;
+        indent_up();
+        indent(out) << "out.writeByteArray(" << name << ".array(), " << name << ".position() + "
+                    << name << ".arrayOffset(), " << name << ".limit() - " << name
+                    << ".position() );" << endl;
+        scope_down(out);
+      } else {
+        switch (((t_base_type*)t)->get_base()) {
+        case t_base_type::TYPE_I16:
+          indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << endl;
+          break;
+        case t_base_type::TYPE_I32:
+          indent(out) << "out.writeInt(" << name << ");" << endl;
+          break;
+        case t_base_type::TYPE_I64:
+          indent(out) << "out.writeLong(" << name << ");" << endl;
+          break;
+        case t_base_type::TYPE_BOOL:
+          indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << endl;
+          break;
+        case t_base_type::TYPE_BYTE:
+          indent(out) << "out.writeByte(" << name << ");" << endl;
+          break;
+        case t_base_type::TYPE_DOUBLE:
+          indent(out) << "out.writeDouble(" << name << ");" << endl;
+          break;
+        case t_base_type::TYPE_STRING:
+          indent(out) << "out.writeString(" << name << ");" << endl;
+          break;
+        case t_base_type::TYPE_VOID:
+          break;
+        }
+      }
+    }
   }
   scope_down(out);
   out << endl;
 
-  out << indent() << "@Override" << endl <<
-          indent() << "public int describeContents() {" << endl;
+  out << indent() << "@Override" << endl << indent() << "public int describeContents() {" << endl;
   indent_up();
-  out <<
-    indent() << "return 0;" << endl;
+  out << indent() << "return 0;" << endl;
   scope_down(out);
   out << endl;
 
   indent(out) << "public " << tname << "(android.os.Parcel in) {" << endl;
   indent_up();
-  //read in the required bitfield
-  switch(needs_isset(tstruct, &bitsetPrimitiveType)) {
+  // read in the required bitfield
+  switch (needs_isset(tstruct, &bitsetPrimitiveType)) {
   case ISSET_NONE:
-	  break;
+    break;
   case ISSET_PRIMITIVE:
-	  indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
-	  if(bitsetPrimitiveType=="byte") {
-		  indent(out) << "__isset_bitfield = in.readByte();" << endl;
-	  } else if(bitsetPrimitiveType=="short") {
-		  indent(out) << "__isset_bitfield = (short) in.readInt();" << endl;
-	  } else if(bitsetPrimitiveType=="int") {
-		  indent(out) << "__isset_bitfield = in.readInt();" << endl;
-	  } else if(bitsetPrimitiveType=="long") {
-		  indent(out) << "__isset_bitfield = in.readLong();" << endl;
-	  }
-	  out << endl;
-	  break;
+    indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
+    if (bitsetPrimitiveType == "byte") {
+      indent(out) << "__isset_bitfield = in.readByte();" << endl;
+    } else if (bitsetPrimitiveType == "short") {
+      indent(out) << "__isset_bitfield = (short) in.readInt();" << endl;
+    } else if (bitsetPrimitiveType == "int") {
+      indent(out) << "__isset_bitfield = in.readInt();" << endl;
+    } else if (bitsetPrimitiveType == "long") {
+      indent(out) << "__isset_bitfield = in.readLong();" << endl;
+    }
+    out << endl;
+    break;
   case ISSET_BITSET:
-	  indent(out) << "//BitSet" << endl;
-	  indent(out) << "__isset_bit_vector = (BitSet) in.readSerializable();" << endl;
-	  out << endl;
-	  break;
+    indent(out) << "//BitSet" << endl;
+    indent(out) << "__isset_bit_vector = (BitSet) in.readSerializable();" << endl;
+    out << endl;
+    break;
   }
-  //read all the fields
+  // read all the fields
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-	  t_type* t = get_true_type((*m_iter)->get_type());
-	  string name = (*m_iter)->get_name();
-	  string prefix = "this." + name;
-
-	  if(t->is_struct()) {
-		  indent(out) << prefix << "= in.readParcelable(" << tname << ".class.getClassLoader());" << endl;
-	  } else if(t->is_enum()) {
-		  indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << endl;
-	  } else if(t->is_list()) {
-		  t_list* list = (t_list*)t;
-		  indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
-		  if(list->get_elem_type()->get_true_type()->is_struct()) {
-			  indent(out) << "in.readTypedList(" << prefix << ", " << type_name(list->get_elem_type()) << ".CREATOR);" << endl;
-		  } else {
-			  indent(out) << "in.readList(" << prefix << ", " << tname << ".class.getClassLoader());" << endl;
-		  }
-	  } else if(t->is_map()) {
-		  indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
-		  indent(out) << " in.readMap(" << prefix << ", " << tname << ".class.getClassLoader());" << endl;
-	  } else if(type_name(t)=="float") {
-		  indent(out) << prefix << " = in.readFloat();" << endl;
-	  } else if(t->is_base_type()) {
-		  t_base_type* bt = (t_base_type*)t;
-		  if (bt->is_binary()) {
-			  indent(out) << "if(in.readInt()==1) {" << endl;
-			  indent_up();
-			  indent(out) << prefix << " = ByteBuffer.wrap(in.createByteArray());" << endl;
-			  scope_down(out);
-		  } else {
-			  switch(bt->get_base()) {
-			  case t_base_type::TYPE_I16:
-				  indent(out) << prefix << " = (short) in.readInt();" << endl;
-				  break;
-			  case t_base_type::TYPE_I32:
-				  indent(out) << prefix << " = in.readInt();" << endl;
-				  break;
-			  case t_base_type::TYPE_I64:
-				  indent(out) << prefix << " = in.readLong();" << endl;
-				  break;
-			  case t_base_type::TYPE_BOOL:
-				  indent(out) << prefix << " = (in.readInt()==1);" << endl;
-				  break;
-			  case t_base_type::TYPE_BYTE:
-				  indent(out) << prefix << " = in.readByte();" << endl;
-				  break;
-			  case t_base_type::TYPE_DOUBLE:
-				  indent(out) << prefix << " = in.readDouble();" << endl;
-				  break;
-			  case t_base_type::TYPE_STRING:
-				  indent(out) << prefix << "= in.readString();" << endl;
-				  break;
-			  case t_base_type::TYPE_VOID:
-				  break;
-			  }
-		  }
-	  }
+    t_type* t = get_true_type((*m_iter)->get_type());
+    string name = (*m_iter)->get_name();
+    string prefix = "this." + name;
+
+    if (t->is_struct()) {
+      indent(out) << prefix << "= in.readParcelable(" << tname << ".class.getClassLoader());"
+                  << endl;
+    } else if (t->is_enum()) {
+      indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << endl;
+    } else if (t->is_list()) {
+      t_list* list = (t_list*)t;
+      indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
+      if (list->get_elem_type()->get_true_type()->is_struct()) {
+        indent(out) << "in.readTypedList(" << prefix << ", " << type_name(list->get_elem_type())
+                    << ".CREATOR);" << endl;
+      } else {
+        indent(out) << "in.readList(" << prefix << ", " << tname << ".class.getClassLoader());"
+                    << endl;
+      }
+    } else if (t->is_map()) {
+      indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
+      indent(out) << " in.readMap(" << prefix << ", " << tname << ".class.getClassLoader());"
+                  << endl;
+    } else if (type_name(t) == "float") {
+      indent(out) << prefix << " = in.readFloat();" << endl;
+    } else if (t->is_base_type()) {
+      t_base_type* bt = (t_base_type*)t;
+      if (bt->is_binary()) {
+        indent(out) << "if(in.readInt()==1) {" << endl;
+        indent_up();
+        indent(out) << prefix << " = ByteBuffer.wrap(in.createByteArray());" << endl;
+        scope_down(out);
+      } else {
+        switch (bt->get_base()) {
+        case t_base_type::TYPE_I16:
+          indent(out) << prefix << " = (short) in.readInt();" << endl;
+          break;
+        case t_base_type::TYPE_I32:
+          indent(out) << prefix << " = in.readInt();" << endl;
+          break;
+        case t_base_type::TYPE_I64:
+          indent(out) << prefix << " = in.readLong();" << endl;
+          break;
+        case t_base_type::TYPE_BOOL:
+          indent(out) << prefix << " = (in.readInt()==1);" << endl;
+          break;
+        case t_base_type::TYPE_BYTE:
+          indent(out) << prefix << " = in.readByte();" << endl;
+          break;
+        case t_base_type::TYPE_DOUBLE:
+          indent(out) << prefix << " = in.readDouble();" << endl;
+          break;
+        case t_base_type::TYPE_STRING:
+          indent(out) << prefix << "= in.readString();" << endl;
+          break;
+        case t_base_type::TYPE_VOID:
+          break;
+        }
+      }
+    }
   }
 
   scope_down(out);
   out << endl;
 
-  indent(out) << "public static final android.os.Parcelable.Creator<" << tname << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << endl;
+  indent(out) << "public static final android.os.Parcelable.Creator<" << tname
+              << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << endl;
   indent_up();
 
-  indent(out) << "@Override" << endl <<
-          indent() << "public " << tname << "[] newArray(int size) {" << endl;
+  indent(out) << "@Override" << endl << indent() << "public " << tname << "[] newArray(int size) {"
+              << endl;
   indent_up();
   indent(out) << "return new " << tname << "[size];" << endl;
   scope_down(out);
   out << endl;
 
-  indent(out) << "@Override" << endl <<
-        indent() << "public " << tname << " createFromParcel(android.os.Parcel in) {" << endl;
+  indent(out) << "@Override" << endl << indent() << "public " << tname
+              << " createFromParcel(android.os.Parcel in) {" << endl;
   indent_up();
   indent(out) << "return new " << tname << "(in);" << endl;
   scope_down(out);
@@ -1738,26 +1773,20 @@ void t_java_generator::generate_java_struct_parcelable(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_struct_equality(ofstream& out,
-                                                     t_struct* tstruct) {
-  out << indent() << "@Override" << endl <<
-    indent() << "public boolean equals(Object that) {" << endl;
+void t_java_generator::generate_java_struct_equality(ofstream& out, t_struct* tstruct) {
+  out << indent() << "@Override" << endl << indent() << "public boolean equals(Object that) {"
+      << endl;
   indent_up();
-  out <<
-    indent() << "if (that == null)" << endl <<
-    indent() << "  return false;" << endl <<
-    indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl <<
-    indent() << "  return this.equals((" << tstruct->get_name() << ")that);" << endl <<
-    indent() << "return false;" << endl;
+  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl
+      << indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl << indent()
+      << "  return this.equals((" << tstruct->get_name() << ")that);" << endl << indent()
+      << "return false;" << endl;
   scope_down(out);
   out << endl;
 
-  out <<
-    indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
+  out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
   indent_up();
-  out <<
-    indent() << "if (that == null)" << endl <<
-    indent() << "  return false;" << endl;
+  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl;
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
@@ -1780,18 +1809,14 @@ void t_java_generator::generate_java_struct_equality(ofstream& out,
       that_present += " && that." + generate_isset_check(*m_iter);
     }
 
-    out <<
-      indent() << "boolean this_present_" << name << " = "
-      << this_present << ";" << endl <<
-      indent() << "boolean that_present_" << name << " = "
-      << that_present << ";" << endl <<
-      indent() << "if (" << "this_present_" << name
-      << " || that_present_" << name << ") {" << endl;
+    out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl
+        << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl
+        << indent() << "if ("
+        << "this_present_" << name << " || that_present_" << name << ") {" << endl;
     indent_up();
-    out <<
-      indent() << "if (!(" << "this_present_" << name
-      << " && that_present_" << name << "))" << endl <<
-      indent() << "  return false;" << endl;
+    out << indent() << "if (!("
+        << "this_present_" << name << " && that_present_" << name << "))" << endl << indent()
+        << "  return false;" << endl;
 
     if (t->is_base_type() && ((t_base_type*)t)->is_binary()) {
       unequal = "!this." + name + ".equals(that." + name + ")";
@@ -1801,9 +1826,7 @@ void t_java_generator::generate_java_struct_equality(ofstream& out,
       unequal = "this." + name + " != that." + name;
     }
 
-    out <<
-      indent() << "if (" << unequal << ")" << endl <<
-      indent() << "  return false;" << endl;
+    out << indent() << "if (" << unequal << ")" << endl << indent() << "  return false;" << endl;
 
     scope_down(out);
   }
@@ -1812,8 +1835,7 @@ void t_java_generator::generate_java_struct_equality(ofstream& out,
   scope_down(out);
   out << endl;
 
-  out << indent() << "@Override" << endl <<
-    indent() << "public int hashCode() {" << endl;
+  out << indent() << "@Override" << endl << indent() << "public int hashCode() {" << endl;
   indent_up();
   indent(out) << "List<Object> list = new ArrayList<Object>();" << endl;
 
@@ -1864,13 +1886,15 @@ void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct*
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_field* field = *m_iter;
-    indent(out) << "lastComparison = Boolean.valueOf(" << generate_isset_check(field) << ").compareTo(other." << generate_isset_check(field) << ");" << endl;
+    indent(out) << "lastComparison = Boolean.valueOf(" << generate_isset_check(field)
+                << ").compareTo(other." << generate_isset_check(field) << ");" << endl;
     indent(out) << "if (lastComparison != 0) {" << endl;
     indent(out) << "  return lastComparison;" << endl;
     indent(out) << "}" << endl;
 
     indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
-    indent(out) << "  lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." << field->get_name() << ", other." << field->get_name() << ");" << endl;
+    indent(out) << "  lastComparison = org.apache.thrift.TBaseHelper.compareTo(this."
+                << field->get_name() << ", other." << field->get_name() << ");" << endl;
     indent(out) << "  if (lastComparison != 0) {" << endl;
     indent(out) << "    return lastComparison;" << endl;
     indent(out) << "  }" << endl;
@@ -1888,21 +1912,19 @@ void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct*
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
-  (void) tstruct;
-  indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {" << endl;
+void t_java_generator::generate_java_struct_reader(ofstream& out, t_struct* tstruct) {
+  (void)tstruct;
+  indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot) throws "
+                 "org.apache.thrift.TException {" << endl;
   indent_up();
   indent(out) << "schemes.get(iprot.getScheme()).getScheme().read(iprot, this);" << endl;
   indent_down();
-  indent(out) << "}" << endl <<
-  endl;
+  indent(out) << "}" << endl << endl;
 }
 
 // generates java method to perform various checks
 // (e.g. check that all required fields are set)
-void t_java_generator::generate_java_validator(ofstream& out,
-                                               t_struct* tstruct){
+void t_java_generator::generate_java_validator(ofstream& out, t_struct* tstruct) {
   indent(out) << "public void validate() throws org.apache.thrift.TException {" << endl;
   indent_up();
 
@@ -1913,17 +1935,21 @@ void t_java_generator::generate_java_validator(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
       if (bean_style_) {
-        out <<
-          indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
-          indent() << "  throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl <<
-          indent() << "}" << endl << endl;
-      } else{
+        out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << indent()
+            << "  throw new org.apache.thrift.protocol.TProtocolException(\"Required field '"
+            << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl << indent()
+            << "}" << endl << endl;
+      } else {
         if (type_can_be_null((*f_iter)->get_type())) {
           indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
-          indent(out) << "  throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
+          indent(out)
+              << "  throw new org.apache.thrift.protocol.TProtocolException(\"Required field '"
+              << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
           indent(out) << "}" << endl;
         } else {
-          indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." << endl;
+          indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
+                      << "' because it's a primitive and you chose the non-beans generator."
+                      << endl;
         }
       }
     }
@@ -1932,7 +1958,7 @@ void t_java_generator::generate_java_validator(ofstream& out,
   out << indent() << "// check for sub-struct validity" << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     t_type* type = (*f_iter)->get_type();
-    if (type->is_struct() && ! ((t_struct*)type)->is_union()) {
+    if (type->is_struct() && !((t_struct*)type)->is_union()) {
       out << indent() << "if (" << (*f_iter)->get_name() << " != null) {" << endl;
       out << indent() << "  " << (*f_iter)->get_name() << ".validate();" << endl;
       out << indent() << "}" << endl;
@@ -1948,10 +1974,10 @@ void t_java_generator::generate_java_validator(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
-  (void) tstruct;
-  indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl;
+void t_java_generator::generate_java_struct_writer(ofstream& out, t_struct* tstruct) {
+  (void)tstruct;
+  indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws "
+                 "org.apache.thrift.TException {" << endl;
   indent_up();
   indent(out) << "schemes.get(oprot.getScheme()).getScheme().write(oprot, this);" << endl;
 
@@ -1967,10 +1993,10 @@ void t_java_generator::generate_java_struct_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_struct_result_writer(ofstream& out,
-                                                          t_struct* tstruct) {
-  (void) tstruct;
-  indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl;
+void t_java_generator::generate_java_struct_result_writer(ofstream& out, t_struct* tstruct) {
+  (void)tstruct;
+  indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws "
+                 "org.apache.thrift.TException {" << endl;
   indent_up();
   indent(out) << "schemes.get(oprot.getScheme()).getScheme().write(oprot, this);" << endl;
 
@@ -1979,20 +2005,24 @@ void t_java_generator::generate_java_struct_result_writer(ofstream& out,
 }
 
 void t_java_generator::generate_java_struct_field_by_id(ofstream& out, t_struct* tstruct) {
-  (void) tstruct;
+  (void)tstruct;
   indent(out) << "public _Fields fieldForId(int fieldId) {" << endl;
   indent(out) << "  return _Fields.findByThriftId(fieldId);" << endl;
   indent(out) << "}" << endl << endl;
 }
 
-void t_java_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
+void t_java_generator::generate_reflection_getters(ostringstream& out,
+                                                   t_type* type,
+                                                   string field_name,
+                                                   string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
 
   if (type->is_base_type() && !type->is_string()) {
     t_base_type* base_type = (t_base_type*)type;
 
-    indent(out) << "return " << type_name(type, true, false) << ".valueOf(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
+    indent(out) << "return " << type_name(type, true, false) << ".valueOf("
+                << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
   } else {
     indent(out) << "return get" << cap_name << "();" << endl << endl;
   }
@@ -2000,7 +2030,10 @@ void t_java_generator::generate_reflection_getters(ostringstream& out, t_type* t
   indent_down();
 }
 
-void t_java_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
+void t_java_generator::generate_reflection_setters(ostringstream& out,
+                                                   t_type* type,
+                                                   string field_name,
+                                                   string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
@@ -2013,7 +2046,8 @@ void t_java_generator::generate_reflection_setters(ostringstream& out, t_type* t
   indent_down();
 }
 
-void t_java_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
+void t_java_generator::generate_generic_field_getters_setters(std::ofstream& out,
+                                                              t_struct* tstruct) {
   std::ostringstream getter_stream;
   std::ostringstream setter_stream;
 
@@ -2032,7 +2066,6 @@ void t_java_generator::generate_generic_field_getters_setters(std::ofstream& out
     indent_down();
   }
 
-
   // create the setter
 
   indent(out) << "public void setFieldValue(_Fields field, Object value) {" << endl;
@@ -2053,12 +2086,13 @@ void t_java_generator::generate_generic_field_getters_setters(std::ofstream& out
 }
 
 // Creates a generic isSet method that takes the field number as argument
-void t_java_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct){
+void t_java_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // create the isSet method
-  indent(out) << "/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */" << endl;
+  indent(out) << "/** Returns true if field corresponding to fieldID is set (has been assigned a "
+                 "value) and false otherwise */" << endl;
   indent(out) << "public boolean isSet(_Fields field) {" << endl;
   indent_up();
   indent(out) << "if (field == null) {" << endl;
@@ -2087,8 +2121,7 @@ void t_java_generator::generate_generic_isset_method(std::ofstream& out, t_struc
  *
  * @param tstruct The struct definition
  */
-void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
-                                                      t_struct* tstruct) {
+void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* tstruct) {
   isset_type issetType = needs_isset(tstruct);
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
@@ -2104,8 +2137,8 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
       out << get_cap_name("size() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? 0 : " <<
-        "this." << field_name << ".size();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? 0 : "
+                  << "this." << field_name << ".size();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
     }
@@ -2119,13 +2152,13 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
       }
 
       // Iterator getter for sets and lists
-      indent(out) << "public java.util.Iterator<" <<
-        type_name(element_type, true, false) <<  "> get" << cap_name;
+      indent(out) << "public java.util.Iterator<" << type_name(element_type, true, false) << "> get"
+                  << cap_name;
       out << get_cap_name("iterator() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? null : " <<
-        "this." << field_name << ".iterator();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? null : "
+                  << "this." << field_name << ".iterator();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
 
@@ -2137,8 +2170,8 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) <<
-        "();" << endl;
+      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
+                  << endl;
       indent_down();
       indent(out) << "}" << endl;
       indent(out) << "this." << field_name << ".add(elem);" << endl;
@@ -2151,14 +2184,14 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
 
       indent(out);
       out << "public void put" << get_cap_name("to");
-      out << cap_name << "(" << type_name(key_type) << " key, "
-        << type_name(val_type) << " val) {" << endl;
+      out << cap_name << "(" << type_name(key_type) << " key, " << type_name(val_type) << " val) {"
+          << endl;
 
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " <<
-        type_name(type, false, true) << "();" << endl;
+      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
+                  << endl;
       indent_down();
       indent(out) << "}" << 

<TRUNCATED>

[16/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_py_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 924bcc7..50af776 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -38,21 +38,19 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Python code generator.
  *
  */
 class t_py_generator : public t_generator {
- public:
-  t_py_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) option_string;
+public:
+  t_py_generator(t_program* program,
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("new_style");
@@ -123,12 +121,12 @@ class t_py_generator : public t_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
@@ -137,7 +135,10 @@ class t_py_generator : public t_generator {
    */
 
   void generate_py_struct(t_struct* tstruct, bool is_exception);
-  void generate_py_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool is_result=false);
+  void generate_py_struct_definition(std::ofstream& out,
+                                     t_struct* tstruct,
+                                     bool is_xception = false,
+                                     bool is_result = false);
   void generate_py_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_py_struct_writer(std::ofstream& out, t_struct* tstruct);
   void generate_py_struct_required_validator(std::ofstream& out, t_struct* tstruct);
@@ -147,80 +148,59 @@ class t_py_generator : public t_generator {
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service*  tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_remote    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_remote(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool inclass=false);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool inclass = false);
 
-  void generate_deserialize_struct       (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream &out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element    (std::ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_python_docstring         (std::ofstream& out,
-                                          t_struct* tstruct);
+  void generate_python_docstring(std::ofstream& out, t_struct* tstruct);
 
-  void generate_python_docstring         (std::ofstream& out,
-                                          t_function* tfunction);
+  void generate_python_docstring(std::ofstream& out, t_function* tfunction);
 
-  void generate_python_docstring         (std::ofstream& out,
-                                          t_doc*    tdoc,
-                                          t_struct* tstruct,
-                                          const char* subheader);
+  void generate_python_docstring(std::ofstream& out,
+                                 t_doc* tdoc,
+                                 t_struct* tstruct,
+                                 const char* subheader);
 
-  void generate_python_docstring         (std::ofstream& out,
-                                          t_doc* tdoc);
+  void generate_python_docstring(std::ofstream& out, t_doc* tdoc);
 
   /**
    * Helper rendering functions
@@ -233,11 +213,10 @@ class t_py_generator : public t_generator {
   std::string declare_argument(t_field* tfield);
   std::string render_field_default_value(t_field* tfield);
   std::string type_name(t_type* ttype);
-  std::string function_signature(t_function* tfunction,
-                                 bool interface=false);
+  std::string function_signature(t_function* tfunction, bool interface = false);
   std::string argument_list(t_struct* tstruct,
-                            std::vector<std::string> *pre=NULL,
-                            std::vector<std::string> *post=NULL);
+                            std::vector<std::string>* pre = NULL,
+                            std::vector<std::string>* post = NULL);
   std::string type_to_enum(t_type* ttype);
   std::string type_to_spec_args(t_type* ttype);
 
@@ -246,9 +225,9 @@ class t_py_generator : public t_generator {
   }
 
   static std::string get_real_py_module(const t_program* program, bool gen_twisted) {
-    if(gen_twisted) {
+    if (gen_twisted) {
       std::string twisted_module = program->get_namespace("py.twisted");
-      if(!twisted_module.empty()){
+      if (!twisted_module.empty()) {
         return twisted_module;
       }
     }
@@ -260,16 +239,15 @@ class t_py_generator : public t_generator {
     return real_module;
   }
 
- private:
-
+private:
   /**
    * True if we should generate new-style classes.
    */
   bool gen_newstyle_;
 
-   /**
-   * True if we should generate dynamic style classes.
-   */
+  /**
+  * True if we should generate dynamic style classes.
+  */
   bool gen_dynamic_;
 
   bool gen_dynbase_;
@@ -307,10 +285,8 @@ class t_py_generator : public t_generator {
 
   std::string package_dir_;
   std::string module_;
-
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -325,7 +301,7 @@ void t_py_generator::init_generator() {
   while (true) {
     // TODO: Do better error checking here.
     MKDIR(package_dir_.c_str());
-    std::ofstream init_py((package_dir_+"/__init__.py").c_str(), std::ios_base::app);
+    std::ofstream init_py((package_dir_ + "/__init__.py").c_str(), std::ios_base::app);
     init_py.close();
     if (module.empty()) {
       break;
@@ -338,22 +314,21 @@ void t_py_generator::init_generator() {
     } else {
       package_dir_ += "/";
       package_dir_ += module.substr(0, pos);
-      module.erase(0, pos+1);
+      module.erase(0, pos + 1);
     }
   }
 
   // Make output file
-  string f_types_name = package_dir_+"/"+"ttypes.py";
+  string f_types_name = package_dir_ + "/" + "ttypes.py";
   f_types_.open(f_types_name.c_str());
 
-  string f_consts_name = package_dir_+"/"+"constants.py";
+  string f_consts_name = package_dir_ + "/" + "constants.py";
   f_consts_.open(f_consts_name.c_str());
 
-  string f_init_name = package_dir_+"/__init__.py";
+  string f_init_name = package_dir_ + "/__init__.py";
   ofstream f_init;
   f_init.open(f_init_name.c_str());
-  f_init  <<
-    "__all__ = ['ttypes', 'constants'";
+  f_init << "__all__ = ['ttypes', 'constants'";
   vector<t_service*> services = program_->get_services();
   vector<t_service*>::iterator sv_iter;
   for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
@@ -363,18 +338,11 @@ void t_py_generator::init_generator() {
   f_init.close();
 
   // Print header
-  f_types_ <<
-    py_autogen_comment() << endl <<
-    py_imports() << endl <<
-    render_includes() << endl <<
-    render_fastbinary_includes() <<
-    endl << endl;
-
-  f_consts_ <<
-    py_autogen_comment() << endl <<
-    py_imports() << endl <<
-    "from ttypes import *" << endl <<
-    endl;
+  f_types_ << py_autogen_comment() << endl << py_imports() << endl << render_includes() << endl
+           << render_fastbinary_includes() << endl << endl;
+
+  f_consts_ << py_autogen_comment() << endl << py_imports() << endl << "from ttypes import *"
+            << endl << endl;
 }
 
 /**
@@ -400,13 +368,12 @@ string t_py_generator::render_fastbinary_includes() {
   if (gen_dynamic_) {
     hdr += std::string(import_dynbase_);
   } else {
-    hdr +=
-      "from thrift.transport import TTransport\n"
-      "from thrift.protocol import TBinaryProtocol, TProtocol\n"
-      "try:\n"
-      "  from thrift.protocol import fastbinary\n"
-      "except:\n"
-      "  fastbinary = None\n";
+    hdr += "from thrift.transport import TTransport\n"
+           "from thrift.protocol import TBinaryProtocol, TProtocol\n"
+           "try:\n"
+           "  from thrift.protocol import fastbinary\n"
+           "except:\n"
+           "  fastbinary = None\n";
   }
   return hdr;
 }
@@ -415,22 +382,16 @@ string t_py_generator::render_fastbinary_includes() {
  * Autogen'd comment
  */
 string t_py_generator::py_autogen_comment() {
-  return
-    std::string("#\n") +
-    "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "#\n" +
-    "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-    "#\n" +
-    "#  options string: " + copy_options_  + "\n" +
-    "#\n";
+  return std::string("#\n") + "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         + "#\n" + "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "#\n"
+         + "#  options string: " + copy_options_ + "\n" + "#\n";
 }
 
 /**
  * Prints standard thrift imports
  */
 string t_py_generator::py_imports() {
-  return
-    string("from thrift.Thrift import TType, TMessageType, TException, TApplicationException");
+  return string("from thrift.Thrift import TType, TMessageType, TException, TApplicationException");
 }
 
 /**
@@ -448,7 +409,7 @@ void t_py_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_py_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -460,11 +421,8 @@ void t_py_generator::generate_typedef(t_typedef* ttypedef) {
 void t_py_generator::generate_enum(t_enum* tenum) {
   std::ostringstream to_string_mapping, from_string_mapping;
 
-  f_types_ <<
-    "class " << tenum->get_name() <<
-    (gen_newstyle_ ? "(object)" : "") <<
-    (gen_dynamic_ ? "(" + gen_dynbaseclass_ + ")" : "") <<
-    ":" << endl;
+  f_types_ << "class " << tenum->get_name() << (gen_newstyle_ ? "(object)" : "")
+           << (gen_dynamic_ ? "(" + gen_dynbaseclass_ + ")" : "") << ":" << endl;
   indent_up();
   generate_python_docstring(f_types_, tenum);
 
@@ -478,12 +436,10 @@ void t_py_generator::generate_enum(t_enum* tenum) {
     indent(f_types_) << (*c_iter)->get_name() << " = " << value << endl;
 
     // Dictionaries to/from string names of enums
-    to_string_mapping <<
-      indent() << indent() << value << ": \"" <<
-      escape_string((*c_iter)->get_name()) << "\"," << endl;
-    from_string_mapping <<
-      indent() << indent() << '"' << escape_string((*c_iter)->get_name()) <<
-      "\": " << value << ',' << endl;
+    to_string_mapping << indent() << indent() << value << ": \""
+                      << escape_string((*c_iter)->get_name()) << "\"," << endl;
+    from_string_mapping << indent() << indent() << '"' << escape_string((*c_iter)->get_name())
+                        << "\": " << value << ',' << endl;
   }
   to_string_mapping << indent() << "}" << endl;
   from_string_mapping << indent() << "}" << endl;
@@ -633,8 +589,7 @@ void t_py_generator::generate_xception(t_struct* txception) {
 /**
  * Generates a python struct
  */
-void t_py_generator::generate_py_struct(t_struct* tstruct,
-                                        bool is_exception) {
+void t_py_generator::generate_py_struct(t_struct* tstruct, bool is_exception) {
   generate_py_struct_definition(f_types_, tstruct, is_exception);
 }
 
@@ -647,13 +602,12 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
                                                    t_struct* tstruct,
                                                    bool is_exception,
                                                    bool is_result) {
-  (void) is_result;
+  (void)is_result;
   const vector<t_field*>& members = tstruct->get_members();
   const vector<t_field*>& sorted_members = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator m_iter;
 
-  out << std::endl <<
-    "class " << tstruct->get_name();
+  out << std::endl << "class " << tstruct->get_name();
   if (is_exception) {
     if (gen_dynamic_) {
       out << "(" << gen_dynbaseclass_exc_ << ")";
@@ -697,11 +651,10 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
     indent(out) << "__slots__ = [ " << endl;
     indent_up();
     for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) {
-      indent(out) <<  "'" << (*m_iter)->get_name()  << "'," << endl;
+      indent(out) << "'" << (*m_iter)->get_name() << "'," << endl;
     }
     indent_down();
     indent(out) << " ]" << endl << endl;
-
   }
 
   // TODO(dreiss): Look into generating an empty tuple instead of None
@@ -719,16 +672,15 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
         indent(out) << "None, # " << sorted_keys_pos << endl;
       }
 
-      indent(out) << "(" << (*m_iter)->get_key() << ", "
-            << type_to_enum((*m_iter)->get_type()) << ", "
-            << "'" << (*m_iter)->get_name() << "'" << ", "
-            << type_to_spec_args((*m_iter)->get_type()) << ", "
-            << render_field_default_value(*m_iter) << ", "
-            << "),"
-            << " # " << sorted_keys_pos
-            << endl;
+      indent(out) << "(" << (*m_iter)->get_key() << ", " << type_to_enum((*m_iter)->get_type())
+                  << ", "
+                  << "'" << (*m_iter)->get_name() << "'"
+                  << ", " << type_to_spec_args((*m_iter)->get_type()) << ", "
+                  << render_field_default_value(*m_iter) << ", "
+                  << "),"
+                  << " # " << sorted_keys_pos << endl;
 
-      sorted_keys_pos ++;
+      sorted_keys_pos++;
     }
 
     indent_down();
@@ -737,10 +689,8 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
     indent(out) << "thrift_spec = None" << endl;
   }
 
-
   if (members.size() > 0) {
-    out <<
-      indent() << "def __init__(self,";
+    out << indent() << "def __init__(self,";
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       // This fills in default values, as opposed to nulls
@@ -755,14 +705,12 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
       // Initialize fields
       t_type* type = (*m_iter)->get_type();
       if (!type->is_base_type() && !type->is_enum() && (*m_iter)->get_value() != NULL) {
-        indent(out) <<
-          "if " << (*m_iter)->get_name() << " is " << "self.thrift_spec[" <<
-            (*m_iter)->get_key() << "][4]:" << endl;
-        indent(out) << "  " << (*m_iter)->get_name() << " = " <<
-          render_field_default_value(*m_iter) << endl;
+        indent(out) << "if " << (*m_iter)->get_name() << " is "
+                    << "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << endl;
+        indent(out) << "  " << (*m_iter)->get_name() << " = " << render_field_default_value(*m_iter)
+                    << endl;
       }
-      indent(out) <<
-        "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << endl;
+      indent(out) << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << endl;
     }
 
     indent_down();
@@ -779,15 +727,13 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
   // because when raised exceptions are printed to the console, __repr__
   // isn't used. See python bug #5882
   if (is_exception) {
-    out <<
-      indent() << "def __str__(self):" << endl <<
-      indent() << "  return repr(self)" << endl <<
-      endl;
+    out << indent() << "def __str__(self):" << endl << indent() << "  return repr(self)" << endl
+        << endl;
   }
 
   out << indent() << "def __hash__(self):" << endl;
   indent_up();
-  indent(out) << "value = 17" << endl;  // PYTHONHASHSEED would be better, but requires Python 3.2.3
+  indent(out) << "value = 17" << endl; // PYTHONHASHSEED would be better, but requires Python 3.2.3
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     indent(out) << "value = (value * 31) ^ hash(self." << (*m_iter)->get_name() + ")" << endl;
   }
@@ -795,61 +741,46 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
   indent_down();
   out << endl;
 
-
   if (!gen_slots_) {
     // Printing utilities so that on the command line thrift
     // structs look pretty like dictionaries
-    out <<
-      indent() << "def __repr__(self):" << endl <<
-      indent() << "  L = ['%s=%r' % (key, value)" << endl <<
-      indent() << "    for key, value in self.__dict__.iteritems()]" << endl <<
-      indent() << "  return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl <<
-      endl;
+    out << indent() << "def __repr__(self):" << endl << indent() << "  L = ['%s=%r' % (key, value)"
+        << endl << indent() << "    for key, value in self.__dict__.iteritems()]" << endl
+        << indent() << "  return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl
+        << endl;
 
     // Equality and inequality methods that compare by value
-    out <<
-      indent() << "def __eq__(self, other):" << endl;
+    out << indent() << "def __eq__(self, other):" << endl;
     indent_up();
-    out <<
-      indent() << "return isinstance(other, self.__class__) and "
-                  "self.__dict__ == other.__dict__" << endl;
+    out << indent() << "return isinstance(other, self.__class__) and "
+                       "self.__dict__ == other.__dict__" << endl;
     indent_down();
     out << endl;
 
-    out <<
-      indent() << "def __ne__(self, other):" << endl;
+    out << indent() << "def __ne__(self, other):" << endl;
     indent_up();
 
-    out <<
-      indent() << "return not (self == other)" << endl;
+    out << indent() << "return not (self == other)" << endl;
     indent_down();
   } else if (!gen_dynamic_) {
     // no base class available to implement __eq__ and __repr__ and __ne__ for us
     // so we must provide one that uses __slots__
-    out <<
-      indent() << "def __repr__(self):" << endl <<
-      indent() << "  L = ['%s=%r' % (key, getattr(self, key))" << endl <<
-      indent() << "    for key in self.__slots__]" << endl <<
-      indent() << "  return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl <<
-      endl;
+    out << indent() << "def __repr__(self):" << endl << indent()
+        << "  L = ['%s=%r' % (key, getattr(self, key))" << endl << indent()
+        << "    for key in self.__slots__]" << endl << indent()
+        << "  return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl << endl;
 
     // Equality method that compares each attribute by value and type, walking __slots__
-    out <<
-      indent() << "def __eq__(self, other):" << endl <<
-      indent() << "  if not isinstance(other, self.__class__):" << endl <<
-      indent() << "    return False" << endl <<
-      indent() << "  for attr in self.__slots__:" << endl <<
-      indent() << "    my_val = getattr(self, attr)" << endl <<
-      indent() << "    other_val = getattr(other, attr)" << endl <<
-      indent() << "    if my_val != other_val:" << endl <<
-      indent() << "      return False" << endl <<
-      indent() << "  return True" << endl <<
-      endl;
-
-    out <<
-      indent() << "def __ne__(self, other):" << endl <<
-      indent() << "  return not (self == other)" << endl <<
-      endl;
+    out << indent() << "def __eq__(self, other):" << endl << indent()
+        << "  if not isinstance(other, self.__class__):" << endl << indent() << "    return False"
+        << endl << indent() << "  for attr in self.__slots__:" << endl << indent()
+        << "    my_val = getattr(self, attr)" << endl << indent()
+        << "    other_val = getattr(other, attr)" << endl << indent()
+        << "    if my_val != other_val:" << endl << indent() << "      return False" << endl
+        << indent() << "  return True" << endl << endl;
+
+    out << indent() << "def __ne__(self, other):" << endl << indent()
+        << "  return not (self == other)" << endl << endl;
   }
   indent_down();
 }
@@ -857,93 +788,75 @@ void t_py_generator::generate_py_struct_definition(ofstream& out,
 /**
  * Generates the read method for a struct
  */
-void t_py_generator::generate_py_struct_reader(ofstream& out,
-                                                t_struct* tstruct) {
+void t_py_generator::generate_py_struct_reader(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  indent(out) <<
-    "def read(self, iprot):" << endl;
+  indent(out) << "def read(self, iprot):" << endl;
   indent_up();
 
-  indent(out) <<
-    "if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated "
-    "and isinstance(iprot.trans, TTransport.CReadableTransport) "
-    "and self.thrift_spec is not None "
-    "and fastbinary is not None:" << endl;
+  indent(out) << "if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated "
+                 "and isinstance(iprot.trans, TTransport.CReadableTransport) "
+                 "and self.thrift_spec is not None "
+                 "and fastbinary is not None:" << endl;
   indent_up();
 
-  indent(out) <<
-    "fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))" << endl;
-  indent(out) <<
-    "return" << endl;
+  indent(out) << "fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))"
+              << endl;
+  indent(out) << "return" << endl;
   indent_down();
 
-  indent(out) <<
-    "iprot.readStructBegin()" << endl;
+  indent(out) << "iprot.readStructBegin()" << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "while True:" << endl;
-    indent_up();
+  indent(out) << "while True:" << endl;
+  indent_up();
 
-    // Read beginning field marker
-    indent(out) <<
-      "(fname, ftype, fid) = iprot.readFieldBegin()" << endl;
+  // Read beginning field marker
+  indent(out) << "(fname, ftype, fid) = iprot.readFieldBegin()" << endl;
 
-    // Check for field STOP marker and break
-    indent(out) <<
-      "if ftype == TType.STOP:" << endl;
-    indent_up();
-    indent(out) <<
-      "break" << endl;
-    indent_down();
+  // Check for field STOP marker and break
+  indent(out) << "if ftype == TType.STOP:" << endl;
+  indent_up();
+  indent(out) << "break" << endl;
+  indent_down();
 
-    // Switch statement on the field we are reading
-    bool first = true;
+  // Switch statement on the field we are reading
+  bool first = true;
 
-    // Generate deserialization code for known cases
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      if (first) {
-        first = false;
-        out <<
-          indent() << "if ";
-      } else {
-        out <<
-          indent() << "elif ";
-      }
-      out << "fid == " << (*f_iter)->get_key() << ":" << endl;
-      indent_up();
-      indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << endl;
-      indent_up();
-      generate_deserialize_field(out, *f_iter, "self.");
-      indent_down();
-      out <<
-        indent() << "else:" << endl <<
-        indent() << "  iprot.skip(ftype)" << endl;
-      indent_down();
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    if (first) {
+      first = false;
+      out << indent() << "if ";
+    } else {
+      out << indent() << "elif ";
     }
+    out << "fid == " << (*f_iter)->get_key() << ":" << endl;
+    indent_up();
+    indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << endl;
+    indent_up();
+    generate_deserialize_field(out, *f_iter, "self.");
+    indent_down();
+    out << indent() << "else:" << endl << indent() << "  iprot.skip(ftype)" << endl;
+    indent_down();
+  }
 
-    // In the default case we skip the field
-    out <<
-      indent() <<  "else:" << endl <<
-      indent() <<  "  iprot.skip(ftype)" << endl;
+  // In the default case we skip the field
+  out << indent() << "else:" << endl << indent() << "  iprot.skip(ftype)" << endl;
 
-    // Read field end marker
-    indent(out) <<
-      "iprot.readFieldEnd()" << endl;
+  // Read field end marker
+  indent(out) << "iprot.readFieldEnd()" << endl;
 
-    indent_down();
+  indent_down();
 
-    indent(out) <<
-      "iprot.readStructEnd()" << endl;
+  indent(out) << "iprot.readStructEnd()" << endl;
 
-    indent_down();
+  indent_down();
   out << endl;
 }
 
-void t_py_generator::generate_py_struct_writer(ofstream& out,
-                                               t_struct* tstruct) {
+void t_py_generator::generate_py_struct_writer(ofstream& out, t_struct* tstruct) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
@@ -951,57 +864,48 @@ void t_py_generator::generate_py_struct_writer(ofstream& out,
   indent(out) << "def write(self, oprot):" << endl;
   indent_up();
 
-  indent(out) <<
-    "if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated "
-    "and self.thrift_spec is not None "
-    "and fastbinary is not None:" << endl;
+  indent(out) << "if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated "
+                 "and self.thrift_spec is not None "
+                 "and fastbinary is not None:" << endl;
   indent_up();
 
-  indent(out) <<
-    "oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))" << endl;
-  indent(out) <<
-    "return" << endl;
+  indent(out)
+      << "oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))"
+      << endl;
+  indent(out) << "return" << endl;
   indent_down();
 
-  indent(out) <<
-    "oprot.writeStructBegin('" << name << "')" << endl;
+  indent(out) << "oprot.writeStructBegin('" << name << "')" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     // Write field header
-    indent(out) <<
-      "if self." << (*f_iter)->get_name() << " is not None:" << endl;
+    indent(out) << "if self." << (*f_iter)->get_name() << " is not None:" << endl;
     indent_up();
-    indent(out) <<
-      "oprot.writeFieldBegin(" <<
-      "'" << (*f_iter)->get_name() << "', " <<
-      type_to_enum((*f_iter)->get_type()) << ", " <<
-      (*f_iter)->get_key() << ")" << endl;
+    indent(out) << "oprot.writeFieldBegin("
+                << "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
+                << ", " << (*f_iter)->get_key() << ")" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "self.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd()" << endl;
+    indent(out) << "oprot.writeFieldEnd()" << endl;
 
     indent_down();
   }
 
   // Write the struct map
-  out <<
-    indent() << "oprot.writeFieldStop()" << endl <<
-    indent() << "oprot.writeStructEnd()" << endl;
+  out << indent() << "oprot.writeFieldStop()" << endl << indent() << "oprot.writeStructEnd()"
+      << endl;
 
   out << endl;
 
   indent_down();
   generate_py_struct_required_validator(out, tstruct);
-  out <<
-    endl;
+  out << endl;
 }
 
-void t_py_generator::generate_py_struct_required_validator(ofstream& out,
-                                               t_struct* tstruct) {
+void t_py_generator::generate_py_struct_required_validator(ofstream& out, t_struct* tstruct) {
   indent(out) << "def validate(self):" << endl;
   indent_up();
 
@@ -1014,8 +918,8 @@ void t_py_generator::generate_py_struct_required_validator(ofstream& out,
       t_field* field = (*f_iter);
       if (field->get_req() == t_field::T_REQUIRED) {
         indent(out) << "if self." << field->get_name() << " is None:" << endl;
-        indent(out) << "  raise TProtocol.TProtocolException(message='Required field " <<
-          field->get_name() << " is unset!')" << endl;
+        indent(out) << "  raise TProtocol.TProtocolException(message='Required field "
+                    << field->get_name() << " is unset!')" << endl;
       }
     }
   }
@@ -1030,29 +934,24 @@ void t_py_generator::generate_py_struct_required_validator(ofstream& out,
  * @param tservice The service definition
  */
 void t_py_generator::generate_service(t_service* tservice) {
-  string f_service_name = package_dir_+"/"+service_name_+".py";
+  string f_service_name = package_dir_ + "/" + service_name_ + ".py";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    py_autogen_comment() << endl <<
-    py_imports() << endl;
+  f_service_ << py_autogen_comment() << endl << py_imports() << endl;
 
   if (tservice->get_extends() != NULL) {
-    f_service_ <<
-      "import " << get_real_py_module(tservice->get_extends()->get_program(), gen_twisted_) <<
-      "." << tservice->get_extends()->get_name() << endl;
+    f_service_ << "import "
+               << get_real_py_module(tservice->get_extends()->get_program(), gen_twisted_) << "."
+               << tservice->get_extends()->get_name() << endl;
   }
 
-  f_service_ <<
-    "from ttypes import *" << endl <<
-    "from thrift.Thrift import TProcessor" << endl <<
-    render_fastbinary_includes() << endl;
+  f_service_ << "from ttypes import *" << endl << "from thrift.Thrift import TProcessor" << endl
+             << render_fastbinary_includes() << endl;
 
   if (gen_twisted_) {
-    f_service_ <<
-      "from zope.interface import Interface, implements" << endl <<
-      "from twisted.internet import defer" << endl <<
-      "from thrift.transport import TTwisted" << endl;
+    f_service_ << "from zope.interface import Interface, implements" << endl
+               << "from twisted.internet import defer" << endl
+               << "from thrift.transport import TTwisted" << endl;
   } else if (gen_tornado_) {
     f_service_ << "from tornado import gen" << endl;
     f_service_ << "from tornado import concurrent" << endl;
@@ -1081,8 +980,7 @@ void t_py_generator::generate_service_helpers(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
 
-  f_service_ <<
-    "# HELPER FUNCTIONS AND STRUCTURES" << endl;
+  f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_struct* ts = (*f_iter)->get_arglist();
@@ -1133,30 +1031,25 @@ void t_py_generator::generate_service_interface(t_service* tservice) {
     }
   }
 
-  f_service_ <<
-    "class Iface" << extends_if << ":" << endl;
+  f_service_ << "class Iface" << extends_if << ":" << endl;
   indent_up();
   generate_python_docstring(f_service_, tservice);
   vector<t_function*> functions = tservice->get_functions();
   if (functions.empty()) {
-    f_service_ <<
-      indent() << "pass" << endl;
+    f_service_ << indent() << "pass" << endl;
   } else {
     vector<t_function*>::iterator f_iter;
     for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-      f_service_ <<
-        indent() << "def " << function_signature(*f_iter, true) << ":" << endl;
+      f_service_ << indent() << "def " << function_signature(*f_iter, true) << ":" << endl;
       indent_up();
       generate_python_docstring(f_service_, (*f_iter));
-      f_service_ <<
-        indent() << "pass" << endl << endl;
+      f_service_ << indent() << "pass" << endl << endl;
       indent_down();
     }
   }
 
   indent_down();
-  f_service_ <<
-    endl;
+  f_service_ << endl;
 }
 
 /**
@@ -1181,96 +1074,76 @@ void t_py_generator::generate_service_client(t_service* tservice) {
   }
 
   if (gen_twisted_) {
-    f_service_ <<
-      "class Client" << extends_client << ":" << endl <<
-      "  implements(Iface)" << endl << endl;
+    f_service_ << "class Client" << extends_client << ":" << endl << "  implements(Iface)" << endl
+               << endl;
   } else {
-    f_service_ <<
-      "class Client(" << extends_client << "Iface):" << endl;
+    f_service_ << "class Client(" << extends_client << "Iface):" << endl;
   }
   indent_up();
   generate_python_docstring(f_service_, tservice);
 
   // Constructor function
   if (gen_twisted_) {
-    f_service_ <<
-      indent() << "def __init__(self, transport, oprot_factory):" << endl;
+    f_service_ << indent() << "def __init__(self, transport, oprot_factory):" << endl;
   } else if (gen_tornado_) {
-    f_service_ <<
-      indent() << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << endl;
+    f_service_ << indent()
+               << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << endl;
   } else {
-    f_service_ <<
-      indent() << "def __init__(self, iprot, oprot=None):" << endl;
+    f_service_ << indent() << "def __init__(self, iprot, oprot=None):" << endl;
   }
   if (extends.empty()) {
     if (gen_twisted_) {
-      f_service_ <<
-        indent() << "  self._transport = transport" << endl <<
-        indent() << "  self._oprot_factory = oprot_factory" << endl <<
-        indent() << "  self._seqid = 0" << endl <<
-        indent() << "  self._reqs = {}" << endl <<
-        endl;
+      f_service_ << indent() << "  self._transport = transport" << endl << indent()
+                 << "  self._oprot_factory = oprot_factory" << endl << indent()
+                 << "  self._seqid = 0" << endl << indent() << "  self._reqs = {}" << endl << endl;
     } else if (gen_tornado_) {
-      f_service_ <<
-        indent() << "  self._transport = transport" << endl <<
-        indent() << "  self._iprot_factory = iprot_factory" << endl <<
-        indent() << "  self._oprot_factory = (oprot_factory if oprot_factory is not None" << endl <<
-        indent() << "                         else iprot_factory)" << endl <<
-        indent() << "  self._seqid = 0" << endl <<
-        indent() << "  self._reqs = {}" << endl <<
-        indent() << "  self._transport.io_loop.spawn_callback(self._start_receiving)" << endl <<
-        endl;
+      f_service_ << indent() << "  self._transport = transport" << endl << indent()
+                 << "  self._iprot_factory = iprot_factory" << endl << indent()
+                 << "  self._oprot_factory = (oprot_factory if oprot_factory is not None" << endl
+                 << indent() << "                         else iprot_factory)" << endl << indent()
+                 << "  self._seqid = 0" << endl << indent() << "  self._reqs = {}" << endl
+                 << indent() << "  self._transport.io_loop.spawn_callback(self._start_receiving)"
+                 << endl << endl;
     } else {
-      f_service_ <<
-        indent() << "  self._iprot = self._oprot = iprot" << endl <<
-        indent() << "  if oprot is not None:" << endl <<
-        indent() << "    self._oprot = oprot" << endl <<
-        indent() << "  self._seqid = 0" << endl <<
-        endl;
+      f_service_ << indent() << "  self._iprot = self._oprot = iprot" << endl << indent()
+                 << "  if oprot is not None:" << endl << indent() << "    self._oprot = oprot"
+                 << endl << indent() << "  self._seqid = 0" << endl << endl;
     }
   } else {
     if (gen_twisted_) {
-      f_service_ <<
-        indent() << "  " << extends << ".Client.__init__(self, transport, oprot_factory)" << endl <<
-        endl;
+      f_service_ << indent() << "  " << extends
+                 << ".Client.__init__(self, transport, oprot_factory)" << endl << endl;
     } else if (gen_tornado_) {
-      f_service_ <<
-        indent() << "  " << extends << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << endl <<
-        endl;
+      f_service_ << indent() << "  " << extends
+                 << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << endl
+                 << endl;
     } else {
-      f_service_ <<
-        indent() << "  " << extends << ".Client.__init__(self, iprot, oprot)" << endl <<
-        endl;
+      f_service_ << indent() << "  " << extends << ".Client.__init__(self, iprot, oprot)" << endl
+                 << endl;
     }
   }
 
   if (gen_tornado_ && extends.empty()) {
-    f_service_ <<
-      indent() << "@gen.engine" << endl <<
-      indent() << "def _start_receiving(self):" << endl <<
-      indent() << "  while True:" << endl <<
-      indent() << "    try:" << endl <<
-      indent() << "      frame = yield self._transport.readFrame()" << endl <<
-      indent() << "    except TTransport.TTransportException as e:" << endl <<
-      indent() << "      for future in self._reqs.itervalues():" << endl <<
-      indent() << "        future.set_exception(e)" << endl <<
-      indent() << "      self._reqs = {}" << endl <<
-      indent() << "      return" << endl <<
-      indent() << "    tr = TTransport.TMemoryBuffer(frame)" << endl <<
-      indent() << "    iprot = self._iprot_factory.getProtocol(tr)" << endl <<
-      indent() << "    (fname, mtype, rseqid) = iprot.readMessageBegin()" << endl <<
-      indent() << "    future = self._reqs.pop(rseqid, None)" << endl <<
-      indent() << "    if not future:" << endl <<
-      indent() << "      # future has already been discarded" << endl <<
-      indent() << "      continue" << endl <<
-      indent() << "    method = getattr(self, 'recv_' + fname)" << endl <<
-      indent() << "    try:" << endl <<
-      indent() << "      result = method(iprot, mtype, rseqid)" << endl <<
-      indent() << "    except Exception as e:" << endl <<
-      indent() << "      future.set_exception(e)" << endl <<
-      indent() << "    else:" << endl <<
-      indent() << "      future.set_result(result)" << endl <<
-      endl;
+    f_service_ << indent() << "@gen.engine" << endl << indent()
+               << "def _start_receiving(self):" << endl << indent() << "  while True:" << endl
+               << indent() << "    try:" << endl << indent()
+               << "      frame = yield self._transport.readFrame()" << endl << indent()
+               << "    except TTransport.TTransportException as e:" << endl << indent()
+               << "      for future in self._reqs.itervalues():" << endl << indent()
+               << "        future.set_exception(e)" << endl << indent() << "      self._reqs = {}"
+               << endl << indent() << "      return" << endl << indent()
+               << "    tr = TTransport.TMemoryBuffer(frame)" << endl << indent()
+               << "    iprot = self._iprot_factory.getProtocol(tr)" << endl << indent()
+               << "    (fname, mtype, rseqid) = iprot.readMessageBegin()" << endl << indent()
+               << "    future = self._reqs.pop(rseqid, None)" << endl << indent()
+               << "    if not future:" << endl << indent()
+               << "      # future has already been discarded" << endl << indent()
+               << "      continue" << endl << indent()
+               << "    method = getattr(self, 'recv_' + fname)" << endl << indent()
+               << "    try:" << endl << indent() << "      result = method(iprot, mtype, rseqid)"
+               << endl << indent() << "    except Exception as e:" << endl << indent()
+               << "      future.set_exception(e)" << endl << indent() << "    else:" << endl
+               << indent() << "      future.set_result(result)" << endl << endl;
   }
 
   // Generate client method implementations
@@ -1283,8 +1156,7 @@ void t_py_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    indent(f_service_) <<
-      "def " << function_signature(*f_iter, false) << ":" << endl;
+    indent(f_service_) << "def " << function_signature(*f_iter, false) << ":" << endl;
     indent_up();
     generate_python_docstring(f_service_, (*f_iter));
     if (gen_twisted_) {
@@ -1295,20 +1167,18 @@ void t_py_generator::generate_service_client(t_service* tservice) {
     } else if (gen_tornado_) {
       indent(f_service_) << "self._seqid += 1" << endl;
       if (!(*f_iter)->is_oneway()) {
-        indent(f_service_) <<
-          "future = self._reqs[self._seqid] = concurrent.Future()" << endl;
+        indent(f_service_) << "future = self._reqs[self._seqid] = concurrent.Future()" << endl;
       }
-      indent(f_service_) <<
-        "self.send_" << funname << "(";
+      indent(f_service_) << "self.send_" << funname << "(";
 
     } else {
-      indent(f_service_) <<
-        "self.send_" << funname << "(";
+      indent(f_service_) << "self.send_" << funname << "(";
     }
 
     bool first = true;
     if (gen_twisted_) {
-      // we need a leading comma if there are args, since it's called as maybeDeferred(funcname, arg)
+      // we need a leading comma if there are args, since it's called as maybeDeferred(funcname,
+      // arg)
       first = false;
     }
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -1340,52 +1210,40 @@ void t_py_generator::generate_service_client(t_service* tservice) {
     if (gen_twisted_) {
       // This block injects the body of the send_<> method for twisted (and a cb/eb pair)
       indent_up();
-      indent(f_service_) <<
-        "d.addCallbacks(" << endl;
+      indent(f_service_) << "d.addCallbacks(" << endl;
 
       indent_up();
-      f_service_ <<
-        indent() << "callback=self.cb_send_" << funname << "," << endl <<
-        indent() << "callbackArgs=(seqid,)," << endl <<
-        indent() << "errback=self.eb_send_" << funname << "," << endl <<
-        indent() << "errbackArgs=(seqid,))" << endl;
+      f_service_ << indent() << "callback=self.cb_send_" << funname << "," << endl << indent()
+                 << "callbackArgs=(seqid,)," << endl << indent() << "errback=self.eb_send_"
+                 << funname << "," << endl << indent() << "errbackArgs=(seqid,))" << endl;
       indent_down();
 
-      indent(f_service_) <<
-        "return d" << endl;
+      indent(f_service_) << "return d" << endl;
       indent_down();
       f_service_ << endl;
 
-      indent(f_service_) <<
-        "def cb_send_" << funname << "(self, _, seqid):" << endl;
+      indent(f_service_) << "def cb_send_" << funname << "(self, _, seqid):" << endl;
       indent_up();
       if ((*f_iter)->is_oneway()) {
         // if one-way, fire the deferred & remove it from _reqs
-        f_service_ << indent() <<
-          "d = self._reqs.pop(seqid)" << endl << indent() <<
-          "d.callback(None)" << endl << indent() <<
-          "return d" << endl;
+        f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent()
+                   << "d.callback(None)" << endl << indent() << "return d" << endl;
       } else {
-        f_service_ << indent() <<
-          "return self._reqs[seqid]" << endl;
+        f_service_ << indent() << "return self._reqs[seqid]" << endl;
       }
       indent_down();
       f_service_ << endl;
 
       // add an errback to fail the request if the call to send_<> raised an exception
-      indent(f_service_) <<
-        "def eb_send_" << funname << "(self, f, seqid):" << endl;
+      indent(f_service_) << "def eb_send_" << funname << "(self, f, seqid):" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "d = self._reqs.pop(seqid)" << endl <<
-        indent() << "d.errback(f)" << endl <<
-        indent() << "return d" << endl;
+      f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent() << "d.errback(f)"
+                 << endl << indent() << "return d" << endl;
       indent_down();
     }
 
     f_service_ << endl;
-    indent(f_service_) <<
-      "def send_" << function_signature(*f_iter, false) << ":" << endl;
+    indent(f_service_) << "def send_" << function_signature(*f_iter, false) << ":" << endl;
     indent_up();
 
     std::string argsname = (*f_iter)->get_name() + "_args";
@@ -1393,35 +1251,29 @@ void t_py_generator::generate_service_client(t_service* tservice) {
 
     // Serialize the request header
     if (gen_twisted_ || gen_tornado_) {
-      f_service_ <<
-        indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << endl <<
-        indent() << "oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
+      f_service_ << indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << endl
+                 << indent() << "oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
                  << messageType << ", self._seqid)" << endl;
     } else {
-      f_service_ <<
-        indent() << "self._oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
+      f_service_ << indent() << "self._oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
                  << messageType << ", self._seqid)" << endl;
     }
 
-    f_service_ <<
-      indent() << "args = " << argsname << "()" << endl;
+    f_service_ << indent() << "args = " << argsname << "()" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args." << (*fld_iter)->get_name() << " = " << (*fld_iter)->get_name() << endl;
+      f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
+                 << (*fld_iter)->get_name() << endl;
     }
 
     // Write to the stream
     if (gen_twisted_ || gen_tornado_) {
-      f_service_ <<
-        indent() << "args.write(oprot)" << endl <<
-        indent() << "oprot.writeMessageEnd()" << endl <<
-        indent() << "oprot.trans.flush()" << endl;
+      f_service_ << indent() << "args.write(oprot)" << endl << indent() << "oprot.writeMessageEnd()"
+                 << endl << indent() << "oprot.trans.flush()" << endl;
     } else {
-      f_service_ <<
-        indent() << "args.write(self._oprot)" << endl <<
-        indent() << "self._oprot.writeMessageEnd()" << endl <<
-        indent() << "self._oprot.trans.flush()" << endl;
+      f_service_ << indent() << "args.write(self._oprot)" << endl << indent()
+                 << "self._oprot.writeMessageEnd()" << endl << indent()
+                 << "self._oprot.trans.flush()" << endl;
     }
 
     indent_down();
@@ -1429,100 +1281,84 @@ void t_py_generator::generate_service_client(t_service* tservice) {
     if (!(*f_iter)->is_oneway()) {
       std::string resultname = (*f_iter)->get_name() + "_result";
       // Open function
-      f_service_ <<
-        endl;
+      f_service_ << endl;
       if (gen_twisted_ || gen_tornado_) {
-        f_service_ <<
-          indent() << "def recv_" << (*f_iter)->get_name() <<
-              "(self, iprot, mtype, rseqid):" << endl;
+        f_service_ << indent() << "def recv_" << (*f_iter)->get_name()
+                   << "(self, iprot, mtype, rseqid):" << endl;
       } else {
         t_struct noargs(program_);
         t_function recv_function((*f_iter)->get_returntype(),
-                               string("recv_") + (*f_iter)->get_name(),
-                               &noargs);
-        f_service_ <<
-          indent() << "def " << function_signature(&recv_function) << ":" << endl;
+                                 string("recv_") + (*f_iter)->get_name(),
+                                 &noargs);
+        f_service_ << indent() << "def " << function_signature(&recv_function) << ":" << endl;
       }
       indent_up();
 
       // TODO(mcslee): Validate message reply here, seq ids etc.
 
       if (gen_twisted_) {
-        f_service_ <<
-          indent() << "d = self._reqs.pop(rseqid)" << endl;
+        f_service_ << indent() << "d = self._reqs.pop(rseqid)" << endl;
       } else if (gen_tornado_) {
       } else {
-        f_service_ <<
-          indent() << "iprot = self._iprot" << endl <<
-          indent() << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl;
+        f_service_ << indent() << "iprot = self._iprot" << endl << indent()
+                   << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl;
       }
 
-      f_service_ <<
-        indent() << "if mtype == TMessageType.EXCEPTION:" << endl <<
-        indent() << "  x = TApplicationException()" << endl;
+      f_service_ << indent() << "if mtype == TMessageType.EXCEPTION:" << endl << indent()
+                 << "  x = TApplicationException()" << endl;
 
       if (gen_twisted_) {
-        f_service_ <<
-          indent() << "  x.read(iprot)" << endl <<
-          indent() << "  iprot.readMessageEnd()" << endl <<
-          indent() << "  return d.errback(x)" << endl <<
-          indent() << "result = " << resultname << "()" << endl <<
-          indent() << "result.read(iprot)" << endl <<
-          indent() << "iprot.readMessageEnd()" << endl;
+        f_service_ << indent() << "  x.read(iprot)" << endl << indent()
+                   << "  iprot.readMessageEnd()" << endl << indent() << "  return d.errback(x)"
+                   << endl << indent() << "result = " << resultname << "()" << endl << indent()
+                   << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl;
       } else {
-        f_service_ <<
-          indent() << "  x.read(iprot)" << endl <<
-          indent() << "  iprot.readMessageEnd()" << endl <<
-          indent() << "  raise x" << endl <<
-          indent() << "result = " << resultname << "()" << endl <<
-          indent() << "result.read(iprot)" << endl <<
-          indent() << "iprot.readMessageEnd()" << endl;
+        f_service_ << indent() << "  x.read(iprot)" << endl << indent()
+                   << "  iprot.readMessageEnd()" << endl << indent() << "  raise x" << endl
+                   << indent() << "result = " << resultname << "()" << endl << indent()
+                   << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl;
       }
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ <<
-          indent() << "if result.success is not None:" << endl;
-          if (gen_twisted_) {
-            f_service_ <<
-              indent() << "  return d.callback(result.success)" << endl;
-          } else {
-            f_service_ <<
-              indent() << "  return result.success" << endl;
-          }
+        f_service_ << indent() << "if result.success is not None:" << endl;
+        if (gen_twisted_) {
+          f_service_ << indent() << "  return d.callback(result.success)" << endl;
+        } else {
+          f_service_ << indent() << "  return result.success" << endl;
+        }
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "if result." << (*x_iter)->get_name() << " is not None:" << endl;
-          if (gen_twisted_) {
-            f_service_ <<
-              indent() << "  return d.errback(result." << (*x_iter)->get_name() << ")" << endl;
-          } else {
-            f_service_ <<
-              indent() << "  raise result." << (*x_iter)->get_name() << "" << endl;
-          }
+        f_service_ << indent() << "if result." << (*x_iter)->get_name() << " is not None:" << endl;
+        if (gen_twisted_) {
+          f_service_ << indent() << "  return d.errback(result." << (*x_iter)->get_name() << ")"
+                     << endl;
+        } else {
+          f_service_ << indent() << "  raise result." << (*x_iter)->get_name() << "" << endl;
+        }
       }
 
       // Careful, only return _result if not a void function
       if ((*f_iter)->get_returntype()->is_void()) {
         if (gen_twisted_) {
-          f_service_ <<
-            indent() << "return d.callback(None)" << endl;
+          f_service_ << indent() << "return d.callback(None)" << endl;
         } else {
-          f_service_ <<
-            indent() << "return" << endl;
+          f_service_ << indent() << "return" << endl;
         }
       } else {
         if (gen_twisted_) {
-          f_service_ <<
-            indent() << "return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\"))" << endl;
+          f_service_
+              << indent()
+              << "return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, \""
+              << (*f_iter)->get_name() << " failed: unknown result\"))" << endl;
         } else {
-          f_service_ <<
-            indent() << "raise TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+          f_service_ << indent()
+                     << "raise TApplicationException(TApplicationException.MISSING_RESULT, \""
+                     << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
         }
       }
 
@@ -1533,8 +1369,7 @@ void t_py_generator::generate_service_client(t_service* tservice) {
   }
 
   indent_down();
-  f_service_ <<
-    endl;
+  f_service_ << endl;
 }
 
 /**
@@ -1544,46 +1379,37 @@ void t_py_generator::generate_service_client(t_service* tservice) {
  */
 void t_py_generator::generate_service_remote(t_service* tservice) {
   vector<t_function*> functions = tservice->get_functions();
-  //Get all function from parents
+  // Get all function from parents
   t_service* parent = tservice->get_extends();
-  while(parent != NULL) {
+  while (parent != NULL) {
     vector<t_function*> p_functions = parent->get_functions();
     functions.insert(functions.end(), p_functions.begin(), p_functions.end());
     parent = parent->get_extends();
   }
   vector<t_function*>::iterator f_iter;
 
-  string f_remote_name = package_dir_+"/"+service_name_+"-remote";
+  string f_remote_name = package_dir_ + "/" + service_name_ + "-remote";
   ofstream f_remote;
   f_remote.open(f_remote_name.c_str());
 
-  f_remote <<
-    "#!/usr/bin/env python" << endl <<
-    py_autogen_comment() << endl <<
-    "import sys" << endl <<
-    "import pprint" << endl <<
-    "from urlparse import urlparse" << endl <<
-    "from thrift.transport import TTransport" << endl <<
-    "from thrift.transport import TSocket" << endl <<
-    "from thrift.transport import TSSLSocket" << endl <<
-    "from thrift.transport import THttpClient" << endl <<
-    "from thrift.protocol import TBinaryProtocol" << endl <<
-    endl;
-
-  f_remote <<
-    "from " << module_ << " import " << service_name_ << endl <<
-    "from " << module_ << ".ttypes import *" << endl <<
-    endl;
-
-  f_remote <<
-    "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << endl <<
-    "  print('')" << endl <<
-    "  print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] function [arg1 [arg2...]]')" << endl <<
-    "  print('')" << endl <<
-    "  print('Functions:')" << endl;
+  f_remote << "#!/usr/bin/env python" << endl << py_autogen_comment() << endl << "import sys"
+           << endl << "import pprint" << endl << "from urlparse import urlparse" << endl
+           << "from thrift.transport import TTransport" << endl
+           << "from thrift.transport import TSocket" << endl
+           << "from thrift.transport import TSSLSocket" << endl
+           << "from thrift.transport import THttpClient" << endl
+           << "from thrift.protocol import TBinaryProtocol" << endl << endl;
+
+  f_remote << "from " << module_ << " import " << service_name_ << endl << "from " << module_
+           << ".ttypes import *" << endl << endl;
+
+  f_remote << "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << endl << "  print('')" << endl
+           << "  print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] "
+              "function [arg1 [arg2...]]')" << endl << "  print('')" << endl
+           << "  print('Functions:')" << endl;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_remote <<
-      "  print('  " << (*f_iter)->get_returntype()->get_name() << " " << (*f_iter)->get_name() << "(";
+    f_remote << "  print('  " << (*f_iter)->get_returntype()->get_name() << " "
+             << (*f_iter)->get_name() << "(";
     t_struct* arg_struct = (*f_iter)->get_arglist();
     const std::vector<t_field*>& args = arg_struct->get_members();
     vector<t_field*>::const_iterator a_iter;
@@ -1595,70 +1421,37 @@ void t_py_generator::generate_service_remote(t_service* tservice) {
       } else {
         f_remote << ", ";
       }
-      f_remote <<
-        args[i]->get_type()->get_name() << " " << args[i]->get_name();
+      f_remote << args[i]->get_type()->get_name() << " " << args[i]->get_name();
     }
     f_remote << ")')" << endl;
   }
-  f_remote <<
-    "  print('')" << endl <<
-    "  sys.exit(0)" << endl <<
-    endl;
-
-  f_remote <<
-    "pp = pprint.PrettyPrinter(indent = 2)" << endl <<
-    "host = 'localhost'" << endl <<
-    "port = 9090" << endl <<
-    "uri = ''" << endl <<
-    "framed = False" << endl <<
-    "ssl = False" << endl <<
-    "http = False" << endl <<
-    "argi = 1" << endl <<
-    endl <<
-    "if sys.argv[argi] == '-h':" << endl <<
-    "  parts = sys.argv[argi+1].split(':')" << endl <<
-    "  host = parts[0]" << endl <<
-    "  if len(parts) > 1:" << endl <<
-    "    port = int(parts[1])" << endl <<
-    "  argi += 2" << endl <<
-    endl <<
-    "if sys.argv[argi] == '-u':" << endl <<
-    "  url = urlparse(sys.argv[argi+1])" << endl <<
-    "  parts = url[1].split(':')" << endl <<
-    "  host = parts[0]" << endl <<
-    "  if len(parts) > 1:" << endl <<
-    "    port = int(parts[1])" << endl <<
-    "  else:" << endl <<
-    "    port = 80" << endl <<
-    "  uri = url[2]" << endl <<
-    "  if url[4]:" << endl <<
-    "    uri += '?%s' % url[4]" << endl <<
-    "  http = True" << endl <<
-    "  argi += 2" << endl <<
-    endl <<
-    "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << endl <<
-    "  framed = True" << endl <<
-    "  argi += 1" << endl <<
-    endl <<
-    "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << endl <<
-    "  ssl = True" << endl <<
-    "  argi += 1" << endl <<
-    endl <<
-    "cmd = sys.argv[argi]" << endl <<
-    "args = sys.argv[argi+1:]" << endl <<
-    endl <<
-    "if http:" << endl <<
-    "  transport = THttpClient.THttpClient(host, port, uri)" << endl <<
-    "else:" << endl <<
-    "  socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port)" << endl <<
-    "  if framed:" << endl <<
-    "    transport = TTransport.TFramedTransport(socket)" << endl <<
-    "  else:" << endl <<
-    "    transport = TTransport.TBufferedTransport(socket)" << endl <<
-    "protocol = TBinaryProtocol.TBinaryProtocol(transport)" << endl <<
-    "client = " << service_name_ << ".Client(protocol)" << endl <<
-    "transport.open()" << endl <<
-    endl;
+  f_remote << "  print('')" << endl << "  sys.exit(0)" << endl << endl;
+
+  f_remote << "pp = pprint.PrettyPrinter(indent = 2)" << endl << "host = 'localhost'" << endl
+           << "port = 9090" << endl << "uri = ''" << endl << "framed = False" << endl
+           << "ssl = False" << endl << "http = False" << endl << "argi = 1" << endl << endl
+           << "if sys.argv[argi] == '-h':" << endl << "  parts = sys.argv[argi+1].split(':')"
+           << endl << "  host = parts[0]" << endl << "  if len(parts) > 1:" << endl
+           << "    port = int(parts[1])" << endl << "  argi += 2" << endl << endl
+           << "if sys.argv[argi] == '-u':" << endl << "  url = urlparse(sys.argv[argi+1])" << endl
+           << "  parts = url[1].split(':')" << endl << "  host = parts[0]" << endl
+           << "  if len(parts) > 1:" << endl << "    port = int(parts[1])" << endl
+           << "  else:" << endl << "    port = 80" << endl << "  uri = url[2]" << endl
+           << "  if url[4]:" << endl << "    uri += '?%s' % url[4]" << endl << "  http = True"
+           << endl << "  argi += 2" << endl << endl
+           << "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << endl
+           << "  framed = True" << endl << "  argi += 1" << endl << endl
+           << "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << endl << "  ssl = True"
+           << endl << "  argi += 1" << endl << endl << "cmd = sys.argv[argi]" << endl
+           << "args = sys.argv[argi+1:]" << endl << endl << "if http:" << endl
+           << "  transport = THttpClient.THttpClient(host, port, uri)" << endl << "else:" << endl
+           << "  socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else "
+              "TSocket.TSocket(host, port)" << endl << "  if framed:" << endl
+           << "    transport = TTransport.TFramedTransport(socket)" << endl << "  else:" << endl
+           << "    transport = TTransport.TBufferedTransport(socket)" << endl
+           << "protocol = TBinaryProtocol.TBinaryProtocol(transport)" << endl
+           << "client = " << service_name_ << ".Client(protocol)" << endl << "transport.open()"
+           << endl << endl;
 
   // Generate the dispatch methods
   bool first = true;
@@ -1675,12 +1468,10 @@ void t_py_generator::generate_service_remote(t_service* tservice) {
     vector<t_field*>::const_iterator a_iter;
     int num_args = args.size();
 
-    f_remote <<
-      "if cmd == '" << (*f_iter)->get_name() << "':" << endl <<
-      "  if len(args) != " << num_args << ":" << endl <<
-      "    print('" << (*f_iter)->get_name() << " requires " << num_args << " args')" << endl <<
-      "    sys.exit(1)" << endl <<
-      "  pp.pprint(client." << (*f_iter)->get_name() << "(";
+    f_remote << "if cmd == '" << (*f_iter)->get_name() << "':" << endl
+             << "  if len(args) != " << num_args << ":" << endl << "    print('"
+             << (*f_iter)->get_name() << " requires " << num_args << " args')" << endl
+             << "    sys.exit(1)" << endl << "  pp.pprint(client." << (*f_iter)->get_name() << "(";
     for (int i = 0; i < num_args; ++i) {
       if (args[i]->get_type()->is_string()) {
         f_remote << "args[" << i << "],";
@@ -1709,16 +1500,11 @@ void t_py_generator::generate_service_remote(t_service* tservice) {
 
   // Make file executable, love that bitwise OR action
   chmod(f_remote_name.c_str(),
-          S_IRUSR
-        | S_IWUSR
-        | S_IXUSR
+        S_IRUSR | S_IWUSR | S_IXUSR
 #ifndef _WIN32
-        | S_IRGRP
-        | S_IXGRP
-        | S_IROTH
-        | S_IXOTH
+        | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
 #endif
-  );
+        );
 
 #endif // _MSC_VER
 }
@@ -1742,88 +1528,71 @@ void t_py_generator::generate_service_server(t_service* tservice) {
 
   // Generate the header portion
   if (gen_twisted_) {
-    f_service_ <<
-      "class Processor(" << extends_processor << "TProcessor):" << endl <<
-      "  implements(Iface)" << endl << endl;
+    f_service_ << "class Processor(" << extends_processor << "TProcessor):" << endl
+               << "  implements(Iface)" << endl << endl;
   } else {
-    f_service_ <<
-      "class Processor(" << extends_processor << "Iface, TProcessor):" << endl;
+    f_service_ << "class Processor(" << extends_processor << "Iface, TProcessor):" << endl;
   }
 
   indent_up();
 
-  indent(f_service_) <<
-    "def __init__(self, handler):" << endl;
+  indent(f_service_) << "def __init__(self, handler):" << endl;
   indent_up();
   if (extends.empty()) {
     if (gen_twisted_) {
-      f_service_ <<
-        indent() << "self._handler = Iface(handler)" << endl;
+      f_service_ << indent() << "self._handler = Iface(handler)" << endl;
     } else {
-      f_service_ <<
-        indent() << "self._handler = handler" << endl;
+      f_service_ << indent() << "self._handler = handler" << endl;
     }
 
-    f_service_ <<
-      indent() << "self._processMap = {}" << endl;
+    f_service_ << indent() << "self._processMap = {}" << endl;
   } else {
     if (gen_twisted_) {
-      f_service_ <<
-        indent() << extends << ".Processor.__init__(self, Iface(handler))" << endl;
+      f_service_ << indent() << extends << ".Processor.__init__(self, Iface(handler))" << endl;
     } else {
-      f_service_ <<
-        indent() << extends << ".Processor.__init__(self, handler)" << endl;
+      f_service_ << indent() << extends << ".Processor.__init__(self, handler)" << endl;
     }
   }
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "self._processMap[\"" << (*f_iter)->get_name() << "\"] = Processor.process_" << (*f_iter)->get_name() << endl;
+    f_service_ << indent() << "self._processMap[\"" << (*f_iter)->get_name()
+               << "\"] = Processor.process_" << (*f_iter)->get_name() << endl;
   }
   indent_down();
   f_service_ << endl;
 
   // Generate the server implementation
-  f_service_ <<
-    indent() << "def process(self, iprot, oprot):" << endl;
+  f_service_ << indent() << "def process(self, iprot, oprot):" << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "(name, type, seqid) = iprot.readMessageBegin()" << endl;
+  f_service_ << indent() << "(name, type, seqid) = iprot.readMessageBegin()" << endl;
 
   // TODO(mcslee): validate message
 
   // HOT: dictionary function lookup
-  f_service_ <<
-    indent() << "if name not in self._processMap:" << endl <<
-    indent() << "  iprot.skip(TType.STRUCT)" << endl <<
-    indent() << "  iprot.readMessageEnd()" << endl <<
-    indent() << "  x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))" << endl <<
-    indent() << "  oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << endl <<
-    indent() << "  x.write(oprot)" << endl <<
-    indent() << "  oprot.writeMessageEnd()" << endl <<
-    indent() << "  oprot.trans.flush()" << endl;
+  f_service_ << indent() << "if name not in self._processMap:" << endl << indent()
+             << "  iprot.skip(TType.STRUCT)" << endl << indent() << "  iprot.readMessageEnd()"
+             << endl << indent()
+             << "  x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown "
+                "function %s' % (name))" << endl << indent()
+             << "  oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << endl << indent()
+             << "  x.write(oprot)" << endl << indent() << "  oprot.writeMessageEnd()" << endl
+             << indent() << "  oprot.trans.flush()" << endl;
 
   if (gen_twisted_) {
-    f_service_ <<
-      indent() << "  return defer.succeed(None)" << endl;
+    f_service_ << indent() << "  return defer.succeed(None)" << endl;
   } else {
-    f_service_ <<
-      indent() << "  return" << endl;
+    f_service_ << indent() << "  return" << endl;
   }
 
-  f_service_ <<
-    indent() << "else:" << endl;
+  f_service_ << indent() << "else:" << endl;
 
   if (gen_twisted_ || gen_tornado_) {
-    f_service_ <<
-      indent() << "  return self._processMap[name](self, seqid, iprot, oprot)" << endl;
+    f_service_ << indent() << "  return self._processMap[name](self, seqid, iprot, oprot)" << endl;
   } else {
-    f_service_ <<
-      indent() << "  self._processMap[name](self, seqid, iprot, oprot)" << endl;
+    f_service_ << indent() << "  self._processMap[name](self, seqid, iprot, oprot)" << endl;
 
     // Read end of args field, the T_STOP, and the struct close
-    f_service_ <<
-      indent() << "return True" << endl;
+    f_service_ << indent() << "return True" << endl;
   }
 
   indent_down();
@@ -1843,19 +1612,15 @@ void t_py_generator::generate_service_server(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_py_generator::generate_process_function(t_service* tservice,
-                                               t_function* tfunction) {
-  (void) tservice;
+void t_py_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open function
   if (gen_tornado_) {
-    f_service_ <<
-      indent() << "@gen.coroutine" << endl <<
-      indent() << "def process_" << tfunction->get_name() <<
-                  "(self, seqid, iprot, oprot):" << endl;
+    f_service_ << indent() << "@gen.coroutine" << endl << indent() << "def process_"
+               << tfunction->get_name() << "(self, seqid, iprot, oprot):" << endl;
   } else {
-    f_service_ <<
-      indent() << "def process_" << tfunction->get_name() <<
-                  "(self, seqid, iprot, oprot):" << endl;
+    f_service_ << indent() << "def process_" << tfunction->get_name()
+               << "(self, seqid, iprot, oprot):" << endl;
   }
 
   indent_up();
@@ -1863,10 +1628,8 @@ void t_py_generator::generate_process_function(t_service* tservice,
   string argsname = tfunction->get_name() + "_args";
   string resultname = tfunction->get_name() + "_result";
 
-  f_service_ <<
-    indent() << "args = " << argsname << "()" << endl <<
-    indent() << "args.read(iprot)" << endl <<
-    indent() << "iprot.readMessageEnd()" << endl;
+  f_service_ << indent() << "args = " << argsname << "()" << endl << indent() << "args.read(iprot)"
+             << endl << indent() << "iprot.readMessageEnd()" << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1874,8 +1637,7 @@ void t_py_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "result = " << resultname << "()" << endl;
+    f_service_ << indent() << "result = " << resultname << "()" << endl;
   }
 
   if (gen_twisted_) {
@@ -1884,9 +1646,8 @@ void t_py_generator::generate_process_function(t_service* tservice,
     const std::vector<t_field*>& fields = arg_struct->get_members();
     vector<t_field*>::const_iterator f_iter;
 
-    f_service_ <<
-      indent() << "d = defer.maybeDeferred(self._handler." <<
-        tfunction->get_name() << ", ";
+    f_service_ << indent() << "d = defer.maybeDeferred(self._handler." << tfunction->get_name()
+               << ", ";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
@@ -1900,76 +1661,61 @@ void t_py_generator::generate_process_function(t_service* tservice,
 
     // Shortcut out here for oneway functions
     if (tfunction->is_oneway()) {
-      f_service_ <<
-        indent() << "return d" << endl;
+      f_service_ << indent() << "return d" << endl;
       indent_down();
       f_service_ << endl;
       return;
     }
 
-    f_service_ <<
-      indent() <<
-        "d.addCallback(self.write_results_success_" <<
-          tfunction->get_name() << ", result, seqid, oprot)" << endl;
+    f_service_ << indent() << "d.addCallback(self.write_results_success_" << tfunction->get_name()
+               << ", result, seqid, oprot)" << endl;
 
     if (xceptions.size() > 0) {
-      f_service_ <<
-        indent() <<
-          "d.addErrback(self.write_results_exception_" <<
-            tfunction->get_name() << ", result, seqid, oprot)" << endl;
+      f_service_ << indent() << "d.addErrback(self.write_results_exception_"
+                 << tfunction->get_name() << ", result, seqid, oprot)" << endl;
     }
 
-    f_service_ <<
-      indent() << "return d" << endl;
+    f_service_ << indent() << "return d" << endl;
 
     indent_down();
     f_service_ << endl;
 
-    indent(f_service_) <<
-        "def write_results_success_" << tfunction->get_name() <<
-        "(self, success, result, seqid, oprot):" << endl;
+    indent(f_service_) << "def write_results_success_" << tfunction->get_name()
+                       << "(self, success, result, seqid, oprot):" << endl;
     indent_up();
-    f_service_ <<
-      indent() << "result.success = success" << endl <<
-      indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() <<
-        "\", TMessageType.REPLY, seqid)" << endl <<
-      indent() << "result.write(oprot)" << endl <<
-      indent() << "oprot.writeMessageEnd()" << endl <<
-      indent() << "oprot.trans.flush()" << endl;
+    f_service_ << indent() << "result.success = success" << endl << indent()
+               << "oprot.writeMessageBegin(\"" << tfunction->get_name()
+               << "\", TMessageType.REPLY, seqid)" << endl << indent() << "result.write(oprot)"
+               << endl << indent() << "oprot.writeMessageEnd()" << endl << indent()
+               << "oprot.trans.flush()" << endl;
     indent_down();
     f_service_ << endl;
 
     // Try block for a function with exceptions
     if (!tfunction->is_oneway() && xceptions.size() > 0) {
-      indent(f_service_) <<
-        "def write_results_exception_" << tfunction->get_name() <<
-        "(self, error, result, seqid, oprot):" << endl;
+      indent(f_service_) << "def write_results_exception_" << tfunction->get_name()
+                         << "(self, error, result, seqid, oprot):" << endl;
       indent_up();
-      f_service_ <<
-        indent() << "try:" << endl;
+      f_service_ << indent() << "try:" << endl;
 
       // Kinda absurd
-      f_service_ <<
-        indent() << "  error.raiseException()" << endl;
+      f_service_ << indent() << "  error.raiseException()" << endl;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "except " << type_name((*x_iter)->get_type()) << ", " << (*x_iter)->get_name() << ":" << endl;
+        f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << ", "
+                   << (*x_iter)->get_name() << ":" << endl;
         if (!tfunction->is_oneway()) {
           indent_up();
-          f_service_ <<
-            indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
+          f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
+                     << (*x_iter)->get_name() << endl;
           indent_down();
         } else {
-          f_service_ <<
-            indent() << "pass" << endl;
+          f_service_ << indent() << "pass" << endl;
         }
       }
-      f_service_ <<
-        indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() <<
-          "\", TMessageType.REPLY, seqid)" << endl <<
-        indent() << "result.write(oprot)" << endl <<
-        indent() << "oprot.writeMessageEnd()" << endl <<
-        indent() << "oprot.trans.flush()" << endl;
+      f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
+                 << "\", TMessageType.REPLY, seqid)" << endl << indent() << "result.write(oprot)"
+                 << endl << indent() << "oprot.writeMessageEnd()" << endl << indent()
+                 << "oprot.trans.flush()" << endl;
       indent_down();
       f_service_ << endl;
     }
@@ -2005,16 +1751,14 @@ void t_py_generator::generate_process_function(t_service* tservice,
     vector<t_field*>::const_iterator f_iter;
 
     if (xceptions.size() > 0) {
-      f_service_ <<
-        indent() << "try:" << endl;
+      f_service_ << indent() << "try:" << endl;
       indent_up();
     }
     f_service_ << indent();
     if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
       f_service_ << "result.success = ";
     }
-    f_service_ <<
-      "yield gen.maybe_future(self._handler." << tfunction->get_name() << "(";
+    f_service_ << "yield gen.maybe_future(self._handler." << tfunction->get_name() << "(";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
@@ -2029,37 +1773,34 @@ void t_py_generator::generate_process_function(t_service* tservice,
     if (!tfunction->is_oneway() && xceptions.size() > 0) {
       indent_down();
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "except " << type_name((*x_iter)->get_type()) << ", " << (*x_iter)->get_name() << ":" << endl;
+        f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << ", "
+                   << (*x_iter)->get_name() << ":" << endl;
         if (!tfunction->is_oneway()) {
           indent_up();
-          f_service_ <<
-            indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
+          f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
+                     << (*x_iter)->get_name() << endl;
           indent_down();
         } else {
-          f_service_ <<
-            indent() << "pass" << endl;
+          f_service_ << indent() << "pass" << endl;
         }
       }
     }
 
     if (!tfunction->is_oneway()) {
-      f_service_ <<
-        indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() << "\", TMessageType.REPLY, seqid)" << endl <<
-        indent() << "result.write(oprot)" << endl <<
-        indent() << "oprot.writeMessageEnd()" << endl <<
-        indent() << "oprot.trans.flush()" << endl;
+      f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
+                 << "\", TMessageType.REPLY, seqid)" << endl << indent() << "result.write(oprot)"
+                 << endl << indent() << "oprot.writeMessageEnd()" << endl << indent()
+                 << "oprot.trans.flush()" << endl;
     }
 
     // Close function
     indent_down();
     f_service_ << endl;
 
-  } else {  // py
+  } else { // py
     // Try block for a function with exceptions
     if (xceptions.size() > 0) {
-      f_service_ <<
-        indent() << "try:" << endl;
+      f_service_ << indent() << "try:" << endl;
       indent_up();
     }
 
@@ -2072,8 +1813,7 @@ void t_py_generator::generate_process_function(t_service* tservice,
     if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
       f_service_ << "result.success = ";
     }
-    f_service_ <<
-      "self._handler." << tfunction->get_name() << "(";
+    f_service_ << "self._handler." << tfunction->get_name() << "(";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
@@ -2088,34 +1828,31 @@ void t_py_generator::generate_process_function(t_service* tservice,
     if (!tfunction->is_oneway() && xceptions.size() > 0) {
       indent_down();
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ <<
-          indent() << "except " << type_name((*x_iter)->get_type()) << ", " << (*x_iter)->get_name() << ":" << endl;
+        f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << ", "
+                   << (*x_iter)->get_name() << ":" << endl;
         if (!tfunction->is_oneway()) {
           indent_up();
-          f_service_ <<
-            indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
+          f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
+                     << (*x_iter)->get_name() << endl;
           indent_down();
         } else {
-          f_service_ <<
-            indent() << "pass" << endl;
+          f_service_ << indent() << "pass" << endl;
         }
       }
     }
 
     // Shortcut out here for oneway functions
     if (tfunction->is_oneway()) {
-      f_service_ <<
-        indent() << "return" << endl;
+      f_service_ << indent() << "return" << endl;
       indent_down();
       f_service_ << endl;
       return;
     }
 
-    f_service_ <<
-      indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name() << "\", TMessageType.REPLY, seqid)" << endl <<
-      indent() << "result.write(oprot)" << endl <<
-      indent() << "oprot.writeMessageEnd()" << endl <<
-      indent() << "oprot.trans.flush()" << endl;
+    f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
+               << "\", TMessageType.REPLY, seqid)" << endl << indent() << "result.write(oprot)"
+               << endl << indent() << "oprot.writeMessageEnd()" << endl << indent()
+               << "oprot.trans.flush()" << endl;
 
     // Close function
     indent_down();
@@ -2126,36 +1863,31 @@ void t_py_generator::generate_process_function(t_service* tservice,
 /**
  * Deserializes a field of any type.
  */
-void t_py_generator::generate_deserialize_field(ofstream &out,
+void t_py_generator::generate_deserialize_field(ofstream& out,
                                                 t_field* tfield,
                                                 string prefix,
                                                 bool inclass) {
-  (void) inclass;
+  (void)inclass;
   t_type* type = get_true_type(tfield->get_type());
 
   if (type->is_void()) {
-    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
-      prefix + tfield->get_name();
+    throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " + prefix + tfield->get_name();
   }
 
   string name = prefix + tfield->get_name();
 
   if (type->is_struct() || type->is_xception()) {
-    generate_deserialize_struct(out,
-                                (t_struct*)type,
-                                 name);
+    generate_deserialize_struct(out, (t_struct*)type, name);
   } else if (type->is_container()) {
     generate_deserialize_container(out, type, name);
   } else if (type->is_base_type() || type->is_enum()) {
-    indent(out) <<
-      name << " = iprot.";
+    indent(out) << name << " = iprot.";
 
     if (type->is_base_type()) {
       t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
       switch (tbase) {
       case t_base_type::TYPE_VOID:
-        throw "compiler error: cannot serialize void field in a struct: " +
-          name;
+        throw "compiler error: cannot serialize void field in a struct: " + name;
         break;
       case t_base_type::TYPE_STRING:
         if (((t_base_type*)type)->is_binary() || !gen_utf8strings_) {
@@ -2192,28 +1924,24 @@ void t_py_generator::generate_deserialize_field(ofstream &out,
 
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
-           tfield->get_name().c_str(), type->get_name().c_str());
+           tfield->get_name().c_str(),
+           type->get_name().c_str());
   }
 }
 
 /**
  * Generates an unserializer for a struct, calling read()
  */
-void t_py_generator::generate_deserialize_struct(ofstream &out,
-                                                  t_struct* tstruct,
-                                                  string prefix) {
-  out <<
-    indent() << prefix << " = " << type_name(tstruct) << "()" << endl <<
-    indent() << prefix << ".read(iprot)" << endl;
+void t_py_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
+  out << indent() << prefix << " = " << type_name(tstruct) << "()" << endl << indent() << prefix
+      << ".read(iprot)" << endl;
 }
 
 /**
  * Serialize a container by writing out the header followed by
  * data and then a footer.
  */
-void t_py_generator::generate_deserialize_container(ofstream &out,
-                                                    t_type* ttype,
-                                                    string prefix) {
+void t_py_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
   string size = tmp("_size");
   string ktype = tmp("_ktype");
   string vtype = tmp("_vtype");
@@ -2226,35 +1954,31 @@ void t_py_generator::generate_deserialize_container(ofstream &out,
 
   // Declare variables, read header
   if (ttype->is_map()) {
-    out <<
-      indent() << prefix << " = {}" << endl <<
-      indent() << "(" << ktype << ", " << vtype << ", " << size << " ) = iprot.readMapBegin()" << endl;
+    out << indent() << prefix << " = {}" << endl << indent() << "(" << ktype << ", " << vtype
+        << ", " << size << " ) = iprot.readMapBegin()" << endl;
   } else if (ttype->is_set()) {
-    out <<
-      indent() << prefix << " = set()" << endl <<
-      indent() << "(" << etype << ", " << size << ") = iprot.readSetBegin()" << endl;
+    out << indent() << prefix << " = set()" << endl << indent() << "(" << etype << ", " << size
+        << ") 

<TRUNCATED>

[27/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_gv_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_gv_generator.cc b/compiler/cpp/src/generate/t_gv_generator.cc
index a6ab53a..4511b29 100644
--- a/compiler/cpp/src/generate/t_gv_generator.cc
+++ b/compiler/cpp/src/generate/t_gv_generator.cc
@@ -38,54 +38,52 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Graphviz code generator
  */
 class t_gv_generator : public t_generator {
-  public:
-    t_gv_generator(
-        t_program* program,
-        const std::map<std::string, std::string>& parsed_options,
-        const std::string& option_string)
-      : t_generator(program)
-    {
-      (void) parsed_options;
-      (void) option_string;
-      out_dir_base_ = "gen-gv";
-
-      std::map<std::string, std::string>::const_iterator iter;
-      iter = parsed_options.find("exceptions");
-      exception_arrows = (iter != parsed_options.end());
-    }
+public:
+  t_gv_generator(t_program* program,
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
+    out_dir_base_ = "gen-gv";
+
+    std::map<std::string, std::string>::const_iterator iter;
+    iter = parsed_options.find("exceptions");
+    exception_arrows = (iter != parsed_options.end());
+  }
 
-    /**
-     * Init and end of generator
-     */
-    void init_generator();
-    void close_generator();
-
-    /**
-     * Program-level generation functions
-     */
-    void generate_typedef (t_typedef*  ttypedef);
-    void generate_enum    (t_enum*     tenum);
-    void generate_const   (t_const*    tconst);
-    void generate_struct  (t_struct*   tstruct);
-    void generate_service (t_service*  tservice);
-
-  protected:
-    /**
-     * Helpers
-     */
-    void print_type(t_type* ttype, string struct_field_ref);
-    void print_const_value(t_type* type, t_const_value* tvalue);
-
-  private:
-    std::ofstream f_out_;
-    std::list<string> edges;
-    bool exception_arrows;
+  /**
+   * Init and end of generator
+   */
+  void init_generator();
+  void close_generator();
+
+  /**
+   * Program-level generation functions
+   */
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_service(t_service* tservice);
+
+protected:
+  /**
+   * Helpers
+   */
+  void print_type(t_type* ttype, string struct_field_ref);
+  void print_const_value(t_type* type, t_const_value* tvalue);
+
+private:
+  std::ofstream f_out_;
+  std::list<string> edges;
+  bool exception_arrows;
 };
 
 /**
@@ -95,14 +93,14 @@ class t_gv_generator : public t_generator {
  * - Write the file header.
  */
 void t_gv_generator::init_generator() {
-  escape_['{']  = "\\{";
-  escape_['}']  = "\\}";
+  escape_['{'] = "\\{";
+  escape_['}'] = "\\}";
 
   // Make output directory
   MKDIR(get_out_dir().c_str());
   string fname = get_out_dir() + program_->get_name() + ".gv";
   f_out_.open(fname.c_str());
-  f_out_ << "digraph \""  << escape_string(program_name_) << "\" {" << endl;
+  f_out_ << "digraph \"" << escape_string(program_name_) << "\" {" << endl;
   f_out_ << "node [style=filled, shape=record];" << endl;
   f_out_ << "edge [arrowsize=0.5];" << endl;
   f_out_ << "rankdir=LR" << endl;
@@ -117,16 +115,16 @@ void t_gv_generator::init_generator() {
 void t_gv_generator::close_generator() {
   // Print edges
   std::list<string>::iterator iter = edges.begin();
-  for ( ; iter != edges.end(); iter++) {
+  for (; iter != edges.end(); iter++) {
     f_out_ << (*iter) << endl;
   }
 
   // Print graph end } and close file
-f_out_ << "}" << endl;
-f_out_.close();
+  f_out_ << "}" << endl;
+  f_out_.close();
 }
 
-void t_gv_generator::generate_typedef (t_typedef* ttypedef) {
+void t_gv_generator::generate_typedef(t_typedef* ttypedef) {
   string name = ttypedef->get_name();
   f_out_ << "node [fillcolor=azure];" << endl;
   f_out_ << name << " [label=\"";
@@ -138,7 +136,7 @@ void t_gv_generator::generate_typedef (t_typedef* ttypedef) {
   f_out_ << "\"];" << endl;
 }
 
-void t_gv_generator::generate_enum (t_enum* tenum) {
+void t_gv_generator::generate_enum(t_enum* tenum) {
   string name = tenum->get_name();
   f_out_ << "node [fillcolor=white];" << endl;
   f_out_ << name << " [label=\"enum " << escape_string(name);
@@ -154,7 +152,7 @@ void t_gv_generator::generate_enum (t_enum* tenum) {
   f_out_ << "\"];" << endl;
 }
 
-void t_gv_generator::generate_const (t_const* tconst) {
+void t_gv_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
 
   f_out_ << "node [fillcolor=aliceblue];" << endl;
@@ -162,14 +160,14 @@ void t_gv_generator::generate_const (t_const* tconst) {
 
   f_out_ << escape_string(name);
   f_out_ << " = ";
-  print_const_value( tconst->get_type(), tconst->get_value());
+  print_const_value(tconst->get_type(), tconst->get_value());
   f_out_ << " :: ";
   print_type(tconst->get_type(), "const_" + name);
 
   f_out_ << "\"];" << endl;
 }
 
-void t_gv_generator::generate_struct  (t_struct*   tstruct) {
+void t_gv_generator::generate_struct(t_struct* tstruct) {
   string name = tstruct->get_name();
 
   if (tstruct->is_xception()) {
@@ -188,7 +186,7 @@ void t_gv_generator::generate_struct  (t_struct*   tstruct) {
 
   vector<t_field*> members = tstruct->get_members();
   vector<t_field*>::iterator mem_iter = members.begin();
-  for ( ; mem_iter != members.end(); mem_iter++) {
+  for (; mem_iter != members.end(); mem_iter++) {
     string field_name = (*mem_iter)->get_name();
 
     // print port (anchor reference)
@@ -197,8 +195,7 @@ void t_gv_generator::generate_struct  (t_struct*   tstruct) {
     // field name :: field type
     f_out_ << (*mem_iter)->get_name();
     f_out_ << " :: ";
-    print_type((*mem_iter)->get_type(),
-        name + ":field_" + field_name);
+    print_type((*mem_iter)->get_type(), name + ":field_" + field_name);
   }
 
   f_out_ << "\"];" << endl;
@@ -235,61 +232,59 @@ void t_gv_generator::print_type(t_type* ttype, string struct_field_ref) {
 void t_gv_generator::print_const_value(t_type* type, t_const_value* tvalue) {
   bool first = true;
   switch (tvalue->get_type()) {
-    case t_const_value::CV_INTEGER:
-      f_out_ << tvalue->get_integer();
-      break;
-    case t_const_value::CV_DOUBLE:
-      f_out_ << tvalue->get_double();
-      break;
-    case t_const_value::CV_STRING:
-      f_out_ << "\\\"" <<  get_escaped_string(tvalue) << "\\\"";
-      break;
-    case t_const_value::CV_MAP:
-      {
-        f_out_ << "\\{ ";
-        map<t_const_value*, t_const_value*> map_elems = tvalue->get_map();
-        map<t_const_value*, t_const_value*>::iterator map_iter;
-        for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
-          if (!first) {
-            f_out_ << ", ";
-          }
-          first = false;
-          print_const_value( ((t_map*)type)->get_key_type(), map_iter->first);
-          f_out_ << " = ";
-          print_const_value( ((t_map*)type)->get_val_type(), map_iter->second);
-        }
-        f_out_ << " \\}";
+  case t_const_value::CV_INTEGER:
+    f_out_ << tvalue->get_integer();
+    break;
+  case t_const_value::CV_DOUBLE:
+    f_out_ << tvalue->get_double();
+    break;
+  case t_const_value::CV_STRING:
+    f_out_ << "\\\"" << get_escaped_string(tvalue) << "\\\"";
+    break;
+  case t_const_value::CV_MAP: {
+    f_out_ << "\\{ ";
+    map<t_const_value*, t_const_value*> map_elems = tvalue->get_map();
+    map<t_const_value*, t_const_value*>::iterator map_iter;
+    for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
+      if (!first) {
+        f_out_ << ", ";
+      }
+      first = false;
+      print_const_value(((t_map*)type)->get_key_type(), map_iter->first);
+      f_out_ << " = ";
+      print_const_value(((t_map*)type)->get_val_type(), map_iter->second);
+    }
+    f_out_ << " \\}";
+  } break;
+  case t_const_value::CV_LIST: {
+    f_out_ << "\\{ ";
+    vector<t_const_value*> list_elems = tvalue->get_list();
+    ;
+    vector<t_const_value*>::iterator list_iter;
+    for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
+      if (!first) {
+        f_out_ << ", ";
       }
-      break;
-    case t_const_value::CV_LIST:
-      {
-        f_out_ << "\\{ ";
-        vector<t_const_value*> list_elems = tvalue->get_list();;
-        vector<t_const_value*>::iterator list_iter;
-        for (list_iter = list_elems.begin(); list_iter != list_elems.end(); list_iter++) {
-          if (!first) {
-            f_out_ << ", ";
-          }
-          first = false;
-          if (type->is_list()) {
-            print_const_value( ((t_list*)type)->get_elem_type(), *list_iter);
-          } else {
-            print_const_value( ((t_set*)type)->get_elem_type(), *list_iter);
-          }
-        }
-        f_out_ << " \\}";
+      first = false;
+      if (type->is_list()) {
+        print_const_value(((t_list*)type)->get_elem_type(), *list_iter);
+      } else {
+        print_const_value(((t_set*)type)->get_elem_type(), *list_iter);
       }
-      break;
-    case t_const_value::CV_IDENTIFIER:
-      f_out_ << escape_string(type->get_name()) << "." << escape_string(tvalue->get_identifier_name());
-      break;
-    default:
-      f_out_ << "UNKNOWN";
-      break;
+    }
+    f_out_ << " \\}";
+  } break;
+  case t_const_value::CV_IDENTIFIER:
+    f_out_ << escape_string(type->get_name()) << "."
+           << escape_string(tvalue->get_identifier_name());
+    break;
+  default:
+    f_out_ << "UNKNOWN";
+    break;
   }
 }
 
-void t_gv_generator::generate_service (t_service*  tservice) {
+void t_gv_generator::generate_service(t_service* tservice) {
   string service_name = get_service_name(tservice);
   f_out_ << "subgraph cluster_" << service_name << " {" << endl;
   f_out_ << "node [fillcolor=bisque];" << endl;
@@ -300,7 +295,7 @@ void t_gv_generator::generate_service (t_service*  tservice) {
 
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator fn_iter = functions.begin();
-  for ( ; fn_iter != functions.end(); fn_iter++) {
+  for (; fn_iter != functions.end(); fn_iter++) {
     string fn_name = (*fn_iter)->get_name();
 
     f_out_ << "function_" << fn_name;
@@ -310,7 +305,7 @@ void t_gv_generator::generate_service (t_service*  tservice) {
 
     vector<t_field*> args = (*fn_iter)->get_arglist()->get_members();
     vector<t_field*>::iterator arg_iter = args.begin();
-    for ( ; arg_iter != args.end(); arg_iter++) {
+    for (; arg_iter != args.end(); arg_iter++) {
       f_out_ << "|<param_" << (*arg_iter)->get_name() << ">";
       f_out_ << (*arg_iter)->get_name();
       if ((*arg_iter)->get_value() != NULL) {
@@ -319,8 +314,7 @@ void t_gv_generator::generate_service (t_service*  tservice) {
       }
       f_out_ << " :: ";
       print_type((*arg_iter)->get_type(),
-          "function_" + fn_name + ":param_" + (*arg_iter)->get_name());
-
+                 "function_" + fn_name + ":param_" + (*arg_iter)->get_name());
     }
     // end of node
     f_out_ << "\"];" << endl;
@@ -329,9 +323,9 @@ void t_gv_generator::generate_service (t_service*  tservice) {
     if (exception_arrows) {
       vector<t_field*> excepts = (*fn_iter)->get_xceptions()->get_members();
       vector<t_field*>::iterator ex_iter = excepts.begin();
-      for ( ; ex_iter != excepts.end(); ex_iter++) {
-        edges.push_back("function_" + fn_name + " -> " +
-            (*ex_iter)->get_type()->get_name() + " [color=red]");
+      for (; ex_iter != excepts.end(); ex_iter++) {
+        edges.push_back("function_" + fn_name + " -> " + (*ex_iter)->get_type()->get_name()
+                        + " [color=red]");
       }
     }
   }
@@ -339,7 +333,7 @@ void t_gv_generator::generate_service (t_service*  tservice) {
   f_out_ << " }" << endl;
 }
 
-THRIFT_REGISTER_GENERATOR(gv, "Graphviz",
-    "    exceptions:      Whether to draw arrows from functions to exception.\n"
-    )
-
+THRIFT_REGISTER_GENERATOR(
+    gv,
+    "Graphviz",
+    "    exceptions:      Whether to draw arrows from functions to exception.\n")


[28/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_go_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc
index adc4221..7610da4 100644
--- a/compiler/cpp/src/generate/t_go_generator.cc
+++ b/compiler/cpp/src/generate/t_go_generator.cc
@@ -46,7 +46,7 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * A helper for automatically formatting the emitted Go code from the Thrift
@@ -57,7 +57,7 @@ static const string endl = "\n";  // avoid ostream << std::endl flushes
  *  - false, if the formatting process failed, which means the basic output was
  *           still generated.
  */
-bool format_go_output(const string &file_path);
+bool format_go_output(const string& file_path);
 
 const string default_thrift_import = "git.apache.org/thrift.git/lib/go/thrift";
 static std::string package_flag;
@@ -65,646 +65,634 @@ static std::string package_flag;
 /**
  * Go code generator.
  */
-class t_go_generator : public t_generator
-{
+class t_go_generator : public t_generator {
 public:
-    t_go_generator(
-        t_program* program,
-        const std::map<std::string, std::string>& parsed_options,
-        const std::string& option_string)
-        : t_generator(program) {
-    	(void) option_string;
-    	std::map<std::string, std::string>::const_iterator iter;
-        out_dir_base_ = "gen-go";
-        gen_thrift_import_ = default_thrift_import;
-
-        iter = parsed_options.find("package_prefix");
-
-        if (iter != parsed_options.end()) {
-            gen_package_prefix_ = (iter->second);
-        }
-
-        iter = parsed_options.find("thrift_import");
-
-        if (iter != parsed_options.end()) {
-            gen_thrift_import_ = (iter->second);
-        }
-
-        iter = parsed_options.find("package");
-
-        if (iter != parsed_options.end()) {
-        	package_flag = (iter->second);
-        }
-    }
-
-    /**
-     * Init and close methods
-     */
-
-    void init_generator();
-    void close_generator();
-
-    /**
-     * Program-level generation functions
-     */
-
-    void generate_typedef(t_typedef*  ttypedef);
-    void generate_enum(t_enum*     tenum);
-    void generate_const(t_const*    tconst);
-    void generate_struct(t_struct*   tstruct);
-    void generate_xception(t_struct*   txception);
-    void generate_service(t_service*  tservice);
-
-    std::string render_const_value(t_type* type, t_const_value* value, const string& name);
-
-    /**
-     * Struct generation code
-     */
-
-    void generate_go_struct(t_struct* tstruct, bool is_exception);
-    void generate_go_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception = false, bool is_result = false, bool is_args = false);
-    void generate_go_struct_initializer(std::ofstream& out, t_struct* tstruct, bool is_args_or_result = false);
-    void generate_isset_helpers(std::ofstream& out, t_struct* tstruct, const string& tstruct_name, bool is_result = false);
-    void generate_go_struct_reader(std::ofstream& out, t_struct* tstruct, const string& tstruct_name, bool is_result = false);
-    void generate_go_struct_writer(std::ofstream& out, t_struct* tstruct, const string& tstruct_name, bool is_result = false);
-    void generate_go_function_helpers(t_function* tfunction);
-    void get_publicized_name_and_def_value(t_field* tfield,
-                                           string* OUT_pub_name,
-                                           t_const_value** OUT_def_value) const;
-
-    /**
-     * Service-level generation functions
-     */
-
-    void generate_service_helpers(t_service*  tservice);
-    void generate_service_interface(t_service* tservice);
-    void generate_service_client(t_service* tservice);
-    void generate_service_remote(t_service* tservice);
-    void generate_service_server(t_service* tservice);
-    void generate_process_function(t_service* tservice, t_function* tfunction);
-
-    /**
-     * Serialization constructs
-     */
-
-    void generate_deserialize_field(std::ofstream &out,
-                                    t_field*    tfield,
-                                    bool        declare,
-                                    std::string prefix = "",
-                                    bool inclass = false,
-                                    bool coerceData = false,
-                                    bool inkey = false,
-                                    bool in_container = false);
-
-    void generate_deserialize_struct(std::ofstream &out,
-                                     t_struct*   tstruct,
-                                     bool        is_pointer_field,
-                                     bool        declare,
-                                     std::string prefix = "");
-
-    void generate_deserialize_container(std::ofstream &out,
-                                        t_type*       ttype,
-                                        bool          pointer_field,
-                                        bool          declare,
-                                        std::string   prefix = "");
-
-    void generate_deserialize_set_element(std::ofstream &out,
-                                          t_set*      tset,
-                                          bool        declare,
-                                          std::string prefix = "");
-
-    void generate_deserialize_map_element(std::ofstream &out,
-                                          t_map*      tmap,
-                                          bool        declare,
-                                          std::string prefix = "");
-
-    void generate_deserialize_list_element(std::ofstream &out,
-                                           t_list*     tlist,
-                                           bool        declare,
-                                           std::string prefix = "");
-
-    void generate_serialize_field(std::ofstream &out,
-                                  t_field*    tfield,
+  t_go_generator(t_program* program,
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_generator(program) {
+    (void)option_string;
+    std::map<std::string, std::string>::const_iterator iter;
+    out_dir_base_ = "gen-go";
+    gen_thrift_import_ = default_thrift_import;
+
+    iter = parsed_options.find("package_prefix");
+
+    if (iter != parsed_options.end()) {
+      gen_package_prefix_ = (iter->second);
+    }
+
+    iter = parsed_options.find("thrift_import");
+
+    if (iter != parsed_options.end()) {
+      gen_thrift_import_ = (iter->second);
+    }
+
+    iter = parsed_options.find("package");
+
+    if (iter != parsed_options.end()) {
+      package_flag = (iter->second);
+    }
+  }
+
+  /**
+   * Init and close methods
+   */
+
+  void init_generator();
+  void close_generator();
+
+  /**
+   * Program-level generation functions
+   */
+
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  std::string render_const_value(t_type* type, t_const_value* value, const string& name);
+
+  /**
+   * Struct generation code
+   */
+
+  void generate_go_struct(t_struct* tstruct, bool is_exception);
+  void generate_go_struct_definition(std::ofstream& out,
+                                     t_struct* tstruct,
+                                     bool is_xception = false,
+                                     bool is_result = false,
+                                     bool is_args = false);
+  void generate_go_struct_initializer(std::ofstream& out,
+                                      t_struct* tstruct,
+                                      bool is_args_or_result = false);
+  void generate_isset_helpers(std::ofstream& out,
+                              t_struct* tstruct,
+                              const string& tstruct_name,
+                              bool is_result = false);
+  void generate_go_struct_reader(std::ofstream& out,
+                                 t_struct* tstruct,
+                                 const string& tstruct_name,
+                                 bool is_result = false);
+  void generate_go_struct_writer(std::ofstream& out,
+                                 t_struct* tstruct,
+                                 const string& tstruct_name,
+                                 bool is_result = false);
+  void generate_go_function_helpers(t_function* tfunction);
+  void get_publicized_name_and_def_value(t_field* tfield,
+                                         string* OUT_pub_name,
+                                         t_const_value** OUT_def_value) const;
+
+  /**
+   * Service-level generation functions
+   */
+
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_remote(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
+
+  /**
+   * Serialization constructs
+   */
+
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  bool declare,
                                   std::string prefix = "",
-                                  bool inkey = false);
-
-    void generate_serialize_struct(std::ofstream &out,
-                                   t_struct*   tstruct,
+                                  bool inclass = false,
+                                  bool coerceData = false,
+                                  bool inkey = false,
+                                  bool in_container = false);
+
+  void generate_deserialize_struct(std::ofstream& out,
+                                   t_struct* tstruct,
+                                   bool is_pointer_field,
+                                   bool declare,
                                    std::string prefix = "");
 
-    void generate_serialize_container(std::ofstream &out,
-                                      t_type*       ttype,
-                                      bool          pointer_field,
-                                      std::string   prefix = "");
-
-    void generate_serialize_map_element(std::ofstream &out,
-                                        t_map*      tmap,
-                                        std::string kiter,
-                                        std::string viter);
-
-    void generate_serialize_set_element(std::ofstream &out,
-                                        t_set*      tmap,
-                                        std::string iter);
-
-    void generate_serialize_list_element(std::ofstream &out,
-                                         t_list*     tlist,
-                                         std::string iter);
-
-    void generate_go_docstring(std::ofstream& out,
-                               t_struct* tstruct);
-
-    void generate_go_docstring(std::ofstream& out,
-                               t_function* tfunction);
-
-    void generate_go_docstring(std::ofstream& out,
-                               t_doc*    tdoc,
-                               t_struct* tstruct,
-                               const char* subheader);
-
-    void generate_go_docstring(std::ofstream& out,
-                               t_doc* tdoc);
-
-    /**
-     * Helper rendering functions
-     */
-
-    std::string go_autogen_comment();
-    std::string go_package();
-    std::string go_imports_begin();
-    std::string go_imports_end();
-    std::string render_includes();
-    std::string render_import_protection();
-    std::string render_fastbinary_includes();
-    std::string declare_argument(t_field* tfield);
-    std::string render_field_initial_value(t_field* tfield,
-                                           const string& name,
-                                           bool optional_field);
-    std::string type_name(t_type* ttype);
-    std::string function_signature(t_function* tfunction, std::string prefix = "");
-    std::string function_signature_if(t_function* tfunction, std::string prefix = "", bool addError = false);
-    std::string argument_list(t_struct* tstruct);
-    std::string type_to_enum(t_type* ttype);
-    std::string type_to_go_type(t_type* ttype, bool is_container_value = false);
-    std::string type_to_go_type_with_opt(t_type* ttype, bool optional_field, bool is_container_value = false);
-    std::string type_to_go_key_type(t_type* ttype);
-    std::string type_to_spec_args(t_type* ttype);
-
-    static std::string get_real_go_module(const t_program* program) {
-
-    	if (!package_flag.empty()) {
-            return package_flag;
-        }
-        std::string real_module = program->get_namespace("go");
-        if (!real_module.empty()) {
-        	return real_module;
-        }
+  void generate_deserialize_container(std::ofstream& out,
+                                      t_type* ttype,
+                                      bool pointer_field,
+                                      bool declare,
+                                      std::string prefix = "");
+
+  void generate_deserialize_set_element(std::ofstream& out,
+                                        t_set* tset,
+                                        bool declare,
+                                        std::string prefix = "");
+
+  void generate_deserialize_map_element(std::ofstream& out,
+                                        t_map* tmap,
+                                        bool declare,
+                                        std::string prefix = "");
+
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         bool declare,
+                                         std::string prefix = "");
+
+  void generate_serialize_field(std::ofstream& out,
+                                t_field* tfield,
+                                std::string prefix = "",
+                                bool inkey = false);
+
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+
+  void generate_serialize_container(std::ofstream& out,
+                                    t_type* ttype,
+                                    bool pointer_field,
+                                    std::string prefix = "");
+
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
+
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
+
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
+
+  void generate_go_docstring(std::ofstream& out, t_struct* tstruct);
+
+  void generate_go_docstring(std::ofstream& out, t_function* tfunction);
+
+  void generate_go_docstring(std::ofstream& out,
+                             t_doc* tdoc,
+                             t_struct* tstruct,
+                             const char* subheader);
+
+  void generate_go_docstring(std::ofstream& out, t_doc* tdoc);
+
+  /**
+   * Helper rendering functions
+   */
+
+  std::string go_autogen_comment();
+  std::string go_package();
+  std::string go_imports_begin();
+  std::string go_imports_end();
+  std::string render_includes();
+  std::string render_import_protection();
+  std::string render_fastbinary_includes();
+  std::string declare_argument(t_field* tfield);
+  std::string render_field_initial_value(t_field* tfield, const string& name, bool optional_field);
+  std::string type_name(t_type* ttype);
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string function_signature_if(t_function* tfunction,
+                                    std::string prefix = "",
+                                    bool addError = false);
+  std::string argument_list(t_struct* tstruct);
+  std::string type_to_enum(t_type* ttype);
+  std::string type_to_go_type(t_type* ttype, bool is_container_value = false);
+  std::string type_to_go_type_with_opt(t_type* ttype,
+                                       bool optional_field,
+                                       bool is_container_value = false);
+  std::string type_to_go_key_type(t_type* ttype);
+  std::string type_to_spec_args(t_type* ttype);
 
-        return lowercase(program->get_name());
+  static std::string get_real_go_module(const t_program* program) {
+
+    if (!package_flag.empty()) {
+      return package_flag;
+    }
+    std::string real_module = program->get_namespace("go");
+    if (!real_module.empty()) {
+      return real_module;
     }
 
-private:
+    return lowercase(program->get_name());
+  }
 
-    std::string gen_package_prefix_;
-    std::string gen_thrift_import_;
-
-    /**
-     * File streams
-     */
-
-    std::ofstream f_types_;
-    std::string f_types_name_;
-    std::ofstream f_consts_;
-    std::string f_consts_name_;
-    std::stringstream f_const_values_;
-    std::ofstream f_service_;
-
-    std::string package_name_;
-    std::string package_dir_;
-
-    static std::string publicize(const std::string& value, bool is_args_or_result = false);
-    static std::string new_prefix(const std::string& value);
-    static std::string privatize(const std::string& value);
-    static std::string variable_name_to_go_name(const std::string& value);
-    static bool is_pointer_field(t_field* tfield, bool in_container = false);
-    static bool omit_initialization(t_field* tfield);
+private:
+  std::string gen_package_prefix_;
+  std::string gen_thrift_import_;
+
+  /**
+   * File streams
+   */
+
+  std::ofstream f_types_;
+  std::string f_types_name_;
+  std::ofstream f_consts_;
+  std::string f_consts_name_;
+  std::stringstream f_const_values_;
+  std::ofstream f_service_;
+
+  std::string package_name_;
+  std::string package_dir_;
+
+  static std::string publicize(const std::string& value, bool is_args_or_result = false);
+  static std::string new_prefix(const std::string& value);
+  static std::string privatize(const std::string& value);
+  static std::string variable_name_to_go_name(const std::string& value);
+  static bool is_pointer_field(t_field* tfield, bool in_container = false);
+  static bool omit_initialization(t_field* tfield);
 };
 
-//returns true if field initialization can be omitted since it has corresponding go type zero value
-//or default value is not set
+// returns true if field initialization can be omitted since it has corresponding go type zero value
+// or default value is not set
 bool t_go_generator::omit_initialization(t_field* tfield) {
-	t_const_value* value = tfield->get_value();
-	if (!value) {
-		return true;
-	}
-	t_type* type = tfield->get_type()->get_true_type();
-    if (type->is_base_type()) {
-        t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
-
-        switch (tbase) {
-        case t_base_type::TYPE_VOID:
-            throw "";
-
-        case t_base_type::TYPE_STRING:
-            if (((t_base_type*)type)->is_binary()) {
-            	//[]byte are always inline
-                return false;
-            }
-            //strings are pointers if has no default
-            return value->get_string().empty();
-
-        case t_base_type::TYPE_BOOL:
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-            return value->get_integer()==0;
-        case t_base_type::TYPE_DOUBLE:
-            if (value->get_type() == t_const_value::CV_INTEGER) {
-                return value->get_integer()==0;
-            } else {
-                return value->get_double()==0.;
-            }
-        }
-    }
-	return false;
+  t_const_value* value = tfield->get_value();
+  if (!value) {
+    return true;
+  }
+  t_type* type = tfield->get_type()->get_true_type();
+  if (type->is_base_type()) {
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+
+    switch (tbase) {
+    case t_base_type::TYPE_VOID:
+      throw "";
+
+    case t_base_type::TYPE_STRING:
+      if (((t_base_type*)type)->is_binary()) {
+        //[]byte are always inline
+        return false;
+      }
+      // strings are pointers if has no default
+      return value->get_string().empty();
+
+    case t_base_type::TYPE_BOOL:
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      return value->get_integer() == 0;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        return value->get_integer() == 0;
+      } else {
+        return value->get_double() == 0.;
+      }
+    }
+  }
+  return false;
+}
+
+// Returns true if the type need a reference if used as optional without default
+static bool type_need_reference(t_type* type) {
+  type = type->get_true_type();
+  if (type->is_map() || type->is_set() || type->is_list() || type->is_struct()
+      || type->is_xception() || (type->is_string() && ((t_base_type*)type)->is_binary())) {
+    return false;
+  }
+  return true;
 }
 
-//Returns true if the type need a reference if used as optional without default
-static bool type_need_reference(t_type* type) {
-	type = type->get_true_type();
-	if( type->is_map()
-	 || type->is_set()
-	 || type->is_list()
-	 || type->is_struct()
-	 || type->is_xception()
-	 || (type->is_string() && ((t_base_type*)type)->is_binary() )) {
-		return false;
-	}
-	return true;
-}
-
-//returns false if field could not use comparison to default value as !IsSet*
+// returns false if field could not use comparison to default value as !IsSet*
 bool t_go_generator::is_pointer_field(t_field* tfield, bool in_container_value) {
-	(void) in_container_value;
-	if (tfield->annotations_.count("cpp.ref")!=0) {
-		return true;
-	}
-	t_type* type = tfield->get_type()->get_true_type();
-	//Structs in containers are pointers
-	if (type->is_struct() || type->is_xception()) {
-		return true;
-	}
-	if (!(tfield->get_req() == t_field::T_OPTIONAL)) {
-		return false;
-	}
-
-	bool has_default = tfield->get_value();
-    if (type->is_base_type()) {
-        t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
-
-        switch (tbase) {
-        case t_base_type::TYPE_VOID:
-            throw "";
-
-        case t_base_type::TYPE_STRING:
-            if (((t_base_type*)type)->is_binary()) {
-            	//[]byte are always inline
-                return false;
-            }
-            //strings are pointers if has no default
-            return !has_default;
-
-        case t_base_type::TYPE_BOOL:
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-        case t_base_type::TYPE_DOUBLE:
-            return !has_default;
-        }
-    } else if (type->is_enum()) {
-        return !has_default;
-    } else if (type->is_struct() || type->is_xception()) {
-    	return true;
-    } else if (type->is_map()) {
-    	return has_default;
-    } else if (type->is_set()) {
-    	return has_default;
-    } else if (type->is_list()) {
-		return has_default;
-    } else if (type->is_typedef()) {
-		return has_default;
-    }
-
-    throw "INVALID TYPE IN type_to_go_type: " + type->get_name();
+  (void)in_container_value;
+  if (tfield->annotations_.count("cpp.ref") != 0) {
+    return true;
+  }
+  t_type* type = tfield->get_type()->get_true_type();
+  // Structs in containers are pointers
+  if (type->is_struct() || type->is_xception()) {
+    return true;
+  }
+  if (!(tfield->get_req() == t_field::T_OPTIONAL)) {
+    return false;
+  }
+
+  bool has_default = tfield->get_value();
+  if (type->is_base_type()) {
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+
+    switch (tbase) {
+    case t_base_type::TYPE_VOID:
+      throw "";
+
+    case t_base_type::TYPE_STRING:
+      if (((t_base_type*)type)->is_binary()) {
+        //[]byte are always inline
+        return false;
+      }
+      // strings are pointers if has no default
+      return !has_default;
+
+    case t_base_type::TYPE_BOOL:
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+    case t_base_type::TYPE_DOUBLE:
+      return !has_default;
+    }
+  } else if (type->is_enum()) {
+    return !has_default;
+  } else if (type->is_struct() || type->is_xception()) {
+    return true;
+  } else if (type->is_map()) {
+    return has_default;
+  } else if (type->is_set()) {
+    return has_default;
+  } else if (type->is_list()) {
+    return has_default;
+  } else if (type->is_typedef()) {
+    return has_default;
+  }
+
+  throw "INVALID TYPE IN type_to_go_type: " + type->get_name();
 }
 
-std::string t_go_generator::publicize(const std::string& value, bool is_args_or_result)
-{
-    if (value.size() <= 0) {
-        return value;
-    }
+std::string t_go_generator::publicize(const std::string& value, bool is_args_or_result) {
+  if (value.size() <= 0) {
+    return value;
+  }
 
-    std::string value2(value), prefix;
+  std::string value2(value), prefix;
 
-    string::size_type dot_pos = value.rfind('.');
-    if (dot_pos != string::npos) {
-      prefix = value.substr(0, dot_pos + 1) + prefix;
-      value2 = value.substr(dot_pos + 1);
-    }
+  string::size_type dot_pos = value.rfind('.');
+  if (dot_pos != string::npos) {
+    prefix = value.substr(0, dot_pos + 1) + prefix;
+    value2 = value.substr(dot_pos + 1);
+  }
 
-    if (!isupper(value2[0])) {
-        value2[0] = toupper(value2[0]);
-    }
+  if (!isupper(value2[0])) {
+    value2[0] = toupper(value2[0]);
+  }
 
-    // as long as we are changing things, let's change _ followed by lowercase to capital
-    for (string::size_type i = 1; i < value2.size() - 1; ++i) {
-        if (value2[i] == '_' && islower(value2[i + 1])) {
-            value2.replace(i, 2, 1, toupper(value2[i + 1]));
-        }
+  // as long as we are changing things, let's change _ followed by lowercase to capital
+  for (string::size_type i = 1; i < value2.size() - 1; ++i) {
+    if (value2[i] == '_' && islower(value2[i + 1])) {
+      value2.replace(i, 2, 1, toupper(value2[i + 1]));
     }
+  }
 
-    // final length before further checks, the string may become longer
-    size_t len_before = value2.length();
+  // final length before further checks, the string may become longer
+  size_t len_before = value2.length();
 
-    // IDL identifiers may start with "New" which interferes with the CTOR pattern
-    // Adding an extra underscore to all those identifiers solves this
-    if( (len_before >= 3) && (value2.substr(0,3) == "New")) {
-        value2 += '_';
-    }
+  // IDL identifiers may start with "New" which interferes with the CTOR pattern
+  // Adding an extra underscore to all those identifiers solves this
+  if ((len_before >= 3) && (value2.substr(0, 3) == "New")) {
+    value2 += '_';
+  }
 
-    // IDL identifiers may end with "Args"/"Result" which interferes with the implicit service function structs
-    // Adding another extra underscore to all those identifiers solves this
-    // Suppress this check for the actual helper struct names
-    if(!is_args_or_result) {
-        bool ends_with_args = (len_before >= 4) && (value2.substr(len_before-4,4) == "Args");
-        bool ends_with_rslt = (len_before >= 6) && (value2.substr(len_before-6,6) == "Result");
-        if( ends_with_args || ends_with_rslt) {
-            value2 += '_';
-        }
+  // IDL identifiers may end with "Args"/"Result" which interferes with the implicit service
+  // function structs
+  // Adding another extra underscore to all those identifiers solves this
+  // Suppress this check for the actual helper struct names
+  if (!is_args_or_result) {
+    bool ends_with_args = (len_before >= 4) && (value2.substr(len_before - 4, 4) == "Args");
+    bool ends_with_rslt = (len_before >= 6) && (value2.substr(len_before - 6, 6) == "Result");
+    if (ends_with_args || ends_with_rslt) {
+      value2 += '_';
     }
+  }
 
-    return prefix + value2;
+  return prefix + value2;
 }
 
-std::string t_go_generator::new_prefix(const std::string& value)
-{
-    if (value.size() <= 0) {
-        return value;
-    }
+std::string t_go_generator::new_prefix(const std::string& value) {
+  if (value.size() <= 0) {
+    return value;
+  }
 
-    string::size_type dot_pos = value.rfind('.');
-    if (dot_pos != string::npos) {
-      return value.substr(0, dot_pos + 1) + "New" + publicize(value.substr(dot_pos + 1));
-    }
-    return "New" + publicize(value);
+  string::size_type dot_pos = value.rfind('.');
+  if (dot_pos != string::npos) {
+    return value.substr(0, dot_pos + 1) + "New" + publicize(value.substr(dot_pos + 1));
+  }
+  return "New" + publicize(value);
 }
 
-std::string t_go_generator::privatize(const std::string& value)
-{
-    if (value.size() <= 0) {
-        return value;
-    }
+std::string t_go_generator::privatize(const std::string& value) {
+  if (value.size() <= 0) {
+    return value;
+  }
 
-    std::string value2(value);
+  std::string value2(value);
 
-    if (!islower(value2[0])) {
-        value2[0] = tolower(value2[0]);
-    }
+  if (!islower(value2[0])) {
+    value2[0] = tolower(value2[0]);
+  }
 
-    // as long as we are changing things, let's change _ followed by lowercase to capital
-    for (string::size_type i = 1; i < value2.size() - 1; ++i) {
-        if (value2[i] == '_' && isalpha(value2[i + 1])) {
-            value2.replace(i, 2, 1, toupper(value2[i + 1]));
-        }
+  // as long as we are changing things, let's change _ followed by lowercase to capital
+  for (string::size_type i = 1; i < value2.size() - 1; ++i) {
+    if (value2[i] == '_' && isalpha(value2[i + 1])) {
+      value2.replace(i, 2, 1, toupper(value2[i + 1]));
     }
+  }
 
-    return value2;
+  return value2;
 }
 
-std::string t_go_generator::variable_name_to_go_name(const std::string& value)
-{
-    if (value.size() <= 0) {
-        return value;
-    }
+std::string t_go_generator::variable_name_to_go_name(const std::string& value) {
+  if (value.size() <= 0) {
+    return value;
+  }
 
-    std::string value2(value);
-    std::transform(value2.begin(), value2.end(), value2.begin(), ::tolower);
+  std::string value2(value);
+  std::transform(value2.begin(), value2.end(), value2.begin(), ::tolower);
 
-    switch (value[0]) {
-    case 'b':
-    case 'B':
-        if (value2 != "break") {
-            return value;
-        }
+  switch (value[0]) {
+  case 'b':
+  case 'B':
+    if (value2 != "break") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'c':
-    case 'C':
-        if (value2 != "case" && value2 != "chan" && value2 != "const" && value2 != "continue") {
-            return value;
-        }
+  case 'c':
+  case 'C':
+    if (value2 != "case" && value2 != "chan" && value2 != "const" && value2 != "continue") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'd':
-    case 'D':
-        if (value2 != "default" && value2 != "defer") {
-            return value;
-        }
+  case 'd':
+  case 'D':
+    if (value2 != "default" && value2 != "defer") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'e':
-    case 'E':
-        if (value2 != "else" && value2 != "error") {
-            return value;
-        }
+  case 'e':
+  case 'E':
+    if (value2 != "else" && value2 != "error") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'f':
-    case 'F':
-        if (value2 != "fallthrough" && value2 != "for" && value2 != "func") {
-            return value;
-        }
+  case 'f':
+  case 'F':
+    if (value2 != "fallthrough" && value2 != "for" && value2 != "func") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'g':
-    case 'G':
-        if (value2 != "go" && value2 != "goto") {
-            return value;
-        }
+  case 'g':
+  case 'G':
+    if (value2 != "go" && value2 != "goto") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'i':
-    case 'I':
-        if (value2 != "if" && value2 != "import" && value2 != "interface") {
-            return value;
-        }
+  case 'i':
+  case 'I':
+    if (value2 != "if" && value2 != "import" && value2 != "interface") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'm':
-    case 'M':
-        if (value2 != "map") {
-            return value;
-        }
+  case 'm':
+  case 'M':
+    if (value2 != "map") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'p':
-    case 'P':
-        if (value2 != "package") {
-            return value;
-        }
+  case 'p':
+  case 'P':
+    if (value2 != "package") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'r':
-    case 'R':
-        if (value2 != "range" && value2 != "return") {
-            return value;
-        }
+  case 'r':
+  case 'R':
+    if (value2 != "range" && value2 != "return") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 's':
-    case 'S':
-        if (value2 != "select" && value2 != "struct" && value2 != "switch") {
-            return value;
-        }
+  case 's':
+  case 'S':
+    if (value2 != "select" && value2 != "struct" && value2 != "switch") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 't':
-    case 'T':
-        if (value2 != "type") {
-            return value;
-        }
+  case 't':
+  case 'T':
+    if (value2 != "type") {
+      return value;
+    }
 
-        break;
+    break;
 
-    case 'v':
-    case 'V':
-        if (value2 != "var") {
-            return value;
-        }
+  case 'v':
+  case 'V':
+    if (value2 != "var") {
+      return value;
+    }
 
-        break;
+    break;
 
-    default:
-        return value;
-    }
+  default:
+    return value;
+  }
 
-    return value2 + "_a1";
+  return value2 + "_a1";
 }
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
  *
  * @param tprogram The program to generate
  */
-void t_go_generator::init_generator()
-{
-    // Make output directory
-    string module = get_real_go_module(program_);
-    string target = module;
-    package_dir_ = get_out_dir();
-
-    while (true) {
-        // TODO: Do better error checking here.
-        MKDIR(package_dir_.c_str());
-
-        if (module.empty()) {
-            break;
-        }
+void t_go_generator::init_generator() {
+  // Make output directory
+  string module = get_real_go_module(program_);
+  string target = module;
+  package_dir_ = get_out_dir();
 
-        string::size_type pos = module.find('.');
+  while (true) {
+    // TODO: Do better error checking here.
+    MKDIR(package_dir_.c_str());
 
-        if (pos == string::npos) {
-            package_dir_ += "/";
-            package_dir_ += module;
-            package_name_ = module;
-            module.clear();
-        } else {
-            package_dir_ += "/";
-            package_dir_ += module.substr(0, pos);
-            module.erase(0, pos + 1);
-        }
+    if (module.empty()) {
+      break;
     }
 
-    string::size_type loc;
+    string::size_type pos = module.find('.');
 
-    while ((loc = target.find(".")) != string::npos) {
-        target.replace(loc, 1, 1, '/');
+    if (pos == string::npos) {
+      package_dir_ += "/";
+      package_dir_ += module;
+      package_name_ = module;
+      module.clear();
+    } else {
+      package_dir_ += "/";
+      package_dir_ += module.substr(0, pos);
+      module.erase(0, pos + 1);
     }
+  }
 
-    // Make output files
-    f_types_name_ = package_dir_ + "/" + "ttypes.go";
-    f_types_.open(f_types_name_.c_str());
+  string::size_type loc;
 
-    f_consts_name_ = package_dir_ + "/" + "constants.go";
-    f_consts_.open(f_consts_name_.c_str());
+  while ((loc = target.find(".")) != string::npos) {
+    target.replace(loc, 1, 1, '/');
+  }
 
-    vector<t_service*> services = program_->get_services();
-    vector<t_service*>::iterator sv_iter;
+  // Make output files
+  f_types_name_ = package_dir_ + "/" + "ttypes.go";
+  f_types_.open(f_types_name_.c_str());
 
-    for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
-        string service_dir = package_dir_ + "/" + underscore((*sv_iter)->get_name()) + "-remote";
-        MKDIR(service_dir.c_str());
-    }
+  f_consts_name_ = package_dir_ + "/" + "constants.go";
+  f_consts_.open(f_consts_name_.c_str());
+
+  vector<t_service*> services = program_->get_services();
+  vector<t_service*>::iterator sv_iter;
 
-    // Print header
-    f_types_ <<
-             go_autogen_comment() <<
-             go_package() <<
-             render_includes() <<
-             render_import_protection();
+  for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
+    string service_dir = package_dir_ + "/" + underscore((*sv_iter)->get_name()) + "-remote";
+    MKDIR(service_dir.c_str());
+  }
 
-    f_consts_ <<
-              go_autogen_comment() <<
-              go_package() <<
-              render_includes();
+  // Print header
+  f_types_ << go_autogen_comment() << go_package() << render_includes()
+           << render_import_protection();
 
-    f_const_values_ << endl << "func init() {" << endl;
+  f_consts_ << go_autogen_comment() << go_package() << render_includes();
 
+  f_const_values_ << endl << "func init() {" << endl;
 }
 
 /**
  * Renders all the imports necessary for including another Thrift program
  */
-string t_go_generator::render_includes()
-{
-    const vector<t_program*>& includes = program_->get_includes();
-    string result = "";
-    string unused_prot = "";
-
-    for (size_t i = 0; i < includes.size(); ++i) {
-        string go_module = get_real_go_module(includes[i]);
-        size_t found = 0;
-        for (size_t j = 0; j < go_module.size(); j++) {
-            // Import statement uses slashes ('/') in namespace
-            if (go_module[j] == '.') {
-                go_module[j] = '/';
-                found = j + 1;
-            }
-        }
+string t_go_generator::render_includes() {
+  const vector<t_program*>& includes = program_->get_includes();
+  string result = "";
+  string unused_prot = "";
 
-        result += "\t\"" + gen_package_prefix_ + go_module + "\"\n";
-        unused_prot += "var _ = " + go_module.substr(found) + ".GoUnusedProtection__\n";
+  for (size_t i = 0; i < includes.size(); ++i) {
+    string go_module = get_real_go_module(includes[i]);
+    size_t found = 0;
+    for (size_t j = 0; j < go_module.size(); j++) {
+      // Import statement uses slashes ('/') in namespace
+      if (go_module[j] == '.') {
+        go_module[j] = '/';
+        found = j + 1;
+      }
     }
 
-    if (includes.size() > 0) {
-        result += "\n";
-    }
+    result += "\t\"" + gen_package_prefix_ + go_module + "\"\n";
+    unused_prot += "var _ = " + go_module.substr(found) + ".GoUnusedProtection__\n";
+  }
 
-    return go_imports_begin() + result + go_imports_end() + unused_prot;
+  if (includes.size() > 0) {
+    result += "\n";
+  }
+
+  return go_imports_begin() + result + go_imports_end() + unused_prot;
 }
 
 string t_go_generator::render_import_protection() {
@@ -714,17 +702,15 @@ string t_go_generator::render_import_protection() {
 /**
  * Renders all the imports necessary to use the accelerated TBinaryProtocol
  */
-string t_go_generator::render_fastbinary_includes()
-{
-    return "";
+string t_go_generator::render_fastbinary_includes() {
+  return "";
 }
 
 /**
  * Autogen'd comment
  */
-string t_go_generator::go_autogen_comment()
-{
-    return
+string t_go_generator::go_autogen_comment() {
+  return
         std::string() +
         "// Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
         "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\n";
@@ -733,21 +719,19 @@ string t_go_generator::go_autogen_comment()
 /**
  * Prints standard thrift package
  */
-string t_go_generator::go_package()
-{
-    return string("package ") + package_name_ + "\n\n";
+string t_go_generator::go_package() {
+  return string("package ") + package_name_ + "\n\n";
 }
 
 /**
  * Render the beginning of the import statement
  */
-string t_go_generator::go_imports_begin()
-{
-    return
-        string("import (\n"
-                "\t\"bytes\"\n"
-                "\t\"fmt\"\n"
-               "\t\"" + gen_thrift_import_ + "\"\n");
+string t_go_generator::go_imports_begin() {
+  return string(
+      "import (\n"
+      "\t\"bytes\"\n"
+      "\t\"fmt\"\n"
+      "\t\"" + gen_thrift_import_ + "\"\n");
 }
 
 /**
@@ -756,30 +740,27 @@ string t_go_generator::go_imports_begin()
  * These "_ =" prevent the go compiler complaining about used imports.
  * This will have to do in lieu of more intelligent import statement construction
  */
-string t_go_generator::go_imports_end()
-{
-    return
-        string(
-            ")\n\n"
-            "// (needed to ensure safety because of naive import list construction.)\n"
-            "var _ = thrift.ZERO\n"
-            "var _ = fmt.Printf\n"
-        	"var _ = bytes.Equal\n\n");
+string t_go_generator::go_imports_end() {
+  return string(
+      ")\n\n"
+      "// (needed to ensure safety because of naive import list construction.)\n"
+      "var _ = thrift.ZERO\n"
+      "var _ = fmt.Printf\n"
+      "var _ = bytes.Equal\n\n");
 }
 
 /**
  * Closes the type files
  */
-void t_go_generator::close_generator()
-{
-    f_const_values_ << "}" << endl << endl;
-    f_consts_ << f_const_values_.str();
+void t_go_generator::close_generator() {
+  f_const_values_ << "}" << endl << endl;
+  f_consts_ << f_const_values_.str();
 
-    // Close types and constants files
-    f_consts_.close();
-    f_types_.close();
-    format_go_output(f_types_name_);
-    format_go_output(f_consts_name_);
+  // Close types and constants files
+  f_consts_.close();
+  f_types_.close();
+  format_go_output(f_types_name_);
+  format_go_output(f_consts_name_);
 }
 
 /**
@@ -787,23 +768,20 @@ void t_go_generator::close_generator()
  *
  * @param ttypedef The type definition
  */
-void t_go_generator::generate_typedef(t_typedef* ttypedef)
-{
-    generate_go_docstring(f_types_, ttypedef);
-    string new_type_name(publicize(ttypedef->get_symbolic()));
-    string base_type(type_to_go_type(ttypedef->get_type()));
+void t_go_generator::generate_typedef(t_typedef* ttypedef) {
+  generate_go_docstring(f_types_, ttypedef);
+  string new_type_name(publicize(ttypedef->get_symbolic()));
+  string base_type(type_to_go_type(ttypedef->get_type()));
 
-    if (base_type == new_type_name) {
-        return;
-    }
+  if (base_type == new_type_name) {
+    return;
+  }
 
-    f_types_ <<
-             "type " << new_type_name << " " << base_type << endl << endl;
-    // Generate a convenience function that converts an instance of a type
-    // (which may be a constant) into a pointer to an instance of a type.
-    f_types_ <<
-             "func " << new_type_name << "Ptr(v " << new_type_name <<  ") *" << new_type_name <<
-             " { return &v }" << endl << endl;
+  f_types_ << "type " << new_type_name << " " << base_type << endl << endl;
+  // Generate a convenience function that converts an instance of a type
+  // (which may be a constant) into a pointer to an instance of a type.
+  f_types_ << "func " << new_type_name << "Ptr(v " << new_type_name << ") *" << new_type_name
+           << " { return &v }" << endl << endl;
 }
 
 /**
@@ -812,87 +790,73 @@ void t_go_generator::generate_typedef(t_typedef* ttypedef)
  *
  * @param tenum The enumeration
  */
-void t_go_generator::generate_enum(t_enum* tenum)
-{
-    std::ostringstream to_string_mapping, from_string_mapping;
-    std::string tenum_name(publicize(tenum->get_name()));
-    generate_go_docstring(f_types_, tenum);
-    f_types_ <<
-             "type " << tenum_name << " int64" << endl <<
-             "const (" << endl;
-    to_string_mapping <<
-                      indent() << "func (p " << tenum_name << ") String() string {" << endl <<
-                      indent() << "  switch p {" << endl;
-    from_string_mapping <<
-                        indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name << ", error) {" << endl <<
-                        indent() << "  switch s {" << endl;
-    vector<t_enum_value*> constants = tenum->get_constants();
-    vector<t_enum_value*>::iterator c_iter;
-    int value = -1;
-
-    for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
-      value = (*c_iter)->get_value();
-
-        string iter_std_name(escape_string((*c_iter)->get_name()));
-        string iter_name((*c_iter)->get_name());
-        f_types_ <<
-                 indent() << "  " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " << value << endl;
-        // Dictionaries to/from string names of enums
-        to_string_mapping <<
-                          indent() << "  case " << tenum_name << "_" << iter_name << ": return \"" << tenum_name << "_" << iter_std_name << "\"" << endl;
-
-        if (iter_std_name != escape_string(iter_name)) {
-            from_string_mapping <<
-                                indent() << "  case \"" << tenum_name << "_" << iter_std_name << "\", \"" << escape_string(iter_name) << "\": return " <<
-                                tenum_name << "_" << iter_name << ", nil " << endl;
-        } else {
-            from_string_mapping <<
-                                indent() << "  case \"" << tenum_name << "_" << iter_std_name << "\": return " <<
-                                tenum_name << "_" << iter_name << ", nil "  << endl;
-        }
+void t_go_generator::generate_enum(t_enum* tenum) {
+  std::ostringstream to_string_mapping, from_string_mapping;
+  std::string tenum_name(publicize(tenum->get_name()));
+  generate_go_docstring(f_types_, tenum);
+  f_types_ << "type " << tenum_name << " int64" << endl << "const (" << endl;
+  to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << endl
+                    << indent() << "  switch p {" << endl;
+  from_string_mapping << indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name
+                      << ", error) {" << endl << indent() << "  switch s {" << endl;
+  vector<t_enum_value*> constants = tenum->get_constants();
+  vector<t_enum_value*>::iterator c_iter;
+  int value = -1;
+
+  for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
+    value = (*c_iter)->get_value();
+
+    string iter_std_name(escape_string((*c_iter)->get_name()));
+    string iter_name((*c_iter)->get_name());
+    f_types_ << indent() << "  " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = "
+             << value << endl;
+    // Dictionaries to/from string names of enums
+    to_string_mapping << indent() << "  case " << tenum_name << "_" << iter_name << ": return \""
+                      << tenum_name << "_" << iter_std_name << "\"" << endl;
+
+    if (iter_std_name != escape_string(iter_name)) {
+      from_string_mapping << indent() << "  case \"" << tenum_name << "_" << iter_std_name
+                          << "\", \"" << escape_string(iter_name) << "\": return " << tenum_name
+                          << "_" << iter_name << ", nil " << endl;
+    } else {
+      from_string_mapping << indent() << "  case \"" << tenum_name << "_" << iter_std_name
+                          << "\": return " << tenum_name << "_" << iter_name << ", nil " << endl;
     }
+  }
 
-    to_string_mapping <<
-                      indent() << "  }" << endl <<
-                      indent() << "  return \"<UNSET>\"" << endl <<
-                      indent() << "}" << endl;
-    from_string_mapping <<
-                        indent() << "  }" << endl <<
-                        indent() << "  return " << tenum_name << "(0)," <<
-                        " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << endl <<
-                        indent() << "}" << endl;
+  to_string_mapping << indent() << "  }" << endl << indent() << "  return \"<UNSET>\"" << endl
+                    << indent() << "}" << endl;
+  from_string_mapping << indent() << "  }" << endl << indent() << "  return " << tenum_name
+                      << "(0),"
+                      << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << endl
+                      << indent() << "}" << endl;
 
-    f_types_ << ")" << endl << endl
-             << to_string_mapping.str() << endl
-             << from_string_mapping.str() << endl << endl;
+  f_types_ << ")" << endl << endl << to_string_mapping.str() << endl << from_string_mapping.str()
+           << endl << endl;
 
-    // Generate a convenience function that converts an instance of an enum
-    // (which may be a constant) into a pointer to an instance of that enum
-    // type.
-    f_types_ <<
-             "func " << tenum_name << "Ptr(v " << tenum_name <<  ") *" << tenum_name <<
-             " { return &v }" << endl << endl;
+  // Generate a convenience function that converts an instance of an enum
+  // (which may be a constant) into a pointer to an instance of that enum
+  // type.
+  f_types_ << "func " << tenum_name << "Ptr(v " << tenum_name << ") *" << tenum_name
+           << " { return &v }" << endl << endl;
 }
 
-
 /**
  * Generate a constant value
  */
-void t_go_generator::generate_const(t_const* tconst)
-{
-    t_type* type = tconst->get_type();
-    string name = publicize(tconst->get_name());
-    t_const_value* value = tconst->get_value();
-
-    if (type->is_base_type() || type->is_enum()) {
-        indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << endl;
-    } else {
-        f_const_values_ <<
-                        indent() << name << " = " << render_const_value(type, value, name) << endl << endl;
+void t_go_generator::generate_const(t_const* tconst) {
+  t_type* type = tconst->get_type();
+  string name = publicize(tconst->get_name());
+  t_const_value* value = tconst->get_value();
 
-        f_consts_ <<
-                  indent() << "var " << name << " " << type_to_go_type(type) << endl;
-    }
+  if (type->is_base_type() || type->is_enum()) {
+    indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << endl;
+  } else {
+    f_const_values_ << indent() << name << " = " << render_const_value(type, value, name) << endl
+                    << endl;
+
+    f_consts_ << indent() << "var " << name << " " << type_to_go_type(type) << endl;
+  }
 }
 
 /**
@@ -900,150 +864,137 @@ void t_go_generator::generate_const(t_const* tconst)
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-string t_go_generator::render_const_value(t_type* type, t_const_value* value, const string& name)
-{
-    type = get_true_type(type);
-    std::ostringstream out;
+string t_go_generator::render_const_value(t_type* type, t_const_value* value, const string& name) {
+  type = get_true_type(type);
+  std::ostringstream out;
+
+  if (type->is_base_type()) {
+    t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
+
+    switch (tbase) {
+    case t_base_type::TYPE_STRING:
+      if (((t_base_type*)type)->is_binary()) {
+        out << "[]byte(\"" << get_escaped_string(value) << "\")";
+      } else {
+        out << '"' << get_escaped_string(value) << '"';
+      }
+
+      break;
+
+    case t_base_type::TYPE_BOOL:
+      out << (value->get_integer() > 0 ? "true" : "false");
+      break;
+
+    case t_base_type::TYPE_BYTE:
+    case t_base_type::TYPE_I16:
+    case t_base_type::TYPE_I32:
+    case t_base_type::TYPE_I64:
+      out << value->get_integer();
+      break;
+
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        out << value->get_integer();
+      } else {
+        out << value->get_double();
+      }
+
+      break;
 
-    if (type->is_base_type()) {
-        t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
-
-        switch (tbase) {
-        case t_base_type::TYPE_STRING:
-            if (((t_base_type*)type)->is_binary()) {
-                out << "[]byte(\"" << get_escaped_string(value) << "\")";
-            } else {
-                out << '"' << get_escaped_string(value) << '"';
-            }
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    }
+  } else if (type->is_enum()) {
+    indent(out) << value->get_integer();
+  } else if (type->is_struct() || type->is_xception()) {
+    out << "&" << publicize(type_name(type)) << "{";
+    indent_up();
+    const vector<t_field*>& fields = ((t_struct*)type)->get_members();
+    vector<t_field*>::const_iterator f_iter;
+    const map<t_const_value*, t_const_value*>& val = value->get_map();
+    map<t_const_value*, t_const_value*>::const_iterator v_iter;
 
-            break;
+    for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+      t_type* field_type = NULL;
 
-        case t_base_type::TYPE_BOOL:
-            out << (value->get_integer() > 0 ? "true" : "false");
-            break;
+      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+        if ((*f_iter)->get_name() == v_iter->first->get_string()) {
+          field_type = (*f_iter)->get_type();
+        }
+      }
 
-        case t_base_type::TYPE_BYTE:
-        case t_base_type::TYPE_I16:
-        case t_base_type::TYPE_I32:
-        case t_base_type::TYPE_I64:
-            out << value->get_integer();
-            break;
+      if (field_type == NULL) {
+        throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
+      }
 
-        case t_base_type::TYPE_DOUBLE:
-            if (value->get_type() == t_const_value::CV_INTEGER) {
-                out << value->get_integer();
-            } else {
-                out << value->get_double();
-            }
+      if (field_type->is_base_type() || field_type->is_enum()) {
+        out << endl << indent() << publicize(v_iter->first->get_string()) << ": "
+            << render_const_value(field_type, v_iter->second, name) << ",";
+      } else {
+        string k(tmp("k"));
+        string v(tmp("v"));
+        out << endl << indent() << v << " := " << render_const_value(field_type, v_iter->second, v)
+            << endl << indent() << name << "." << publicize(v_iter->first->get_string()) << " = "
+            << v;
+      }
+    }
 
-            break;
+    out << "}";
 
-        default:
-            throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
-        }
-    } else if (type->is_enum()) {
-        indent(out) << value->get_integer();
-    } else if (type->is_struct() || type->is_xception()) {
-        out <<
-            "&" << publicize(type_name(type)) << "{";
-        indent_up();
-        const vector<t_field*>& fields = ((t_struct*)type)->get_members();
-        vector<t_field*>::const_iterator f_iter;
-        const map<t_const_value*, t_const_value*>& val = value->get_map();
-        map<t_const_value*, t_const_value*>::const_iterator v_iter;
-
-        for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-            t_type* field_type = NULL;
-
-            for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-                if ((*f_iter)->get_name() == v_iter->first->get_string()) {
-                    field_type = (*f_iter)->get_type();
-                }
-            }
-
-            if (field_type == NULL) {
-                throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
-            }
-
-            if (field_type->is_base_type() || field_type->is_enum()) {
-                out << endl <<
-                    indent() << publicize(v_iter->first->get_string()) << ": " << render_const_value(field_type, v_iter->second, name) << ",";
-            } else {
-                string k(tmp("k"));
-                string v(tmp("v"));
-                out << endl <<
-                    indent() << v << " := " << render_const_value(field_type, v_iter->second, v) << endl <<
-                    indent() << name << "." << publicize(v_iter->first->get_string()) << " = " << v;
-            }
-        }
+    indent_down();
+  } else if (type->is_map()) {
+    t_type* ktype = ((t_map*)type)->get_key_type();
+    t_type* vtype = ((t_map*)type)->get_val_type();
+    const map<t_const_value*, t_const_value*>& val = value->get_map();
+    out << "map[" << type_to_go_type(ktype) << "]" << type_to_go_type(vtype, true) << "{" << endl;
+    indent_up();
+    map<t_const_value*, t_const_value*>::const_iterator v_iter;
 
-        out << "}";
-
-        indent_down();
-    } else if (type->is_map()) {
-        t_type* ktype = ((t_map*)type)->get_key_type();
-        t_type* vtype = ((t_map*)type)->get_val_type();
-        const map<t_const_value*, t_const_value*>& val = value->get_map();
-        out <<
-            "map[" << type_to_go_type(ktype) << "]" << type_to_go_type(vtype, true) << "{" << endl;
-        indent_up();
-        map<t_const_value*, t_const_value*>::const_iterator v_iter;
-
-        for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-            out <<
-                indent() << render_const_value(ktype, v_iter->first, name) << ": " <<
-                render_const_value(vtype, v_iter->second, name) << "," << endl;
-        }
+    for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+      out << indent() << render_const_value(ktype, v_iter->first, name) << ": "
+          << render_const_value(vtype, v_iter->second, name) << "," << endl;
+    }
 
-        indent_down();
-        out <<
-            indent() << "}";
-    } else if (type->is_list()) {
-        t_type* etype = ((t_list*)type)->get_elem_type();
-        const vector<t_const_value*>& val = value->get_list();
-        out <<
-            "[]" << type_to_go_type(etype) << "{" << endl;
-        indent_up();
-        vector<t_const_value*>::const_iterator v_iter;
-
-        for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-            out <<
-                indent() << render_const_value(etype, *v_iter, name) << ", ";
-        }
+    indent_down();
+    out << indent() << "}";
+  } else if (type->is_list()) {
+    t_type* etype = ((t_list*)type)->get_elem_type();
+    const vector<t_const_value*>& val = value->get_list();
+    out << "[]" << type_to_go_type(etype) << "{" << endl;
+    indent_up();
+    vector<t_const_value*>::const_iterator v_iter;
 
-        indent_down();
-        out <<
-            indent() << "}";
-    } else if (type->is_set()) {
-        t_type* etype = ((t_set*)type)->get_elem_type();
-        const vector<t_const_value*>& val = value->get_list();
-        out <<
-            "map[" << type_to_go_key_type(etype) << "]bool{" << endl;
-        indent_up();
-        vector<t_const_value*>::const_iterator v_iter;
-
-        for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-            out <<
-                indent() << render_const_value(etype, *v_iter, name) << ": true," << endl;
+    for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+      out << indent() << render_const_value(etype, *v_iter, name) << ", ";
+    }
 
-        }
+    indent_down();
+    out << indent() << "}";
+  } else if (type->is_set()) {
+    t_type* etype = ((t_set*)type)->get_elem_type();
+    const vector<t_const_value*>& val = value->get_list();
+    out << "map[" << type_to_go_key_type(etype) << "]bool{" << endl;
+    indent_up();
+    vector<t_const_value*>::const_iterator v_iter;
 
-        indent_down();
-        out <<
-            indent() << "}";
-    } else {
-        throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
+    for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
+      out << indent() << render_const_value(etype, *v_iter, name) << ": true," << endl;
     }
 
-    return out.str();
+    indent_down();
+    out << indent() << "}";
+  } else {
+    throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
+  }
+
+  return out.str();
 }
 
 /**
  * Generates a go struct
  */
-void t_go_generator::generate_struct(t_struct* tstruct)
-{
-    generate_go_struct(tstruct, false);
+void t_go_generator::generate_struct(t_struct* tstruct) {
+  generate_go_struct(tstruct, false);
 }
 
 /**
@@ -1052,47 +1003,46 @@ void t_go_generator::generate_struct(t_struct* tstruct)
  *
  * @param txception The struct definition
  */
-void t_go_generator::generate_xception(t_struct* txception)
-{
-    generate_go_struct(txception, true);
+void t_go_generator::generate_xception(t_struct* txception) {
+  generate_go_struct(txception, true);
 }
 
 /**
  * Generates a go struct
  */
-void t_go_generator::generate_go_struct(t_struct* tstruct,
-                                        bool is_exception)
-{
-    generate_go_struct_definition(f_types_, tstruct, is_exception);
+void t_go_generator::generate_go_struct(t_struct* tstruct, bool is_exception) {
+  generate_go_struct_definition(f_types_, tstruct, is_exception);
 }
 
 void t_go_generator::get_publicized_name_and_def_value(t_field* tfield,
                                                        string* OUT_pub_name,
                                                        t_const_value** OUT_def_value) const {
-    const string base_field_name = tfield->get_name();
-    const string escaped_field_name = escape_string(base_field_name);
-    const string go_safe_name = variable_name_to_go_name(escaped_field_name);
-    *OUT_pub_name = publicize(go_safe_name);
-    *OUT_def_value = tfield->get_value();
+  const string base_field_name = tfield->get_name();
+  const string escaped_field_name = escape_string(base_field_name);
+  const string go_safe_name = variable_name_to_go_name(escaped_field_name);
+  *OUT_pub_name = publicize(go_safe_name);
+  *OUT_def_value = tfield->get_value();
 }
 
 void t_go_generator::generate_go_struct_initializer(ofstream& out,
-        t_struct* tstruct,
-        bool is_args_or_result)
-{
-    out << publicize(type_name(tstruct), is_args_or_result) << "{";
-    const vector<t_field*>& members = tstruct->get_members();
-    for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        bool pointer_field = is_pointer_field(*m_iter);
-        string publicized_name;
-        t_const_value* def_value;
-        get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value);
-        if (!pointer_field && def_value != NULL && !omit_initialization(*m_iter)) {
-            out << endl << indent() << publicized_name << ": " << render_field_initial_value(*m_iter, (*m_iter)->get_name(), pointer_field) << "," << endl;
-        }
-    }
-
-    out << "}" << endl;
+                                                    t_struct* tstruct,
+                                                    bool is_args_or_result) {
+  out << publicize(type_name(tstruct), is_args_or_result) << "{";
+  const vector<t_field*>& members = tstruct->get_members();
+  for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();
+       ++m_iter) {
+    bool pointer_field = is_pointer_field(*m_iter);
+    string publicized_name;
+    t_const_value* def_value;
+    get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value);
+    if (!pointer_field && def_value != NULL && !omit_initialization(*m_iter)) {
+      out << endl << indent() << publicized_name << ": "
+          << render_field_initial_value(*m_iter, (*m_iter)->get_name(), pointer_field) << ","
+          << endl;
+    }
+  }
+
+  out << "}" << endl;
 }
 
 /**
@@ -1101,419 +1051,369 @@ void t_go_generator::generate_go_struct_initializer(ofstream& out,
  * @param tstruct The struct definition
  */
 void t_go_generator::generate_go_struct_definition(ofstream& out,
-        t_struct* tstruct,
-        bool is_exception,
-        bool is_result,
-        bool is_args)
-{
-    const vector<t_field*>& members = tstruct->get_members();
-    const vector<t_field*>& sorted_members = tstruct->get_sorted_members();
-    vector<t_field*>::const_iterator m_iter;
-
-    std::string tstruct_name(publicize(tstruct->get_name(), is_args||is_result));
-    out <<
-        indent() << "type " << tstruct_name << " struct {" << endl;
-    /*
-       Here we generate the structure specification for the fastbinary codec.
-       These specifications have the following structure:
-       thrift_spec -> tuple of item_spec
-       item_spec -> nil | (tag, type_enum, name, spec_args, default)
-       tag -> integer
-       type_enum -> TType.I32 | TType.STRING | TType.STRUCT | ...
-       name -> string_literal
-       default -> nil  # Handled by __init__
-       spec_args -> nil  # For simple types
-                  | (type_enum, spec_args)  # Value type for list/set
-                  | (type_enum, spec_args, type_enum, spec_args)
-                    # Key and value for map
-                  | (class_name, spec_args_ptr) # For struct/exception
-       class_name -> identifier  # Basically a pointer to the class
-       spec_args_ptr -> expression  # just class_name.spec_args
-
-       TODO(dreiss): Consider making this work for structs with negative tags.
-    */
-    // TODO(dreiss): Look into generating an empty tuple instead of nil
-    // for structures with no members.
-    // TODO(dreiss): Test encoding of structs where some inner structs
-    // don't have thrift_spec.
-    indent_up();
-
-    if (sorted_members.empty() || (sorted_members[0]->get_key() >= 0)) {
-        int sorted_keys_pos = 0;
-
-        for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) {
-            if( sorted_keys_pos != (*m_iter)->get_key()) {
-                int first_unused = std::max(1,sorted_keys_pos++);
-                while( sorted_keys_pos != (*m_iter)->get_key()) {
-                    ++sorted_keys_pos;
-                }
-                int last_unused = sorted_keys_pos - 1;
-                if (first_unused < last_unused) {
-                    indent(out) << "// unused fields # " << first_unused << " to "<< last_unused << endl;
-                } else if (first_unused == last_unused) {
-                    indent(out) << "// unused field # " << first_unused << endl;
-                }
-            }
-
-            t_type* fieldType = (*m_iter)->get_type();
-            string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter));
-            string gotag("json:\"" + escape_string((*m_iter)->get_name()) + "\"");
-            std::map<string, string>::iterator it = (*m_iter)->annotations_.find("go.tag");
-            if (it != (*m_iter)->annotations_.end()) {
-            	gotag = it->second;
-            }
-            indent(out) << publicize(variable_name_to_go_name((*m_iter)->get_name())) << " "
-                        << goType << " `thrift:\""
-                        << escape_string((*m_iter)->get_name())
-                        << "," << sorted_keys_pos;
-
-            if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
-                out << ",required";
-            }
-
-            out << "\" " <<gotag <<"`" << endl;
-            sorted_keys_pos ++;
-        }
-    } else {
-        for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-            // This fills in default values, as opposed to nulls
-            out <<
-                indent() << publicize((*m_iter)->get_name()) << " " <<
-                type_to_go_type((*m_iter)->get_type()) << endl;
-        }
-    }
-
-    indent_down();
-    out <<
-        indent() << "}" << endl << endl <<
-        indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << endl <<
-        indent() << "  return &";
-    generate_go_struct_initializer(out, tstruct, is_result || is_args);
-	out <<
-        indent() << "}" << endl << endl;
-    // Default values for optional fields
+                                                   t_struct* tstruct,
+                                                   bool is_exception,
+                                                   bool is_result,
+                                                   bool is_args) {
+  const vector<t_field*>& members = tstruct->get_members();
+  const vector<t_field*>& sorted_members = tstruct->get_sorted_members();
+  vector<t_field*>::const_iterator m_iter;
+
+  std::string tstruct_name(publicize(tstruct->get_name(), is_args || is_result));
+  out << indent() << "type " << tstruct_name << " struct {" << endl;
+  /*
+     Here we generate the structure specification for the fastbinary codec.
+     These specifications have the following structure:
+     thrift_spec -> tuple of item_spec
+     item_spec -> nil | (tag, type_enum, name, spec_args, default)
+     tag -> integer
+     type_enum -> TType.I32 | TType.STRING | TType.STRUCT | ...
+     name -> string_literal
+     default -> nil  # Handled by __init__
+     spec_args -> nil  # For simple types
+                | (type_enum, spec_args)  # Value type for list/set
+                | (type_enum, spec_args, type_enum, spec_args)
+                  # Key and value for map
+                | (class_name, spec_args_ptr) # For struct/exception
+     class_name -> identifier  # Basically a pointer to the class
+     spec_args_ptr -> expression  # just class_name.spec_args
+
+     TODO(dreiss): Consider making this work for structs with negative tags.
+  */
+  // TODO(dreiss): Look into generating an empty tuple instead of nil
+  // for structures with no members.
+  // TODO(dreiss): Test encoding of structs where some inner structs
+  // don't have thrift_spec.
+  indent_up();
+
+  if (sorted_members.empty() || (sorted_members[0]->get_key() >= 0)) {
+    int sorted_keys_pos = 0;
+
+    for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) {
+      if (sorted_keys_pos != (*m_iter)->get_key()) {
+        int first_unused = std::max(1, sorted_keys_pos++);
+        while (sorted_keys_pos != (*m_iter)->get_key()) {
+          ++sorted_keys_pos;
+        }
+        int last_unused = sorted_keys_pos - 1;
+        if (first_unused < last_unused) {
+          indent(out) << "// unused fields # " << first_unused << " to " << last_unused << endl;
+        } else if (first_unused == last_unused) {
+          indent(out) << "// unused field # " << first_unused << endl;
+        }
+      }
+
+      t_type* fieldType = (*m_iter)->get_type();
+      string goType = type_to_go_type_with_opt(fieldType, is_pointer_field(*m_iter));
+      string gotag("json:\"" + escape_string((*m_iter)->get_name()) + "\"");
+      std::map<string, string>::iterator it = (*m_iter)->annotations_.find("go.tag");
+      if (it != (*m_iter)->annotations_.end()) {
+        gotag = it->second;
+      }
+      indent(out) << publicize(variable_name_to_go_name((*m_iter)->get_name())) << " " << goType
+                  << " `thrift:\"" << escape_string((*m_iter)->get_name()) << ","
+                  << sorted_keys_pos;
+
+      if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
+        out << ",required";
+      }
+
+      out << "\" " << gotag << "`" << endl;
+      sorted_keys_pos++;
+    }
+  } else {
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        string publicized_name;
-        t_const_value* def_value;
-        get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value);
-        t_type* fieldType = (*m_iter)->get_type();
-        string goType = type_to_go_type_with_opt(fieldType, false);
-        string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT";
-        if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) {
-            out << indent() << "var " << def_var_name <<" "<<goType ;
-            if (def_value != NULL) {
-                out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name()) ;
-            }
-            out <<endl;
-        }
-        if (is_pointer_field(*m_iter)) {
-            string goOptType = type_to_go_type_with_opt(fieldType, true);
-            string maybepointer = goOptType!=goType?"*":"";
-            out <<indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "<< goType<<" {" << endl
-                <<indent() << "  if !p.IsSet" <<publicized_name <<"() {" <<endl
-                <<indent() << "    return " <<def_var_name <<endl
-                <<indent() << "  }" <<endl
-                <<indent() << "return "<<maybepointer <<"p." <<publicized_name <<endl
-                <<indent() << "}" <<endl;
-        } else {
-            out <<endl
-            	<<indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "<< goType<<" {" << endl
-                <<indent() << "return p." <<publicized_name <<endl
-                <<indent() << "}" <<endl;
-
-        }
+      // This fills in default values, as opposed to nulls
+      out << indent() << publicize((*m_iter)->get_name()) << " "
+          << type_to_go_type((*m_iter)->get_type()) << endl;
+    }
+  }
+
+  indent_down();
+  out << indent() << "}" << endl << endl << indent() << "func New" << tstruct_name << "() *"
+      << tstruct_name << " {" << endl << indent() << "  return &";
+  generate_go_struct_initializer(out, tstruct, is_result || is_args);
+  out << indent() << "}" << endl << endl;
+  // Default values for optional fields
+  for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
+    string publicized_name;
+    t_const_value* def_value;
+    get_publicized_name_and_def_value(*m_iter, &publicized_name, &def_value);
+    t_type* fieldType = (*m_iter)->get_type();
+    string goType = type_to_go_type_with_opt(fieldType, false);
+    string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT";
+    if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) {
+      out << indent() << "var " << def_var_name << " " << goType;
+      if (def_value != NULL) {
+        out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name());
+      }
+      out << endl;
+    }
+    if (is_pointer_field(*m_iter)) {
+      string goOptType = type_to_go_type_with_opt(fieldType, true);
+      string maybepointer = goOptType != goType ? "*" : "";
+      out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "
+          << goType << " {" << endl << indent() << "  if !p.IsSet" << publicized_name << "() {"
+          << endl << indent() << "    return " << def_var_name << endl << indent() << "  }" << endl
+          << indent() << "return " << maybepointer << "p." << publicized_name << endl << indent()
+          << "}" << endl;
+    } else {
+      out << endl << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "
+          << goType << " {" << endl << indent() << "return p." << publicized_name << endl
+          << indent() << "}" << endl;
     }
+  }
 
-    generate_isset_helpers(out, tstruct, tstruct_name, is_result);
-    generate_go_struct_reader(out, tstruct, tstruct_name, is_result);
-    generate_go_struct_writer(out, tstruct, tstruct_name, is_result);
+  generate_isset_helpers(out, tstruct, tstruct_name, is_result);
+  generate_go_struct_reader(out, tstruct, tstruct_name, is_result);
+  generate_go_struct_writer(out, tstruct, tstruct_name, is_result);
 
-    out <<
-        indent() << "func (p *" << tstruct_name << ") String() string {" << endl <<
-        indent() << "  if p == nil {" << endl <<
-        indent() << "    return \"<nil>\"" << endl <<
-        indent() << "  }" << endl <<
-        indent() << "  return fmt.Sprintf(\"" << escape_string(tstruct_name) << "(%+v)\", *p)" << endl <<
-        indent() << "}" << endl << endl;
+  out << indent() << "func (p *" << tstruct_name << ") String() string {" << endl << indent()
+      << "  if p == nil {" << endl << indent() << "    return \"<nil>\"" << endl << indent()
+      << "  }" << endl << indent() << "  return fmt.Sprintf(\"" << escape_string(tstruct_name)
+      << "(%+v)\", *p)" << endl << indent() << "}" << endl << endl;
 
-    if(is_exception) {
-        out <<
-            indent() << "func (p *" << tstruct_name << ") Error() string {" << endl <<
-            indent() << "  return p.String()" << endl <<
-            indent() << "}" << endl << endl;
-    }
+  if (is_exception) {
+    out << indent() << "func (p *" << tstruct_name << ") Error() string {" << endl << indent()
+        << "  return p.String()" << endl << indent() << "}" << endl << endl;
+  }
 }
 
 /**
  * Generates the IsSet helper methods for a struct
  */
 void t_go_generator::generate_isset_helpers(ofstream& out,
-        t_struct* tstruct,
-        const string& tstruct_name,
-        bool is_result)
-{
-    (void) is_result;
-    const vector<t_field*>& fields = tstruct->get_members();
-    vector<t_field*>::const_iterator f_iter;
-    const string escaped_tstruct_name(escape_string(tstruct->get_name()));
-
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        const string field_name(publicize(variable_name_to_go_name(escape_string((*f_iter)->get_name()))));
-        if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) {
-            out <<
-                indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {" << endl;
-            indent_up();
-        	t_type* ttype = (*f_iter)->get_type()->get_true_type();
-        	bool is_byteslice = ttype->is_base_type() && ((t_base_type*)ttype)->is_binary() ;
-        	bool compare_to_nil_only = ttype->is_set()
-        			|| ttype->is_list()
-        			|| ttype->is_map()
-        			|| (is_byteslice && !(*f_iter)->get_value());
-            if (is_pointer_field(*f_iter) || compare_to_nil_only) {
-				out <<
-					indent() << "return p." << field_name << " != nil" << endl;
-            } else {
-                string def_var_name = tstruct_name + "_" + field_name + "_DEFAULT";
-                if (is_byteslice) {
-    				out << indent() << "return !bytes.Equal(p." << field_name << ", "<<def_var_name  << ")" << endl;
-                } else {
-    				out << indent() << "return p." << field_name << " != "<<def_var_name  << endl;
-                }
-            }
-            indent_down();
-            out <<
-                indent() << "}" << endl << endl;
+                                            t_struct* tstruct,
+                                            const string& tstruct_name,
+                                            bool is_result) {
+  (void)is_result;
+  const vector<t_field*>& fields = tstruct->get_members();
+  vector<t_field*>::const_iterator f_iter;
+  const string escaped_tstruct_name(escape_string(tstruct->get_name()));
+
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    const string field_name(
+        publicize(variable_name_to_go_name(escape_string((*f_iter)->get_name()))));
+    if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) {
+      out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {"
+          << endl;
+      indent_up();
+      t_type* ttype = (*f_iter)->get_type()->get_true_type();
+      bool is_byteslice = ttype->is_base_type() && ((t_base_type*)ttype)->is_binary();
+      bool compare_to_nil_only = ttype->is_set() || ttype->is_list() || ttype->is_map()
+                                 || (is_byteslice && !(*f_iter)->get_value());
+      if (is_pointer_field(*f_iter) || compare_to_nil_only) {
+        out << indent() << "return p." << field_name << " != nil" << endl;
+      } else {
+        string def_var_name = tstruct_name + "_" + field_name + "_DEFAULT";
+        if (is_byteslice) {
+          out << indent() << "return !bytes.Equal(p." << field_name << ", " << def_var_name << ")"
+              << endl;
+        } else {
+          out << indent() << "return p." << field_name << " != " << def_var_name << endl;
         }
+      }
+      indent_down();
+      out << indent() << "}" << endl << endl;
     }
+  }
 }
 
 /**
  * Generates the read method for a struct
  */
 void t_go_generator::generate_go_struct_reader(ofstream& out,
-        t_struct* tstruct,
-        const string& tstruct_name,
-        bool is_result)
-{
-	(void) is_result;
-	const vector<t_field*>& fields = tstruct->get_members();
-    vector<t_field*>::const_iterator f_iter;
-    string escaped_tstruct_name(escape_string(tstruct->get_name()));
-    out <<
-        indent() << "func (p *" << tstruct_name << ") Read(iprot thrift.TProtocol) error {" << endl;
+                                               t_struct* tstruct,
+                                               const string& tstruct_name,
+                                               bool is_result) {
+  (void)is_result;
+  const vector<t_field*>& fields = tstruct->get_members();
+  vector<t_field*>::const_iterator f_iter;
+  string escaped_tstruct_name(escape_string(tstruct->get_name()));
+  out << indent() << "func (p *" << tstruct_name << ") Read(iprot thrift.TProtocol) error {"
+      << endl;
+  indent_up();
+  out << indent() << "if _, err := iprot.ReadStructBegin(); err != nil {" << endl << indent()
+      << "  return fmt.Errorf(\"%T read error: %s\", p, err)" << endl << indent() << "}" << endl;
+  // Loop over reading in fields
+  indent(out) << "for {" << endl;
+  indent_up();
+  // Read beginning field marker
+  out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()" << endl << indent()
+      << "if err != nil {" << endl << indent()
+      << "  return fmt.Errorf(\"%T field %d read error: %s\", p, fieldId, err)" << endl << indent()
+      << "}" << endl;
+  // Check for field STOP marker and break
+  out << indent() << "if fieldTypeId == thrift.STOP { break; }" << endl;
+
+  string thriftFieldTypeId;
+  // Generate deserialization code for known cases
+  int32_t field_id = -1;
+
+  // Switch statement on the field we are reading, false if no fields present
+  bool have_switch = !fields.empty();
+  if (have_switch) {
+    indent(out) << "switch fieldId {" << endl;
+  }
+
+  // All the fields we know
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    field_id = (*f_iter)->get_key();
+
+    // if negative id, ensure we generate a valid method name
+    string field_method_prefix("ReadField");
+
+    if (field_id < 0) {
+      field_method_prefix += "_";
+      field_id *= -1;
+    }
+
+    out << indent() << "case " << field_id << ":" << endl;
     indent_up();
-    out <<
-        indent() << "if _, err := iprot.ReadStructBegin(); err != nil {" << endl <<
-        indent() << "  return fmt.Errorf(\"%T read error: %s\", p, err)" << endl <<
-        indent() << "}" << endl;
-    // Loop over reading in fields
-    indent(out) << "for {" << endl;
-    indent_up();
-    // Read beginning field marker
-    out <<
-        indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()" << endl <<
-        indent() << "if err != nil {" << endl <<
-        indent() << "  return fmt.Errorf(\"%T field %d read error: %s\", p, fieldId, err)" << endl <<
-        indent() << "}" << endl;
-    // Check for field STOP marker and break
-    out <<
-        indent() << "if fieldTypeId == thrift.STOP { break; }" << endl;
-
-    string thriftFieldTypeId;
-    // Generate deserialization code for known cases
-    int32_t field_id = -1;
-
-    // Switch statement on the field we are reading, false if no fields present
-    bool have_switch = !fields.empty();
-    if( have_switch) {
-        indent(out) << "switch fieldId {" << endl;
-    }
-
-    // All the fields we know
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        field_id = (*f_iter)->get_key();
+    thriftFieldTypeId = type_to_enum((*f_iter)->get_type());
 
-        // if negative id, ensure we generate a valid method name
-        string field_method_prefix("ReadField");
-
-        if (field_id < 0) {
-            field_method_prefix += "_";
-            field_id *= -1;
-        }
-
-        out <<
-            indent() <<"case " << field_id << ":" << endl;
-        indent_up();
-        thriftFieldTypeId = type_to_enum((*f_iter)->get_type());
-
-        if (thriftFieldTypeId == "thrift.BINARY") {
-            thriftFieldTypeId = "thrift.STRING";
-        }
-
-        out <<
-            indent() << "if err := p." << field_method_prefix << field_id << "(iprot); err != nil {" << endl <<
-            indent() << "  return err" << endl <<
-            indent() << "}" << endl;
-        indent_down();
+    if (thriftFieldTypeId == "thrift.BINARY") {
+      thriftFieldTypeId = "thrift.STRING";
     }
 
-    // Begin switch default case
-    if( have_switch) {
-        out <<
-            indent() << "default:" << endl;
-            indent_up();
-    }
+    out << indent() << "if err := p." << field_method_prefix << field_id << "(iprot); err != nil {"
+        << endl << indent() << "  return err" << endl << indent() << "}" << endl;
+    indent_down();
+  }
 
-    // Skip unknown fields in either case
-    out <<
-        indent() << "if err := iprot.Skip(fieldTypeId); err != nil {" << endl <<
-        indent() << "  return err" << endl <<
-        indent() << "}" << endl;
+  // Begin switch default case
+  if (have_switch) {
+    out << indent() << "default:" << endl;
+    indent_up();
+  }
 
-    // End switch default case
-    if( have_switch) {
-        indent_down();
-        out <<
-            indent() << "}" << endl;
-    }
+  // Skip unknown fields in either case
+  out << indent() << "if err := iprot.Skip(fieldTypeId); err != nil {" << endl << indent()
+      << "  return err" << endl << indent() << "}" << endl;
 
-    // Read field end marker
-    out <<
-        indent() << "if err := iprot.ReadFieldEnd(); err != nil {" << endl <<
-        indent() << "  return err" << endl <<
-        indent() << "}" << endl;
+  // End switch default case
+  if (have_switch) {
     indent_down();
-    out <<
-        indent() << "}" << endl <<
-        indent() << "if err := iprot.ReadStructEnd(); err != nil {" << endl <<
-        indent() << "  return fmt.Errorf(\"%T read struct end error: %s\", p, err)" << endl <<
-        indent() << "}" << endl <<
-        indent() << "return nil" << endl;
+    out << indent() << "}" << endl;
+  }
+
+  // Read field end marker
+  out << indent() << "if err := iprot.ReadFieldEnd(); err != nil {" << endl << indent()
+      << "  return err" << endl << indent() << "}" << endl;
+  indent_down();
+  out << indent() << "}" << endl << indent() << "if err := iprot.ReadStructEnd(); err != nil {"
+      << endl << indent() << "  return fmt.Errorf(\"%T read struct end error: %s\", p, err)" << endl
+      << indent() << "}" << endl << indent() << "return nil" << endl;
+  indent_down();
+  out << indent() << "}" << endl << endl;
+
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    string field_type_name(publicize((*f_iter)->get_type()->get_name()));
+    string field_name(publicize((*f_iter)->get_name()));
+    string field_method_prefix("ReadField");
+    int32_t field_id = (*f_iter)->get_key();
+
+    if (field_id < 0) {
+      field_method_prefix += "_";
+      field_id *= -1;
+    }
+
+    out << indent() << "func (p *" << tstruct_name << ")  " << field_method_prefix << field_id
+        << "(iprot thrift.TProtocol) error {" << endl;
+    indent_up();
+    generate_deserialize_field(out, *f_iter, false, "p.");
     indent_down();
-    out <<
-        indent() << "}" << endl << endl;
-
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        string field_type_name(publicize((*f_iter)->get_type()->get_name()));
-        string field_name(publicize((*f_iter)->get_name()));
-        string field_method_prefix("ReadField");
-        int32_t field_id = (*f_iter)->get_key();
-
-        if (field_id < 0) {
-            field_method_prefix += "_";
-            field_id *= -1;
-        }
-
-        out <<
-            indent() << "func (p *" << tstruct_name << ")  " << field_method_prefix << field_id << "(iprot thrift.TProtocol) error {" << endl;
-        indent_up();
-        generate_deserialize_field(out, *f_iter, false, "p.");
-        indent_down();
-        out <<
-            indent() << "  return nil" << endl <<
-            indent() 

<TRUNCATED>

[33/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/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 42fe9e2..05ac216 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -40,21 +40,19 @@ using std::ostream;
 using std::string;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * C++ code generator. This is legitimacy incarnate.
  *
  */
 class t_cpp_generator : public t_oop_generator {
- public:
-  t_cpp_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_cpp_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("pure_enums");
@@ -78,8 +76,7 @@ class t_cpp_generator : public t_oop_generator {
     iter = parsed_options.find("templates");
     gen_templates_ = (iter != parsed_options.end());
 
-    gen_templates_only_ =
-      (iter != parsed_options.end() && iter->second == "only");
+    gen_templates_only_ = (iter != parsed_options.end() && iter->second == "only");
 
     out_dir_base_ = "gen-cpp";
   }
@@ -100,115 +97,106 @@ class t_cpp_generator : public t_oop_generator {
   void generate_typedef(t_typedef* ttypedef);
   void generate_enum(t_enum* tenum);
   void generate_forward_declaration(t_struct* tstruct);
-  void generate_struct(t_struct* tstruct) {
-    generate_cpp_struct(tstruct, false);
-  }
-  void generate_xception(t_struct* txception) {
-    generate_cpp_struct(txception, true);
-  }
+  void generate_struct(t_struct* tstruct) { generate_cpp_struct(tstruct, false); }
+  void generate_xception(t_struct* txception) { generate_cpp_struct(txception, true); }
   void generate_cpp_struct(t_struct* tstruct, bool is_exception);
 
   void generate_service(t_service* tservice);
 
   void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
-  std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
-
-  void generate_struct_declaration    (std::ofstream& out, t_struct* tstruct,
-                                      bool is_exception=false,
-                                      bool pointers=false,
-                                      bool read=true,
-                                      bool write=true,
-                                      bool swap=false);
-  void generate_struct_definition   (std::ofstream& out, std::ofstream& force_cpp_out, t_struct* tstruct, bool setters=true);
-  void generate_copy_constructor     (std::ofstream& out, t_struct* tstruct, bool is_exception);
-  void generate_assignment_operator  (std::ofstream& out, t_struct* tstruct);
-  void generate_struct_fingerprint   (std::ofstream& out, t_struct* tstruct, bool is_definition);
-  void generate_struct_reader        (std::ofstream& out, t_struct* tstruct, bool pointers=false);
-  void generate_struct_writer        (std::ofstream& out, t_struct* tstruct, bool pointers=false);
-  void generate_struct_result_writer (std::ofstream& out, t_struct* tstruct, bool pointers=false);
-  void generate_struct_swap          (std::ofstream& out, t_struct* tstruct);
+  std::string render_const_value(std::ofstream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
+
+  void generate_struct_declaration(std::ofstream& out,
+                                   t_struct* tstruct,
+                                   bool is_exception = false,
+                                   bool pointers = false,
+                                   bool read = true,
+                                   bool write = true,
+                                   bool swap = false);
+  void generate_struct_definition(std::ofstream& out,
+                                  std::ofstream& force_cpp_out,
+                                  t_struct* tstruct,
+                                  bool setters = true);
+  void generate_copy_constructor(std::ofstream& out, t_struct* tstruct, bool is_exception);
+  void generate_assignment_operator(std::ofstream& out, t_struct* tstruct);
+  void generate_struct_fingerprint(std::ofstream& out, t_struct* tstruct, bool is_definition);
+  void generate_struct_reader(std::ofstream& out, t_struct* tstruct, bool pointers = false);
+  void generate_struct_writer(std::ofstream& out, t_struct* tstruct, bool pointers = false);
+  void generate_struct_result_writer(std::ofstream& out, t_struct* tstruct, bool pointers = false);
+  void generate_struct_swap(std::ofstream& out, t_struct* tstruct);
   void generate_struct_ostream_operator(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_interface (t_service* tservice, string style);
-  void generate_service_interface_factory (t_service* tservice, string style);
-  void generate_service_null      (t_service* tservice, string style);
-  void generate_service_multiface (t_service* tservice);
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice, string style);
-  void generate_service_processor (t_service* tservice, string style);
-  void generate_service_skeleton  (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction,
-                                   string style, bool specialized=false);
-  void generate_function_helpers  (t_service* tservice, t_function* tfunction);
-  void generate_service_async_skeleton (t_service* tservice);
+  void generate_service_interface(t_service* tservice, string style);
+  void generate_service_interface_factory(t_service* tservice, string style);
+  void generate_service_null(t_service* tservice, string style);
+  void generate_service_multiface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice, string style);
+  void generate_service_processor(t_service* tservice, string style);
+  void generate_service_skeleton(t_service* tservice);
+  void generate_process_function(t_service* tservice,
+                                 t_function* tfunction,
+                                 string style,
+                                 bool specialized = false);
+  void generate_function_helpers(t_service* tservice, t_function* tfunction);
+  void generate_service_async_skeleton(t_service* tservice);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          std::string suffix="");
-
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="",
-                                          bool pointer=false);
-
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
-
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="");
-
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
-
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix,
-                                          bool push_back,
-                                          std::string index);
-
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          std::string suffix="");
-
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="",
-                                          bool pointer=false);
-
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
-
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter);
-
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter);
-
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string iter);
-
-  void generate_function_call            (ostream& out,
-                                          t_function* tfunction,
-                                          string target,
-                                          string iface,
-                                          string arg_prefix);
+  void generate_deserialize_field(std::ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  std::string suffix = "");
+
+  void generate_deserialize_struct(std::ofstream& out,
+                                   t_struct* tstruct,
+                                   std::string prefix = "",
+                                   bool pointer = false);
+
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
+
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
+
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix,
+                                         bool push_back,
+                                         std::string index);
+
+  void generate_serialize_field(std::ofstream& out,
+                                t_field* tfield,
+                                std::string prefix = "",
+                                std::string suffix = "");
+
+  void generate_serialize_struct(std::ofstream& out,
+                                 t_struct* tstruct,
+                                 std::string prefix = "",
+                                 bool pointer = false);
+
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+
+  void generate_serialize_map_element(std::ofstream& out, t_map* tmap, std::string iter);
+
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
+
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
+
+  void generate_function_call(ostream& out,
+                              t_function* tfunction,
+                              string target,
+                              string iface,
+                              string arg_prefix);
   /*
    * Helper rendering functions
    */
@@ -216,14 +204,23 @@ class t_cpp_generator : public t_oop_generator {
   std::string namespace_prefix(std::string ns);
   std::string namespace_open(std::string ns);
   std::string namespace_close(std::string ns);
-  std::string type_name(t_type* ttype, bool in_typedef=false, bool arg=false);
+  std::string type_name(t_type* ttype, bool in_typedef = false, bool arg = false);
   std::string base_type_name(t_base_type::t_base tbase);
-  std::string declare_field(t_field* tfield, bool init=false, bool pointer=false, bool constant=false, bool reference=false);
-  std::string function_signature(t_function* tfunction, std::string style, std::string prefix="", bool name_params=true);
-  std::string cob_function_signature(t_function* tfunction, std::string prefix="", bool name_params=true);
-  std::string argument_list(t_struct* tstruct, bool name_params=true, bool start_comma=false);
+  std::string declare_field(t_field* tfield,
+                            bool init = false,
+                            bool pointer = false,
+                            bool constant = false,
+                            bool reference = false);
+  std::string function_signature(t_function* tfunction,
+                                 std::string style,
+                                 std::string prefix = "",
+                                 bool name_params = true);
+  std::string cob_function_signature(t_function* tfunction,
+                                     std::string prefix = "",
+                                     bool name_params = true);
+  std::string argument_list(t_struct* tstruct, bool name_params = true, bool start_comma = false);
   std::string type_to_enum(t_type* ttype);
-  std::string local_reflection_name(const char*, t_type* ttype, bool external=false);
+  std::string local_reflection_name(const char*, t_type* ttype, bool external = false);
 
   void generate_enum_constant_list(std::ofstream& f,
                                    const vector<t_enum_value*>& constants,
@@ -237,25 +234,19 @@ class t_cpp_generator : public t_oop_generator {
   void generate_local_reflection(std::ofstream& out, t_type* ttype, bool is_definition);
   void generate_local_reflection_pointer(std::ofstream& out, t_type* ttype);
 
-  bool is_reference(t_field* tfield) {
-    return tfield->get_reference();
-  }
+  bool is_reference(t_field* tfield) { return tfield->get_reference(); }
 
   bool is_complex_type(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return
-      ttype->is_container() ||
-      ttype->is_struct() ||
-      ttype->is_xception() ||
-      (ttype->is_base_type() && (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING));
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
+           || (ttype->is_base_type()
+               && (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING));
   }
 
-  void set_use_include_prefix(bool use_include_prefix) {
-    use_include_prefix_ = use_include_prefix;
-  }
+  void set_use_include_prefix(bool use_include_prefix) { use_include_prefix_ = use_include_prefix; }
 
- private:
+private:
   /**
    * Returns the include prefix to use for a file generated by program, or the
    * empty string if no include prefix should be used.
@@ -346,60 +337,48 @@ void t_cpp_generator::init_generator() {
   MKDIR(get_out_dir().c_str());
 
   // Make output file
-  string f_types_name = get_out_dir()+program_name_+"_types.h";
+  string f_types_name = get_out_dir() + program_name_ + "_types.h";
   f_types_.open(f_types_name.c_str());
 
-  string f_types_impl_name = get_out_dir()+program_name_+"_types.cpp";
+  string f_types_impl_name = get_out_dir() + program_name_ + "_types.cpp";
   f_types_impl_.open(f_types_impl_name.c_str());
 
   if (gen_templates_) {
     // If we don't open the stream, it appears to just discard data,
     // which is fine.
-    string f_types_tcc_name = get_out_dir()+program_name_+"_types.tcc";
+    string f_types_tcc_name = get_out_dir() + program_name_ + "_types.tcc";
     f_types_tcc_.open(f_types_tcc_name.c_str());
   }
 
   // Print header
-  f_types_ <<
-    autogen_comment();
-  f_types_impl_ <<
-    autogen_comment();
-  f_types_tcc_ <<
-    autogen_comment();
+  f_types_ << autogen_comment();
+  f_types_impl_ << autogen_comment();
+  f_types_tcc_ << autogen_comment();
 
   // Start ifndef
-  f_types_ <<
-    "#ifndef " << program_name_ << "_TYPES_H" << endl <<
-    "#define " << program_name_ << "_TYPES_H" << endl <<
-    endl;
-  f_types_tcc_ <<
-    "#ifndef " << program_name_ << "_TYPES_TCC" << endl <<
-    "#define " << program_name_ << "_TYPES_TCC" << endl <<
-    endl;
+  f_types_ << "#ifndef " << program_name_ << "_TYPES_H" << endl << "#define " << program_name_
+           << "_TYPES_H" << endl << endl;
+  f_types_tcc_ << "#ifndef " << program_name_ << "_TYPES_TCC" << endl << "#define " << program_name_
+               << "_TYPES_TCC" << endl << endl;
 
   // Include base types
-  f_types_ <<
-    "#include <iosfwd>" << endl << endl <<
-    "#include <thrift/Thrift.h>" << endl <<
-    "#include <thrift/TApplicationException.h>" << endl <<
-    "#include <thrift/protocol/TProtocol.h>" << endl <<
-    "#include <thrift/transport/TTransport.h>" << endl <<
-    endl;
+  f_types_ << "#include <iosfwd>" << endl << endl << "#include <thrift/Thrift.h>" << endl
+           << "#include <thrift/TApplicationException.h>" << endl
+           << "#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();
   for (size_t i = 0; i < includes.size(); ++i) {
-    f_types_ <<
-      "#include \"" << get_include_prefix(*(includes[i])) <<
-      includes[i]->get_name() << "_types.h\"" << endl;
+    f_types_ << "#include \"" << get_include_prefix(*(includes[i])) << includes[i]->get_name()
+             << "_types.h\"" << endl;
 
     // XXX(simpkins): If gen_templates_ is enabled, we currently assume all
     // included files were also generated with templates enabled.
-    f_types_tcc_ <<
-      "#include \"" << get_include_prefix(*(includes[i])) <<
-      includes[i]->get_name() << "_types.tcc\"" << endl;
+    f_types_tcc_ << "#include \"" << get_include_prefix(*(includes[i])) << includes[i]->get_name()
+                 << "_types.tcc\"" << endl;
   }
   f_types_ << endl;
 
@@ -407,32 +386,23 @@ void t_cpp_generator::init_generator() {
   const vector<string>& cpp_includes = program_->get_cpp_includes();
   for (size_t i = 0; i < cpp_includes.size(); ++i) {
     if (cpp_includes[i][0] == '<') {
-      f_types_ <<
-        "#include " << cpp_includes[i] << endl;
+      f_types_ << "#include " << cpp_includes[i] << endl;
     } else {
-      f_types_ <<
-        "#include \"" << cpp_includes[i] << "\"" << endl;
+      f_types_ << "#include \"" << cpp_includes[i] << "\"" << endl;
     }
   }
-  f_types_ <<
-    endl;
+  f_types_ << endl;
 
   // Include the types file
-  f_types_impl_ <<
-    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-    "_types.h\"" << endl <<
-    endl;
-  f_types_tcc_ <<
-    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-    "_types.h\"" << endl <<
-    endl;
+  f_types_impl_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
+                << "_types.h\"" << endl << endl;
+  f_types_tcc_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
+               << "_types.h\"" << endl << endl;
 
   // If we are generating local reflection metadata, we need to include
   // the definition of TypeSpec.
   if (gen_dense_) {
-    f_types_impl_ <<
-      "#include <thrift/TReflectionLocal.h>" << endl <<
-      endl;
+    f_types_impl_ << "#include <thrift/TReflectionLocal.h>" << endl << endl;
   }
 
   // The swap() code needs <algorithm> for std::swap()
@@ -445,17 +415,11 @@ void t_cpp_generator::init_generator() {
   ns_open_ = namespace_open(program_->get_namespace("cpp"));
   ns_close_ = namespace_close(program_->get_namespace("cpp"));
 
-  f_types_ <<
-    ns_open_ << endl <<
-    endl;
+  f_types_ << ns_open_ << endl << endl;
 
-  f_types_impl_ <<
-    ns_open_ << endl <<
-    endl;
+  f_types_impl_ << ns_open_ << endl << endl;
 
-  f_types_tcc_ <<
-    ns_open_ << endl <<
-    endl;
+  f_types_tcc_ << ns_open_ << endl << endl;
 }
 
 /**
@@ -463,30 +427,21 @@ void t_cpp_generator::init_generator() {
  */
 void t_cpp_generator::close_generator() {
   // Close namespace
-  f_types_ <<
-    ns_close_ << endl <<
-    endl;
-  f_types_impl_ <<
-    ns_close_ << endl;
-  f_types_tcc_ <<
-    ns_close_ << endl <<
-    endl;
+  f_types_ << ns_close_ << endl << endl;
+  f_types_impl_ << ns_close_ << endl;
+  f_types_tcc_ << ns_close_ << endl << endl;
 
   // Include the types.tcc file from the types header file,
   // so clients don't have to explicitly include the tcc file.
   // TODO(simpkins): Make this a separate option.
   if (gen_templates_) {
-    f_types_ <<
-      "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-      "_types.tcc\"" << endl <<
-      endl;
+    f_types_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
+             << "_types.tcc\"" << endl << endl;
   }
 
   // Close ifndef
-  f_types_ <<
-    "#endif" << endl;
-  f_types_tcc_ <<
-    "#endif" << endl;
+  f_types_ << "#endif" << endl;
+  f_types_tcc_ << "#endif" << endl;
 
   // Close output file
   f_types_.close();
@@ -500,12 +455,10 @@ void t_cpp_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_cpp_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_ <<
-    indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << ttypedef->get_symbolic() << ";" << endl <<
-    endl;
+  f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " "
+           << ttypedef->get_symbolic() << ";" << endl << endl;
 }
 
-
 void t_cpp_generator::generate_enum_constant_list(std::ofstream& f,
                                                   const vector<t_enum_value*>& constants,
                                                   const char* prefix,
@@ -522,8 +475,7 @@ void t_cpp_generator::generate_enum_constant_list(std::ofstream& f,
     } else {
       f << "," << endl;
     }
-    indent(f)
-      << prefix << (*c_iter)->get_name() << suffix;
+    indent(f) << prefix << (*c_iter)->get_name() << suffix;
     if (include_values) {
       f << " = " << (*c_iter)->get_value();
     }
@@ -546,12 +498,10 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
   std::string enum_name = tenum->get_name();
   if (!gen_pure_enums_) {
     enum_name = "type";
-    f_types_ <<
-      indent() << "struct " << tenum->get_name() << " {" << endl;
+    f_types_ << indent() << "struct " << tenum->get_name() << " {" << endl;
     indent_up();
   }
-  f_types_ <<
-    indent() << "enum " << enum_name;
+  f_types_ << indent() << "enum " << enum_name;
 
   generate_enum_constant_list(f_types_, constants, "", "", true);
 
@@ -570,24 +520,20 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
     prefix = tenum->get_name() + "::";
   }
 
-  f_types_impl_ <<
-    indent() << "int _k" << tenum->get_name() << "Values[] =";
+  f_types_impl_ << indent() << "int _k" << tenum->get_name() << "Values[] =";
   generate_enum_constant_list(f_types_impl_, constants, prefix.c_str(), "", false);
 
-  f_types_impl_ <<
-    indent() << "const char* _k" << tenum->get_name() << "Names[] =";
+  f_types_impl_ << indent() << "const char* _k" << tenum->get_name() << "Names[] =";
   generate_enum_constant_list(f_types_impl_, constants, "\"", "\"", false);
 
-  f_types_ <<
-    indent() << "extern const std::map<int, const char*> _" <<
-    tenum->get_name() << "_VALUES_TO_NAMES;" << endl << endl;
+  f_types_ << indent() << "extern const std::map<int, const char*> _" << tenum->get_name()
+           << "_VALUES_TO_NAMES;" << endl << endl;
 
-  f_types_impl_ <<
-    indent() << "const std::map<int, const char*> _" << tenum->get_name() <<
-    "_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(" << constants.size() <<
-    ", _k" << tenum->get_name() << "Values" <<
-    ", _k" << tenum->get_name() << "Names), " <<
-    "::apache::thrift::TEnumIterator(-1, NULL, NULL));" << endl << endl;
+  f_types_impl_ << indent() << "const std::map<int, const char*> _" << tenum->get_name()
+                << "_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(" << constants.size() << ", _k"
+                << tenum->get_name() << "Values"
+                << ", _k" << tenum->get_name() << "Names), "
+                << "::apache::thrift::TEnumIterator(-1, NULL, NULL));" << endl << endl;
 
   generate_local_reflection(f_types_, tenum, false);
   generate_local_reflection(f_types_impl_, tenum, true);
@@ -597,59 +543,41 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
  * Generates a class that holds all the constants.
  */
 void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
-  string f_consts_name = get_out_dir()+program_name_+"_constants.h";
+  string f_consts_name = get_out_dir() + program_name_ + "_constants.h";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
-  string f_consts_impl_name = get_out_dir()+program_name_+"_constants.cpp";
+  string f_consts_impl_name = get_out_dir() + program_name_ + "_constants.cpp";
   ofstream f_consts_impl;
   f_consts_impl.open(f_consts_impl_name.c_str());
 
   // Print header
-  f_consts <<
-    autogen_comment();
-  f_consts_impl <<
-    autogen_comment();
+  f_consts << autogen_comment();
+  f_consts_impl << autogen_comment();
 
   // Start ifndef
-  f_consts <<
-    "#ifndef " << program_name_ << "_CONSTANTS_H" << endl <<
-    "#define " << program_name_ << "_CONSTANTS_H" << endl <<
-    endl <<
-    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-    "_types.h\"" << endl <<
-    endl <<
-    ns_open_ << endl <<
-    endl;
-
-  f_consts_impl <<
-    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-    "_constants.h\"" << endl <<
-    endl <<
-    ns_open_ << endl <<
-    endl;
-
-  f_consts <<
-    "class " << program_name_ << "Constants {" << endl <<
-    " public:" << endl <<
-    "  " << program_name_ << "Constants();" << endl <<
-    endl;
+  f_consts << "#ifndef " << program_name_ << "_CONSTANTS_H" << endl << "#define " << program_name_
+           << "_CONSTANTS_H" << endl << endl << "#include \"" << get_include_prefix(*get_program())
+           << program_name_ << "_types.h\"" << endl << endl << ns_open_ << endl << endl;
+
+  f_consts_impl << "#include \"" << get_include_prefix(*get_program()) << program_name_
+                << "_constants.h\"" << endl << endl << ns_open_ << endl << endl;
+
+  f_consts << "class " << program_name_ << "Constants {" << endl << " public:" << endl << "  "
+           << program_name_ << "Constants();" << endl << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     string name = (*c_iter)->get_name();
     t_type* type = (*c_iter)->get_type();
-    f_consts <<
-      indent() << type_name(type) << " " << name << ";" << endl;
+    f_consts << indent() << type_name(type) << " " << name << ";" << endl;
   }
   indent_down();
-  f_consts <<
-    "};" << endl;
+  f_consts << "};" << endl;
 
-  f_consts_impl <<
-    "const " << program_name_ << "Constants g_" << program_name_ << "_constants;" << endl <<
-    endl <<
-    program_name_ << "Constants::" << program_name_ << "Constants() {" << endl;
+  f_consts_impl << "const " << program_name_ << "Constants g_" << program_name_ << "_constants;"
+                << endl << endl << program_name_ << "Constants::" << program_name_
+                << "Constants() {" << endl;
   indent_up();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     print_const_value(f_consts_impl,
@@ -658,22 +586,13 @@ void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
                       (*c_iter)->get_value());
   }
   indent_down();
-  indent(f_consts_impl) <<
-    "}" << endl;
-
-  f_consts <<
-    endl <<
-    "extern const " << program_name_ << "Constants g_" << program_name_ << "_constants;" << endl <<
-    endl <<
-    ns_close_ << endl <<
-    endl <<
-    "#endif" << endl;
+  indent(f_consts_impl) << "}" << endl;
+
+  f_consts << endl << "extern const " << program_name_ << "Constants g_" << program_name_
+           << "_constants;" << endl << endl << ns_close_ << endl << endl << "#endif" << endl;
   f_consts.close();
 
-  f_consts_impl <<
-    endl <<
-    ns_close_ << endl <<
-    endl;
+  f_consts_impl << endl << ns_close_ << endl << endl;
 }
 
 /**
@@ -681,15 +600,17 @@ void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-void t_cpp_generator::print_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
+void t_cpp_generator::print_const_value(ofstream& out,
+                                        string name,
+                                        t_type* type,
+                                        t_const_value* value) {
   type = get_true_type(type);
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
-    indent(out) << name << " = " << v2 << ";" << endl <<
-      endl;
+    indent(out) << name << " = " << v2 << ";" << endl << endl;
   } else if (type->is_enum()) {
-    indent(out) << name << " = (" << type_name(type) << ")" << value->get_integer() << ";" << endl <<
-      endl;
+    indent(out) << name << " = (" << type_name(type) << ")" << value->get_integer() << ";" << endl
+                << endl;
   } else if (type->is_struct() || type->is_xception()) {
     const vector<t_field*>& fields = ((t_struct*)type)->get_members();
     vector<t_field*>::const_iterator f_iter;
@@ -710,8 +631,8 @@ void t_cpp_generator::print_const_value(ofstream& out, string name, t_type* type
       }
       string val = render_const_value(out, name, field_type, v_iter->second);
       indent(out) << name << "." << v_iter->first->get_string() << " = " << val << ";" << endl;
-      if(is_nonrequired_field) {
-          indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl;
+      if (is_nonrequired_field) {
+        indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl;
       }
     }
     out << endl;
@@ -752,8 +673,11 @@ void t_cpp_generator::print_const_value(ofstream& out, string name, t_type* type
 /**
  *
  */
-string t_cpp_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+string t_cpp_generator::render_const_value(ofstream& out,
+                                           string name,
+                                           t_type* type,
+                                           t_const_value* value) {
+  (void)name;
   std::ostringstream render;
 
   if (type->is_base_type()) {
@@ -797,9 +721,7 @@ string t_cpp_generator::render_const_value(ofstream& out, string name, t_type* t
 
 void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) {
   // Forward declare struct def
-  f_types_ <<
-    indent() << "class " << tstruct->get_name() << ";" << endl <<
-    endl;
+  f_types_ << indent() << "class " << tstruct->get_name() << ";" << endl << endl;
 }
 
 /**
@@ -810,8 +732,7 @@ void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) {
  * @param tstruct The struct definition
  */
 void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) {
-  generate_struct_declaration(f_types_, tstruct, is_exception,
-                             false, true, true, true);
+  generate_struct_declaration(f_types_, tstruct, is_exception, false, true, true, true);
   generate_struct_definition(f_types_impl_, f_types_impl_, tstruct);
   generate_struct_fingerprint(f_types_impl_, tstruct, true);
   generate_local_reflection(f_types_, tstruct, false);
@@ -827,15 +748,13 @@ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception)
   generate_struct_ostream_operator(f_types_impl_, tstruct);
 }
 
-void t_cpp_generator::generate_copy_constructor(
-  ofstream& out,
-  t_struct* tstruct,
-  bool is_exception) {
+void t_cpp_generator::generate_copy_constructor(ofstream& out,
+                                                t_struct* tstruct,
+                                                bool is_exception) {
   std::string tmp_name = tmp("other");
 
-  indent(out) << tstruct->get_name() << "::" <<
-    tstruct->get_name() << "(const " << tstruct->get_name() <<
-    "& " << tmp_name << ") ";
+  indent(out) << tstruct->get_name() << "::" << tstruct->get_name() << "(const "
+              << tstruct->get_name() << "& " << tmp_name << ") ";
   if (is_exception)
     out << ": TException() ";
   out << "{" << endl;
@@ -852,8 +771,8 @@ void t_cpp_generator::generate_copy_constructor(
   for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) {
     if ((*f_iter)->get_req() != t_field::T_REQUIRED)
       has_nonrequired_fields = true;
-    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." <<
-      (*f_iter)->get_name() << ";" << endl;
+    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." << (*f_iter)->get_name() << ";"
+                << endl;
   }
 
   if (has_nonrequired_fields)
@@ -863,14 +782,12 @@ void t_cpp_generator::generate_copy_constructor(
   indent(out) << "}" << endl;
 }
 
-void t_cpp_generator::generate_assignment_operator(
-  ofstream& out,
-  t_struct* tstruct) {
+void t_cpp_generator::generate_assignment_operator(ofstream& out, t_struct* tstruct) {
   std::string tmp_name = tmp("other");
 
   indent(out) << tstruct->get_name() << "& " << tstruct->get_name() << "::"
-    "operator=(const " << tstruct->get_name() <<
-    "& " << tmp_name << ") {" << endl;
+                                                                       "operator=(const "
+              << tstruct->get_name() << "& " << tmp_name << ") {" << endl;
   indent_up();
 
   const vector<t_field*>& members = tstruct->get_members();
@@ -884,8 +801,8 @@ void t_cpp_generator::generate_assignment_operator(
   for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) {
     if ((*f_iter)->get_req() != t_field::T_REQUIRED)
       has_nonrequired_fields = true;
-    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." <<
-      (*f_iter)->get_name() << ";" << endl;
+    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." << (*f_iter)->get_name() << ";"
+                << endl;
   }
   if (has_nonrequired_fields)
     indent(out) << "__isset = " << tmp_name << ".__isset;" << endl;
@@ -902,12 +819,12 @@ void t_cpp_generator::generate_assignment_operator(
  * @param tstruct The struct
  */
 void t_cpp_generator::generate_struct_declaration(ofstream& out,
-                                                 t_struct* tstruct,
-                                                 bool is_exception,
-                                                 bool pointers,
-                                                 bool read,
-                                                 bool write,
-                                                 bool swap) {
+                                                  t_struct* tstruct,
+                                                  bool is_exception,
+                                                  bool pointers,
+                                                  bool read,
+                                                  bool write,
+                                                  bool swap) {
   string extends = "";
   if (is_exception) {
     extends = " : public ::apache::thrift::TException";
@@ -930,12 +847,10 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
 
   if (has_nonrequired_fields && (!pointers || read)) {
 
-    out <<
-      indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl;
+    out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl;
     indent_up();
 
-    indent(out) <<
-      "_" << tstruct->get_name() << "__isset() ";
+    indent(out) << "_" << tstruct->get_name() << "__isset() ";
     bool first = true;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
@@ -944,34 +859,28 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
       string isSet = ((*m_iter)->get_value() != NULL) ? "true" : "false";
       if (first) {
         first = false;
-        out <<
-          ": " << (*m_iter)->get_name() << "(" << isSet << ")";
+        out << ": " << (*m_iter)->get_name() << "(" << isSet << ")";
       } else {
-        out <<
-          ", " << (*m_iter)->get_name() << "(" << isSet << ")";
+        out << ", " << (*m_iter)->get_name() << "(" << isSet << ")";
       }
     }
     out << " {}" << endl;
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
-        indent(out) <<
-          "bool " << (*m_iter)->get_name() << " :1;" << endl;
-        }
+        indent(out) << "bool " << (*m_iter)->get_name() << " :1;" << endl;
       }
-
-      indent_down();
-      indent(out) <<
-        "} _" << tstruct->get_name() << "__isset;" << endl;
     }
 
+    indent_down();
+    indent(out) << "} _" << tstruct->get_name() << "__isset;" << endl;
+  }
+
   out << endl;
 
   // Open struct def
-  out <<
-    indent() << "class " << tstruct->get_name() << extends << " {" << endl <<
-    indent() << " public:" << endl <<
-    endl;
+  out << indent() << "class " << tstruct->get_name() << extends << " {" << endl << indent()
+      << " public:" << endl << endl;
   indent_up();
 
   // Put the fingerprint up top for all to see.
@@ -979,16 +888,14 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
 
   if (!pointers) {
     // Copy constructor
-    indent(out) <<
-      tstruct->get_name() << "(const " << tstruct->get_name() << "&);" << endl;
+    indent(out) << tstruct->get_name() << "(const " << tstruct->get_name() << "&);" << endl;
 
     // Assignment Operator
-    indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&);" << endl;
+    indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&);"
+                << endl;
 
     // Default constructor
-    indent(out) <<
-      tstruct->get_name() << "()";
-
+    indent(out) << tstruct->get_name() << "()";
 
     bool init_ctor = false;
 
@@ -1031,29 +938,26 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
   }
 
   if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
-    out <<
-      endl <<
-      indent() << "virtual ~" << tstruct->get_name() << "() throw();" << endl;
+    out << endl << indent() << "virtual ~" << tstruct->get_name() << "() throw();" << endl;
   }
 
   // Pointer to this structure's reflection local typespec.
   if (gen_dense_) {
-    indent(out) <<
-      "static ::apache::thrift::reflection::local::TypeSpec* local_reflection;" <<
-      endl << endl;
+    indent(out) << "static ::apache::thrift::reflection::local::TypeSpec* local_reflection;" << endl
+                << endl;
   }
 
   // Declare all fields
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) <<
-      declare_field(*m_iter, false, (pointers && !(*m_iter)->get_type()->is_xception()), !read) << endl;
+    indent(out) << declare_field(*m_iter,
+                                 false,
+                                 (pointers && !(*m_iter)->get_type()->is_xception()),
+                                 !read) << endl;
   }
 
   // Add the __isset data member if we need it, using the definition from above
   if (has_nonrequired_fields && (!pointers || read)) {
-    out <<
-      endl <<
-      indent() << "_" << tstruct->get_name() << "__isset __isset;" << endl;
+    out << endl << indent() << "_" << tstruct->get_name() << "__isset __isset;" << endl;
   }
 
   // Create a setter function for each field
@@ -1062,16 +966,12 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
       continue;
     }
     if (is_reference((*m_iter))) {
-      out <<
-        endl <<
-        indent() << "void __set_" << (*m_iter)->get_name() <<
-        "(boost::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">";
+      out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(boost::shared_ptr<"
+          << type_name((*m_iter)->get_type(), false, false) << ">";
       out << " val);" << endl;
     } else {
-      out <<
-        endl <<
-        indent() << "void __set_" << (*m_iter)->get_name() <<
-        "(" << type_name((*m_iter)->get_type(), false, true);
+      out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "("
+          << type_name((*m_iter)->get_type(), false, true);
       out << " val);" << endl;
     }
   }
@@ -1082,65 +982,53 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
     if (!gen_no_default_operators_) {
       // Generate an equality testing operator.  Make it inline since the compiler
       // will do a better job than we would when deciding whether to inline it.
-      out <<
-        indent() << "bool operator == (const " << tstruct->get_name() << " & " <<
-        (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl;
+      out << indent() << "bool operator == (const " << tstruct->get_name() << " & "
+          << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl;
       scope_up(out);
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
         // Most existing Thrift code does not use isset or optional/required,
         // so we treat "default" fields as required.
         if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
-          out <<
-            indent() << "if (!(" << (*m_iter)->get_name()
-                     << " == rhs." << (*m_iter)->get_name() << "))" << endl <<
-            indent() << "  return false;" << endl;
+          out << indent() << "if (!(" << (*m_iter)->get_name() << " == rhs."
+              << (*m_iter)->get_name() << "))" << endl << indent() << "  return false;" << endl;
         } else {
-          out <<
-            indent() << "if (__isset." << (*m_iter)->get_name()
-                     << " != rhs.__isset." << (*m_iter)->get_name() << ")" << endl <<
-            indent() << "  return false;" << endl <<
-            indent() << "else if (__isset." << (*m_iter)->get_name() << " && !("
-                     << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name()
-                     << "))" << endl <<
-            indent() << "  return false;" << endl;
+          out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset."
+              << (*m_iter)->get_name() << ")" << endl << indent() << "  return false;" << endl
+              << indent() << "else if (__isset." << (*m_iter)->get_name() << " && !("
+              << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl
+              << indent() << "  return false;" << endl;
         }
       }
       indent(out) << "return true;" << endl;
       scope_down(out);
-      out <<
-        indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {" << endl <<
-        indent() << "  return !(*this == rhs);" << endl <<
-        indent() << "}" << endl << endl;
+      out << indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {"
+          << endl << indent() << "  return !(*this == rhs);" << endl << indent() << "}" << endl
+          << endl;
 
       // Generate the declaration of a less-than operator.  This must be
       // implemented by the application developer if they wish to use it.  (They
       // will get a link error if they try to use it without an implementation.)
-      out <<
-        indent() << "bool operator < (const "
-                 << tstruct->get_name() << " & ) const;" << endl << endl;
+      out << indent() << "bool operator < (const " << tstruct->get_name() << " & ) const;" << endl
+          << endl;
     }
   }
 
   if (read) {
     if (gen_templates_) {
-      out <<
-        indent() << "template <class Protocol_>" << endl <<
-        indent() << "uint32_t read(Protocol_* iprot);" << endl;
+      out << indent() << "template <class Protocol_>" << endl << indent()
+          << "uint32_t read(Protocol_* iprot);" << endl;
     } else {
-      out <<
-        indent() << "uint32_t read(" <<
-        "::apache::thrift::protocol::TProtocol* iprot);" << endl;
+      out << indent() << "uint32_t read("
+          << "::apache::thrift::protocol::TProtocol* iprot);" << endl;
     }
   }
   if (write) {
     if (gen_templates_) {
-      out <<
-        indent() << "template <class Protocol_>" << endl <<
-        indent() << "uint32_t write(Protocol_* oprot) const;" << endl;
+      out << indent() << "template <class Protocol_>" << endl << indent()
+          << "uint32_t write(Protocol_* oprot) const;" << endl;
     } else {
-      out <<
-        indent() << "uint32_t write(" <<
-        "::apache::thrift::protocol::TProtocol* oprot) const;" << endl;
+      out << indent() << "uint32_t write("
+          << "::apache::thrift::protocol::TProtocol* oprot) const;" << endl;
     }
   }
   out << endl;
@@ -1151,16 +1039,12 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
   out << ";" << endl;
 
   indent_down();
-  indent(out) <<
-    "};" << endl <<
-    endl;
+  indent(out) << "};" << endl << endl;
 
   if (swap) {
     // Generate a namespace-scope swap() function
-    out <<
-      indent() << "void swap(" << tstruct->get_name() << " &a, " <<
-      tstruct->get_name() << " &b);" << endl <<
-      endl;
+    out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
+        << " &b);" << endl << endl;
   }
 }
 
@@ -1172,12 +1056,10 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
   vector<t_field*>::const_iterator m_iter;
   const vector<t_field*>& members = tstruct->get_members();
 
-
   // Destructor
   if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
-    force_cpp_out <<
-      endl <<
-      indent() << tstruct->get_name() << "::~" << tstruct->get_name() << "() throw() {" << endl;
+    force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
+                  << "() throw() {" << endl;
     indent_up();
 
     indent_down();
@@ -1189,16 +1071,13 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if (is_reference((*m_iter))) {
         std::string type = type_name((*m_iter)->get_type());
-        out <<
-          endl <<
-          indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() <<
-          "(boost::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">";
+        out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
+            << (*m_iter)->get_name() << "(boost::shared_ptr<"
+            << type_name((*m_iter)->get_type(), false, false) << ">";
         out << " val) {" << endl;
       } else {
-        out <<
-          endl <<
-          indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() <<
-          "(" << type_name((*m_iter)->get_type(), false, true);
+        out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
+            << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true);
         out << " val) {" << endl;
       }
       indent_up();
@@ -1209,12 +1088,9 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
       // for optional fields change __isset.name to true
       bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL;
       if (is_optional) {
-        out <<
-          indent() <<
-          indent() << "__isset." << (*m_iter)->get_name() << " = true;" << endl;
+        out << indent() << indent() << "__isset." << (*m_iter)->get_name() << " = true;" << endl;
       }
-      out <<
-        indent()<< "}" << endl;
+      out << indent() << "}" << endl;
     }
   }
   out << endl;
@@ -1239,16 +1115,13 @@ void t_cpp_generator::generate_struct_fingerprint(ofstream& out,
     comment = "; // ";
   }
 
-  if (! tstruct->has_fingerprint()) {
-    tstruct->generate_fingerprint();  // lazy fingerprint generation
+  if (!tstruct->has_fingerprint()) {
+    tstruct->generate_fingerprint(); // lazy fingerprint generation
   }
   if (tstruct->has_fingerprint()) {
-    out <<
-      indent() << stat << "const char* " << nspace
-        << "ascii_fingerprint" << comment << "= \"" <<
-        tstruct->get_ascii_fingerprint() << "\";" << endl <<
-      indent() << stat << "const uint8_t " << nspace <<
-        "binary_fingerprint[" << t_type::fingerprint_len << "]" << comment << "= {";
+    out << indent() << stat << "const char* " << nspace << "ascii_fingerprint" << comment << "= \""
+        << tstruct->get_ascii_fingerprint() << "\";" << endl << indent() << stat << "const uint8_t "
+        << nspace << "binary_fingerprint[" << t_type::fingerprint_len << "]" << comment << "= {";
     const char* comma = "";
     for (int i = 0; i < t_type::fingerprint_len; i++) {
       out << comma << "0x" << t_struct::byte_to_hex(tstruct->get_binary_fingerprint()[i]);
@@ -1269,7 +1142,7 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
   }
   ttype = get_true_type(ttype);
   string key = ttype->get_ascii_fingerprint() + (is_definition ? "-defn" : "-decl");
-  assert(ttype->has_fingerprint());  // test AFTER get due to lazy fingerprint generation
+  assert(ttype->has_fingerprint()); // test AFTER get due to lazy fingerprint generation
 
   // Note that we have generated this fingerprint.  If we already did, bail out.
   if (!reflected_fingerprints_.insert(key).second) {
@@ -1303,40 +1176,34 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
 
     // For definitions of structures, do the arrays of metas and field specs also.
     if (is_definition) {
-      out <<
-        indent() << "::apache::thrift::reflection::local::FieldMeta" << endl <<
-        indent() << local_reflection_name("metas", ttype) <<"[] = {" << endl;
+      out << indent() << "::apache::thrift::reflection::local::FieldMeta" << endl << indent()
+          << local_reflection_name("metas", ttype) << "[] = {" << endl;
       indent_up();
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        indent(out) << "{ " << (*m_iter)->get_key() << ", " <<
-          (((*m_iter)->get_req() == t_field::T_OPTIONAL) ? "true" : "false") <<
-          " }," << endl;
+        indent(out) << "{ " << (*m_iter)->get_key() << ", "
+                    << (((*m_iter)->get_req() == t_field::T_OPTIONAL) ? "true" : "false") << " },"
+                    << endl;
       }
       // Zero for the T_STOP marker.
       indent(out) << "{ 0, false }" << endl << "};" << endl;
       indent_down();
 
-      out <<
-        indent() << "::apache::thrift::reflection::local::TypeSpec*" << endl <<
-        indent() << local_reflection_name("specs", ttype) <<"[] = {" << endl;
+      out << indent() << "::apache::thrift::reflection::local::TypeSpec*" << endl << indent()
+          << local_reflection_name("specs", ttype) << "[] = {" << endl;
       indent_up();
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        indent(out) << "&" <<
-          local_reflection_name("typespec", (*m_iter)->get_type(), true) << "," << endl;
+        indent(out) << "&" << local_reflection_name("typespec", (*m_iter)->get_type(), true) << ","
+                    << endl;
       }
-      indent(out) << "&" <<
-        local_reflection_name("typespec", g_type_void) << "," << endl;
+      indent(out) << "&" << local_reflection_name("typespec", g_type_void) << "," << endl;
       indent_down();
       indent(out) << "};" << endl;
     }
   }
 
-  out <<
-    indent() << "// " << ttype->get_fingerprint_material() << endl <<
-    indent() << (is_definition ? "" : "extern ") <<
-      "::apache::thrift::reflection::local::TypeSpec" << endl <<
-      local_reflection_name("typespec", ttype) <<
-      (is_definition ? "(" : ";") << endl;
+  out << indent() << "// " << ttype->get_fingerprint_material() << endl << indent()
+      << (is_definition ? "" : "extern ") << "::apache::thrift::reflection::local::TypeSpec" << endl
+      << local_reflection_name("typespec", ttype) << (is_definition ? "(" : ";") << endl;
 
   if (!is_definition) {
     out << endl;
@@ -1352,22 +1219,22 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
   }
 
   if (ttype->is_struct()) {
-    out << "," << endl <<
-      indent() << type_name(ttype) << "::binary_fingerprint," << endl <<
-      indent() << local_reflection_name("metas", ttype) << "," << endl <<
-      indent() << local_reflection_name("specs", ttype);
+    out << "," << endl << indent() << type_name(ttype) << "::binary_fingerprint," << endl
+        << indent() << local_reflection_name("metas", ttype) << "," << endl << indent()
+        << local_reflection_name("specs", ttype);
   } else if (ttype->is_list()) {
-    out << "," << endl <<
-      indent() << "&" << local_reflection_name("typespec", ((t_list*)ttype)->get_elem_type(), true) << "," << endl <<
-      indent() << "NULL";
+    out << "," << endl << indent() << "&"
+        << local_reflection_name("typespec", ((t_list*)ttype)->get_elem_type(), true) << "," << endl
+        << indent() << "NULL";
   } else if (ttype->is_set()) {
-    out << "," << endl <<
-      indent() << "&" << local_reflection_name("typespec", ((t_set*)ttype)->get_elem_type(), true) << "," << endl <<
-      indent() << "NULL";
+    out << "," << endl << indent() << "&"
+        << local_reflection_name("typespec", ((t_set*)ttype)->get_elem_type(), true) << "," << endl
+        << indent() << "NULL";
   } else if (ttype->is_map()) {
-    out << "," << endl <<
-      indent() << "&" << local_reflection_name("typespec", ((t_map*)ttype)->get_key_type(), true) << "," << endl <<
-      indent() << "&" << local_reflection_name("typespec", ((t_map*)ttype)->get_val_type(), true);
+    out << "," << endl << indent() << "&"
+        << local_reflection_name("typespec", ((t_map*)ttype)->get_key_type(), true) << "," << endl
+        << indent() << "&"
+        << local_reflection_name("typespec", ((t_map*)ttype)->get_val_type(), true);
   }
 
   out << ");" << endl << endl;
@@ -1379,16 +1246,13 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
  * Writes the structure's static pointer to its local reflection typespec
  * into the implementation file.
  */
-void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out,
-                                                        t_type* ttype) {
+void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out, t_type* ttype) {
   if (!gen_dense_) {
     return;
   }
-  indent(out) <<
-    "::apache::thrift::reflection::local::TypeSpec* " <<
-      ttype->get_name() << "::local_reflection = " << endl <<
-    indent() << "  &" << local_reflection_name("typespec", ttype) << ";" <<
-    endl << endl;
+  indent(out) << "::apache::thrift::reflection::local::TypeSpec* " << ttype->get_name()
+              << "::local_reflection = " << endl << indent() << "  &"
+              << local_reflection_name("typespec", ttype) << ";" << endl << endl;
 }
 
 /**
@@ -1397,18 +1261,13 @@ void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out,
  * @param out Stream to write to
  * @param tstruct The struct
  */
-void t_cpp_generator::generate_struct_reader(ofstream& out,
-                                             t_struct* tstruct,
-                                             bool pointers) {
+void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, bool pointers) {
   if (gen_templates_) {
-    out <<
-      indent() << "template <class Protocol_>" << endl <<
-      indent() << "uint32_t " << tstruct->get_name() <<
-      "::read(Protocol_* iprot) {" << endl;
+    out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
+        << tstruct->get_name() << "::read(Protocol_* iprot) {" << endl;
   } else {
-    indent(out) <<
-      "uint32_t " << tstruct->get_name() <<
-      "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl;
+    indent(out) << "uint32_t " << tstruct->get_name()
+                << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl;
   }
   indent_up();
 
@@ -1416,17 +1275,11 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables
-  out <<
-    endl <<
-    indent() << "uint32_t xfer = 0;" << endl <<
-    indent() << "std::string fname;" << endl <<
-    indent() << "::apache::thrift::protocol::TType ftype;" << endl <<
-    indent() << "int16_t fid;" << endl <<
-    endl <<
-    indent() << "xfer += iprot->readStructBegin(fname);" << endl <<
-    endl <<
-    indent() << "using ::apache::thrift::protocol::TProtocolException;" << endl <<
-    endl;
+  out << endl << indent() << "uint32_t xfer = 0;" << endl << indent() << "std::string fname;"
+      << endl << indent() << "::apache::thrift::protocol::TType ftype;" << endl << indent()
+      << "int16_t fid;" << endl << endl << indent() << "xfer += iprot->readStructBegin(fname);"
+      << endl << endl << indent() << "using ::apache::thrift::protocol::TProtocolException;" << endl
+      << endl;
 
   // Required variables aren't in __isset, so we need tmp vars to check them.
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1435,44 +1288,34 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
   }
   out << endl;
 
-
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
-    scope_up(out);
+  indent(out) << "while (true)" << endl;
+  scope_up(out);
 
-    // Read beginning field marker
-    indent(out) <<
-      "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl;
+  // Read beginning field marker
+  indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl;
 
-    // Check for field STOP marker
-    out <<
-      indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl <<
-      indent() << "  break;" << endl <<
-      indent() << "}" << endl;
+  // Check for field STOP marker
+  out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl << indent()
+      << "  break;" << endl << indent() << "}" << endl;
 
-    if(fields.empty()) {
-      out <<
-        indent() << "xfer += iprot->skip(ftype);" << endl;
-    }
-    else {
-      // Switch statement on the field we are reading
-      indent(out) <<
-        "switch (fid)" << endl;
+  if (fields.empty()) {
+    out << indent() << "xfer += iprot->skip(ftype);" << endl;
+  } else {
+    // Switch statement on the field we are reading
+    indent(out) << "switch (fid)" << endl;
 
-        scope_up(out);
+    scope_up(out);
 
-        // Generate deserialization code for known cases
-        for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-          indent(out) <<
-            "case " << (*f_iter)->get_key() << ":" << endl;
-          indent_up();
-          indent(out) <<
-            "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-          indent_up();
+    // Generate deserialization code for known cases
+    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+      indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+      indent_up();
+      indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+      indent_up();
 
-          const char *isset_prefix =
-            ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset." : "isset_";
+      const char* isset_prefix = ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset."
+                                                                               : "isset_";
 
 #if 0
           // This code throws an exception if the same field is encountered twice.
@@ -1484,42 +1327,34 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
             indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
 #endif
 
-          if (pointers && !(*f_iter)->get_type()->is_xception()) {
-            generate_deserialize_field(out, *f_iter, "(*(this->", "))");
-          } else {
-            generate_deserialize_field(out, *f_iter, "this->");
-          }
-          out <<
-            indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl;
-          indent_down();
-          out <<
-            indent() << "} else {" << endl <<
-            indent() << "  xfer += iprot->skip(ftype);" << endl <<
-            // TODO(dreiss): Make this an option when thrift structs
-            // have a common base class.
-            // indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl <<
-            indent() << "}" << endl <<
-            indent() << "break;" << endl;
-          indent_down();
+      if (pointers && !(*f_iter)->get_type()->is_xception()) {
+        generate_deserialize_field(out, *f_iter, "(*(this->", "))");
+      } else {
+        generate_deserialize_field(out, *f_iter, "this->");
       }
+      out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl;
+      indent_down();
+      out << indent() << "} else {" << endl << indent() << "  xfer += iprot->skip(ftype);" << endl
+          <<
+          // TODO(dreiss): Make this an option when thrift structs
+          // have a common base class.
+          // indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl <<
+          indent() << "}" << endl << indent() << "break;" << endl;
+      indent_down();
+    }
 
-      // In the default case we skip the field
-      out <<
-        indent() << "default:" << endl <<
-        indent() << "  xfer += iprot->skip(ftype);" << endl <<
-        indent() << "  break;" << endl;
-
-      scope_down(out);
-    } //!fields.empty()
-    // Read field end marker
-    indent(out) <<
-      "xfer += iprot->readFieldEnd();" << endl;
+    // In the default case we skip the field
+    out << indent() << "default:" << endl << indent() << "  xfer += iprot->skip(ftype);" << endl
+        << indent() << "  break;" << endl;
 
     scope_down(out);
+  } //!fields.empty()
+  // Read field end marker
+  indent(out) << "xfer += iprot->readFieldEnd();" << endl;
+
+  scope_down(out);
 
-  out <<
-    endl <<
-    indent() << "xfer += iprot->readStructEnd();" << endl;
+  out << endl << indent() << "xfer += iprot->readStructEnd();" << endl;
 
   // Throw if any required fields are missing.
   // We do this after reading the struct end so that
@@ -1527,16 +1362,14 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
   out << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if ((*f_iter)->get_req() == t_field::T_REQUIRED)
-      out <<
-        indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << endl <<
-        indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
+      out << indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << endl << indent()
+          << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
   }
 
   indent(out) << "return xfer;" << endl;
 
   indent_down();
-  indent(out) <<
-    "}" << endl << endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1545,35 +1378,28 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
  * @param out Stream to write to
  * @param tstruct The struct
  */
-void t_cpp_generator::generate_struct_writer(ofstream& out,
-                                             t_struct* tstruct,
-                                             bool pointers) {
+void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, bool pointers) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
 
   if (gen_templates_) {
-    out <<
-      indent() << "template <class Protocol_>" << endl <<
-      indent() << "uint32_t " << tstruct->get_name() <<
-      "::write(Protocol_* oprot) const {" << endl;
+    out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
+        << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl;
   } else {
-    indent(out) <<
-      "uint32_t " << tstruct->get_name() <<
-      "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+    indent(out) << "uint32_t " << tstruct->get_name()
+                << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
   }
   indent_up();
 
-  out <<
-    indent() << "uint32_t xfer = 0;" << endl;
+  out << indent() << "uint32_t xfer = 0;" << endl;
 
   indent(out) << "oprot->incrementRecursionDepth();" << endl;
-  indent(out) <<
-    "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+  indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
 
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    bool check_if_set = (*f_iter)->get_req() == t_field::T_OPTIONAL ||
-                        (*f_iter)->get_type()->is_xception();
+    bool check_if_set = (*f_iter)->get_req() == t_field::T_OPTIONAL
+                        || (*f_iter)->get_type()->is_xception();
     if (check_if_set) {
       out << endl << indent() << "if (this->__isset." << (*f_iter)->get_name() << ") {" << endl;
       indent_up();
@@ -1582,11 +1408,9 @@ void t_cpp_generator::generate_struct_writer(ofstream& out,
     }
 
     // Write field header
-    out <<
-      indent() << "xfer += oprot->writeFieldBegin(" <<
-      "\"" << (*f_iter)->get_name() << "\", " <<
-      type_to_enum((*f_iter)->get_type()) << ", " <<
-      (*f_iter)->get_key() << ");" << endl;
+    out << indent() << "xfer += oprot->writeFieldBegin("
+        << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
+        << (*f_iter)->get_key() << ");" << endl;
     // Write field contents
     if (pointers && !(*f_iter)->get_type()->is_xception()) {
       generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1594,8 +1418,7 @@ void t_cpp_generator::generate_struct_writer(ofstream& out,
       generate_serialize_field(out, *f_iter, "this->");
     }
     // Write field closer
-    indent(out) <<
-      "xfer += oprot->writeFieldEnd();" << endl;
+    indent(out) << "xfer += oprot->writeFieldEnd();" << endl;
     if (check_if_set) {
       indent_down();
       indent(out) << '}';
@@ -1605,16 +1428,12 @@ void t_cpp_generator::generate_struct_writer(ofstream& out,
   out << endl;
 
   // Write the struct map
-  out <<
-    indent() << "xfer += oprot->writeFieldStop();" << endl <<
-    indent() << "xfer += oprot->writeStructEnd();" << endl <<
-    indent() << "oprot->decrementRecursionDepth();" << endl <<
-    indent() << "return xfer;" << endl;
+  out << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
+      << "xfer += oprot->writeStructEnd();" << endl << indent()
+      << "oprot->decrementRecursionDepth();" << endl << indent() << "return xfer;" << endl;
 
   indent_down();
-  indent(out) <<
-    "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1633,35 +1452,25 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
   vector<t_field*>::const_iterator f_iter;
 
   if (gen_templates_) {
-    out <<
-      indent() << "template <class Protocol_>" << endl <<
-      indent() << "uint32_t " << tstruct->get_name() <<
-      "::write(Protocol_* oprot) const {" << endl;
+    out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
+        << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl;
   } else {
-    indent(out) <<
-      "uint32_t " << tstruct->get_name() <<
-      "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+    indent(out) << "uint32_t " << tstruct->get_name()
+                << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
   }
   indent_up();
 
-  out <<
-    endl <<
-    indent() << "uint32_t xfer = 0;" << endl <<
-    endl;
+  out << endl << indent() << "uint32_t xfer = 0;" << endl << endl;
 
-  indent(out) <<
-    "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+  indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
 
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out <<
-        endl <<
-        indent() << "if ";
+      out << endl << indent() << "if ";
     } else {
-      out <<
-        " else if ";
+      out << " else if ";
     }
 
     out << "(this->__isset." << (*f_iter)->get_name() << ") {" << endl;
@@ -1669,11 +1478,9 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
     indent_up();
 
     // Write field header
-    out <<
-      indent() << "xfer += oprot->writeFieldBegin(" <<
-      "\"" << (*f_iter)->get_name() << "\", " <<
-      type_to_enum((*f_iter)->get_type()) << ", " <<
-      (*f_iter)->get_key() << ");" << endl;
+    out << indent() << "xfer += oprot->writeFieldBegin("
+        << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
+        << (*f_iter)->get_key() << ");" << endl;
     // Write field contents
     if (pointers) {
       generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1688,16 +1495,11 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
   }
 
   // Write the struct map
-  out <<
-    endl <<
-    indent() << "xfer += oprot->writeFieldStop();" << endl <<
-    indent() << "xfer += oprot->writeStructEnd();" << endl <<
-    indent() << "return xfer;" << endl;
+  out << endl << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
+      << "xfer += oprot->writeStructEnd();" << endl << indent() << "return xfer;" << endl;
 
   indent_down();
-  indent(out) <<
-    "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1707,93 +1509,76 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
  * @param tstruct The struct
  */
 void t_cpp_generator::generate_struct_swap(ofstream& out, t_struct* tstruct) {
-  out <<
-    indent() << "void swap(" << tstruct->get_name() << " &a, " <<
-    tstruct->get_name() << " &b) {" << endl;
+  out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
+      << " &b) {" << endl;
   indent_up();
 
   // Let argument-dependent name lookup find the correct swap() function to
   // use based on the argument types.  If none is found in the arguments'
   // namespaces, fall back to ::std::swap().
-  out <<
-    indent() << "using ::std::swap;" << endl;
+  out << indent() << "using ::std::swap;" << endl;
 
   bool has_nonrequired_fields = false;
   const vector<t_field*>& fields = tstruct->get_members();
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
-    t_field *tfield = *f_iter;
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    t_field* tfield = *f_iter;
 
     if (tfield->get_req() != t_field::T_REQUIRED) {
       has_nonrequired_fields = true;
     }
 
-    out <<
-      indent() << "swap(a." << tfield->get_name() <<
-      ", b." << tfield->get_name() << ");" << endl;
+    out << indent() << "swap(a." << tfield->get_name() << ", b." << tfield->get_name() << ");"
+        << endl;
   }
 
   if (has_nonrequired_fields) {
-    out <<
-      indent() << "swap(a.__isset, b.__isset);" << endl;
+    out << indent() << "swap(a.__isset, b.__isset);" << endl;
   }
 
   // handle empty structs
   if (fields.size() == 0) {
-    out <<
-      indent() << "(void) a;" << endl;
-    out <<
-      indent() << "(void) b;" << endl;
+    out << indent() << "(void) a;" << endl;
+    out << indent() << "(void) b;" << endl;
   }
 
   scope_down(out);
   out << endl;
 }
 
-void t_cpp_generator::generate_struct_ostream_operator_decl(std::ofstream& out,
-                                                            t_struct* tstruct) {
-  out << "std::ostream& operator<<(std::ostream& out, const "
-      << tstruct->get_name() << "& obj)";
+void t_cpp_generator::generate_struct_ostream_operator_decl(std::ofstream& out, t_struct* tstruct) {
+  out << "std::ostream& operator<<(std::ostream& out, const " << tstruct->get_name() << "& obj)";
 }
 
-namespace struct_ostream_operator_generator
-{
-void generate_required_field_value(std::ofstream& out, const t_field* field)
-{
+namespace struct_ostream_operator_generator {
+void generate_required_field_value(std::ofstream& out, const t_field* field) {
   out << " << to_string(obj." << field->get_name() << ")";
 }
 
-void generate_optional_field_value(std::ofstream& out, const t_field* field)
-{
+void generate_optional_field_value(std::ofstream& out, const t_field* field) {
   out << "; (obj.__isset." << field->get_name() << " ? (out";
   generate_required_field_value(out, field);
   out << ") : (out << \"<null>\"))";
 }
 
-void generate_field_value(std::ofstream& out, const t_field* field)
-{
+void generate_field_value(std::ofstream& out, const t_field* field) {
   if (field->get_req() == t_field::T_OPTIONAL)
     generate_optional_field_value(out, field);
   else
     generate_required_field_value(out, field);
 }
 
-void generate_field_name(std::ofstream& out, const t_field* field)
-{
+void generate_field_name(std::ofstream& out, const t_field* field) {
   out << "\"" << field->get_name() << "=\"";
 }
 
-void generate_field(std::ofstream& out, const t_field* field)
-{
+void generate_field(std::ofstream& out, const t_field* field) {
   generate_field_name(out, field);
   generate_field_value(out, field);
 }
 
 void generate_fields(std::ofstream& out,
                      const vector<t_field*>& fields,
-                     const std::string& indent)
-{
+                     const std::string& indent) {
   const vector<t_field*>::const_iterator beg = fields.begin();
   const vector<t_field*>::const_iterator end = fields.end();
 
@@ -1808,45 +1593,35 @@ void generate_fields(std::ofstream& out,
     out << ";" << endl;
   }
 }
-
-
 }
 
 /**
  * Generates operator<<
  */
-void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out,
-                                                       t_struct* tstruct) {
+void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out, t_struct* tstruct) {
   out << indent();
   generate_struct_ostream_operator_decl(out, tstruct);
   out << " {" << endl;
 
   indent_up();
 
-  out <<
-    indent() << "using apache::thrift::to_string;" << endl;
+  out << indent() << "using apache::thrift::to_string;" << endl;
 
   // eliminate compiler unused warning
   const vector<t_field*>& fields = tstruct->get_members();
   if (fields.empty())
     out << indent() << "(void) obj;" << endl;
 
-  out <<
-    indent() << "out << \"" << tstruct->get_name() << "(\";" << endl;
+  out << indent() << "out << \"" << tstruct->get_name() << "(\";" << endl;
 
-  struct_ostream_operator_generator::generate_fields(out,
-                                                     fields,
-                                                     indent());
+  struct_ostream_operator_generator::generate_fields(out, fields, indent());
 
-  out <<
-    indent() << "out << \")\";" << endl <<
-    indent() << "return out;" << endl;
+  out << indent() << "out << \")\";" << endl << indent() << "return out;" << endl;
 
   indent_down();
   out << "}" << endl << endl;
 }
 
-
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1859,85 +1634,62 @@ void t_cpp_generator::generate_service(t_service* tservice) {
   string svcname = tservice->get_name();
 
   // Make output files
-  string f_header_name = get_out_dir()+svcname+".h";
+  string f_header_name = get_out_dir() + svcname + ".h";
   f_header_.open(f_header_name.c_str());
 
   // Print header file includes
-  f_header_ <<
-    autogen_comment();
-  f_header_ <<
-    "#ifndef " << svcname << "_H" << endl <<
-    "#define " << svcname << "_H" << endl <<
-    endl;
+  f_header_ << autogen_comment();
+  f_header_ << "#ifndef " << svcname << "_H" << endl << "#define " << svcname << "_H" << endl
+            << endl;
   if (gen_cob_style_) {
-    f_header_ <<
-      "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
-      "#include <thrift/cxxfunctional.h>" << endl <<
-      "namespace apache { namespace thrift { namespace async {" << endl <<
-      "class TAsyncChannel;" << endl <<
-      "}}}" << endl;
-  }
-  f_header_ <<
-    "#include <thrift/TDispatchProcessor.h>" << endl;
+    f_header_ << "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
+        "#include <thrift/cxxfunctional.h>" << endl
+              << "namespace apache { namespace thrift { namespace async {" << endl
+              << "class TAsyncChannel;" << endl << "}}}" << endl;
+  }
+  f_header_ << "#include <thrift/TDispatchProcessor.h>" << endl;
   if (gen_cob_style_) {
-    f_header_ <<
-      "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
+    f_header_ << "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
   }
-  f_header_ <<
-    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-    "_types.h\"" << endl;
+  f_header_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ << "_types.h\""
+            << endl;
 
   t_service* extends_service = tservice->get_extends();
   if (extends_service != NULL) {
-    f_header_ <<
-      "#include \"" << get_include_prefix(*(extends_service->get_program())) <<
-      extends_service->get_name() << ".h\"" << endl;
+    f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program()))
+              << extends_service->get_name() << ".h\"" << endl;
   }
 
-  f_header_ <<
-    endl <<
-    ns_open_ << endl <<
-    endl;
+  f_header_ << endl << ns_open_ << endl << endl;
 
   // Service implementation file includes
-  string f_service_name = get_out_dir()+svcname+".cpp";
+  string f_service_name = get_out_dir() + svcname + ".cpp";
   f_service_.open(f_service_name.c_str());
-  f_service_ <<
-    autogen_comment();
-  f_service_ <<
-    "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl;
+  f_service_ << autogen_comment();
+  f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl;
   if (gen_cob_style_) {
-    f_service_ <<
-      "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+    f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
   }
   if (gen_templates_) {
-    f_service_ <<
-      "#include \"" << get_include_prefix(*get_program()) << svcname <<
-      ".tcc\"" << endl;
+    f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\""
+               << endl;
 
-    string f_service_tcc_name = get_out_dir()+svcname+".tcc";
+    string f_service_tcc_name = get_out_dir() + svcname + ".tcc";
     f_service_tcc_.open(f_service_tcc_name.c_str());
-    f_service_tcc_ <<
-      autogen_comment();
-    f_service_tcc_ <<
-      "#include \"" << get_include_prefix(*get_program()) << svcname <<
-      ".h\"" << endl;
+    f_service_tcc_ << autogen_comment();
+    f_service_tcc_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\""
+                   << endl;
 
-    f_service_tcc_ <<
-      "#ifndef " << svcname << "_TCC" << endl <<
-      "#define " << svcname << "_TCC" << endl <<
-      endl;
+    f_service_tcc_ << "#ifndef " << svcname << "_TCC" << endl << "#define " << svcname << "_TCC"
+                   << endl << endl;
 
     if (gen_cob_style_) {
-      f_service_tcc_ <<
-        "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+      f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
     }
   }
 
-  f_service_ <<
-    endl << ns_open_ << endl << endl;
-  f_service_tcc_ <<
-    endl << ns_open_ << endl << endl;
+  f_service_ << endl << ns_open_ << endl << endl;
+  f_service_tcc_ << endl << ns_open_ << endl << endl;
 
   // Generate all the components
   generate_service_interface(tservice, "");
@@ -1961,30 +1713,19 @@ void t_cpp_generator::generate_service(t_service* tservice) {
   }
 
   // Close the namespace
-  f_service_ <<
-    ns_close_ << endl <<
-    endl;
-  f_service_tcc_ <<
-    ns_close_ << endl <<
-    endl;
-  f_header_ <<
-    ns_close_ << endl <<
-    endl;
+  f_service_ << ns_close_ << endl << endl;
+  f_service_tcc_ << ns_close_ << endl << endl;
+  f_header_ << ns_close_ << endl << endl;
 
   // TODO(simpkins): Make this a separate option
   if (gen_templates_) {
-    f_header_ <<
-      "#include \"" << get_include_prefix(*get_program()) << svcname <<
-      ".tcc\"" << endl <<
-      "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
-      "_types.tcc\"" << endl <<
-      endl;
+    f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << endl
+              << "#include \"" << get_include_prefix(*get_program()) << program_name_
+              << "_types.tcc\"" << endl << endl;
   }
 
-  f_header_ <<
-    "#endif" << endl;
-  f_service_tcc_ <<
-    "#endif" << endl;
+  f_header_ << "#endif" << endl;
+  f_service_tcc_ << "#endif" << endl;
 
   // Close the files
   f_service_tcc_.close();
@@ -2037,17 +1778,14 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
     if (gen_templates_) {
       client_name += "T";
       service_if_name += "T";
-      indent(f_header_) <<
-        "template <class Protocol_>" << endl;
+      indent(f_header_) << "template <class Protocol_>" << endl;
     }
-    indent(f_header_) << "class " << client_name << ";" <<
-      endl << endl;
+    indent(f_header_) << "class " << client_name << ";" << endl << endl;
   }
 
   string extends = "";
   if (tservice->get_extends() != NULL) {
-    extends = " : virtual public " + type_name(tservice->get_extends()) +
-      style + "If";
+    extends = " : virtual public " + type_name(tservice->get_extends()) + style + "If";
     if (style == "CobCl" && gen_templates_) {
       // TODO(simpkins): If gen_templates_ is enabled, we currently assume all
       // parent services were also generated with templates enabled.
@@ -2058,33 +1796,26 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
   if (style == "CobCl" && gen_templates_) {
     f_header_ << "template <class Protocol_>" << endl;
   }
-  f_header_ <<
-    "class " << service_if_name << extends << " {" << endl <<
-    " public:" << endl;
+  f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl;
   indent_up();
-  f_header_ <<
-    indent() << "virtual ~" << service_if_name << "() {}" << endl;
+  f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl;
 
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    if ((*f_iter)->has_doc()) f_header_ << endl;
+    if ((*f_iter)->has_doc())
+      f_header_ << endl;
     generate_java_doc(f_header_, *f_iter);
-    f_header_ <<
-      indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << endl;
+    f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << endl;
   }
   indent_down();
-  f_header_ <<
-    "};" << endl << endl;
+  f_header_ << "};" << endl << endl;
 
   if (style == "CobCl" && gen_templates_) {
     // generate a backwards-compatible typedef for clients that do not
     // know about the new template-style code
-    f_header_ <<
-      "typedef " << service_if_name <<
-      "< ::apache::thrift::protocol::TProtocol> " <<
-      service_name_ << style << "If;" <<
-      endl << endl;
+    f_header_ << "typedef " << service_if_name << "< ::apache::thrift::protocol::TProtocol> "
+              << service_name_ << style << "If;" << endl << endl;
   }
 }
 
@@ -2093,8 +1824,7 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
  *
  * @param tservice The service to generate an interface factory for.
  */
-void t_cpp_generator::generate_service_interface_factory(t_service* tservice,
-                                                         string style) {
+void t_cpp_generator::generate_service_interface_factory(t_service* tservice, string style) {
   string service_if_name = service_name_ + style + "If";
 
   // Figure out the name of the upper-most parent class.
@@ -2125,56 +1855,38 @@ void t_cpp_generator::generate_service_interface_factory(t_service* tservice,
   string factory_name = service_if_name + "Factory";
   string extends;
   if (tservice->get_extends() != NULL) {
-    extends = " : virtual public " + type_name(tservice->get_extends()) +
-      style + "IfFactory";
+    extends = " : virtual public " + type_name(tservice->get_extends()) + style + "IfFactory";
   }
 
-  f_header_ <<
-    "class " << factory_name << extends << " {" << endl <<
-    " public:" << endl;
+  f_header_ << "class " << factory_name << extends << " {" << endl << " public:" << endl;
   indent_up();
-  f_header_ <<
-    indent() << "typedef " << service_if_name << " Handler;" << endl <<
-    endl <<
-    indent() << "virtual ~" << factory_name << "() {}" << endl <<
-    endl <<
-    indent() << "virtual " << service_if_name << "* getHandler(" <<
-      "const ::apache::thrift::TConnectionInfo& connInfo) = 0;" <<
-    endl <<
-    indent() << "virtual void releaseHandler(" << base_if_name <<
-    "* /* handler */) = 0;" << endl;
+  f_header_ << indent() << "typedef " << service_if_name << " Handler;" << endl << endl << indent()
+            << "virtual ~" << factory_name << "() {}" << endl << endl << indent() << "virtual "
+            << service_if_name << "* getHandler("
+            << "const ::apache::thrift::TConnectionInfo& connInfo) = 0;" << endl << indent()
+            << "virtual void releaseHandler(" << base_if_name << "* /* handler */) = 0;" << endl;
 
   indent_down();
-  f_header_ <<
-    "};" << endl << endl;
+  f_header_ << "};" << endl << endl;
 
   // Generate the singleton factory class
   string singleton_factory_name = service_if_name + "SingletonFactory";
-  f_header_ <<
-    "class " << singleton_factory_name <<
-    " : virtual public " << factory_name << " {" << endl <<
-    " public:" << endl;
+  f_header_ << "class " << singleton_factory_name << " : virtual public " << factory_name << " {"
+            << endl << " public:" << endl;
   indent_up();
-  f_header_ <<
-    indent() << singleton_factory_name << "(const boost::shared_ptr<" <<
-    service_if_name << ">& iface) : iface_(iface) {}" << endl <<
-    indent() << "virtual ~" << singleton_factory_name << "() {}" << endl <<
-    endl <<
-    indent() << "virtual " << service_if_name << "* getHandler(" <<
-      "const ::apache::thrift::TConnectionInfo&) {" << endl <<
-    indent() << "  return iface_.get();" << endl <<
-    indent() << "}" << endl <<
-    indent() << "virtual void releaseHandler(" << base_if_name <<
-    "* /* handler */) {}" << endl;
-
-  f_header_ <<
-    endl <<
-    " protected:" << endl <<
-    indent() << "boost::shared_ptr<" << service_if_name << "> iface_;" << endl;
+  f_header_ << indent() << singleton_factory_name << "(const boost::shared_ptr<" << service_if_name
+            << ">& iface) : iface_(iface) {}" << endl << indent() << "virtual ~"
+            << singleton_factory_name << "() {}" << endl << endl << indent() << "virtual "
+            << service_if_na

<TRUNCATED>

[11/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/processor/PeekProcessor.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
index 9303a13..8c9a463 100644
--- a/lib/cpp/src/thrift/processor/PeekProcessor.cpp
+++ b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
@@ -23,13 +23,16 @@ using namespace apache::thrift::transport;
 using namespace apache::thrift::protocol;
 using namespace apache::thrift;
 
-namespace apache { namespace thrift { namespace processor {
+namespace apache {
+namespace thrift {
+namespace processor {
 
 PeekProcessor::PeekProcessor() {
   memoryBuffer_.reset(new TMemoryBuffer());
   targetTransport_ = memoryBuffer_;
 }
-PeekProcessor::~PeekProcessor() {}
+PeekProcessor::~PeekProcessor() {
+}
 
 void PeekProcessor::initialize(boost::shared_ptr<TProcessor> actualProcessor,
                                boost::shared_ptr<TProtocolFactory> protocolFactory,
@@ -49,11 +52,13 @@ void PeekProcessor::setTargetTransport(boost::shared_ptr<TTransport> targetTrans
   if (boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport_)) {
     memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport);
   } else if (boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)) {
-    memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>(boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport());
+    memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>(
+        boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport());
   }
 
   if (!memoryBuffer_) {
-    throw TException("Target transport must be a TMemoryBuffer or a TPipedTransport with TMemoryBuffer");
+    throw TException(
+        "Target transport must be a TMemoryBuffer or a TPipedTransport with TMemoryBuffer");
   }
 }
 
@@ -107,21 +112,21 @@ bool PeekProcessor::process(boost::shared_ptr<TProtocol> in,
 }
 
 void PeekProcessor::peekName(const std::string& fname) {
-  (void) fname;
+  (void)fname;
 }
 
 void PeekProcessor::peekBuffer(uint8_t* buffer, uint32_t size) {
-  (void) buffer;
-  (void) size;
+  (void)buffer;
+  (void)size;
 }
 
-void PeekProcessor::peek(boost::shared_ptr<TProtocol> in,
-                         TType ftype,
-                         int16_t fid) {
-  (void) fid;
+void PeekProcessor::peek(boost::shared_ptr<TProtocol> in, TType ftype, int16_t fid) {
+  (void)fid;
   in->skip(ftype);
 }
 
-void PeekProcessor::peekEnd() {}
-
-}}}
+void PeekProcessor::peekEnd() {
+}
+}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/processor/PeekProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.h b/lib/cpp/src/thrift/processor/PeekProcessor.h
index 9cfb35a..21c5999 100644
--- a/lib/cpp/src/thrift/processor/PeekProcessor.h
+++ b/lib/cpp/src/thrift/processor/PeekProcessor.h
@@ -27,7 +27,9 @@
 #include <thrift/transport/TBufferTransports.h>
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace processor {
+namespace apache {
+namespace thrift {
+namespace processor {
 
 /*
  * Class for peeking at the raw data that is being processed by another processor
@@ -36,7 +38,7 @@ namespace apache { namespace thrift { namespace processor {
  */
 class PeekProcessor : public apache::thrift::TProcessor {
 
- public:
+public:
   PeekProcessor();
   virtual ~PeekProcessor();
 
@@ -44,11 +46,13 @@ class PeekProcessor : public apache::thrift::TProcessor {
   //             protocolFactory  - the protocol factory used to wrap the memory buffer
   //             transportFactory - this TPipedTransportFactory is used to wrap the source transport
   //                                via a call to getPipedTransport
-  void initialize(boost::shared_ptr<apache::thrift::TProcessor> actualProcessor,
-                  boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
-                  boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory);
+  void initialize(
+      boost::shared_ptr<apache::thrift::TProcessor> actualProcessor,
+      boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
+      boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory);
 
-  boost::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport(boost::shared_ptr<apache::thrift::transport::TTransport> in);
+  boost::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport(
+      boost::shared_ptr<apache::thrift::transport::TTransport> in);
 
   void setTargetTransport(boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport);
 
@@ -65,14 +69,15 @@ class PeekProcessor : public apache::thrift::TProcessor {
                     int16_t fid);
   virtual void peekEnd();
 
- private:
+private:
   boost::shared_ptr<apache::thrift::TProcessor> actualProcessor_;
   boost::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_;
   boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_;
   boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_;
   boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport_;
 };
-
-}}} // apache::thrift::processor
+}
+}
+} // apache::thrift::processor
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/processor/StatsProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/processor/StatsProcessor.h b/lib/cpp/src/thrift/processor/StatsProcessor.h
index 0fc123e..e8ca067 100644
--- a/lib/cpp/src/thrift/processor/StatsProcessor.h
+++ b/lib/cpp/src/thrift/processor/StatsProcessor.h
@@ -25,7 +25,9 @@
 #include <thrift/protocol/TProtocol.h>
 #include <TProcessor.h>
 
-namespace apache { namespace thrift { namespace processor {
+namespace apache {
+namespace thrift {
+namespace processor {
 
 /*
  * Class for keeping track of function call statistics and printing them if desired
@@ -33,11 +35,8 @@ namespace apache { namespace thrift { namespace processor {
  */
 class StatsProcessor : public apache::thrift::TProcessor {
 public:
-  StatsProcessor(bool print, bool frequency)
-    : print_(print),
-      frequency_(frequency)
-  {}
-  virtual ~StatsProcessor() {};
+  StatsProcessor(bool print, bool frequency) : print_(print), frequency_(frequency) {}
+  virtual ~StatsProcessor(){};
 
   virtual bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot,
                        boost::shared_ptr<apache::thrift::protocol::TProtocol> poprot,
@@ -88,169 +87,145 @@ public:
     return true;
   }
 
-  const std::map<std::string, int64_t>& get_frequency_map() {
-    return frequency_map_;
-  }
+  const std::map<std::string, int64_t>& get_frequency_map() { return frequency_map_; }
 
 protected:
   void printAndPassToBuffer(apache::thrift::protocol::TType ftype) {
     switch (ftype) {
-      case apache::thrift::protocol::T_BOOL:
-        {
-          bool boolv;
-          piprot_->readBool(boolv);
-          if (print_) {
-            printf("%d", boolv);
-          }
-        }
-        break;
-      case apache::thrift::protocol::T_BYTE:
-        {
-          int8_t bytev;
-          piprot_->readByte(bytev);
-          if (print_) {
-            printf("%d", bytev);
-          }
-        }
-        break;
-      case apache::thrift::protocol::T_I16:
-        {
-          int16_t i16;
-          piprot_->readI16(i16);
-          if (print_) {
-            printf("%d", i16);
-          }
-        }
-        break;
-      case apache::thrift::protocol::T_I32:
-        {
-          int32_t i32;
-          piprot_->readI32(i32);
-          if (print_) {
-            printf("%d", i32);
-          }
-        }
-        break;
-      case apache::thrift::protocol::T_I64:
-        {
-          int64_t i64;
-          piprot_->readI64(i64);
-          if (print_) {
-            printf("%ld", i64);
-          }
+    case apache::thrift::protocol::T_BOOL: {
+      bool boolv;
+      piprot_->readBool(boolv);
+      if (print_) {
+        printf("%d", boolv);
+      }
+    } break;
+    case apache::thrift::protocol::T_BYTE: {
+      int8_t bytev;
+      piprot_->readByte(bytev);
+      if (print_) {
+        printf("%d", bytev);
+      }
+    } break;
+    case apache::thrift::protocol::T_I16: {
+      int16_t i16;
+      piprot_->readI16(i16);
+      if (print_) {
+        printf("%d", i16);
+      }
+    } break;
+    case apache::thrift::protocol::T_I32: {
+      int32_t i32;
+      piprot_->readI32(i32);
+      if (print_) {
+        printf("%d", i32);
+      }
+    } break;
+    case apache::thrift::protocol::T_I64: {
+      int64_t i64;
+      piprot_->readI64(i64);
+      if (print_) {
+        printf("%ld", i64);
+      }
+    } break;
+    case apache::thrift::protocol::T_DOUBLE: {
+      double dub;
+      piprot_->readDouble(dub);
+      if (print_) {
+        printf("%f", dub);
+      }
+    } break;
+    case apache::thrift::protocol::T_STRING: {
+      std::string str;
+      piprot_->readString(str);
+      if (print_) {
+        printf("%s", str.c_str());
+      }
+    } break;
+    case apache::thrift::protocol::T_STRUCT: {
+      std::string name;
+      int16_t fid;
+      apache::thrift::protocol::TType ftype;
+      piprot_->readStructBegin(name);
+      if (print_) {
+        printf("<");
+      }
+      while (true) {
+        piprot_->readFieldBegin(name, ftype, fid);
+        if (ftype == apache::thrift::protocol::T_STOP) {
+          break;
         }
-        break;
-      case apache::thrift::protocol::T_DOUBLE:
-        {
-          double dub;
-          piprot_->readDouble(dub);
-          if (print_) {
-            printf("%f", dub);
-          }
+        printAndPassToBuffer(ftype);
+        if (print_) {
+          printf(",");
         }
-        break;
-      case apache::thrift::protocol::T_STRING:
-        {
-          std::string str;
-          piprot_->readString(str);
-          if (print_) {
-            printf("%s", str.c_str());
-          }
+        piprot_->readFieldEnd();
+      }
+      piprot_->readStructEnd();
+      if (print_) {
+        printf("\b>");
+      }
+    } break;
+    case apache::thrift::protocol::T_MAP: {
+      apache::thrift::protocol::TType keyType;
+      apache::thrift::protocol::TType valType;
+      uint32_t i, size;
+      piprot_->readMapBegin(keyType, valType, size);
+      if (print_) {
+        printf("{");
+      }
+      for (i = 0; i < size; i++) {
+        printAndPassToBuffer(keyType);
+        if (print_) {
+          printf("=>");
         }
-        break;
-      case apache::thrift::protocol::T_STRUCT:
-        {
-          std::string name;
-          int16_t fid;
-          apache::thrift::protocol::TType ftype;
-          piprot_->readStructBegin(name);
-          if (print_) {
-            printf("<");
-          }
-          while (true) {
-            piprot_->readFieldBegin(name, ftype, fid);
-            if (ftype == apache::thrift::protocol::T_STOP) {
-              break;
-            }
-            printAndPassToBuffer(ftype);
-            if (print_) {
-              printf(",");
-            }
-            piprot_->readFieldEnd();
-          }
-          piprot_->readStructEnd();
-          if (print_) {
-            printf("\b>");
-          }
+        printAndPassToBuffer(valType);
+        if (print_) {
+          printf(",");
         }
-        break;
-      case apache::thrift::protocol::T_MAP:
-        {
-          apache::thrift::protocol::TType keyType;
-          apache::thrift::protocol::TType valType;
-          uint32_t i, size;
-          piprot_->readMapBegin(keyType, valType, size);
-          if (print_) {
-            printf("{");
-          }
-          for (i = 0; i < size; i++) {
-            printAndPassToBuffer(keyType);
-            if (print_) {
-              printf("=>");
-            }
-            printAndPassToBuffer(valType);
-            if (print_) {
-              printf(",");
-            }
-          }
-          piprot_->readMapEnd();
-          if (print_) {
-            printf("\b}");
-          }
-        }
-        break;
-      case apache::thrift::protocol::T_SET:
-        {
-          apache::thrift::protocol::TType elemType;
-          uint32_t i, size;
-          piprot_->readSetBegin(elemType, size);
-          if (print_) {
-            printf("{");
-          }
-          for (i = 0; i < size; i++) {
-            printAndPassToBuffer(elemType);
-            if (print_) {
-              printf(",");
-            }
-          }
-          piprot_->readSetEnd();
-          if (print_) {
-            printf("\b}");
-          }
+      }
+      piprot_->readMapEnd();
+      if (print_) {
+        printf("\b}");
+      }
+    } break;
+    case apache::thrift::protocol::T_SET: {
+      apache::thrift::protocol::TType elemType;
+      uint32_t i, size;
+      piprot_->readSetBegin(elemType, size);
+      if (print_) {
+        printf("{");
+      }
+      for (i = 0; i < size; i++) {
+        printAndPassToBuffer(elemType);
+        if (print_) {
+          printf(",");
         }
-        break;
-      case apache::thrift::protocol::T_LIST:
-        {
-          apache::thrift::protocol::TType elemType;
-          uint32_t i, size;
-          piprot_->readListBegin(elemType, size);
-          if (print_) {
-            printf("[");
-          }
-          for (i = 0; i < size; i++) {
-            printAndPassToBuffer(elemType);
-            if (print_) {
-              printf(",");
-            }
-          }
-          piprot_->readListEnd();
-          if (print_) {
-            printf("\b]");
-          }
+      }
+      piprot_->readSetEnd();
+      if (print_) {
+        printf("\b}");
+      }
+    } break;
+    case apache::thrift::protocol::T_LIST: {
+      apache::thrift::protocol::TType elemType;
+      uint32_t i, size;
+      piprot_->readListBegin(elemType, size);
+      if (print_) {
+        printf("[");
+      }
+      for (i = 0; i < size; i++) {
+        printAndPassToBuffer(elemType);
+        if (print_) {
+          printf(",");
         }
-        break;
-      default:
-        break;
+      }
+      piprot_->readListEnd();
+      if (print_) {
+        printf("\b]");
+      }
+    } break;
+    default:
+      break;
     }
   }
 
@@ -260,7 +235,8 @@ protected:
   bool print_;
   bool frequency_;
 };
-
-}}} // apache::thrift::processor
+}
+}
+} // apache::thrift::processor
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
index a352d90..a97f6a9 100644
--- a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
+++ b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
@@ -25,194 +25,177 @@
 #include <thrift/TProcessor.h>
 #include <boost/tokenizer.hpp>
 
-namespace apache
-{
-    namespace thrift
-    {
-        using boost::shared_ptr;
-
-        namespace protocol {
-
-            /**
-             *  To be able to work with any protocol, we needed
-             *  to allow them to call readMessageBegin() and get a TMessage in exactly
-             *  the standard format, without the service name prepended to TMessage.name.
-             */
-            class StoredMessageProtocol : public TProtocolDecorator
-            {
-            public:
-                StoredMessageProtocol( shared_ptr<protocol::TProtocol> _protocol,
-                    const std::string& _name, const TMessageType _type,
-                    const int32_t _seqid) :
-                    TProtocolDecorator(_protocol),
-                    name(_name),
-                    type(_type),
-                    seqid(_seqid)
-                {
-                }
-
-                uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid)
-                {
-
-                    _name  = name;
-                    _type  = type;
-                    _seqid = seqid;
-
-                    return 0; // (Normal TProtocol read functions return number of bytes read)
-                }
-
-                std::string name;
-                TMessageType type;
-                int32_t seqid;
-            };
-        } //namespace protocol
-
-        /**
-         * <code>TMultiplexedProcessor</code> is a <code>TProcessor</code> allowing
-         * a single <code>TServer</code> to provide multiple services.
-         *
-         * <p>To do so, you instantiate the processor and then register additional
-         * processors with it, as shown in the following example:</p>
-         *
-         * <blockquote><code>
-         *     shared_ptr<TMultiplexedProcessor> processor(new TMultiplexedProcessor());
-         *
-         *     processor->registerProcessor(
-         *         "Calculator",
-         *         shared_ptr<TProcessor>( new CalculatorProcessor(
-         *             shared_ptr<CalculatorHandler>( new CalculatorHandler()))));
-         *
-         *     processor->registerProcessor(
-         *         "WeatherReport",
-         *         shared_ptr<TProcessor>( new WeatherReportProcessor(
-         *             shared_ptr<WeatherReportHandler>( new WeatherReportHandler()))));
-         *
-         *     shared_ptr<TServerTransport> transport(new TServerSocket(9090));
-         *     TSimpleServer server(processor, transport);
-         *
-         *     server.serve();
-         * </code></blockquote>
-         */
-        class TMultiplexedProcessor : public TProcessor
-        {
-        public:
-            typedef std::map< std::string, shared_ptr<TProcessor> > services_t;
-
-           /**
-             * 'Register' a service with this <code>TMultiplexedProcessor</code>.  This
-             * allows us to broker requests to individual services by using the service
-             * name to select them at request time.
-             *
-             * \param [in] serviceName Name of a service, has to be identical to the name
-             *                         declared in the Thrift IDL, e.g. "WeatherReport".
-             * \param [in] processor   Implementation of a service, ususally referred to
-             *                         as "handlers", e.g. WeatherReportHandler,
-             *                         implementing WeatherReportIf interface.
-             */
-            void registerProcessor( const std::string & serviceName,
-                                    shared_ptr<TProcessor> processor )
-            {
-                services[serviceName] = processor;
-            }
-
-            /**
-             * This implementation of <code>process</code> performs the following steps:
-             *
-             * <ol>
-             *     <li>Read the beginning of the message.</li>
-             *     <li>Extract the service name from the message.</li>
-             *     <li>Using the service name to locate the appropriate processor.</li>
-             *     <li>Dispatch to the processor, with a decorated instance of TProtocol
-             *         that allows readMessageBegin() to return the original TMessage.</li>
-             * </ol>
-             *
-             * \throws TException If the message type is not T_CALL or T_ONEWAY, if
-             * the service name was not found in the message, or if the service
-             * name was not found in the service map.
-             */
-            bool process( shared_ptr<protocol::TProtocol> in,
-                          shared_ptr<protocol::TProtocol> out,
-                          void *connectionContext)
-            {
-                std::string name;
-                protocol::TMessageType type;
-                int32_t seqid;
-
-                // Use the actual underlying protocol (e.g. TBinaryProtocol) to read the
-                // message header.  This pulls the message "off the wire", which we'll
-                // deal with at the end of this method.
-                in->readMessageBegin(name, type, seqid);
-
-                if( type != protocol::T_CALL && type != protocol::T_ONEWAY ) {
-                    // Unexpected message type.
-                    in->skip(::apache::thrift::protocol::T_STRUCT);
-                    in->readMessageEnd();
-                    in->getTransport()->readEnd();
-                    const std::string msg("TMultiplexedProcessor: Unexpected message type");
-                    ::apache::thrift::TApplicationException x(
-                        ::apache::thrift::TApplicationException::PROTOCOL_ERROR,
-                        msg);
-                    out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid);
-                    x.write(out.get());
-                    out->writeMessageEnd();
-                    out->getTransport()->writeEnd();
-                    out->getTransport()->flush();
-                    throw TException(msg);
-                }
-
-                // Extract the service name
-
-                boost::tokenizer<boost::char_separator<char> > tok( name, boost::char_separator<char>(":") );
-
-                std::vector<std::string> tokens;
-                std::copy( tok.begin(), tok.end(), std::back_inserter(tokens) );
-
-                // A valid message should consist of two tokens: the service
-                // name and the name of the method to call.
-                if( tokens.size() == 2 )
-                {
-                    // Search for a processor associated with this service name.
-                    services_t::iterator it = services.find(tokens[0]);
-
-                    if( it != services.end() )
-                    {
-                        shared_ptr<TProcessor> processor = it->second;
-                        // Let the processor registered for this service name
-                        // process the message.
-                        return processor->process(
-                            shared_ptr<protocol::TProtocol>(
-                                new protocol::StoredMessageProtocol( in, tokens[1], type, seqid ) ),
-                            out, connectionContext );
-                    }
-                    else
-                    {
-                        // Unknown service.
-                        in->skip(::apache::thrift::protocol::T_STRUCT);
-                        in->readMessageEnd();
-                        in->getTransport()->readEnd();
-
-                        std::string msg("TMultiplexedProcessor: Unknown service: ");
-                        msg += tokens[0];
-                        ::apache::thrift::TApplicationException x(
-                            ::apache::thrift::TApplicationException::PROTOCOL_ERROR,
-                            msg);
-                        out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid);
-                        x.write(out.get());
-                        out->writeMessageEnd();
-                        out->getTransport()->writeEnd();
-                        out->getTransport()->flush();
-                        msg += ". Did you forget to call registerProcessor()?";
-                        throw TException(msg);
-                    }
-                }
-                return false;
-            }
-
-        private:
-            /** Map of service processor objects, indexed by service names. */
-            services_t services;
-        };
+namespace apache {
+namespace thrift {
+using boost::shared_ptr;
+
+namespace protocol {
+
+/**
+ *  To be able to work with any protocol, we needed
+ *  to allow them to call readMessageBegin() and get a TMessage in exactly
+ *  the standard format, without the service name prepended to TMessage.name.
+ */
+class StoredMessageProtocol : public TProtocolDecorator {
+public:
+  StoredMessageProtocol(shared_ptr<protocol::TProtocol> _protocol,
+                        const std::string& _name,
+                        const TMessageType _type,
+                        const int32_t _seqid)
+    : TProtocolDecorator(_protocol), name(_name), type(_type), seqid(_seqid) {}
+
+  uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid) {
+
+    _name = name;
+    _type = type;
+    _seqid = seqid;
+
+    return 0; // (Normal TProtocol read functions return number of bytes read)
+  }
+
+  std::string name;
+  TMessageType type;
+  int32_t seqid;
+};
+} // namespace protocol
+
+/**
+ * <code>TMultiplexedProcessor</code> is a <code>TProcessor</code> allowing
+ * a single <code>TServer</code> to provide multiple services.
+ *
+ * <p>To do so, you instantiate the processor and then register additional
+ * processors with it, as shown in the following example:</p>
+ *
+ * <blockquote><code>
+ *     shared_ptr<TMultiplexedProcessor> processor(new TMultiplexedProcessor());
+ *
+ *     processor->registerProcessor(
+ *         "Calculator",
+ *         shared_ptr<TProcessor>( new CalculatorProcessor(
+ *             shared_ptr<CalculatorHandler>( new CalculatorHandler()))));
+ *
+ *     processor->registerProcessor(
+ *         "WeatherReport",
+ *         shared_ptr<TProcessor>( new WeatherReportProcessor(
+ *             shared_ptr<WeatherReportHandler>( new WeatherReportHandler()))));
+ *
+ *     shared_ptr<TServerTransport> transport(new TServerSocket(9090));
+ *     TSimpleServer server(processor, transport);
+ *
+ *     server.serve();
+ * </code></blockquote>
+ */
+class TMultiplexedProcessor : public TProcessor {
+public:
+  typedef std::map<std::string, shared_ptr<TProcessor> > services_t;
+
+  /**
+    * 'Register' a service with this <code>TMultiplexedProcessor</code>.  This
+    * allows us to broker requests to individual services by using the service
+    * name to select them at request time.
+    *
+    * \param [in] serviceName Name of a service, has to be identical to the name
+    *                         declared in the Thrift IDL, e.g. "WeatherReport".
+    * \param [in] processor   Implementation of a service, ususally referred to
+    *                         as "handlers", e.g. WeatherReportHandler,
+    *                         implementing WeatherReportIf interface.
+    */
+  void registerProcessor(const std::string& serviceName, shared_ptr<TProcessor> processor) {
+    services[serviceName] = processor;
+  }
+
+  /**
+   * This implementation of <code>process</code> performs the following steps:
+   *
+   * <ol>
+   *     <li>Read the beginning of the message.</li>
+   *     <li>Extract the service name from the message.</li>
+   *     <li>Using the service name to locate the appropriate processor.</li>
+   *     <li>Dispatch to the processor, with a decorated instance of TProtocol
+   *         that allows readMessageBegin() to return the original TMessage.</li>
+   * </ol>
+   *
+   * \throws TException If the message type is not T_CALL or T_ONEWAY, if
+   * the service name was not found in the message, or if the service
+   * name was not found in the service map.
+   */
+  bool process(shared_ptr<protocol::TProtocol> in,
+               shared_ptr<protocol::TProtocol> out,
+               void* connectionContext) {
+    std::string name;
+    protocol::TMessageType type;
+    int32_t seqid;
+
+    // Use the actual underlying protocol (e.g. TBinaryProtocol) to read the
+    // message header.  This pulls the message "off the wire", which we'll
+    // deal with at the end of this method.
+    in->readMessageBegin(name, type, seqid);
+
+    if (type != protocol::T_CALL && type != protocol::T_ONEWAY) {
+      // Unexpected message type.
+      in->skip(::apache::thrift::protocol::T_STRUCT);
+      in->readMessageEnd();
+      in->getTransport()->readEnd();
+      const std::string msg("TMultiplexedProcessor: Unexpected message type");
+      ::apache::thrift::TApplicationException
+          x(::apache::thrift::TApplicationException::PROTOCOL_ERROR, msg);
+      out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+      x.write(out.get());
+      out->writeMessageEnd();
+      out->getTransport()->writeEnd();
+      out->getTransport()->flush();
+      throw TException(msg);
     }
+
+    // Extract the service name
+
+    boost::tokenizer<boost::char_separator<char> > tok(name, boost::char_separator<char>(":"));
+
+    std::vector<std::string> tokens;
+    std::copy(tok.begin(), tok.end(), std::back_inserter(tokens));
+
+    // A valid message should consist of two tokens: the service
+    // name and the name of the method to call.
+    if (tokens.size() == 2) {
+      // Search for a processor associated with this service name.
+      services_t::iterator it = services.find(tokens[0]);
+
+      if (it != services.end()) {
+        shared_ptr<TProcessor> processor = it->second;
+        // Let the processor registered for this service name
+        // process the message.
+        return processor
+            ->process(shared_ptr<protocol::TProtocol>(
+                          new protocol::StoredMessageProtocol(in, tokens[1], type, seqid)),
+                      out,
+                      connectionContext);
+      } else {
+        // Unknown service.
+        in->skip(::apache::thrift::protocol::T_STRUCT);
+        in->readMessageEnd();
+        in->getTransport()->readEnd();
+
+        std::string msg("TMultiplexedProcessor: Unknown service: ");
+        msg += tokens[0];
+        ::apache::thrift::TApplicationException
+            x(::apache::thrift::TApplicationException::PROTOCOL_ERROR, msg);
+        out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid);
+        x.write(out.get());
+        out->writeMessageEnd();
+        out->getTransport()->writeEnd();
+        out->getTransport()->flush();
+        msg += ". Did you forget to call registerProcessor()?";
+        throw TException(msg);
+      }
+    }
+    return false;
+  }
+
+private:
+  /** Map of service processor objects, indexed by service names. */
+  services_t services;
+};
+}
 }
 
 #endif // THRIFT_TMULTIPLEXEDPROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TBase64Utils.cpp b/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
index cd343ed..beb76eb 100644
--- a/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
+++ b/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
@@ -23,13 +23,14 @@
 
 using std::string;
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
+static const uint8_t* kBase64EncodeTable
+    = (const uint8_t*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
-static const uint8_t *kBase64EncodeTable = (const uint8_t *)
-  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-void  base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
+void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf) {
   buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3f];
   if (len == 3) {
     buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)];
@@ -38,42 +39,279 @@ void  base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
   } else if (len == 2) {
     buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)];
     buf[2] = kBase64EncodeTable[(in[1] << 2) & 0x3c];
-  } else  { // len == 1
+  } else { // len == 1
     buf[1] = kBase64EncodeTable[(in[0] << 4) & 0x30];
   }
 }
 
-static const uint8_t kBase64DecodeTable[256] ={
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0xff,0xff,0xff,0x3f,
-0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
-0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xff,0xff,0xff,0xff,0xff,
-0xff,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
-0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+static const uint8_t kBase64DecodeTable[256] = {
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0x3e,
+    0xff,
+    0xff,
+    0xff,
+    0x3f,
+    0x34,
+    0x35,
+    0x36,
+    0x37,
+    0x38,
+    0x39,
+    0x3a,
+    0x3b,
+    0x3c,
+    0x3d,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0x00,
+    0x01,
+    0x02,
+    0x03,
+    0x04,
+    0x05,
+    0x06,
+    0x07,
+    0x08,
+    0x09,
+    0x0a,
+    0x0b,
+    0x0c,
+    0x0d,
+    0x0e,
+    0x0f,
+    0x10,
+    0x11,
+    0x12,
+    0x13,
+    0x14,
+    0x15,
+    0x16,
+    0x17,
+    0x18,
+    0x19,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0x1a,
+    0x1b,
+    0x1c,
+    0x1d,
+    0x1e,
+    0x1f,
+    0x20,
+    0x21,
+    0x22,
+    0x23,
+    0x24,
+    0x25,
+    0x26,
+    0x27,
+    0x28,
+    0x29,
+    0x2a,
+    0x2b,
+    0x2c,
+    0x2d,
+    0x2e,
+    0x2f,
+    0x30,
+    0x31,
+    0x32,
+    0x33,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
 };
 
-void base64_decode(uint8_t *buf, uint32_t len) {
-  buf[0] = (kBase64DecodeTable[buf[0]] << 2) |
-           (kBase64DecodeTable[buf[1]] >> 4);
+void base64_decode(uint8_t* buf, uint32_t len) {
+  buf[0] = (kBase64DecodeTable[buf[0]] << 2) | (kBase64DecodeTable[buf[1]] >> 4);
   if (len > 2) {
-    buf[1] = ((kBase64DecodeTable[buf[1]] << 4) & 0xf0) |
-              (kBase64DecodeTable[buf[2]] >> 2);
+    buf[1] = ((kBase64DecodeTable[buf[1]] << 4) & 0xf0) | (kBase64DecodeTable[buf[2]] >> 2);
     if (len > 3) {
-      buf[2] = ((kBase64DecodeTable[buf[2]] << 6) & 0xc0) |
-                (kBase64DecodeTable[buf[3]]);
+      buf[2] = ((kBase64DecodeTable[buf[2]] << 6) & 0xc0) | (kBase64DecodeTable[buf[3]]);
     }
   }
 }
-
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TBase64Utils.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TBase64Utils.h b/lib/cpp/src/thrift/protocol/TBase64Utils.h
index 3def733..1ea6744 100644
--- a/lib/cpp/src/thrift/protocol/TBase64Utils.h
+++ b/lib/cpp/src/thrift/protocol/TBase64Utils.h
@@ -23,20 +23,23 @@
 #include <stdint.h>
 #include <string>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 // in must be at least len bytes
 // len must be 1, 2, or 3
 // buf must be a buffer of at least 4 bytes and may not overlap in
 // the data is not padded with '='; the caller can do this if desired
-void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf);
+void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf);
 
 // buf must be a buffer of at least 4 bytes and contain base64 encoded values
 // buf will be changed to contain output bytes
 // len is number of bytes to consume from input (must be 2, 3, or 4)
 // no '=' padding should be included in the input
-void base64_decode(uint8_t *buf, uint32_t len);
-
-}}} // apache::thrift::protocol
+void base64_decode(uint8_t* buf, uint32_t len);
+}
+}
+} // apache::thrift::protocol
 
 #endif // #define _THRIFT_PROTOCOL_TBASE64UTILS_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
index a5b19e5..88b91e5 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
@@ -25,7 +25,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 /**
  * The default binary protocol for thrift. Writes all data in a very basic
@@ -33,37 +35,36 @@ namespace apache { namespace thrift { namespace protocol {
  *
  */
 template <class Transport_>
-class TBinaryProtocolT
-  : public TVirtualProtocol< TBinaryProtocolT<Transport_> > {
- protected:
+class TBinaryProtocolT : public TVirtualProtocol<TBinaryProtocolT<Transport_> > {
+protected:
   static const int32_t VERSION_MASK = ((int32_t)0xffff0000);
   static const int32_t VERSION_1 = ((int32_t)0x80010000);
   // VERSION_2 (0x80020000)  is taken by TDenseProtocol.
 
- public:
-  TBinaryProtocolT(boost::shared_ptr<Transport_> trans) :
-    TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans),
-    trans_(trans.get()),
-    string_limit_(0),
-    container_limit_(0),
-    strict_read_(false),
-    strict_write_(true),
-    string_buf_(NULL),
-    string_buf_size_(0) {}
+public:
+  TBinaryProtocolT(boost::shared_ptr<Transport_> trans)
+    : TVirtualProtocol<TBinaryProtocolT<Transport_> >(trans),
+      trans_(trans.get()),
+      string_limit_(0),
+      container_limit_(0),
+      strict_read_(false),
+      strict_write_(true),
+      string_buf_(NULL),
+      string_buf_size_(0) {}
 
   TBinaryProtocolT(boost::shared_ptr<Transport_> trans,
                    int32_t string_limit,
                    int32_t container_limit,
                    bool strict_read,
-                   bool strict_write) :
-    TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans),
-    trans_(trans.get()),
-    string_limit_(string_limit),
-    container_limit_(container_limit),
-    strict_read_(strict_read),
-    strict_write_(strict_write),
-    string_buf_(NULL),
-    string_buf_size_(0) {}
+                   bool strict_write)
+    : TVirtualProtocol<TBinaryProtocolT<Transport_> >(trans),
+      trans_(trans.get()),
+      string_limit_(string_limit),
+      container_limit_(container_limit),
+      strict_read_(strict_read),
+      strict_write_(strict_write),
+      string_buf_(NULL),
+      string_buf_size_(0) {}
 
   ~TBinaryProtocolT() {
     if (string_buf_ != NULL) {
@@ -72,13 +73,9 @@ class TBinaryProtocolT
     }
   }
 
-  void setStringSizeLimit(int32_t string_limit) {
-    string_limit_ = string_limit;
-  }
+  void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
 
-  void setContainerSizeLimit(int32_t container_limit) {
-    container_limit_ = container_limit;
-  }
+  void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
 
   void setStrict(bool strict_read, bool strict_write) {
     strict_read_ = strict_read;
@@ -95,22 +92,17 @@ class TBinaryProtocolT
 
   /*ol*/ uint32_t writeMessageEnd();
 
-
   inline uint32_t writeStructBegin(const char* name);
 
   inline uint32_t writeStructEnd();
 
-  inline uint32_t writeFieldBegin(const char* name,
-                                  const TType fieldType,
-                                  const int16_t fieldId);
+  inline uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
 
   inline uint32_t writeFieldEnd();
 
   inline uint32_t writeFieldStop();
 
-  inline uint32_t writeMapBegin(const TType keyType,
-                                const TType valType,
-                                const uint32_t size);
+  inline uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
 
   inline uint32_t writeMapEnd();
 
@@ -143,10 +135,7 @@ class TBinaryProtocolT
    * Reading functions
    */
 
-
-  /*ol*/ uint32_t readMessageBegin(std::string& name,
-                                   TMessageType& messageType,
-                                   int32_t& seqid);
+  /*ol*/ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
 
   /*ol*/ uint32_t readMessageEnd();
 
@@ -154,15 +143,11 @@ class TBinaryProtocolT
 
   inline uint32_t readStructEnd();
 
-  inline uint32_t readFieldBegin(std::string& name,
-                                 TType& fieldType,
-                                 int16_t& fieldId);
+  inline uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
 
   inline uint32_t readFieldEnd();
 
-  inline uint32_t readMapBegin(TType& keyType,
-                               TType& valType,
-                               uint32_t& size);
+  inline uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
 
   inline uint32_t readMapEnd();
 
@@ -176,7 +161,7 @@ class TBinaryProtocolT
 
   inline uint32_t readBool(bool& value);
   // Provide the default readBool() implementation for std::vector<bool>
-  using TVirtualProtocol< TBinaryProtocolT<Transport_> >::readBool;
+  using TVirtualProtocol<TBinaryProtocolT<Transport_> >::readBool;
 
   inline uint32_t readByte(int8_t& byte);
 
@@ -188,13 +173,13 @@ class TBinaryProtocolT
 
   inline uint32_t readDouble(double& dub);
 
-  template<typename StrType>
+  template <typename StrType>
   inline uint32_t readString(StrType& str);
 
   inline uint32_t readBinary(std::string& str);
 
- protected:
-  template<typename StrType>
+protected:
+  template <typename StrType>
   uint32_t readStringBody(StrType& str, int32_t sz);
 
   Transport_* trans_;
@@ -210,7 +195,6 @@ class TBinaryProtocolT
   // avoid memory churn allocating memory on every string read
   uint8_t* string_buf_;
   int32_t string_buf_size_;
-
 };
 
 typedef TBinaryProtocolT<TTransport> TBinaryProtocol;
@@ -220,29 +204,24 @@ typedef TBinaryProtocolT<TTransport> TBinaryProtocol;
  */
 template <class Transport_>
 class TBinaryProtocolFactoryT : public TProtocolFactory {
- public:
-  TBinaryProtocolFactoryT() :
-    string_limit_(0),
-    container_limit_(0),
-    strict_read_(false),
-    strict_write_(true) {}
-
-  TBinaryProtocolFactoryT(int32_t string_limit, int32_t container_limit,
-                          bool strict_read, bool strict_write) :
-    string_limit_(string_limit),
-    container_limit_(container_limit),
-    strict_read_(strict_read),
-    strict_write_(strict_write) {}
+public:
+  TBinaryProtocolFactoryT()
+    : string_limit_(0), container_limit_(0), strict_read_(false), strict_write_(true) {}
+
+  TBinaryProtocolFactoryT(int32_t string_limit,
+                          int32_t container_limit,
+                          bool strict_read,
+                          bool strict_write)
+    : string_limit_(string_limit),
+      container_limit_(container_limit),
+      strict_read_(strict_read),
+      strict_write_(strict_write) {}
 
   virtual ~TBinaryProtocolFactoryT() {}
 
-  void setStringSizeLimit(int32_t string_limit) {
-    string_limit_ = string_limit;
-  }
+  void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
 
-  void setContainerSizeLimit(int32_t container_limit) {
-    container_limit_ = container_limit;
-  }
+  void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
 
   void setStrict(bool strict_read, bool strict_write) {
     strict_read_ = strict_read;
@@ -250,32 +229,36 @@ class TBinaryProtocolFactoryT : public TProtocolFactory {
   }
 
   boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
-    boost::shared_ptr<Transport_> specific_trans =
-      boost::dynamic_pointer_cast<Transport_>(trans);
+    boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans);
     TProtocol* prot;
     if (specific_trans) {
-      prot = new TBinaryProtocolT<Transport_>(specific_trans, string_limit_,
-                                              container_limit_, strict_read_,
+      prot = new TBinaryProtocolT<Transport_>(specific_trans,
+                                              string_limit_,
+                                              container_limit_,
+                                              strict_read_,
                                               strict_write_);
     } else {
-      prot = new TBinaryProtocol(trans, string_limit_, container_limit_,
-                                 strict_read_, strict_write_);
+      prot = new TBinaryProtocol(trans,
+                                 string_limit_,
+                                 container_limit_,
+                                 strict_read_,
+                                 strict_write_);
     }
 
     return boost::shared_ptr<TProtocol>(prot);
   }
 
- private:
+private:
   int32_t string_limit_;
   int32_t container_limit_;
   bool strict_read_;
   bool strict_write_;
-
 };
 
 typedef TBinaryProtocolFactoryT<TTransport> TBinaryProtocolFactory;
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #include <thrift/protocol/TBinaryProtocol.tcc>
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
index 40226a5..0d72d8a 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
@@ -24,8 +24,9 @@
 
 #include <limits>
 
-
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::writeMessageBegin(const std::string& name,
@@ -54,7 +55,7 @@ uint32_t TBinaryProtocolT<Transport_>::writeMessageEnd() {
 
 template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::writeStructBegin(const char* name) {
-  (void) name;
+  (void)name;
   return 0;
 }
 
@@ -67,7 +68,7 @@ template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::writeFieldBegin(const char* name,
                                                        const TType fieldType,
                                                        const int16_t fieldId) {
-  (void) name;
+  (void)name;
   uint32_t wsize = 0;
   wsize += writeByte((int8_t)fieldType);
   wsize += writeI16(fieldId);
@@ -81,8 +82,7 @@ uint32_t TBinaryProtocolT<Transport_>::writeFieldEnd() {
 
 template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::writeFieldStop() {
-  return
-    writeByte((int8_t)T_STOP);
+  return writeByte((int8_t)T_STOP);
 }
 
 template <class Transport_>
@@ -102,10 +102,9 @@ uint32_t TBinaryProtocolT<Transport_>::writeMapEnd() {
 }
 
 template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::writeListBegin(const TType elemType,
-                                                      const uint32_t size) {
+uint32_t TBinaryProtocolT<Transport_>::writeListBegin(const TType elemType, const uint32_t size) {
   uint32_t wsize = 0;
-  wsize += writeByte((int8_t) elemType);
+  wsize += writeByte((int8_t)elemType);
   wsize += writeI32((int32_t)size);
   return wsize;
 }
@@ -116,8 +115,7 @@ uint32_t TBinaryProtocolT<Transport_>::writeListEnd() {
 }
 
 template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::writeSetBegin(const TType elemType,
-                                                     const uint32_t size) {
+uint32_t TBinaryProtocolT<Transport_>::writeSetBegin(const TType elemType, const uint32_t size) {
   uint32_t wsize = 0;
   wsize += writeByte((int8_t)elemType);
   wsize += writeI32((int32_t)size);
@@ -131,7 +129,7 @@ uint32_t TBinaryProtocolT<Transport_>::writeSetEnd() {
 
 template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::writeBool(const bool value) {
-  uint8_t tmp =  value ? 1 : 0;
+  uint8_t tmp = value ? 1 : 0;
   this->trans_->write(&tmp, 1);
   return 1;
 }
@@ -174,11 +172,10 @@ uint32_t TBinaryProtocolT<Transport_>::writeDouble(const double dub) {
   return 8;
 }
 
-
 template <class Transport_>
-template<typename StrType>
+template <typename StrType>
 uint32_t TBinaryProtocolT<Transport_>::writeString(const StrType& str) {
-  if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
+  if (str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   uint32_t size = static_cast<uint32_t>(str.size());
   uint32_t result = writeI32((int32_t)size);
@@ -216,7 +213,8 @@ uint32_t TBinaryProtocolT<Transport_>::readMessageBegin(std::string& name,
     result += readI32(seqid);
   } else {
     if (this->strict_read_) {
-      throw TProtocolException(TProtocolException::BAD_VERSION, "No version identifier... old protocol client in strict mode?");
+      throw TProtocolException(TProtocolException::BAD_VERSION,
+                               "No version identifier... old protocol client in strict mode?");
     } else {
       // Handle pre-versioned input
       int8_t type;
@@ -249,7 +247,7 @@ template <class Transport_>
 uint32_t TBinaryProtocolT<Transport_>::readFieldBegin(std::string& name,
                                                       TType& fieldType,
                                                       int16_t& fieldId) {
-  (void) name;
+  (void)name;
   uint32_t result = 0;
   int8_t type;
   result += readByte(type);
@@ -294,8 +292,7 @@ uint32_t TBinaryProtocolT<Transport_>::readMapEnd() {
 }
 
 template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::readListBegin(TType& elemType,
-                                                     uint32_t& size) {
+uint32_t TBinaryProtocolT<Transport_>::readListBegin(TType& elemType, uint32_t& size) {
   int8_t e;
   uint32_t result = 0;
   int32_t sizei;
@@ -317,8 +314,7 @@ uint32_t TBinaryProtocolT<Transport_>::readListEnd() {
 }
 
 template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::readSetBegin(TType& elemType,
-                                                    uint32_t& size) {
+uint32_t TBinaryProtocolT<Transport_>::readSetBegin(TType& elemType, uint32_t& size) {
   int8_t e;
   uint32_t result = 0;
   int32_t sizei;
@@ -404,7 +400,7 @@ uint32_t TBinaryProtocolT<Transport_>::readDouble(double& dub) {
 }
 
 template <class Transport_>
-template<typename StrType>
+template <typename StrType>
 uint32_t TBinaryProtocolT<Transport_>::readString(StrType& str) {
   uint32_t result;
   int32_t size;
@@ -418,9 +414,8 @@ uint32_t TBinaryProtocolT<Transport_>::readBinary(std::string& str) {
 }
 
 template <class Transport_>
-template<typename StrType>
-uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str,
-                                                      int32_t size) {
+template <typename StrType>
+uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str, int32_t size) {
   uint32_t result = 0;
 
   // Catch error cases
@@ -447,10 +442,11 @@ uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str,
   }
 
   str.resize(size);
-  this->trans_->readAll(reinterpret_cast<uint8_t *>(&str[0]), size);
+  this->trans_->readAll(reinterpret_cast<uint8_t*>(&str[0]), size);
   return (uint32_t)size;
 }
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TCompactProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index ce60b45..5b7ade2 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -25,21 +25,22 @@
 #include <stack>
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 /**
  * C++ Implementation of the Compact Protocol as described in THRIFT-110
  */
 template <class Transport_>
-class TCompactProtocolT
-  : public TVirtualProtocol< TCompactProtocolT<Transport_> > {
-
- protected:
-  static const int8_t  PROTOCOL_ID = (int8_t)0x82u;
-  static const int8_t  VERSION_N = 1;
-  static const int8_t  VERSION_MASK = 0x1f; // 0001 1111
-  static const int8_t  TYPE_MASK = (int8_t)0xE0u; // 1110 0000
-  static const int8_t  TYPE_BITS = 0x07; // 0000 0111
+class TCompactProtocolT : public TVirtualProtocol<TCompactProtocolT<Transport_> > {
+
+protected:
+  static const int8_t PROTOCOL_ID = (int8_t)0x82u;
+  static const int8_t VERSION_N = 1;
+  static const int8_t VERSION_MASK = 0x1f;       // 0001 1111
+  static const int8_t TYPE_MASK = (int8_t)0xE0u; // 1110 0000
+  static const int8_t TYPE_BITS = 0x07;          // 0000 0111
   static const int32_t TYPE_SHIFT_AMOUNT = 5;
 
   Transport_* trans_;
@@ -71,37 +72,34 @@ class TCompactProtocolT
   std::stack<int16_t> lastField_;
   int16_t lastFieldId_;
 
- public:
-  TCompactProtocolT(boost::shared_ptr<Transport_> trans) :
-    TVirtualProtocol< TCompactProtocolT<Transport_> >(trans),
-    trans_(trans.get()),
-    lastFieldId_(0),
-    string_limit_(0),
-    string_buf_(NULL),
-    string_buf_size_(0),
-    container_limit_(0) {
+public:
+  TCompactProtocolT(boost::shared_ptr<Transport_> trans)
+    : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans),
+      trans_(trans.get()),
+      lastFieldId_(0),
+      string_limit_(0),
+      string_buf_(NULL),
+      string_buf_size_(0),
+      container_limit_(0) {
     booleanField_.name = NULL;
     boolValue_.hasBoolValue = false;
   }
 
   TCompactProtocolT(boost::shared_ptr<Transport_> trans,
                     int32_t string_limit,
-                    int32_t container_limit) :
-    TVirtualProtocol< TCompactProtocolT<Transport_> >(trans),
-    trans_(trans.get()),
-    lastFieldId_(0),
-    string_limit_(string_limit),
-    string_buf_(NULL),
-    string_buf_size_(0),
-    container_limit_(container_limit) {
+                    int32_t container_limit)
+    : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans),
+      trans_(trans.get()),
+      lastFieldId_(0),
+      string_limit_(string_limit),
+      string_buf_(NULL),
+      string_buf_size_(0),
+      container_limit_(container_limit) {
     booleanField_.name = NULL;
     boolValue_.hasBoolValue = false;
   }
 
-  ~TCompactProtocolT() {
-    free(string_buf_);
-  }
-
+  ~TCompactProtocolT() { free(string_buf_); }
 
   /**
    * Writing functions
@@ -115,21 +113,15 @@ class TCompactProtocolT
 
   uint32_t writeStructEnd();
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId);
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
 
   uint32_t writeFieldStop();
 
-  uint32_t writeListBegin(const TType elemType,
-                          const uint32_t size);
+  uint32_t writeListBegin(const TType elemType, const uint32_t size);
 
-  uint32_t writeSetBegin(const TType elemType,
-                         const uint32_t size);
+  uint32_t writeSetBegin(const TType elemType, const uint32_t size);
 
-  virtual uint32_t writeMapBegin(const TType keyType,
-                                 const TType valType,
-                                 const uint32_t size);
+  virtual uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
 
   uint32_t writeBool(const bool value);
 
@@ -157,7 +149,7 @@ class TCompactProtocolT
   uint32_t writeSetEnd() { return 0; }
   uint32_t writeFieldEnd() { return 0; }
 
- protected:
+protected:
   int32_t writeFieldBeginInternal(const char* name,
                                   const TType fieldType,
                                   const int16_t fieldId,
@@ -169,32 +161,24 @@ class TCompactProtocolT
   uint32_t i32ToZigzag(const int32_t n);
   inline int8_t getCompactType(const TType ttype);
 
- public:
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid);
+public:
+  uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
 
   uint32_t readStructBegin(std::string& name);
 
   uint32_t readStructEnd();
 
-  uint32_t readFieldBegin(std::string& name,
-                          TType& fieldType,
-                          int16_t& fieldId);
+  uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
 
-  uint32_t readMapBegin(TType& keyType,
-                        TType& valType,
-                        uint32_t& size);
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
 
-  uint32_t readListBegin(TType& elemType,
-                         uint32_t& size);
+  uint32_t readListBegin(TType& elemType, uint32_t& size);
 
-  uint32_t readSetBegin(TType& elemType,
-                        uint32_t& size);
+  uint32_t readSetBegin(TType& elemType, uint32_t& size);
 
   uint32_t readBool(bool& value);
   // Provide the default readBool() implementation for std::vector<bool>
-  using TVirtualProtocol< TCompactProtocolT<Transport_> >::readBool;
+  using TVirtualProtocol<TCompactProtocolT<Transport_> >::readBool;
 
   uint32_t readByte(int8_t& byte);
 
@@ -220,7 +204,7 @@ class TCompactProtocolT
   uint32_t readListEnd() { return 0; }
   uint32_t readSetEnd() { return 0; }
 
- protected:
+protected:
   uint32_t readVarint32(int32_t& i32);
   uint32_t readVarint64(int64_t& i64);
   int32_t zigzagToI32(uint32_t n);
@@ -242,32 +226,23 @@ typedef TCompactProtocolT<TTransport> TCompactProtocol;
  */
 template <class Transport_>
 class TCompactProtocolFactoryT : public TProtocolFactory {
- public:
-  TCompactProtocolFactoryT() :
-    string_limit_(0),
-    container_limit_(0) {}
+public:
+  TCompactProtocolFactoryT() : string_limit_(0), container_limit_(0) {}
 
-  TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit) :
-    string_limit_(string_limit),
-    container_limit_(container_limit) {}
+  TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit)
+    : string_limit_(string_limit), container_limit_(container_limit) {}
 
   virtual ~TCompactProtocolFactoryT() {}
 
-  void setStringSizeLimit(int32_t string_limit) {
-    string_limit_ = string_limit;
-  }
+  void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
 
-  void setContainerSizeLimit(int32_t container_limit) {
-    container_limit_ = container_limit;
-  }
+  void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
 
   boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
-    boost::shared_ptr<Transport_> specific_trans =
-      boost::dynamic_pointer_cast<Transport_>(trans);
+    boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans);
     TProtocol* prot;
     if (specific_trans) {
-      prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_,
-                                               container_limit_);
+      prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_, container_limit_);
     } else {
       prot = new TCompactProtocol(trans, string_limit_, container_limit_);
     }
@@ -275,15 +250,15 @@ class TCompactProtocolFactoryT : public TProtocolFactory {
     return boost::shared_ptr<TProtocol>(prot);
   }
 
- private:
+private:
   int32_t string_limit_;
   int32_t container_limit_;
-
 };
 
 typedef TCompactProtocolFactoryT<TTransport> TCompactProtocolFactory;
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
 
 #include <thrift/protocol/TCompactProtocol.tcc>
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
index 63ea14d..4687e82 100644
--- a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
@@ -28,7 +28,6 @@
 
 using std::string;
 
-
 static string byte_to_hex(const uint8_t byte) {
   char buf[3];
   int ret = std::sprintf(buf, "%02x", (int)byte);
@@ -38,28 +37,46 @@ static string byte_to_hex(const uint8_t byte) {
   return buf;
 }
 
-
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 string TDebugProtocol::fieldTypeName(TType type) {
   switch (type) {
-    case T_STOP   : return "stop"   ;
-    case T_VOID   : return "void"   ;
-    case T_BOOL   : return "bool"   ;
-    case T_BYTE   : return "byte"   ;
-    case T_I16    : return "i16"    ;
-    case T_I32    : return "i32"    ;
-    case T_U64    : return "u64"    ;
-    case T_I64    : return "i64"    ;
-    case T_DOUBLE : return "double" ;
-    case T_STRING : return "string" ;
-    case T_STRUCT : return "struct" ;
-    case T_MAP    : return "map"    ;
-    case T_SET    : return "set"    ;
-    case T_LIST   : return "list"   ;
-    case T_UTF8   : return "utf8"   ;
-    case T_UTF16  : return "utf16"  ;
-    default: return "unknown";
+  case T_STOP:
+    return "stop";
+  case T_VOID:
+    return "void";
+  case T_BOOL:
+    return "bool";
+  case T_BYTE:
+    return "byte";
+  case T_I16:
+    return "i16";
+  case T_I32:
+    return "i32";
+  case T_U64:
+    return "u64";
+  case T_I64:
+    return "i64";
+  case T_DOUBLE:
+    return "double";
+  case T_STRING:
+    return "string";
+  case T_STRUCT:
+    return "struct";
+  case T_MAP:
+    return "map";
+  case T_SET:
+    return "set";
+  case T_LIST:
+    return "list";
+  case T_UTF8:
+    return "utf8";
+  case T_UTF16:
+    return "utf16";
+  default:
+    return "unknown";
   }
 }
 
@@ -75,19 +92,19 @@ void TDebugProtocol::indentDown() {
 }
 
 uint32_t TDebugProtocol::writePlain(const string& str) {
-  if(str.length() > (std::numeric_limits<uint32_t>::max)())
+  if (str.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length()));
   return static_cast<uint32_t>(str.length());
 }
 
 uint32_t TDebugProtocol::writeIndented(const string& str) {
-  if(str.length() > (std::numeric_limits<uint32_t>::max)())
+  if (str.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
-  if(indent_str_.length() > (std::numeric_limits<uint32_t>::max)())
+  if (indent_str_.length() > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   uint64_t total_len = indent_str_.length() + str.length();
-  if(total_len > (std::numeric_limits<uint32_t>::max)())
+  if (total_len > (std::numeric_limits<uint32_t>::max)())
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   trans_->write((uint8_t*)indent_str_.data(), static_cast<uint32_t>(indent_str_.length()));
   trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length()));
@@ -98,52 +115,51 @@ uint32_t TDebugProtocol::startItem() {
   uint32_t size;
 
   switch (write_state_.back()) {
-    case UNINIT:
-      // XXX figure out what to do here.
-      //throw TProtocolException(TProtocolException::INVALID_DATA);
-      //return writeIndented(str);
-      return 0;
-    case STRUCT:
-      return 0;
-    case SET:
-      return writeIndented("");
-    case MAP_KEY:
-      return writeIndented("");
-    case MAP_VALUE:
-      return writePlain(" -> ");
-    case LIST:
-      size = writeIndented(
-          "[" + boost::lexical_cast<string>(list_idx_.back()) + "] = ");
-      list_idx_.back()++;
-      return size;
-    default:
-      throw std::logic_error("Invalid enum value.");
+  case UNINIT:
+    // XXX figure out what to do here.
+    // throw TProtocolException(TProtocolException::INVALID_DATA);
+    // return writeIndented(str);
+    return 0;
+  case STRUCT:
+    return 0;
+  case SET:
+    return writeIndented("");
+  case MAP_KEY:
+    return writeIndented("");
+  case MAP_VALUE:
+    return writePlain(" -> ");
+  case LIST:
+    size = writeIndented("[" + boost::lexical_cast<string>(list_idx_.back()) + "] = ");
+    list_idx_.back()++;
+    return size;
+  default:
+    throw std::logic_error("Invalid enum value.");
   }
 }
 
 uint32_t TDebugProtocol::endItem() {
-  //uint32_t size;
+  // uint32_t size;
 
   switch (write_state_.back()) {
-    case UNINIT:
-      // XXX figure out what to do here.
-      //throw TProtocolException(TProtocolException::INVALID_DATA);
-      //return writeIndented(str);
-      return 0;
-    case STRUCT:
-      return writePlain(",\n");
-    case SET:
-      return writePlain(",\n");
-    case MAP_KEY:
-      write_state_.back() = MAP_VALUE;
-      return 0;
-    case MAP_VALUE:
-      write_state_.back() = MAP_KEY;
-      return writePlain(",\n");
-    case LIST:
-      return writePlain(",\n");
-    default:
-      throw std::logic_error("Invalid enum value.");
+  case UNINIT:
+    // XXX figure out what to do here.
+    // throw TProtocolException(TProtocolException::INVALID_DATA);
+    // return writeIndented(str);
+    return 0;
+  case STRUCT:
+    return writePlain(",\n");
+  case SET:
+    return writePlain(",\n");
+  case MAP_KEY:
+    write_state_.back() = MAP_VALUE;
+    return 0;
+  case MAP_VALUE:
+    write_state_.back() = MAP_KEY;
+    return writePlain(",\n");
+  case LIST:
+    return writePlain(",\n");
+  default:
+    throw std::logic_error("Invalid enum value.");
   }
 }
 
@@ -158,13 +174,21 @@ uint32_t TDebugProtocol::writeItem(const std::string& str) {
 uint32_t TDebugProtocol::writeMessageBegin(const std::string& name,
                                            const TMessageType messageType,
                                            const int32_t seqid) {
-  (void) seqid;
+  (void)seqid;
   string mtype;
   switch (messageType) {
-    case T_CALL      : mtype = "call"   ; break;
-    case T_REPLY     : mtype = "reply"  ; break;
-    case T_EXCEPTION : mtype = "exn"    ; break;
-    case T_ONEWAY    : mtype = "oneway" ; break;
+  case T_CALL:
+    mtype = "call";
+    break;
+  case T_REPLY:
+    mtype = "reply";
+    break;
+  case T_EXCEPTION:
+    mtype = "exn";
+    break;
+  case T_ONEWAY:
+    mtype = "oneway";
+    break;
   }
 
   uint32_t size = writeIndented("(" + mtype + ") " + name + "(");
@@ -200,12 +224,10 @@ uint32_t TDebugProtocol::writeFieldBegin(const char* name,
                                          const int16_t fieldId) {
   // sprintf(id_str, "%02d", fieldId);
   string id_str = boost::lexical_cast<string>(fieldId);
-  if (id_str.length() == 1) id_str = '0' + id_str;
+  if (id_str.length() == 1)
+    id_str = '0' + id_str;
 
-  return writeIndented(
-      id_str + ": " +
-      name + " (" +
-      fieldTypeName(fieldType) + ") = ");
+  return writeIndented(id_str + ": " + name + " (" + fieldTypeName(fieldType) + ") = ");
 }
 
 uint32_t TDebugProtocol::writeFieldEnd() {
@@ -215,7 +237,7 @@ uint32_t TDebugProtocol::writeFieldEnd() {
 
 uint32_t TDebugProtocol::writeFieldStop() {
   return 0;
-    //writeIndented("***STOP***\n");
+  // writeIndented("***STOP***\n");
 }
 
 uint32_t TDebugProtocol::writeMapBegin(const TType keyType,
@@ -241,8 +263,7 @@ uint32_t TDebugProtocol::writeMapEnd() {
   return size;
 }
 
-uint32_t TDebugProtocol::writeListBegin(const TType elemType,
-                                        const uint32_t size) {
+uint32_t TDebugProtocol::writeListBegin(const TType elemType, const uint32_t size) {
   // TODO(dreiss): Optimize short arrays.
   uint32_t bsize = 0;
   bsize += startItem();
@@ -265,8 +286,7 @@ uint32_t TDebugProtocol::writeListEnd() {
   return size;
 }
 
-uint32_t TDebugProtocol::writeSetBegin(const TType elemType,
-                                       const uint32_t size) {
+uint32_t TDebugProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
   // TODO(dreiss): Optimize short sets.
   uint32_t bsize = 0;
   bsize += startItem();
@@ -311,7 +331,6 @@ uint32_t TDebugProtocol::writeDouble(const double dub) {
   return writeItem(boost::lexical_cast<string>(dub));
 }
 
-
 uint32_t TDebugProtocol::writeString(const string& str) {
   // XXX Raw/UTF-8?
 
@@ -332,16 +351,30 @@ uint32_t TDebugProtocol::writeString(const string& str) {
       output += *it;
     } else {
       switch (*it) {
-        case '\a': output += "\\a"; break;
-        case '\b': output += "\\b"; break;
-        case '\f': output += "\\f"; break;
-        case '\n': output += "\\n"; break;
-        case '\r': output += "\\r"; break;
-        case '\t': output += "\\t"; break;
-        case '\v': output += "\\v"; break;
-        default:
-          output += "\\x";
-          output += byte_to_hex(*it);
+      case '\a':
+        output += "\\a";
+        break;
+      case '\b':
+        output += "\\b";
+        break;
+      case '\f':
+        output += "\\f";
+        break;
+      case '\n':
+        output += "\\n";
+        break;
+      case '\r':
+        output += "\\r";
+        break;
+      case '\t':
+        output += "\\t";
+        break;
+      case '\v':
+        output += "\\v";
+        break;
+      default:
+        output += "\\x";
+        output += byte_to_hex(*it);
       }
     }
   }
@@ -354,5 +387,6 @@ uint32_t TDebugProtocol::writeBinary(const string& str) {
   // XXX Hex?
   return TDebugProtocol::writeString(str);
 }
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TDebugProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
index f85e691..cc93230 100644
--- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
@@ -24,7 +24,9 @@
 
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
 /*
 
@@ -39,44 +41,30 @@ Complaints are not. :R
 
 */
 
-
 /**
  * Protocol that prints the payload in a nice human-readable format.
  * Reading from this protocol is not supported.
  *
  */
 class TDebugProtocol : public TVirtualProtocol<TDebugProtocol> {
- private:
-  enum write_state_t
-  { UNINIT
-  , STRUCT
-  , LIST
-  , SET
-  , MAP_KEY
-  , MAP_VALUE
-  };
-
- public:
+private:
+  enum write_state_t { UNINIT, STRUCT, LIST, SET, MAP_KEY, MAP_VALUE };
+
+public:
   TDebugProtocol(boost::shared_ptr<TTransport> trans)
-    : TVirtualProtocol<TDebugProtocol>(trans)
-    , trans_(trans.get())
-    , string_limit_(DEFAULT_STRING_LIMIT)
-    , string_prefix_size_(DEFAULT_STRING_PREFIX_SIZE)
-  {
+    : TVirtualProtocol<TDebugProtocol>(trans),
+      trans_(trans.get()),
+      string_limit_(DEFAULT_STRING_LIMIT),
+      string_prefix_size_(DEFAULT_STRING_PREFIX_SIZE) {
     write_state_.push_back(UNINIT);
   }
 
   static const int32_t DEFAULT_STRING_LIMIT = 256;
   static const int32_t DEFAULT_STRING_PREFIX_SIZE = 16;
 
-  void setStringSizeLimit(int32_t string_limit) {
-    string_limit_ = string_limit;
-  }
-
-  void setStringPrefixSize(int32_t string_prefix_size) {
-    string_prefix_size_ = string_prefix_size;
-  }
+  void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
 
+  void setStringPrefixSize(int32_t string_prefix_size) { string_prefix_size_ = string_prefix_size; }
 
   uint32_t writeMessageBegin(const std::string& name,
                              const TMessageType messageType,
@@ -84,32 +72,25 @@ class TDebugProtocol : public TVirtualProtocol<TDebugProtocol> {
 
   uint32_t writeMessageEnd();
 
-
   uint32_t writeStructBegin(const char* name);
 
   uint32_t writeStructEnd();
 
-  uint32_t writeFieldBegin(const char* name,
-                           const TType fieldType,
-                           const int16_t fieldId);
+  uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
 
   uint32_t writeFieldEnd();
 
   uint32_t writeFieldStop();
 
-  uint32_t writeMapBegin(const TType keyType,
-                         const TType valType,
-                         const uint32_t size);
+  uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
 
   uint32_t writeMapEnd();
 
-  uint32_t writeListBegin(const TType elemType,
-                          const uint32_t size);
+  uint32_t writeListBegin(const TType elemType, const uint32_t size);
 
   uint32_t writeListEnd();
 
-  uint32_t writeSetBegin(const TType elemType,
-                         const uint32_t size);
+  uint32_t writeSetBegin(const TType elemType, const uint32_t size);
 
   uint32_t writeSetEnd();
 
@@ -129,8 +110,7 @@ class TDebugProtocol : public TVirtualProtocol<TDebugProtocol> {
 
   uint32_t writeBinary(const std::string& str);
 
-
- private:
+private:
   void indentUp();
   void indentDown();
   uint32_t writePlain(const std::string& str);
@@ -157,25 +137,25 @@ class TDebugProtocol : public TVirtualProtocol<TDebugProtocol> {
  * Constructs debug protocol handlers
  */
 class TDebugProtocolFactory : public TProtocolFactory {
- public:
+public:
   TDebugProtocolFactory() {}
   virtual ~TDebugProtocolFactory() {}
 
   boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
     return boost::shared_ptr<TProtocol>(new TDebugProtocol(trans));
   }
-
 };
-
-}}} // apache::thrift::protocol
-
+}
+}
+} // apache::thrift::protocol
 
 // TODO(dreiss): Move (part of) ThriftDebugString into a .cpp file and remove this.
 #include <thrift/transport/TBufferTransports.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
-template<typename ThriftStruct>
+template <typename ThriftStruct>
 std::string ThriftDebugString(const ThriftStruct& ts) {
   using namespace apache::thrift::transport;
   using namespace apache::thrift::protocol;
@@ -218,10 +198,7 @@ std::string DebugString(const std::vector<Object>& vec) {
   return std::string((char*)buf, (unsigned int)size);
 }
 #endif // 0
-
-}} // apache::thrift
-
+}
+} // apache::thrift
 
 #endif // #ifndef _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_
-
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
index 4fbfc13..d6644b7 100644
--- a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
@@ -117,24 +117,24 @@ using std::string;
 #define UNLIKELY(val) (val)
 #endif
 
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
 
-const int TDenseProtocol::FP_PREFIX_LEN =
-  apache::thrift::reflection::local::FP_PREFIX_LEN;
+const int TDenseProtocol::FP_PREFIX_LEN = apache::thrift::reflection::local::FP_PREFIX_LEN;
 
 // Top TypeSpec.  TypeSpec of the structure being encoded.
-#define TTS  (ts_stack_.back())  // type = TypeSpec*
+#define TTS (ts_stack_.back()) // type = TypeSpec*
 // InDeX.  Index into TTS of the current/next field to encode.
-#define IDX (idx_stack_.back())  // type = int
+#define IDX (idx_stack_.back()) // type = int
 // Field TypeSpec.  TypeSpec of the current/next field to encode.
-#define FTS (TTS->tstruct.specs[IDX])  // type = TypeSpec*
+#define FTS (TTS->tstruct.specs[IDX]) // type = TypeSpec*
 // Field MeTa.  Metadata of the current/next field to encode.
-#define FMT (TTS->tstruct.metas[IDX])  // type = FieldMeta
+#define FMT (TTS->tstruct.metas[IDX]) // type = FieldMeta
 // SubType 1/2.  TypeSpec of the first/second subtype of this container.
 #define ST1 (TTS->tcontainer.subtype1)
 #define ST2 (TTS->tcontainer.subtype2)
 
-
 /**
  * Checks that @c ttype is indeed the ttype that we should be writing,
  * according to our typespec.  Aborts if the test fails and debugging in on.
@@ -161,30 +161,28 @@ inline void TDenseProtocol::stateTransition() {
 
   switch (TTS->ttype) {
 
-    case T_STRUCT:
-      assert(old_tts == FTS);
-      break;
-
-    case T_LIST:
-    case T_SET:
-      assert(old_tts == ST1);
-      ts_stack_.push_back(old_tts);
-      break;
-
-    case T_MAP:
-      assert(old_tts == (mkv_stack_.back() ? ST1 : ST2));
-      mkv_stack_.back() = !mkv_stack_.back();
-      ts_stack_.push_back(mkv_stack_.back() ? ST1 : ST2);
-      break;
-
-    default:
-      assert(!"Invalid TType in stateTransition.");
-      break;
-
+  case T_STRUCT:
+    assert(old_tts == FTS);
+    break;
+
+  case T_LIST:
+  case T_SET:
+    assert(old_tts == ST1);
+    ts_stack_.push_back(old_tts);
+    break;
+
+  case T_MAP:
+    assert(old_tts == (mkv_stack_.back() ? ST1 : ST2));
+    mkv_stack_.back() = !mkv_stack_.back();
+    ts_stack_.push_back(mkv_stack_.back() ? ST1 : ST2);
+    break;
+
+  default:
+    assert(!"Invalid TType in stateTransition.");
+    break;
   }
 }
 
-
 /*
  * Variable-length quantity functions.
  */
@@ -192,7 +190,7 @@ inline void TDenseProtocol::stateTransition() {
 inline uint32_t TDenseProtocol::vlqRead(uint64_t& vlq) {
   uint32_t used = 0;
   uint64_t val = 0;
-  uint8_t buf[10];  // 64 bits / (7 bits/byte) = 10 bytes.
+  uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
   uint32_t buf_size = sizeof(buf);
   const uint8_t* borrowed = trans_->borrow(buf, &buf_size);
 
@@ -210,7 +208,8 @@ inline uint32_t TDenseProtocol::vlqRead(uint64_t& vlq) {
       // Have to check for invalid data so we don't crash.
       if (UNLIKELY(used == sizeof(buf))) {
         resetState();
-        throw TProtocolException(TProtocolException::INVALID_DATA, "Variable-length int over 10 bytes.");
+        throw TProtocolException(TProtocolException::INVALID_DATA,
+                                 "Variable-length int over 10 bytes.");
       }
     }
   }
@@ -228,14 +227,15 @@ inline uint32_t TDenseProtocol::vlqRead(uint64_t& vlq) {
       // Might as well check for invalid data on the slow path too.
       if (UNLIKELY(used >= sizeof(buf))) {
         resetState();
-        throw TProtocolException(TProtocolException::INVALID_DATA, "Variable-length int over 10 bytes.");
+        throw TProtocolException(TProtocolException::INVALID_DATA,
+                                 "Variable-length int over 10 bytes.");
       }
     }
   }
 }
 
 inline uint32_t TDenseProtocol::vlqWrite(uint64_t vlq) {
-  uint8_t buf[10];  // 64 bits / (7 bits/byte) = 10 bytes.
+  uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
   int32_t pos = sizeof(buf) - 1;
 
   // Write the thing from back to front.
@@ -253,12 +253,10 @@ inline uint32_t TDenseProtocol::vlqWrite(uint64_t vlq) {
   // Back up one step before writing.
   pos++;
 
-  trans_->write(buf+pos, static_cast<uint32_t>(sizeof(buf) - pos));
+  trans_->write(buf + pos, static_cast<uint32_t>(sizeof(buf) - pos));
   return static_cast<uint32_t>(sizeof(buf) - pos);
 }
 
-
-
 /*
  * Writing functions.
  */
@@ -281,7 +279,7 @@ uint32_t TDenseProtocol::writeMessageEnd() {
 }
 
 uint32_t TDenseProtocol::writeStructBegin(const char* name) {
-  (void) name;
+  (void)name;
   uint32_t xfer = 0;
 
   // The TypeSpec stack should be empty if this is the top-level read/write.
@@ -315,7 +313,7 @@ uint32_t TDenseProtocol::writeStructEnd() {
 uint32_t TDenseProtocol::writeFieldBegin(const char* name,
                                          const TType fieldType,
                                          const int16_t fieldId) {
-  (void) name;
+  (void)name;
   uint32_t xfer = 0;
 
   // Skip over optional fields.
@@ -380,8 +378,7 @@ uint32_t TDenseProtocol::writeMapEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::writeListBegin(const TType elemType,
-                                        const uint32_t size) {
+uint32_t TDenseProtocol::writeListBegin(const TType elemType, const uint32_t size) {
   checkTType(T_LIST);
 
   assert(elemType == ST1->ttype);
@@ -396,8 +393,7 @@ uint32_t TDenseProtocol::writeListEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::writeSetBegin(const TType elemType,
-                                       const uint32_t size) {
+uint32_t TDenseProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
   checkTType(T_SET);
 
   assert(elemType == ST1->ttype);
@@ -463,7 +459,7 @@ inline uint32_t TDenseProtocol::subWriteI32(const int32_t i32) {
 }
 
 uint32_t TDenseProtocol::subWriteString(const std::string& str) {
-  if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
+  if (str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
     throw TProtocolException(TProtocolException::SIZE_LIMIT);
   uint32_t size = static_cast<uint32_t>(str.size());
   uint32_t xfer = subWriteI32((int32_t)size);
@@ -473,8 +469,6 @@ uint32_t TDenseProtocol::subWriteString(const std::string& str) {
   return xfer + size;
 }
 
-
-
 /*
  * Reading functions
  *
@@ -501,7 +495,8 @@ uint32_t TDenseProtocol::readMessageBegin(std::string& name,
     xfer += subReadString(name);
     xfer += subReadI32(seqid);
   } else {
-    throw TProtocolException(TProtocolException::BAD_VERSION, "No version identifier... old protocol client in strict mode?");
+    throw TProtocolException(TProtocolException::BAD_VERSION,
+                             "No version identifier... old protocol client in strict mode?");
   }
   return xfer;
 }
@@ -511,7 +506,7 @@ uint32_t TDenseProtocol::readMessageEnd() {
 }
 
 uint32_t TDenseProtocol::readStructBegin(string& name) {
-  (void) name;
+  (void)name;
   uint32_t xfer = 0;
 
   if (ts_stack_.empty()) {
@@ -530,7 +525,7 @@ uint32_t TDenseProtocol::readStructBegin(string& name) {
       if (std::memcmp(buf, type_spec_->fp_prefix, FP_PREFIX_LEN) != 0) {
         resetState();
         throw TProtocolException(TProtocolException::INVALID_DATA,
-            "Fingerprint in data does not match type_spec.");
+                                 "Fingerprint in data does not match type_spec.");
       }
     }
   }
@@ -546,10 +541,8 @@ uint32_t TDenseProtocol::readStructEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::readFieldBegin(string& name,
-                                        TType& fieldType,
-                                        int16_t& fieldId) {
-  (void) name;
+uint32_t TDenseProtocol::readFieldBegin(string& name, TType& fieldType, int16_t& fieldId) {
+  (void)name;
   uint32_t xfer = 0;
 
   // For optional fields, check to see if they are there.
@@ -565,7 +558,7 @@ uint32_t TDenseProtocol::readFieldBegin(string& name,
   // Once we hit a mandatory field, or an optional field that is present,
   // we know that FMT and FTS point to the appropriate field.
 
-  fieldId   = FMT.tag;
+  fieldId = FMT.tag;
   fieldType = FTS->ttype;
 
   // Normally, we push the TypeSpec that we are about to read,
@@ -581,9 +574,7 @@ uint32_t TDenseProtocol::readFieldEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::readMapBegin(TType& keyType,
-                                      TType& valType,
-                                      uint32_t& size) {
+uint32_t TDenseProtocol::readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
   checkTType(T_MAP);
 
   uint32_t xfer = 0;
@@ -614,8 +605,7 @@ uint32_t TDenseProtocol::readMapEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::readListBegin(TType& elemType,
-                                       uint32_t& size) {
+uint32_t TDenseProtocol::readListBegin(TType& elemType, uint32_t& size) {
   checkTType(T_LIST);
 
   uint32_t xfer = 0;
@@ -643,8 +633,7 @@ uint32_t TDenseProtocol::readListEnd() {
   return 0;
 }
 
-uint32_t TDenseProtocol::readSetBegin(TType& elemType,
-                                      uint32_t& size) {
+uint32_t TDenseProtocol::readSetBegin(TType& elemType, uint32_t& size) {
   checkTType(T_SET);
 
   uint32_t xfer = 0;
@@ -692,8 +681,7 @@ uint32_t TDenseProtocol::readI16(int16_t& i16) {
   int64_t val = (int64_t)u64;
   if (UNLIKELY(val > INT16_MAX || val < INT16_MIN)) {
     resetState();
-    throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "i16 out of range.");
+    throw TProtocolException(TProtocolException::INVALID_DATA, "i16 out of range.");
   }
   i16 = (int16_t)val;
   return rv;
@@ -707,8 +695,7 @@ uint32_t TDenseProtocol::readI32(int32_t& i32) {
   int64_t val = (int64_t)u64;
   if (UNLIKELY(val > INT32_MAX || val < INT32_MIN)) {
     resetState();
-    throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "i32 out of range.");
+    throw TProtocolException(TProtocolException::INVALID_DATA, "i32 out of range.");
   }
   i32 = (int32_t)val;
   return rv;
@@ -722,8 +709,7 @@ uint32_t TDenseProtocol::readI64(int64_t& i64) {
   int64_t val = (int64_t)u64;
   if (UNLIKELY(val > INT64_MAX || val < INT64_MIN)) {
     resetState();
-    throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "i64 out of range.");
+    throw TProtocolException(TProtocolException::INVALID_DATA, "i64 out of range.");
   }
   i64 = (int64_t)val;
   return rv;
@@ -751,8 +737,7 @@ uint32_t TDenseProtocol::subReadI32(int32_t& i32) {
   int64_t val = (int64_t)u64;
   if (UNLIKELY(val > INT32_MAX || val < INT32_MIN)) {
     resetState();
-    throw TProtocolException(TProtocolException::INVALID_DATA,
-                             "i32 out of range.");
+    throw TProtocolException(TProtocolException::INVALID_DATA, "i32 out of range.");
   }
   i32 = (int32_t)val;
   return rv;
@@ -764,5 +749,6 @@ uint32_t TDenseProtocol::subReadString(std::string& str) {
   xfer = subReadI32(size);
   return xfer + readStringBody(str, size);
 }
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol


[04/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/SocketPair.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/SocketPair.cpp b/lib/cpp/src/thrift/windows/SocketPair.cpp
index 4b65e6b..7228832 100644
--- a/lib/cpp/src/thrift/windows/SocketPair.cpp
+++ b/lib/cpp/src/thrift/windows/SocketPair.cpp
@@ -36,67 +36,65 @@
 // Win32
 #include <WS2tcpip.h>
 
-int thrift_socketpair(int d, int type, int protocol, THRIFT_SOCKET sv[2])
-{
-    THRIFT_UNUSED_VARIABLE(protocol);
-    THRIFT_UNUSED_VARIABLE(type);
-    THRIFT_UNUSED_VARIABLE(d);
+int thrift_socketpair(int d, int type, int protocol, THRIFT_SOCKET sv[2]) {
+  THRIFT_UNUSED_VARIABLE(protocol);
+  THRIFT_UNUSED_VARIABLE(type);
+  THRIFT_UNUSED_VARIABLE(d);
 
-    union {
-       struct sockaddr_in inaddr;
-       struct sockaddr addr;
-    } a;
-    THRIFT_SOCKET listener;
-    int e;
-    socklen_t addrlen = sizeof(a.inaddr);
-    DWORD flags = 0;
-    int reuse = 1;
+  union {
+    struct sockaddr_in inaddr;
+    struct sockaddr addr;
+  } a;
+  THRIFT_SOCKET listener;
+  int e;
+  socklen_t addrlen = sizeof(a.inaddr);
+  DWORD flags = 0;
+  int reuse = 1;
 
-    if (sv == 0) {
-      WSASetLastError(WSAEINVAL);
-      return SOCKET_ERROR;
-    }
+  if (sv == 0) {
+    WSASetLastError(WSAEINVAL);
+    return SOCKET_ERROR;
+  }
 
-    listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-    if (listener == INVALID_SOCKET)
-        return SOCKET_ERROR;
+  listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (listener == INVALID_SOCKET)
+    return SOCKET_ERROR;
 
-    memset(&a, 0, sizeof(a));
-    a.inaddr.sin_family = AF_INET;
-    a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-    a.inaddr.sin_port = 0;
+  memset(&a, 0, sizeof(a));
+  a.inaddr.sin_family = AF_INET;
+  a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+  a.inaddr.sin_port = 0;
 
-    sv[0] = sv[1] = INVALID_SOCKET;
-    do {
-        //ignore errors coming out of this setsockopt.  This is because
-        //SO_EXCLUSIVEADDRUSE requires admin privileges on WinXP, but we don't
-        //want to force socket pairs to be an admin.
-        setsockopt(listener, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
-               (char*) &reuse, (socklen_t) sizeof(reuse));
-        if  (bind(listener, &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
-            break;
-        if  (getsockname(listener, &a.addr, &addrlen) == SOCKET_ERROR)
-            break;
-        if (listen(listener, 1) == SOCKET_ERROR)
-            break;
-        sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
-        if (sv[0] == INVALID_SOCKET)
-            break;
-        if (connect(sv[0], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
-            break;
-        sv[1] = accept(listener, NULL, NULL);
-        if (sv[1] == INVALID_SOCKET)
-            break;
+  sv[0] = sv[1] = INVALID_SOCKET;
+  do {
+    // ignore errors coming out of this setsockopt.  This is because
+    // SO_EXCLUSIVEADDRUSE requires admin privileges on WinXP, but we don't
+    // want to force socket pairs to be an admin.
+    setsockopt(listener, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&reuse, (socklen_t)sizeof(reuse));
+    if (bind(listener, &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
+      break;
+    if (getsockname(listener, &a.addr, &addrlen) == SOCKET_ERROR)
+      break;
+    if (listen(listener, 1) == SOCKET_ERROR)
+      break;
+    sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
+    if (sv[0] == INVALID_SOCKET)
+      break;
+    if (connect(sv[0], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
+      break;
+    sv[1] = accept(listener, NULL, NULL);
+    if (sv[1] == INVALID_SOCKET)
+      break;
 
-        closesocket(listener);
-        return 0;
+    closesocket(listener);
+    return 0;
 
-    } while (0);
+  } while (0);
 
-    e = WSAGetLastError();
-    closesocket(listener);
-    closesocket(sv[0]);
-    closesocket(sv[1]);
-    WSASetLastError(e);
-    return SOCKET_ERROR;
+  e = WSAGetLastError();
+  closesocket(listener);
+  closesocket(sv[0]);
+  closesocket(sv[1]);
+  WSASetLastError(e);
+  return SOCKET_ERROR;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/Sync.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/Sync.h b/lib/cpp/src/thrift/windows/Sync.h
index ded6ea3..5d32199 100644
--- a/lib/cpp/src/thrift/windows/Sync.h
+++ b/lib/cpp/src/thrift/windows/Sync.h
@@ -33,53 +33,55 @@
   code, use the classes found in the concurrency namespace
 */
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 struct TCriticalSection : boost::noncopyable {
   CRITICAL_SECTION cs;
-  TCriticalSection() {InitializeCriticalSection(&cs);}
-  ~TCriticalSection() {DeleteCriticalSection(&cs);}
+  TCriticalSection() { InitializeCriticalSection(&cs); }
+  ~TCriticalSection() { DeleteCriticalSection(&cs); }
 };
 
 class TAutoCrit : boost::noncopyable {
 private:
-  CRITICAL_SECTION *cs_;
+  CRITICAL_SECTION* cs_;
+
 public:
-  explicit TAutoCrit(TCriticalSection &cs) : cs_(&cs.cs) {EnterCriticalSection(cs_);}
-  ~TAutoCrit() {LeaveCriticalSection(cs_);}
+  explicit TAutoCrit(TCriticalSection& cs) : cs_(&cs.cs) { EnterCriticalSection(cs_); }
+  ~TAutoCrit() { LeaveCriticalSection(cs_); }
 };
 
 struct TAutoResetEvent : boost::noncopyable {
   HANDLE h;
 
   TAutoResetEvent() {
-    h = CreateEvent( NULL, FALSE, FALSE, NULL);
-    if(h == NULL) {
+    h = CreateEvent(NULL, FALSE, FALSE, NULL);
+    if (h == NULL) {
       GlobalOutput.perror("TAutoResetEvent unable to create event, GLE=", GetLastError());
       throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
     }
   }
-  ~TAutoResetEvent() {CloseHandle(h);}
+  ~TAutoResetEvent() { CloseHandle(h); }
 };
 
 struct TManualResetEvent : boost::noncopyable {
   HANDLE h;
 
   TManualResetEvent() {
-    h = CreateEvent( NULL, TRUE, FALSE, NULL);
-    if(h == NULL) {
+    h = CreateEvent(NULL, TRUE, FALSE, NULL);
+    if (h == NULL) {
       GlobalOutput.perror("TManualResetEvent unable to create event, GLE=", GetLastError());
       throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
     }
   }
-  ~TManualResetEvent() {CloseHandle(h);}
+  ~TManualResetEvent() { CloseHandle(h); }
 };
 
 struct TAutoHandle : boost::noncopyable {
   HANDLE h;
   explicit TAutoHandle(HANDLE h_ = INVALID_HANDLE_VALUE) : h(h_) {}
   ~TAutoHandle() {
-    if(h != INVALID_HANDLE_VALUE)
+    if (h != INVALID_HANDLE_VALUE)
       CloseHandle(h);
   }
 
@@ -89,14 +91,14 @@ struct TAutoHandle : boost::noncopyable {
     return retval;
   }
   void reset(HANDLE h_ = INVALID_HANDLE_VALUE) {
-    if(h_ == h)
+    if (h_ == h)
       return;
-    if(h != INVALID_HANDLE_VALUE)
+    if (h != INVALID_HANDLE_VALUE)
       CloseHandle(h);
     h = h_;
   }
 };
-
-}} //apache::thrift
+}
+} // apache::thrift
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
index 2e306c6..2e0ccf5 100644
--- a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
+++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
@@ -23,51 +23,49 @@
 #include <boost/assert.hpp>
 #include <stdexcept>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 TWinsockSingleton::instance_ptr TWinsockSingleton::instance_ptr_(NULL);
 #if USE_BOOST_THREAD
-boost::once_flag                TWinsockSingleton::flags_ = BOOST_ONCE_INIT;
+boost::once_flag TWinsockSingleton::flags_ = BOOST_ONCE_INIT;
 #elif USE_STD_THREAD
-std::once_flag                  TWinsockSingleton::flags_;
+std::once_flag TWinsockSingleton::flags_;
 #else
 #error For windows you must choose USE_BOOST_THREAD or USE_STD_THREAD
 #endif
 
 //------------------------------------------------------------------------------
-TWinsockSingleton::TWinsockSingleton(void)
-{
-    WORD    version(MAKEWORD(2, 2));
-    WSAData data = {0};
+TWinsockSingleton::TWinsockSingleton(void) {
+  WORD version(MAKEWORD(2, 2));
+  WSAData data = {0};
 
-    int error(WSAStartup(version, &data));
-    if (error != 0)
-    {
-        BOOST_ASSERT(false);
-        throw std::runtime_error("Failed to initialise Winsock.");
-    }
+  int error(WSAStartup(version, &data));
+  if (error != 0) {
+    BOOST_ASSERT(false);
+    throw std::runtime_error("Failed to initialise Winsock.");
+  }
 }
 
 //------------------------------------------------------------------------------
-TWinsockSingleton::~TWinsockSingleton(void)
-{
-    WSACleanup();
+TWinsockSingleton::~TWinsockSingleton(void) {
+  WSACleanup();
 }
 
 //------------------------------------------------------------------------------
-void TWinsockSingleton::create(void)
-{
+void TWinsockSingleton::create(void) {
 #if USE_BOOST_THREAD
-    boost::call_once(init, flags_);
+  boost::call_once(init, flags_);
 #elif USE_STD_THREAD
-    std::call_once(flags_, init);
+  std::call_once(flags_, init);
 #endif
 }
 
 //------------------------------------------------------------------------------
-void TWinsockSingleton::init(void)
-{
-    instance_ptr_.reset(new TWinsockSingleton);
+void TWinsockSingleton::init(void) {
+  instance_ptr_.reset(new TWinsockSingleton);
 }
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/TWinsockSingleton.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.h b/lib/cpp/src/thrift/windows/TWinsockSingleton.h
index ab12c22..dc1b52f 100644
--- a/lib/cpp/src/thrift/windows/TWinsockSingleton.h
+++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.h
@@ -42,47 +42,43 @@
 #error For windows you must choose USE_BOOST_THREAD or USE_STD_THREAD
 #endif
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 
 /**
  * Winsock2 must be intialised once only in order to create sockets. This class
  * performs a one time initialisation when create is called.
  */
-class TWinsockSingleton : private boost::noncopyable
-{
+class TWinsockSingleton : private boost::noncopyable {
 
 public:
-
-    typedef boost::scoped_ptr<TWinsockSingleton> instance_ptr;
+  typedef boost::scoped_ptr<TWinsockSingleton> instance_ptr;
 
 private:
-
-    TWinsockSingleton(void);
+  TWinsockSingleton(void);
 
 public:
-
-    ~TWinsockSingleton(void);
+  ~TWinsockSingleton(void);
 
 public:
-
-    static void create(void);
+  static void create(void);
 
 private:
-
-    static void init(void);
+  static void init(void);
 
 private:
-
-    static instance_ptr     instance_ptr_;
+  static instance_ptr instance_ptr_;
 #if USE_BOOST_THREAD
-    static boost::once_flag flags_;
+  static boost::once_flag flags_;
 #elif USE_STD_THREAD
-    static std::once_flag flags_;
+  static std::once_flag flags_;
 #else
 #error Need a non-Boost non-C++11 way to track single initialization here.
 #endif
 };
-
-}}} // apache::thrift::transport
+}
+}
+} // apache::thrift::transport
 
 #endif // _THRIFT_TRANSPORT_WINDOWS_TWINSOCKSINGLETON_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/WinFcntl.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/WinFcntl.cpp b/lib/cpp/src/thrift/windows/WinFcntl.cpp
index 3dd4e3d..c8b85f3 100644
--- a/lib/cpp/src/thrift/windows/WinFcntl.cpp
+++ b/lib/cpp/src/thrift/windows/WinFcntl.cpp
@@ -19,54 +19,46 @@
 
 #include <thrift/windows/WinFcntl.h>
 
-int thrift_fcntl(THRIFT_SOCKET fd, int cmd, int flags)
-{
-    if(cmd != THRIFT_F_GETFL && cmd != THRIFT_F_SETFL)
-    {
-        return -1;
-    }
+int thrift_fcntl(THRIFT_SOCKET fd, int cmd, int flags) {
+  if (cmd != THRIFT_F_GETFL && cmd != THRIFT_F_SETFL) {
+    return -1;
+  }
 
-    if(flags != THRIFT_O_NONBLOCK && flags != 0)
-    {
-        return -1;
-    }
+  if (flags != THRIFT_O_NONBLOCK && flags != 0) {
+    return -1;
+  }
 
-    if(cmd == THRIFT_F_GETFL)
-    {
-        return 0;
-    }
+  if (cmd == THRIFT_F_GETFL) {
+    return 0;
+  }
 
-    int res;
-    if(flags)
-    {
-        res = ioctlsocket(fd, FIONBIO, reinterpret_cast<u_long *>(&(flags = 1)));
-    }
-    else
-    {
-        res = ioctlsocket(fd, FIONBIO, reinterpret_cast<u_long *>(&(flags = 0)));
-    }
+  int res;
+  if (flags) {
+    res = ioctlsocket(fd, FIONBIO, reinterpret_cast<u_long*>(&(flags = 1)));
+  } else {
+    res = ioctlsocket(fd, FIONBIO, reinterpret_cast<u_long*>(&(flags = 0)));
+  }
 
-    return res;
+  return res;
 }
 
-#if WINVER <= 0x0502 //XP, Server2003
-int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout)
-{
+#if WINVER <= 0x0502 // XP, Server2003
+int thrift_poll(THRIFT_POLLFD* fdArray, ULONG nfds, INT timeout) {
   fd_set read_fds, write_fds;
-  fd_set* read_fds_ptr  = NULL;
+  fd_set* read_fds_ptr = NULL;
   fd_set* write_fds_ptr = NULL;
 
   FD_ZERO(&read_fds);
   FD_ZERO(&write_fds);
 
-  for(ULONG i=0; i<nfds; i++) {
-    //Read (in) socket
-    if((fdArray[i].events & THRIFT_POLLIN) == THRIFT_POLLIN) {
+  for (ULONG i = 0; i < nfds; i++) {
+    // Read (in) socket
+    if ((fdArray[i].events & THRIFT_POLLIN) == THRIFT_POLLIN) {
       read_fds_ptr = &read_fds;
       FD_SET(fdArray[i].fd, &read_fds);
     }
-    //Write (out) socket
-    else if((fdArray[i].events & THRIFT_POLLOUT) == THRIFT_POLLOUT) {
+    // Write (out) socket
+    else if ((fdArray[i].events & THRIFT_POLLOUT) == THRIFT_POLLOUT) {
       write_fds_ptr = &write_fds;
       FD_SET(fdArray[i].fd, &write_fds);
     }
@@ -74,37 +66,35 @@ int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout)
 
   timeval time_out;
   timeval* time_out_ptr = NULL;
-  if(timeout >= 0) {
+  if (timeout >= 0) {
     timeval time_out = {timeout / 1000, (timeout % 1000) * 1000};
     time_out_ptr = &time_out;
-  }
-  else { //to avoid compiler warnings
+  } else { // to avoid compiler warnings
     (void)time_out;
     (void)timeout;
   }
 
   int sktready = select(1, read_fds_ptr, write_fds_ptr, NULL, time_out_ptr);
-  if(sktready > 0) {
-    for(ULONG i=0; i<nfds; i++) {
+  if (sktready > 0) {
+    for (ULONG i = 0; i < nfds; i++) {
       fdArray[i].revents = 0;
-      if(FD_ISSET(fdArray[i].fd, &read_fds))
+      if (FD_ISSET(fdArray[i].fd, &read_fds))
         fdArray[i].revents |= THRIFT_POLLIN;
-      if(FD_ISSET(fdArray[i].fd, &write_fds))
+      if (FD_ISSET(fdArray[i].fd, &write_fds))
         fdArray[i].revents |= THRIFT_POLLOUT;
     }
   }
   return sktready;
 }
-#else //Vista, Win7...
-int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout)
-{
+#else  // Vista, Win7...
+int thrift_poll(THRIFT_POLLFD* fdArray, ULONG nfds, INT timeout) {
   return WSAPoll(fdArray, nfds, timeout);
 }
 #endif // WINVER
 
 #ifdef _WIN32_WCE
 std::string thrift_wstr2str(std::wstring ws) {
-	std::string s(ws.begin(), ws.end());
-	return s;
+  std::string s(ws.begin(), ws.end());
+  return s;
 }
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/WinFcntl.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/WinFcntl.h b/lib/cpp/src/thrift/windows/WinFcntl.h
index 118c9a4..6c6be97 100644
--- a/lib/cpp/src/thrift/windows/WinFcntl.h
+++ b/lib/cpp/src/thrift/windows/WinFcntl.h
@@ -36,17 +36,17 @@
 #include <Winsock2.h>
 #include <thrift/transport/PlatformSocket.h>
 
-#if WINVER <= 0x0502 //XP, Server2003
+#if WINVER <= 0x0502 // XP, Server2003
 struct thrift_pollfd {
-  THRIFT_SOCKET  fd;
-  SHORT   events;
-  SHORT   revents;
+  THRIFT_SOCKET fd;
+  SHORT events;
+  SHORT revents;
 };
 #endif
 
 extern "C" {
 int thrift_fcntl(THRIFT_SOCKET fd, int cmd, int flags);
-int thrift_poll(THRIFT_POLLFD *fdArray, ULONG nfds, INT timeout);
+int thrift_poll(THRIFT_POLLFD* fdArray, ULONG nfds, INT timeout);
 }
 
 #ifdef _WIN32_WCE

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/windows/config.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/config.h b/lib/cpp/src/thrift/windows/config.h
index 9261ca8..dd0da35 100644
--- a/lib/cpp/src/thrift/windows/config.h
+++ b/lib/cpp/src/thrift/windows/config.h
@@ -30,53 +30,53 @@
 
 // use std::thread in MSVC11 (2012) or newer
 #if _MSC_VER >= 1700
-#  define USE_STD_THREAD 1
+#define USE_STD_THREAD 1
 // otherwise use boost threads
 #else
-#  define USE_BOOST_THREAD 1
+#define USE_BOOST_THREAD 1
 #endif
 
 #ifndef TARGET_WIN_XP
-#  define TARGET_WIN_XP 1
+#define TARGET_WIN_XP 1
 #endif
 
 #if TARGET_WIN_XP
-#  ifndef WINVER
-#    define WINVER 0x0501
-#  endif
-#  ifndef _WIN32_WINNT
-#    define _WIN32_WINNT 0x0501
-#  endif
+#ifndef WINVER
+#define WINVER 0x0501
+#endif
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
 #endif
 
 #ifndef _WIN32_WINNT
-#  define _WIN32_WINNT 0x0601
+#define _WIN32_WINNT 0x0601
 #endif
 
 #if defined(_M_IX86) || defined(_M_X64)
-#  define ARITHMETIC_RIGHT_SHIFT 1
-#  define SIGNED_RIGHT_SHIFT_IS 1
+#define ARITHMETIC_RIGHT_SHIFT 1
+#define SIGNED_RIGHT_SHIFT_IS 1
 #endif
 
-#pragma warning(disable: 4996) // Deprecated posix name.
+#pragma warning(disable : 4996) // Deprecated posix name.
 
 #define VERSION "1.0.0-dev"
 #define HAVE_GETTIMEOFDAY 1
 #define HAVE_SYS_STAT_H 1
 
 #ifdef HAVE_STDINT_H
-#  include <stdint.h>
+#include <stdint.h>
 #else
-#  include <boost/cstdint.hpp>
+#include <boost/cstdint.hpp>
 
-typedef boost::int64_t    int64_t;
-typedef boost::uint64_t  uint64_t;
-typedef boost::int32_t    int32_t;
-typedef boost::uint32_t  uint32_t;
-typedef boost::int16_t    int16_t;
-typedef boost::uint16_t  uint16_t;
-typedef boost::int8_t      int8_t;
-typedef boost::uint8_t    uint8_t;
+typedef boost::int64_t int64_t;
+typedef boost::uint64_t uint64_t;
+typedef boost::int32_t int32_t;
+typedef boost::uint32_t uint32_t;
+typedef boost::int16_t int16_t;
+typedef boost::uint16_t uint16_t;
+typedef boost::int8_t int8_t;
+typedef boost::uint8_t uint8_t;
 #endif
 
 #include <thrift/transport/PlatformSocket.h>
@@ -93,6 +93,6 @@ typedef boost::uint8_t    uint8_t;
 #pragma comment(lib, "Ws2.lib")
 #else
 #pragma comment(lib, "Ws2_32.lib")
-#pragma comment(lib, "advapi32.lib") //For security APIs in TPipeServer
+#pragma comment(lib, "advapi32.lib") // For security APIs in TPipeServer
 #endif
 #endif // _THRIFT_WINDOWS_CONFIG_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/AllProtocolTests.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/AllProtocolTests.cpp b/lib/cpp/test/AllProtocolTests.cpp
index 65d1927..29ba193 100644
--- a/lib/cpp/test/AllProtocolTests.cpp
+++ b/lib/cpp/test/AllProtocolTests.cpp
@@ -31,8 +31,8 @@ using namespace apache::thrift::transport;
 char errorMessage[ERR_LEN];
 
 int main(int argc, char** argv) {
-  (void) argc;
-  (void) argv;
+  (void)argc;
+  (void)argv;
   try {
     testProtocol<TBinaryProtocol>("TBinaryProtocol");
     testProtocol<TCompactProtocol>("TCompactProtocol");

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/AllProtocolTests.tcc
----------------------------------------------------------------------
diff --git a/lib/cpp/test/AllProtocolTests.tcc b/lib/cpp/test/AllProtocolTests.tcc
index 3c98943..8c8eaa8 100644
--- a/lib/cpp/test/AllProtocolTests.tcc
+++ b/lib/cpp/test/AllProtocolTests.tcc
@@ -45,7 +45,10 @@ void testNaked(Val val) {
   Val out;
   GenericIO::read(protocol, out);
   if (out != val) {
-    THRIFT_SNPRINTF(errorMessage, ERR_LEN, "Invalid naked test (type: %s)", ClassNames::getName<Val>());
+    THRIFT_SNPRINTF(errorMessage,
+                    ERR_LEN,
+                    "Invalid naked test (type: %s)",
+                    ClassNames::getName<Val>());
     throw TException(errorMessage);
   }
 }
@@ -97,22 +100,18 @@ void testMessage() {
     const char* name;
     TMessageType type;
     int32_t seqid;
-  } messages[] = {
-    {"short message name", T_CALL, 0},
-    {"1", T_REPLY, 12345},
-    {"loooooooooooooooooooooooooooooooooong", T_EXCEPTION, 1 << 16},
-    {"one way push", T_ONEWAY, 12},
-    {"Janky", T_CALL, 0}
-  };
+  } messages[] = {{"short message name", T_CALL, 0},
+                  {"1", T_REPLY, 12345},
+                  {"loooooooooooooooooooooooooooooooooong", T_EXCEPTION, 1 << 16},
+                  {"one way push", T_ONEWAY, 12},
+                  {"Janky", T_CALL, 0}};
   const int messages_count = sizeof(messages) / sizeof(TMessage);
 
   for (int i = 0; i < messages_count; i++) {
     shared_ptr<TTransport> transport(new TMemoryBuffer());
     shared_ptr<TProtocol> protocol(new TProto(transport));
 
-    protocol->writeMessageBegin(messages[i].name,
-                                messages[i].type,
-                                messages[i].seqid);
+    protocol->writeMessageBegin(messages[i].name, messages[i].type, messages[i].seqid);
     protocol->writeMessageEnd();
 
     std::string name;
@@ -120,9 +119,7 @@ void testMessage() {
     int32_t seqid;
 
     protocol->readMessageBegin(name, type, seqid);
-    if (name != messages[i].name ||
-        type != messages[i].type ||
-        seqid != messages[i].seqid) {
+    if (name != messages[i].name || type != messages[i].type || seqid != messages[i].seqid) {
       throw TException("readMessageBegin failed.");
     }
   }
@@ -191,7 +188,6 @@ void testProtocol(const char* protoname) {
     testNaked<TProto, int64_t>((std::numeric_limits<int64_t>::min)());
     testNaked<TProto, int64_t>((std::numeric_limits<int64_t>::max)());
 
-
     testNaked<TProto, int64_t>(0);
     for (int64_t i = 0; i < 62; i++) {
       testNaked<TProto, int64_t>(1L << i);
@@ -210,7 +206,7 @@ void testProtocol(const char* protoname) {
     testNaked<TProto, std::string>("short");
     testNaked<TProto, std::string>("borderlinetiny");
     testNaked<TProto, std::string>("a bit longer than the smallest possible");
-    testNaked<TProto, std::string>("\x1\x2\x3\x4\x5\x6\x7\x8\x9\xA"); //kinda binary test
+    testNaked<TProto, std::string>("\x1\x2\x3\x4\x5\x6\x7\x8\x9\xA"); // kinda binary test
 
     testField<TProto, T_STRING, std::string>("");
     testField<TProto, T_STRING, std::string>("short");

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/Base64Test.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/Base64Test.cpp b/lib/cpp/test/Base64Test.cpp
index 5caaae8..e9e86dd 100644
--- a/lib/cpp/test/Base64Test.cpp
+++ b/lib/cpp/test/Base64Test.cpp
@@ -23,7 +23,7 @@
 using apache::thrift::protocol::base64_encode;
 using apache::thrift::protocol::base64_decode;
 
-BOOST_AUTO_TEST_SUITE( Base64Test )
+BOOST_AUTO_TEST_SUITE(Base64Test)
 
 void setupTestData(int i, uint8_t* data, int& len) {
   len = 0;
@@ -42,7 +42,7 @@ void checkEncoding(uint8_t* data, int len) {
   }
 }
 
-BOOST_AUTO_TEST_CASE( test_Base64_Encode_Decode ) {
+BOOST_AUTO_TEST_CASE(test_Base64_Encode_Decode) {
   int len;
   uint8_t testInput[3];
   uint8_t testOutput[4];
@@ -64,7 +64,6 @@ BOOST_AUTO_TEST_CASE( test_Base64_Encode_Decode ) {
     // decode output and check that it matches input
     base64_decode(testOutput, len + 1);
     BOOST_ASSERT(0 == memcmp(testInput, testOutput, len));
-
   }
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/Benchmark.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp
index 3571150..cf6b79a 100644
--- a/lib/cpp/test/Benchmark.cpp
+++ b/lib/cpp/test/Benchmark.cpp
@@ -34,12 +34,8 @@ class Timer {
 public:
   timeval vStart;
 
-  Timer() {
-    THRIFT_GETTIMEOFDAY(&vStart, 0);
-  }
-  void start() {
-    THRIFT_GETTIMEOFDAY(&vStart, 0);
-  }
+  Timer() { THRIFT_GETTIMEOFDAY(&vStart, 0); }
+  void start() { THRIFT_GETTIMEOFDAY(&vStart, 0); }
 
   double frame() {
     timeval vEnd;
@@ -48,7 +44,6 @@ public:
     double dend = vEnd.tv_sec + ((double)vEnd.tv_usec / 1000000.0);
     return dend - dstart;
   }
-
 };
 
 int main() {
@@ -59,15 +54,15 @@ int main() {
   using namespace boost;
 
   OneOfEach ooe;
-  ooe.im_true   = true;
-  ooe.im_false  = false;
-  ooe.a_bite    = 0x7f;
+  ooe.im_true = true;
+  ooe.im_false = false;
+  ooe.a_bite = 0x7f;
   ooe.integer16 = 27000;
-  ooe.integer32 = 1<<24;
+  ooe.integer32 = 1 << 24;
   ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
   ooe.double_precision = M_PI;
-  ooe.some_characters  = "JSON THIS! \"\1";
-  ooe.zomg_unicode     = "\xd7\n\a\t";
+  ooe.some_characters = "JSON THIS! \"\1";
+  ooe.zomg_unicode = "\xd7\n\a\t";
   ooe.base64 = "\1\2\3\255";
 
   boost::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer());
@@ -77,7 +72,7 @@ int main() {
   {
     Timer timer;
 
-    for (int i = 0; i < num; i ++) {
+    for (int i = 0; i < num; i++) {
       buf->resetBuffer();
       TBinaryProtocolT<TBufferBase> prot(buf);
       ooe.write(&prot);
@@ -94,18 +89,17 @@ int main() {
 
     Timer timer;
 
-    for (int i = 0; i < num; i ++) {
+    for (int i = 0; i < num; i++) {
       OneOfEach ooe2;
       boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize));
-      //buf2->resetBuffer(data, datasize);
+      // buf2->resetBuffer(data, datasize);
       TBinaryProtocolT<TBufferBase> prot(buf2);
       ooe2.read(&prot);
 
-      //cout << apache::thrift::ThriftDebugString(ooe2) << endl << endl;
+      // cout << apache::thrift::ThriftDebugString(ooe2) << endl << endl;
     }
     cout << " Read: " << num / (1000 * timer.frame()) << " kHz" << endl;
   }
 
-
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/DebugProtoTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/DebugProtoTest.cpp b/lib/cpp/test/DebugProtoTest.cpp
index 5649e18..98c66b8 100644
--- a/lib/cpp/test/DebugProtoTest.cpp
+++ b/lib/cpp/test/DebugProtoTest.cpp
@@ -28,37 +28,34 @@ int main() {
   using std::endl;
   using namespace thrift::test::debug;
 
-
   OneOfEach ooe;
-  ooe.im_true   = true;
-  ooe.im_false  = false;
-  ooe.a_bite    = 0x7f;
+  ooe.im_true = true;
+  ooe.im_false = false;
+  ooe.a_bite = 0x7f;
   ooe.integer16 = 27000;
-  ooe.integer32 = 1<<24;
+  ooe.integer32 = 1 << 24;
   ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
   ooe.double_precision = M_PI;
-  ooe.some_characters  = "Debug THIS!";
-  ooe.zomg_unicode     = "\xd7\n\a\t";
+  ooe.some_characters = "Debug THIS!";
+  ooe.zomg_unicode = "\xd7\n\a\t";
 
   cout << apache::thrift::ThriftDebugString(ooe) << endl << endl;
 
-
   Nesting n;
   n.my_ooe = ooe;
   n.my_ooe.integer16 = 16;
   n.my_ooe.integer32 = 32;
   n.my_ooe.integer64 = 64;
-  n.my_ooe.double_precision = (std::sqrt(5.0)+1)/2;
-  n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
+  n.my_ooe.double_precision = (std::sqrt(5.0) + 1) / 2;
+  n.my_ooe.some_characters = ":R (me going \"rrrr\")";
   n.my_ooe.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
                               "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
                               "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
-  n.my_bonk.type    = 31337;
+  n.my_bonk.type = 31337;
   n.my_bonk.message = "I am a bonk... xor!";
 
   cout << apache::thrift::ThriftDebugString(n) << endl << endl;
 
-
   HolyMoley hm;
 
   hm.big.push_back(ooe);
@@ -80,27 +77,26 @@ int main() {
 
   std::vector<Bonk> stage2;
   hm.bonks["nothing"] = stage2;
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 1;
   stage2.back().message = "Wait.";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 2;
   stage2.back().message = "What?";
   hm.bonks["something"] = stage2;
   stage2.clear();
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 3;
   stage2.back().message = "quoth";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 4;
   stage2.back().message = "the raven";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 5;
   stage2.back().message = "nevermore";
   hm.bonks["poe"] = stage2;
 
   cout << apache::thrift::ThriftDebugString(hm) << endl << endl;
 
-
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/DebugProtoTest_extras.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/DebugProtoTest_extras.cpp b/lib/cpp/test/DebugProtoTest_extras.cpp
index c89db74..5c4fd35 100644
--- a/lib/cpp/test/DebugProtoTest_extras.cpp
+++ b/lib/cpp/test/DebugProtoTest_extras.cpp
@@ -21,13 +21,15 @@
 
 #include "gen-cpp/DebugProtoTest_types.h"
 
-
-namespace thrift { namespace test { namespace debug {
+namespace thrift {
+namespace test {
+namespace debug {
 
 bool Empty::operator<(Empty const& other) const {
-  (void) other;
+  (void)other;
   // It is empty, so all are equal.
   return false;
 }
-
-}}}
+}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/DenseProtoTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/DenseProtoTest.cpp b/lib/cpp/test/DenseProtoTest.cpp
index f73579f..d827d3c 100644
--- a/lib/cpp/test/DenseProtoTest.cpp
+++ b/lib/cpp/test/DenseProtoTest.cpp
@@ -42,7 +42,6 @@ g++ -Wall -g -I../lib/cpp/src -I/usr/local/include/boost-1_33_1 \
 #include <thrift/protocol/TDenseProtocol.h>
 #include <thrift/transport/TBufferTransports.h>
 
-
 // Can't use memcmp here.  GCC is too smart.
 bool my_memeq(const char* str1, const char* str2, int len) {
   for (int i = 0; i < len; i++) {
@@ -53,7 +52,6 @@ bool my_memeq(const char* str1, const char* str2, int len) {
   return true;
 }
 
-
 int main() {
   using std::string;
   using std::cout;
@@ -63,36 +61,33 @@ int main() {
   using namespace apache::thrift::transport;
   using namespace apache::thrift::protocol;
 
-
   OneOfEach ooe;
-  ooe.im_true   = true;
-  ooe.im_false  = false;
-  ooe.a_bite    = 0xd6;
+  ooe.im_true = true;
+  ooe.im_false = false;
+  ooe.a_bite = 0xd6;
   ooe.integer16 = 27000;
-  ooe.integer32 = 1<<24;
+  ooe.integer32 = 1 << 24;
   ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
   ooe.double_precision = M_PI;
-  ooe.some_characters  = "Debug THIS!";
-  ooe.zomg_unicode     = "\xd7\n\a\t";
-
-  //cout << apache::thrift::ThriftDebugString(ooe) << endl << endl;
+  ooe.some_characters = "Debug THIS!";
+  ooe.zomg_unicode = "\xd7\n\a\t";
 
+  // cout << apache::thrift::ThriftDebugString(ooe) << endl << endl;
 
   Nesting n;
   n.my_ooe = ooe;
   n.my_ooe.integer16 = 16;
   n.my_ooe.integer32 = 32;
   n.my_ooe.integer64 = 64;
-  n.my_ooe.double_precision = (std::sqrt(5)+1)/2;
-  n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
+  n.my_ooe.double_precision = (std::sqrt(5) + 1) / 2;
+  n.my_ooe.some_characters = ":R (me going \"rrrr\")";
   n.my_ooe.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
                               "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
                               "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
-  n.my_bonk.type    = 31337;
+  n.my_bonk.type = 31337;
   n.my_bonk.message = "I am a bonk... xor!";
 
-  //cout << apache::thrift::ThriftDebugString(n) << endl << endl;
-
+  // cout << apache::thrift::ThriftDebugString(n) << endl << endl;
 
   HolyMoley hm;
 
@@ -115,26 +110,26 @@ int main() {
 
   std::vector<Bonk> stage2;
   hm.bonks["nothing"] = stage2;
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 1;
   stage2.back().message = "Wait.";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 2;
   stage2.back().message = "What?";
   hm.bonks["something"] = stage2;
   stage2.clear();
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 3;
   stage2.back().message = "quoth";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 4;
   stage2.back().message = "the raven";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 5;
   stage2.back().message = "nevermore";
   hm.bonks["poe"] = stage2;
 
-  //cout << apache::thrift::ThriftDebugString(hm) << endl << endl;
+  // cout << apache::thrift::ThriftDebugString(hm) << endl << endl;
 
   shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer());
   shared_ptr<TDenseProtocol> proto(new TDenseProtocol(buffer));
@@ -146,16 +141,16 @@ int main() {
 
   assert(hm == hm2);
 
-
   // Let's test out the variable-length ints, shall we?
   uint64_t vlq;
-  #define checkout(i, c) { \
-    buffer->resetBuffer(); \
-    proto->vlqWrite(i); \
-    proto->getTransport()->flush(); \
-    assert(my_memeq(buffer->getBufferAsString().data(), c, sizeof(c)-1)); \
-    proto->vlqRead(vlq); \
-    assert(vlq == i); \
+#define checkout(i, c)                                                                             \
+  {                                                                                                \
+    buffer->resetBuffer();                                                                         \
+    proto->vlqWrite(i);                                                                            \
+    proto->getTransport()->flush();                                                                \
+    assert(my_memeq(buffer->getBufferAsString().data(), c, sizeof(c) - 1));                        \
+    proto->vlqRead(vlq);                                                                           \
+    assert(vlq == i);                                                                              \
   }
 
   checkout(0x00000000, "\x00");
@@ -292,7 +287,6 @@ int main() {
 
   assert(mo1 == mo6);
 
-
   // Test fingerprint checking stuff.
 
   {
@@ -366,7 +360,7 @@ int main() {
     buffer->resetBuffer();
     // Make sure the fingerprint prefix is right.
     buffer->write(Nesting::binary_fingerprint, 4);
-    for (int j = 0; j < 1024*1024; j++) {
+    for (int j = 0; j < 1024 * 1024; j++) {
       uint8_t r = std::rand();
       buffer->write(&r, 1);
     }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/EnumTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/EnumTest.cpp b/lib/cpp/test/EnumTest.cpp
index 72f98bb..0e34b16 100644
--- a/lib/cpp/test/EnumTest.cpp
+++ b/lib/cpp/test/EnumTest.cpp
@@ -20,9 +20,9 @@
 #include <boost/test/unit_test.hpp>
 #include "gen-cpp/EnumTest_types.h"
 
-BOOST_AUTO_TEST_SUITE( EnumTest )
+BOOST_AUTO_TEST_SUITE(EnumTest)
 
-BOOST_AUTO_TEST_CASE( test_enum ) {
+BOOST_AUTO_TEST_CASE(test_enum) {
   // Check that all the enum values match what we expect
   BOOST_CHECK_EQUAL(MyEnum1::ME1_0, 0);
   BOOST_CHECK_EQUAL(MyEnum1::ME1_1, 1);
@@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE( test_enum ) {
   BOOST_CHECK_EQUAL(MyEnum4::ME4_C, 0x7fffffff);
 }
 
-BOOST_AUTO_TEST_CASE( test_enum_constant ) {
+BOOST_AUTO_TEST_CASE(test_enum_constant) {
   MyStruct ms;
   BOOST_CHECK_EQUAL(ms.me2_2, 2);
   BOOST_CHECK_EQUAL(ms.me3_n2, -2);

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/GenericHelpers.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/GenericHelpers.h b/lib/cpp/test/GenericHelpers.h
index 1853a37..c175561 100644
--- a/lib/cpp/test/GenericHelpers.h
+++ b/lib/cpp/test/GenericHelpers.h
@@ -29,22 +29,41 @@ using namespace apache::thrift::protocol;
 
 /* ClassName Helper for cleaner exceptions */
 class ClassNames {
- public:
+public:
   template <typename T>
-  static const char* getName() { return "Unknown type"; }
+  static const char* getName() {
+    return "Unknown type";
+  }
 };
 
-template <> const char* ClassNames::getName<int8_t>() { return "byte"; }
-template <> const char* ClassNames::getName<int16_t>() { return "short"; }
-template <> const char* ClassNames::getName<int32_t>() { return "int"; }
-template <> const char* ClassNames::getName<int64_t>() { return "long"; }
-template <> const char* ClassNames::getName<double>() { return "double"; }
-template <> const char* ClassNames::getName<std::string>() { return "string"; }
+template <>
+const char* ClassNames::getName<int8_t>() {
+  return "byte";
+}
+template <>
+const char* ClassNames::getName<int16_t>() {
+  return "short";
+}
+template <>
+const char* ClassNames::getName<int32_t>() {
+  return "int";
+}
+template <>
+const char* ClassNames::getName<int64_t>() {
+  return "long";
+}
+template <>
+const char* ClassNames::getName<double>() {
+  return "double";
+}
+template <>
+const char* ClassNames::getName<std::string>() {
+  return "string";
+}
 
 /* Generic Protocol I/O function for tests */
 class GenericIO {
- public:
-
+public:
   /* Write functions */
 
   static uint32_t write(shared_ptr<TProtocol> proto, const int8_t& val) {
@@ -73,30 +92,19 @@ class GenericIO {
 
   /* Read functions */
 
-  static uint32_t read(shared_ptr<TProtocol> proto, int8_t& val) {
-    return proto->readByte(val);
-  }
+  static uint32_t read(shared_ptr<TProtocol> proto, int8_t& val) { return proto->readByte(val); }
 
-  static uint32_t read(shared_ptr<TProtocol> proto, int16_t& val) {
-    return proto->readI16(val);
-  }
+  static uint32_t read(shared_ptr<TProtocol> proto, int16_t& val) { return proto->readI16(val); }
 
-  static uint32_t read(shared_ptr<TProtocol> proto, int32_t& val) {
-    return proto->readI32(val);
-  }
+  static uint32_t read(shared_ptr<TProtocol> proto, int32_t& val) { return proto->readI32(val); }
 
-  static uint32_t read(shared_ptr<TProtocol> proto, int64_t& val) {
-    return proto->readI64(val);
-  }
+  static uint32_t read(shared_ptr<TProtocol> proto, int64_t& val) { return proto->readI64(val); }
 
-  static uint32_t read(shared_ptr<TProtocol> proto, double& val) {
-    return proto->readDouble(val);
-  }
+  static uint32_t read(shared_ptr<TProtocol> proto, double& val) { return proto->readDouble(val); }
 
   static uint32_t read(shared_ptr<TProtocol> proto, std::string& val) {
     return proto->readString(val);
   }
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/JSONProtoTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/JSONProtoTest.cpp b/lib/cpp/test/JSONProtoTest.cpp
index a3259c0..aa07f93 100644
--- a/lib/cpp/test/JSONProtoTest.cpp
+++ b/lib/cpp/test/JSONProtoTest.cpp
@@ -32,35 +32,33 @@ int main() {
   using apache::thrift::protocol::TJSONProtocol;
 
   OneOfEach ooe;
-  ooe.im_true   = true;
-  ooe.im_false  = false;
-  ooe.a_bite    = 0x7f;
+  ooe.im_true = true;
+  ooe.im_false = false;
+  ooe.a_bite = 0x7f;
   ooe.integer16 = 27000;
-  ooe.integer32 = 1<<24;
+  ooe.integer32 = 1 << 24;
   ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
   ooe.double_precision = M_PI;
-  ooe.some_characters  = "JSON THIS! \"\1";
-  ooe.zomg_unicode     = "\xd7\n\a\t";
+  ooe.some_characters = "JSON THIS! \"\1";
+  ooe.zomg_unicode = "\xd7\n\a\t";
   ooe.base64 = "\1\2\3\255";
   cout << apache::thrift::ThriftJSONString(ooe) << endl << endl;
 
-
   Nesting n;
   n.my_ooe = ooe;
   n.my_ooe.integer16 = 16;
   n.my_ooe.integer32 = 32;
   n.my_ooe.integer64 = 64;
-  n.my_ooe.double_precision = (std::sqrt(5.0)+1)/2;
-  n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
+  n.my_ooe.double_precision = (std::sqrt(5.0) + 1) / 2;
+  n.my_ooe.some_characters = ":R (me going \"rrrr\")";
   n.my_ooe.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
                               "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
                               "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
-  n.my_bonk.type    = 31337;
+  n.my_bonk.type = 31337;
   n.my_bonk.message = "I am a bonk... xor!";
 
   cout << apache::thrift::ThriftJSONString(n) << endl << endl;
 
-
   HolyMoley hm;
 
   hm.big.push_back(ooe);
@@ -82,21 +80,21 @@ int main() {
 
   std::vector<Bonk> stage2;
   hm.bonks["nothing"] = stage2;
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 1;
   stage2.back().message = "Wait.";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 2;
   stage2.back().message = "What?";
   hm.bonks["something"] = stage2;
   stage2.clear();
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 3;
   stage2.back().message = "quoth";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 4;
   stage2.back().message = "the raven";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 5;
   stage2.back().message = "nevermore";
   hm.bonks["poe"] = stage2;
@@ -106,7 +104,6 @@ int main() {
   boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer());
   boost::shared_ptr<TJSONProtocol> proto(new TJSONProtocol(buffer));
 
-
   cout << "Testing ooe" << endl;
 
   ooe.write(proto.get());
@@ -115,7 +112,6 @@ int main() {
 
   assert(ooe == ooe2);
 
-
   cout << "Testing hm" << endl;
 
   hm.write(proto.get());
@@ -129,10 +125,10 @@ int main() {
   assert(hm != hm2);
 
   Doubles dub;
-  dub.nan = HUGE_VAL/HUGE_VAL;
+  dub.nan = HUGE_VAL / HUGE_VAL;
   dub.inf = HUGE_VAL;
   dub.neginf = -HUGE_VAL;
-  dub.repeating = 10.0/3.0;
+  dub.repeating = 10.0 / 3.0;
   dub.big = 1E+305;
   dub.tiny = 1E-305;
   dub.zero = 0.0;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/OpenSSLManualInitTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp
index fbecbc3..b04ed43 100644
--- a/lib/cpp/test/OpenSSLManualInitTest.cpp
+++ b/lib/cpp/test/OpenSSLManualInitTest.cpp
@@ -69,8 +69,7 @@ void test_openssl_availability() {
 boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
   THRIFT_UNUSED_VARIABLE(argc);
   THRIFT_UNUSED_VARIABLE(argv);
-  boost::unit_test::test_suite* suite =
-    &boost::unit_test::framework::master_test_suite();
+  boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();
   suite->p_name.value = "OpenSSLManualInit";
 
   suite->add(BOOST_TEST_CASE(test_openssl_availability));

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/OptionalRequiredTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/OptionalRequiredTest.cpp b/lib/cpp/test/OptionalRequiredTest.cpp
index 44b6885..79fa697 100644
--- a/lib/cpp/test/OptionalRequiredTest.cpp
+++ b/lib/cpp/test/OptionalRequiredTest.cpp
@@ -38,7 +38,6 @@ using namespace apache::thrift;
 using namespace apache::thrift::transport;
 using namespace apache::thrift::protocol;
 
-
 /*
 template<typename Struct>
 void trywrite(const Struct& s, bool should_work) {
@@ -55,13 +54,12 @@ void trywrite(const Struct& s, bool should_work) {
 */
 
 template <typename Struct1, typename Struct2>
-void write_to_read(const Struct1 & w, Struct2 & r) {
+void write_to_read(const Struct1& w, Struct2& r) {
   TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer));
   w.write(&protocol);
   r.read(&protocol);
 }
 
-
 int main() {
 
   cout << "This old school struct should have three fields." << endl;
@@ -98,22 +96,22 @@ int main() {
     Simple s1, s2, s3;
     s1.im_optional = 10;
     assert(!s1.__isset.im_default);
-  //assert(!s1.__isset.im_required);  // Compile error.
+    // assert(!s1.__isset.im_required);  // Compile error.
     assert(!s1.__isset.im_optional);
 
     write_to_read(s1, s2);
 
-    assert( s2.__isset.im_default);
-  //assert( s2.__isset.im_required);  // Compile error.
+    assert(s2.__isset.im_default);
+    // assert( s2.__isset.im_required);  // Compile error.
     assert(!s2.__isset.im_optional);
     assert(s3.im_optional == 0);
 
     s1.__isset.im_optional = true;
     write_to_read(s1, s3);
 
-    assert( s3.__isset.im_default);
-  //assert( s3.__isset.im_required);  // Compile error.
-    assert( s3.__isset.im_optional);
+    assert(s3.__isset.im_default);
+    // assert( s3.__isset.im_required);  // Compile error.
+    assert(s3.__isset.im_optional);
     assert(s3.im_optional == 10);
   }
 
@@ -126,7 +124,7 @@ int main() {
     write_to_read(t2, t1);
     write_to_read(t1, t2);
     assert(!t1.__isset.im_default);
-    assert( t2.__isset.im_optional);
+    assert(t2.__isset.im_optional);
     assert(t1.im_default == t2.im_optional);
     assert(t1.im_default == 0);
   }
@@ -156,8 +154,8 @@ int main() {
     try {
       write_to_read(t2, t3);
       abort();
+    } catch (const TProtocolException&) {
     }
-    catch (const TProtocolException&) {}
 
     write_to_read(t3, t2);
     assert(t2.__isset.im_optional);
@@ -169,7 +167,6 @@ int main() {
     cout << ThriftDebugString(c) << endl;
   }
 
-
   {
     Tricky1 t1;
     Tricky2 t2;
@@ -194,12 +191,12 @@ int main() {
     assert(o1 == o2);
     o1.__isset.im_str = o2.__isset.im_str = true;
     assert(o1 == o2);
-    map<int32_t,string> mymap;
+    map<int32_t, string> mymap;
     mymap[1] = "bar";
     mymap[2] = "baz";
-    o1.im_big.push_back(map<int32_t,string>());
+    o1.im_big.push_back(map<int32_t, string>());
     assert(o1 != o2);
-    o2.im_big.push_back(map<int32_t,string>());
+    o2.im_big.push_back(map<int32_t, string>());
     assert(o1 == o2);
     o2.im_big.push_back(mymap);
     assert(o1 != o2);
@@ -220,7 +217,7 @@ int main() {
     o3.im_big.push_back(mymap);
     assert(o1 == o3);
 
-    //cout << ThriftDebugString(o3) << endl;
+    // cout << ThriftDebugString(o3) << endl;
   }
 
   {

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/RWMutexStarveTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/RWMutexStarveTest.cpp b/lib/cpp/test/RWMutexStarveTest.cpp
index e6cccf2..32c1531 100644
--- a/lib/cpp/test/RWMutexStarveTest.cpp
+++ b/lib/cpp/test/RWMutexStarveTest.cpp
@@ -33,16 +33,13 @@ using boost::unit_test::framework::master_test_suite;
 using namespace apache::thrift::concurrency;
 using namespace std;
 
-class Locker : public Runnable
-{
+class Locker : public Runnable {
 protected:
-  Locker(boost::shared_ptr<ReadWriteMutex> rwlock, bool writer) :
-    rwlock_(rwlock), writer_(writer),
-    started_(false), gotLock_(false), signaled_(false) { }
+  Locker(boost::shared_ptr<ReadWriteMutex> rwlock, bool writer)
+    : rwlock_(rwlock), writer_(writer), started_(false), gotLock_(false), signaled_(false) {}
 
 public:
-  virtual void run()
-  {
+  virtual void run() {
     started_ = true;
     if (writer_) {
       rwlock_->acquireWrite();
@@ -68,20 +65,17 @@ protected:
   volatile bool signaled_;
 };
 
-class Reader : public Locker
-{
+class Reader : public Locker {
 public:
-  Reader(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, false) { }
+  Reader(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, false) {}
 };
 
-class Writer : public Locker
-{
+class Writer : public Locker {
 public:
-  Writer(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, true) { }
+  Writer(boost::shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, true) {}
 };
 
-void test_starve(PosixThreadFactory::POLICY policy)
-{
+void test_starve(PosixThreadFactory::POLICY policy) {
   // the man pages for pthread_wrlock_rdlock suggest that any OS guarantee about
   // writer starvation may be influenced by the scheduling policy, so let's try
   // all 3 policies to see if any of them work.
@@ -148,20 +142,17 @@ void test_starve(PosixThreadFactory::POLICY policy)
   BOOST_CHECK_MESSAGE(success, "writer is starving");
 }
 
-BOOST_AUTO_TEST_SUITE( RWMutexStarveTest )
+BOOST_AUTO_TEST_SUITE(RWMutexStarveTest)
 
-BOOST_AUTO_TEST_CASE( test_starve_other )
-{
+BOOST_AUTO_TEST_CASE(test_starve_other) {
   test_starve(PosixThreadFactory::OTHER);
 }
 
-BOOST_AUTO_TEST_CASE( test_starve_rr )
-{
+BOOST_AUTO_TEST_CASE(test_starve_rr) {
   test_starve(PosixThreadFactory::ROUND_ROBIN);
 }
 
-BOOST_AUTO_TEST_CASE( test_starve_fifo )
-{
+BOOST_AUTO_TEST_CASE(test_starve_fifo) {
   test_starve(PosixThreadFactory::FIFO);
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/RecursiveTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/RecursiveTest.cpp b/lib/cpp/test/RecursiveTest.cpp
index 24c0f7c..a74be91 100644
--- a/lib/cpp/test/RecursiveTest.cpp
+++ b/lib/cpp/test/RecursiveTest.cpp
@@ -27,7 +27,7 @@
 
 using apache::thrift::transport::TMemoryBuffer;
 using apache::thrift::protocol::TBinaryProtocol;
-    using boost::shared_ptr;
+using boost::shared_ptr;
 
 int main() {
   shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer());
@@ -71,5 +71,4 @@ int main() {
     assert(false);
   } catch (const apache::thrift::protocol::TProtocolException& e) {
   }
-
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/SpecializationTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/SpecializationTest.cpp b/lib/cpp/test/SpecializationTest.cpp
index 0bef12a..856bdac 100644
--- a/lib/cpp/test/SpecializationTest.cpp
+++ b/lib/cpp/test/SpecializationTest.cpp
@@ -12,20 +12,20 @@ using namespace apache::thrift::transport;
 using namespace apache::thrift::protocol;
 
 typedef TBinaryProtocolT<TMemoryBuffer> MyProtocol;
-//typedef TBinaryProtocolT<TTransport> MyProtocol;
+// typedef TBinaryProtocolT<TTransport> MyProtocol;
 
 int main() {
 
   OneOfEach ooe;
-  ooe.im_true   = true;
-  ooe.im_false  = false;
-  ooe.a_bite    = 0x7f;
+  ooe.im_true = true;
+  ooe.im_false = false;
+  ooe.a_bite = 0x7f;
   ooe.integer16 = 27000;
-  ooe.integer32 = 1<<24;
+  ooe.integer32 = 1 << 24;
   ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
   ooe.double_precision = M_PI;
-  ooe.some_characters  = "JSON THIS! \"\1";
-  ooe.zomg_unicode     = "\xd7\n\a\t";
+  ooe.some_characters = "JSON THIS! \"\1";
+  ooe.zomg_unicode = "\xd7\n\a\t";
   ooe.base64 = "\1\2\3\255";
 
   Nesting n;
@@ -33,12 +33,12 @@ int main() {
   n.my_ooe.integer16 = 16;
   n.my_ooe.integer32 = 32;
   n.my_ooe.integer64 = 64;
-  n.my_ooe.double_precision = (std::sqrt(5.0)+1)/2;
-  n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
+  n.my_ooe.double_precision = (std::sqrt(5.0) + 1) / 2;
+  n.my_ooe.some_characters = ":R (me going \"rrrr\")";
   n.my_ooe.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
                               "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
                               "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
-  n.my_bonk.type    = 31337;
+  n.my_bonk.type = 31337;
   n.my_bonk.message = "I am a bonk... xor!";
 
   HolyMoley hm;
@@ -62,21 +62,21 @@ int main() {
 
   std::vector<Bonk> stage2;
   hm.bonks["nothing"] = stage2;
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 1;
   stage2.back().message = "Wait.";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 2;
   stage2.back().message = "What?";
   hm.bonks["something"] = stage2;
   stage2.clear();
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 3;
   stage2.back().message = "quoth";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 4;
   stage2.back().message = "the raven";
-  stage2.resize(stage2.size()+1);
+  stage2.resize(stage2.size() + 1);
   stage2.back().type = 5;
   stage2.back().message = "nevermore";
   hm.bonks["poe"] = stage2;
@@ -92,7 +92,6 @@ int main() {
 
   assert(ooe == ooe2);
 
-
   cout << "Testing hm" << endl;
 
   hm.write(proto.get());

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TFDTransportTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TFDTransportTest.cpp b/lib/cpp/test/TFDTransportTest.cpp
index 7b962d8..9d2bd90 100644
--- a/lib/cpp/test/TFDTransportTest.cpp
+++ b/lib/cpp/test/TFDTransportTest.cpp
@@ -25,13 +25,10 @@
 using apache::thrift::transport::TTransportException;
 using apache::thrift::transport::TFDTransport;
 
-class DummyException : std::exception {
-};
+class DummyException : std::exception {};
 
 int main() {
-  {
-    TFDTransport t(256, TFDTransport::NO_CLOSE_ON_DESTROY);
-  }
+  { TFDTransport t(256, TFDTransport::NO_CLOSE_ON_DESTROY); }
 
   try {
     {
@@ -56,5 +53,4 @@ int main() {
   }
 
   return 0;
-
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TFileTransportTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp
old mode 100755
new mode 100644
index 67e05e3..294c9a6
--- a/lib/cpp/test/TFileTransportTest.cpp
+++ b/lib/cpp/test/TFileTransportTest.cpp
@@ -41,7 +41,6 @@ static const char* tmp_dir = "/tmp";
 class FsyncLog;
 FsyncLog* fsync_log;
 
-
 /**************************************************************************
  * Helper code
  **************************************************************************/
@@ -49,11 +48,11 @@ FsyncLog* fsync_log;
 // Provide BOOST_WARN_LT() and BOOST_WARN_GT(), in case we're compiled
 // with an older version of boost
 #ifndef BOOST_WARN_LT
-#define BOOST_WARN_CMP(a, b, op, check_fn) \
-  check_fn((a) op (b), \
-           "check " BOOST_STRINGIZE(a) " " BOOST_STRINGIZE(op) " " \
-           BOOST_STRINGIZE(b) " failed: " BOOST_STRINGIZE(a) "=" << (a) << \
-           " " BOOST_STRINGIZE(b) "=" << (b))
+#define BOOST_WARN_CMP(a, b, op, check_fn)                                                         \
+  check_fn((a)op(b),                                                                               \
+           "check " BOOST_STRINGIZE(a) " " BOOST_STRINGIZE(op) " " BOOST_STRINGIZE(                \
+               b) " failed: " BOOST_STRINGIZE(a) "="                                               \
+           << (a) << " " BOOST_STRINGIZE(b) "=" << (b))
 
 #define BOOST_WARN_LT(a, b) BOOST_WARN_CMP(a, b, <, BOOST_WARN_MESSAGE)
 #define BOOST_WARN_GT(a, b) BOOST_WARN_CMP(a, b, >, BOOST_WARN_MESSAGE)
@@ -64,7 +63,7 @@ FsyncLog* fsync_log;
  * Class to record calls to fsync
  */
 class FsyncLog {
- public:
+public:
   struct FsyncCall {
     struct timeval time;
     int fd;
@@ -74,17 +73,15 @@ class FsyncLog {
   FsyncLog() {}
 
   void fsync(int fd) {
-    (void) fd;
+    (void)fd;
     FsyncCall call;
     gettimeofday(&call.time, NULL);
     calls_.push_back(call);
   }
 
-  const CallList* getCalls() const {
-    return &calls_;
-  }
+  const CallList* getCalls() const { return &calls_; }
 
- private:
+private:
   CallList calls_;
 };
 
@@ -92,7 +89,7 @@ class FsyncLog {
  * Helper class to clean up temporary files
  */
 class TempFile {
- public:
+public:
   TempFile(const char* directory, const char* prefix) {
     size_t path_len = strlen(directory) + strlen(prefix) + 8;
     path_ = new char[path_len];
@@ -109,13 +106,9 @@ class TempFile {
     close();
   }
 
-  const char* getPath() const {
-    return path_;
-  }
+  const char* getPath() const { return path_; }
 
-  int getFD() const {
-    return fd_;
-  }
+  int getFD() const { return fd_; }
 
   void unlink() {
     if (path_) {
@@ -134,7 +127,7 @@ class TempFile {
     fd_ = -1;
   }
 
- private:
+private:
   char* path_;
   int fd_;
 };
@@ -142,8 +135,7 @@ class TempFile {
 // Use our own version of fsync() for testing.
 // This returns immediately, so timing in test_destructor() isn't affected by
 // waiting on the actual filesystem.
-extern "C"
-int fsync(int fd) {
+extern "C" int fsync(int fd) {
   if (fsync_log) {
     fsync_log->fsync(fd);
   }
@@ -154,7 +146,6 @@ int time_diff(const struct timeval* t1, const struct timeval* t2) {
   return (t2->tv_usec - t1->tv_usec) + (t2->tv_sec - t1->tv_sec) * 1000000;
 }
 
-
 /**************************************************************************
  * Test cases
  **************************************************************************/
@@ -221,8 +212,7 @@ BOOST_AUTO_TEST_CASE(test_destructor) {
 /**
  * Make sure setFlushMaxUs() is honored.
  */
-void test_flush_max_us_impl(uint32_t flush_us, uint32_t write_us,
-                            uint32_t test_us) {
+void test_flush_max_us_impl(uint32_t flush_us, uint32_t write_us, uint32_t test_us) {
   // TFileTransport only calls fsync() if data has been written,
   // so make sure the write interval is smaller than the flush interval.
   BOOST_WARN(write_us < flush_us);
@@ -277,13 +267,10 @@ void test_flush_max_us_impl(uint32_t flush_us, uint32_t write_us,
   const FsyncLog::CallList* calls = log.getCalls();
   // We added 1 fsync call above.
   // Make sure TFileTransport called fsync at least once
-  BOOST_WARN_GE(calls->size(),
-                 static_cast<FsyncLog::CallList::size_type>(1));
+  BOOST_WARN_GE(calls->size(), static_cast<FsyncLog::CallList::size_type>(1));
 
   const struct timeval* prev_time = NULL;
-  for (FsyncLog::CallList::const_iterator it = calls->begin();
-       it != calls->end();
-       ++it) {
+  for (FsyncLog::CallList::const_iterator it = calls->begin(); it != calls->end(); ++it) {
     if (prev_time) {
       int delta = time_diff(prev_time, &it->time);
       BOOST_WARN_LT(delta, max_allowed_delta);
@@ -352,11 +339,8 @@ void print_usage(FILE* f, const char* argv0) {
 }
 
 void parse_args(int argc, char* argv[]) {
-  struct option long_opts[] = {
-    { "help", false, NULL, 'h' },
-    { "tmp-dir", true, NULL, 't' },
-    { NULL, 0, NULL, 0 }
-  };
+  struct option long_opts[]
+      = {{"help", false, NULL, 'h'}, {"tmp-dir", true, NULL, 't'}, {NULL, 0, NULL, 0}};
 
   while (true) {
     optopt = 1;
@@ -366,26 +350,25 @@ void parse_args(int argc, char* argv[]) {
     }
 
     switch (optchar) {
-      case 't':
-        tmp_dir = optarg;
-        break;
-      case 'h':
-        print_usage(stdout, argv[0]);
-        exit(0);
-      case '?':
-        exit(1);
-      default:
-        // Only happens if someone adds another option to the optarg string,
-        // but doesn't update the switch statement to handle it.
-        fprintf(stderr, "unknown option \"-%c\"\n", optchar);
-        exit(1);
+    case 't':
+      tmp_dir = optarg;
+      break;
+    case 'h':
+      print_usage(stdout, argv[0]);
+      exit(0);
+    case '?':
+      exit(1);
+    default:
+      // Only happens if someone adds another option to the optarg string,
+      // but doesn't update the switch statement to handle it.
+      fprintf(stderr, "unknown option \"-%c\"\n", optchar);
+      exit(1);
     }
   }
 }
 
 boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
-  boost::unit_test::framework::master_test_suite().p_name.value =
-    "TFileTransportTest";
+  boost::unit_test::framework::master_test_suite().p_name.value = "TFileTransportTest";
 
   // Parse arguments
   parse_args(argc, argv);

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TMemoryBufferTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp
index b81a667..cf49477 100644
--- a/lib/cpp/test/TMemoryBufferTest.cpp
+++ b/lib/cpp/test/TMemoryBufferTest.cpp
@@ -25,84 +25,84 @@
 #include <thrift/protocol/TBinaryProtocol.h>
 #include "gen-cpp/ThriftTest_types.h"
 
-BOOST_AUTO_TEST_SUITE( TMemoryBufferTest )
-
-BOOST_AUTO_TEST_CASE( test_roundtrip ) {
-    using apache::thrift::transport::TMemoryBuffer;
-    using apache::thrift::protocol::TBinaryProtocol;
-    using boost::shared_ptr;
-
-    shared_ptr<TMemoryBuffer> strBuffer(new TMemoryBuffer());
-    shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(strBuffer));
-
-    thrift::test::Xtruct a;
-    a.i32_thing = 10;
-    a.i64_thing = 30;
-    a.string_thing ="holla back a";
-
-    a.write(binaryProtcol.get());
-    std::string serialized = strBuffer->getBufferAsString();
-
-    shared_ptr<TMemoryBuffer> strBuffer2(new TMemoryBuffer());
-    shared_ptr<TBinaryProtocol> binaryProtcol2(new TBinaryProtocol(strBuffer2));
-
-    strBuffer2->resetBuffer((uint8_t*)serialized.data(), static_cast<uint32_t>(serialized.length()));
-    thrift::test::Xtruct a2;
-    a2.read(binaryProtcol2.get());
-
-    assert(a == a2);
+BOOST_AUTO_TEST_SUITE(TMemoryBufferTest)
+
+BOOST_AUTO_TEST_CASE(test_roundtrip) {
+  using apache::thrift::transport::TMemoryBuffer;
+  using apache::thrift::protocol::TBinaryProtocol;
+  using boost::shared_ptr;
+
+  shared_ptr<TMemoryBuffer> strBuffer(new TMemoryBuffer());
+  shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(strBuffer));
+
+  thrift::test::Xtruct a;
+  a.i32_thing = 10;
+  a.i64_thing = 30;
+  a.string_thing = "holla back a";
+
+  a.write(binaryProtcol.get());
+  std::string serialized = strBuffer->getBufferAsString();
+
+  shared_ptr<TMemoryBuffer> strBuffer2(new TMemoryBuffer());
+  shared_ptr<TBinaryProtocol> binaryProtcol2(new TBinaryProtocol(strBuffer2));
+
+  strBuffer2->resetBuffer((uint8_t*)serialized.data(), static_cast<uint32_t>(serialized.length()));
+  thrift::test::Xtruct a2;
+  a2.read(binaryProtcol2.get());
+
+  assert(a == a2);
+}
+
+BOOST_AUTO_TEST_CASE(test_copy) {
+  using apache::thrift::transport::TMemoryBuffer;
+  using std::string;
+  using std::cout;
+  using std::endl;
+
+  string* str1 = new string("abcd1234");
+  const char* data1 = str1->data();
+  TMemoryBuffer buf((uint8_t*)str1->data(),
+                    static_cast<uint32_t>(str1->length()),
+                    TMemoryBuffer::COPY);
+  delete str1;
+  string* str2 = new string("plsreuse");
+  bool obj_reuse = (str1 == str2);
+  bool dat_reuse = (data1 == str2->data());
+  cout << "Object reuse: " << obj_reuse << "   Data reuse: " << dat_reuse
+       << ((obj_reuse && dat_reuse) ? "   YAY!" : "") << endl;
+  delete str2;
+
+  string str3 = "wxyz", str4 = "6789";
+  buf.readAppendToString(str3, 4);
+  buf.readAppendToString(str4, INT_MAX);
+
+  assert(str3 == "wxyzabcd");
+  assert(str4 == "67891234");
+}
+
+BOOST_AUTO_TEST_CASE(test_exceptions) {
+  using apache::thrift::transport::TTransportException;
+  using apache::thrift::transport::TMemoryBuffer;
+  using std::string;
+
+  char data[] = "foo\0bar";
+
+  TMemoryBuffer buf1((uint8_t*)data, 7, TMemoryBuffer::OBSERVE);
+  string str = buf1.getBufferAsString();
+  assert(str.length() == 7);
+  buf1.resetBuffer();
+  try {
+    buf1.write((const uint8_t*)"foo", 3);
+    assert(false);
+  } catch (TTransportException&) {
   }
 
-BOOST_AUTO_TEST_CASE( test_copy )
-  {
-    using apache::thrift::transport::TMemoryBuffer;
-    using std::string;
-    using std::cout;
-    using std::endl;
-
-    string* str1 = new string("abcd1234");
-    const char* data1 = str1->data();
-    TMemoryBuffer buf((uint8_t*)str1->data(), static_cast<uint32_t>(str1->length()), TMemoryBuffer::COPY);
-    delete str1;
-    string* str2 = new string("plsreuse");
-    bool obj_reuse = (str1 == str2);
-    bool dat_reuse = (data1 == str2->data());
-    cout << "Object reuse: " << obj_reuse << "   Data reuse: " << dat_reuse
-      << ((obj_reuse && dat_reuse) ? "   YAY!" : "") << endl;
-    delete str2;
-
-    string str3 = "wxyz", str4 = "6789";
-    buf.readAppendToString(str3, 4);
-    buf.readAppendToString(str4, INT_MAX);
-
-    assert(str3 == "wxyzabcd");
-    assert(str4 == "67891234");
-  }
-
-BOOST_AUTO_TEST_CASE( test_exceptions )
-  {
-    using apache::thrift::transport::TTransportException;
-    using apache::thrift::transport::TMemoryBuffer;
-    using std::string;
-
-    char data[] = "foo\0bar";
-
-    TMemoryBuffer buf1((uint8_t*)data, 7, TMemoryBuffer::OBSERVE);
-    string str = buf1.getBufferAsString();
-    assert(str.length() == 7);
-    buf1.resetBuffer();
-    try {
-      buf1.write((const uint8_t*)"foo", 3);
-      assert(false);
-    } catch (TTransportException&) {}
-
-    TMemoryBuffer buf2((uint8_t*)data, 7, TMemoryBuffer::COPY);
-    try {
-      buf2.write((const uint8_t*)"bar", 3);
-    } catch (TTransportException&) {
-      assert(false);
-    }
+  TMemoryBuffer buf2((uint8_t*)data, 7, TMemoryBuffer::COPY);
+  try {
+    buf2.write((const uint8_t*)"bar", 3);
+  } catch (TTransportException&) {
+    assert(false);
   }
+}
 
 BOOST_AUTO_TEST_SUITE_END()
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TPipedTransportTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TPipedTransportTest.cpp b/lib/cpp/test/TPipedTransportTest.cpp
index 7762f05..53a6fb5 100644
--- a/lib/cpp/test/TPipedTransportTest.cpp
+++ b/lib/cpp/test/TPipedTransportTest.cpp
@@ -36,18 +36,17 @@ int main() {
 
   underlying->write((uint8_t*)"abcd", 4);
   trans->readAll(buffer, 2);
-  assert( string((char*)buffer, 2) == "ab" );
+  assert(string((char*)buffer, 2) == "ab");
   trans->readEnd();
-  assert( pipe->getBufferAsString() == "ab" );
+  assert(pipe->getBufferAsString() == "ab");
   pipe->resetBuffer();
   underlying->write((uint8_t*)"ef", 2);
   trans->readAll(buffer, 2);
-  assert( string((char*)buffer, 2) == "cd" );
+  assert(string((char*)buffer, 2) == "cd");
   trans->readAll(buffer, 2);
-  assert( string((char*)buffer, 2) == "ef" );
+  assert(string((char*)buffer, 2) == "ef");
   trans->readEnd();
-  assert( pipe->getBufferAsString() == "cdef" );
+  assert(pipe->getBufferAsString() == "cdef");
 
   return 0;
-
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/ThriftTest_extras.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/ThriftTest_extras.cpp b/lib/cpp/test/ThriftTest_extras.cpp
index 33f681f..af5606e 100644
--- a/lib/cpp/test/ThriftTest_extras.cpp
+++ b/lib/cpp/test/ThriftTest_extras.cpp
@@ -22,12 +22,12 @@
 #include <thrift/protocol/TDebugProtocol.h>
 #include "gen-cpp/ThriftTest_types.h"
 
-
-namespace thrift { namespace test {
+namespace thrift {
+namespace test {
 
 bool Insanity::operator<(thrift::test::Insanity const& other) const {
   using apache::thrift::ThriftDebugString;
   return ThriftDebugString(*this) < ThriftDebugString(other);
 }
-
-}}
+}
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/ToStringTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/ToStringTest.cpp b/lib/cpp/test/ToStringTest.cpp
index 1a89c11..d204cb3 100644
--- a/lib/cpp/test/ToStringTest.cpp
+++ b/lib/cpp/test/ToStringTest.cpp
@@ -30,9 +30,9 @@
 
 using apache::thrift::to_string;
 
-BOOST_AUTO_TEST_SUITE( ToStringTest )
+BOOST_AUTO_TEST_SUITE(ToStringTest)
 
-BOOST_AUTO_TEST_CASE( base_types_to_string ) {
+BOOST_AUTO_TEST_CASE(base_types_to_string) {
   BOOST_CHECK_EQUAL(to_string(10), "10");
   BOOST_CHECK_EQUAL(to_string(true), "1");
   BOOST_CHECK_EQUAL(to_string('a'), "a");
@@ -40,91 +40,91 @@ BOOST_AUTO_TEST_CASE( base_types_to_string ) {
   BOOST_CHECK_EQUAL(to_string("abc"), "abc");
 }
 
-BOOST_AUTO_TEST_CASE( empty_vector_to_string ) {
+BOOST_AUTO_TEST_CASE(empty_vector_to_string) {
   std::vector<int> l;
   BOOST_CHECK_EQUAL(to_string(l), "[]");
 }
 
-BOOST_AUTO_TEST_CASE( single_item_vector_to_string ) {
+BOOST_AUTO_TEST_CASE(single_item_vector_to_string) {
   std::vector<int> l;
   l.push_back(100);
   BOOST_CHECK_EQUAL(to_string(l), "[100]");
 }
 
-BOOST_AUTO_TEST_CASE( multiple_item_vector_to_string ) {
+BOOST_AUTO_TEST_CASE(multiple_item_vector_to_string) {
   std::vector<int> l;
   l.push_back(100);
   l.push_back(150);
   BOOST_CHECK_EQUAL(to_string(l), "[100, 150]");
 }
 
-BOOST_AUTO_TEST_CASE( empty_map_to_string ) {
+BOOST_AUTO_TEST_CASE(empty_map_to_string) {
   std::map<int, std::string> m;
   BOOST_CHECK_EQUAL(to_string(m), "{}");
 }
 
-BOOST_AUTO_TEST_CASE( single_item_map_to_string ) {
+BOOST_AUTO_TEST_CASE(single_item_map_to_string) {
   std::map<int, std::string> m;
   m[12] = "abc";
   BOOST_CHECK_EQUAL(to_string(m), "{12: abc}");
 }
 
-BOOST_AUTO_TEST_CASE( multi_item_map_to_string ) {
+BOOST_AUTO_TEST_CASE(multi_item_map_to_string) {
   std::map<int, std::string> m;
   m[12] = "abc";
   m[31] = "xyz";
   BOOST_CHECK_EQUAL(to_string(m), "{12: abc, 31: xyz}");
 }
 
-BOOST_AUTO_TEST_CASE( empty_set_to_string ) {
+BOOST_AUTO_TEST_CASE(empty_set_to_string) {
   std::set<char> s;
   BOOST_CHECK_EQUAL(to_string(s), "{}");
 }
 
-BOOST_AUTO_TEST_CASE( single_item_set_to_string ) {
+BOOST_AUTO_TEST_CASE(single_item_set_to_string) {
   std::set<char> s;
   s.insert('c');
   BOOST_CHECK_EQUAL(to_string(s), "{c}");
 }
 
-BOOST_AUTO_TEST_CASE( multi_item_set_to_string ) {
+BOOST_AUTO_TEST_CASE(multi_item_set_to_string) {
   std::set<char> s;
   s.insert('a');
   s.insert('z');
   BOOST_CHECK_EQUAL(to_string(s), "{a, z}");
 }
 
-BOOST_AUTO_TEST_CASE( generated_empty_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_empty_object_to_string) {
   thrift::test::EmptyStruct e;
   BOOST_CHECK_EQUAL(to_string(e), "EmptyStruct()");
 }
 
-BOOST_AUTO_TEST_CASE( generated_single_basic_field_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_single_basic_field_object_to_string) {
   thrift::test::StructA a;
   a.__set_s("abcd");
   BOOST_CHECK_EQUAL(to_string(a), "StructA(s=abcd)");
 }
 
-BOOST_AUTO_TEST_CASE( generated_two_basic_fields_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_two_basic_fields_object_to_string) {
   thrift::test::Bonk a;
   a.__set_message("abcd");
   a.__set_type(1234);
   BOOST_CHECK_EQUAL(to_string(a), "Bonk(message=abcd, type=1234)");
 }
 
-BOOST_AUTO_TEST_CASE( generated_optional_fields_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_optional_fields_object_to_string) {
   thrift::test::Tricky2 a;
   BOOST_CHECK_EQUAL(to_string(a), "Tricky2(im_optional=<null>)");
   a.__set_im_optional(123);
   BOOST_CHECK_EQUAL(to_string(a), "Tricky2(im_optional=123)");
 }
 
-BOOST_AUTO_TEST_CASE( generated_nested_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_nested_object_to_string) {
   thrift::test::OneField a;
   BOOST_CHECK_EQUAL(to_string(a), "OneField(field=EmptyStruct())");
 }
 
-BOOST_AUTO_TEST_CASE( generated_nested_list_object_to_string ) {
+BOOST_AUTO_TEST_CASE(generated_nested_list_object_to_string) {
   thrift::test::ListBonks l;
   l.bonk.assign(2, thrift::test::Bonk());
   l.bonk[0].__set_message("a");


[30/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_delphi_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_delphi_generator.cc b/compiler/cpp/src/generate/t_delphi_generator.cc
index 1012614..682c18d 100644
--- a/compiler/cpp/src/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/generate/t_delphi_generator.cc
@@ -45,236 +45,375 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
-
-class t_delphi_generator : public t_oop_generator
-{
-  public:
-    t_delphi_generator(
-        t_program* program,
-        const std::map<std::string, std::string>& parsed_options,
-        const std::string& option_string)
-      : t_oop_generator(program)
-    {
-      (void) option_string;
-      indent_impl_ = 0;
-      has_forward = false;
-      has_enum = false;
-      has_const = false;
-      std::map<std::string, std::string>::const_iterator iter;
-
-      iter = parsed_options.find("ansistr_binary");
-      ansistr_binary_ = (iter != parsed_options.end());
-      iter = parsed_options.find("register_types");
-      register_types_ = (iter != parsed_options.end());
-      iter = parsed_options.find("constprefix");
-      constprefix_ = (iter != parsed_options.end());
-      iter = parsed_options.find("events");
-      events_ = (iter != parsed_options.end());
-      iter = parsed_options.find("xmldoc");
-      xmldoc_ = (iter != parsed_options.end());
-
-
-      out_dir_base_ = "gen-delphi";
-      escape_.clear();
-      escape_['\''] = "''";
-    }
-
-
-    void init_generator();
-    void close_generator();
-
-    void generate_consts(std::vector<t_const*> consts);
-
-    void generate_typedef (t_typedef* ttypedef);
-    void generate_enum (t_enum* tenum);
-    void generate_forward_declaration(t_struct* tstruct);
-    void generate_struct (t_struct* tstruct);
-    void generate_xception (t_struct* txception);
-    void generate_service (t_service* tservice);
-    void generate_property(ostream& out, t_field* tfield, bool isPublic,  bool is_xception);
-    void generate_property_writer_(ostream& out, t_field* tfield, bool isPublic);
-
-    void generate_delphi_property(ostream& out, bool struct_is_exception, t_field* tfield, bool isPublic, std::string fieldPrefix = "");
-    void generate_delphi_isset_reader_definition(ostream& out, t_field* tfield, bool is_xception);
-    void generate_delphi_property_reader_definition(ostream& out, t_field* tfield, bool is_xception_class);
-    void generate_delphi_property_writer_definition(ostream& out, t_field* tfield, bool is_xception_class);
-    void generate_delphi_property_reader_impl(ostream& out, std::string cls_prefix, std::string name, t_type* type, t_field* tfield, std::string fieldPrefix, bool is_xception_class);
-    void generate_delphi_property_writer_impl(ostream& out, std::string cls_prefix, std::string name, t_type* type, t_field* tfield, std::string fieldPrefix, bool is_xception_class, bool is_union, bool is_xception_factory, std::string xception_factroy_name);
-    void generate_delphi_clear_union_value(ostream& out, std::string cls_prefix, std::string name, t_type* type, t_field* tfield, std::string fieldPrefix, bool is_xception_class, bool is_union, bool is_xception_factory, std::string xception_factroy_name);
-    void generate_delphi_isset_reader_impl(ostream& out, std::string cls_prefix, std::string name, t_type* type, t_field* tfield, std::string fieldPrefix, bool is_xception);
-    void generate_delphi_struct_writer_impl(ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception);
-    void generate_delphi_struct_result_writer_impl(ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception);
-
-    void generate_delphi_struct_tostring_impl(ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_x_factory);
-
-    void add_delphi_uses_list( string unitname);
-
-    void generate_delphi_struct_reader_impl(ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception);
-    void generate_delphi_create_exception_impl(ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception);
-
-    bool const_needs_var(t_type* type);
-    void print_const_prop(std::ostream& out, string name, t_type* type, t_const_value* value);
-    void print_private_field(std::ostream& out, string name, t_type* type, t_const_value* value);
-    void print_const_value ( std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value);
-    void initialize_field(std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value);
-    void finalize_field(std::ostream& out, std::string name, t_type* type, t_const_value* value, std::string cls_nm = "");
-    std::string render_const_value( std::ostream& local_vars, std::ostream& out, std::string name, t_type* type, t_const_value* value);
-    void print_const_def_value( std::ostream& vars, std::ostream& out, std::string name, t_type* type, t_const_value* value, std::string cls_nm = "");
-    std::string make_constants_classname();
-
-    void generate_delphi_struct(t_struct* tstruct, bool is_exception);
-    void generate_delphi_struct_impl( ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
-    void print_delphi_struct_type_factory_func(  ostream& out, t_struct* tstruct);
-    void generate_delphi_struct_type_factory(  ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
-    void generate_delphi_struct_type_factory_registration(  ostream& out, std::string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result = false, bool is_x_factory = false);
-    void generate_delphi_struct_definition(std::ostream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false, bool is_x_factory = false);
-    void generate_delphi_struct_reader(std::ostream& out, t_struct* tstruct);
-    void generate_delphi_struct_result_writer(std::ostream& out, t_struct* tstruct);
-    void generate_delphi_struct_writer(std::ostream& out, t_struct* tstruct);
-    void generate_delphi_struct_tostring(std::ostream& out, t_struct* tstruct);
-
-    void generate_function_helpers(t_function* tfunction);
-    void generate_service_interface (t_service* tservice);
-    void generate_service_helpers (t_service* tservice);
-    void generate_service_client (t_service* tservice);
-    void generate_service_server (t_service* tservice);
-    void generate_process_function (t_service* tservice, t_function* function);
-
-    void generate_deserialize_field (std::ostream& out, bool is_xception, t_field* tfield, std::string prefix, std::ostream& local_vars);
-    void generate_deserialize_struct (std::ostream& out, t_struct* tstruct, std::string name, std::string prefix);
-    void generate_deserialize_container(ostream& out, bool is_xception, t_type* ttype, string name, std::ostream& local_vars);
-
-    void generate_deserialize_set_element (std::ostream& out, bool is_xception, t_set* tset, std::string prefix, std::ostream& local_vars);
-    void generate_deserialize_map_element (std::ostream& out, bool is_xception, t_map* tmap, std::string prefix, std::ostream& local_vars);
-    void generate_deserialize_list_element (std::ostream& out, bool is_xception, t_list* list, std::string prefix, std::ostream& local_vars);
-
-    void generate_serialize_field (std::ostream& out, bool is_xception, t_field* tfield, std::string prefix, std::ostream& local_vars);
-    void generate_serialize_struct (std::ostream& out, t_struct* tstruct, std::string prefix, std::ostream& local_vars);
-    void generate_serialize_container (std::ostream& out, bool is_xception, t_type* ttype, std::string prefix, std::ostream& local_vars);
-    void generate_serialize_map_element (std::ostream& out, bool is_xception, t_map* tmap, std::string iter, std::string map, std::ostream& local_vars);
-    void generate_serialize_set_element (std::ostream& out, bool is_xception, t_set* tmap, std::string iter, std::ostream& local_vars);
-    void generate_serialize_list_element (std::ostream& out, bool is_xception, t_list* tlist, std::string iter, std::ostream& local_vars);
-
-    void delphi_type_usings(std::ostream& out);
-    std::string delphi_thrift_usings();
-
-    std::string type_name( t_type* ttype, bool b_cls=false, bool b_no_postfix=false, bool b_exception_factory=false, bool b_full_exception_factory = false);
-    std::string normalize_clsnm(std::string name, std::string prefix, bool b_no_check_keyword = false);
-    std::string make_valid_delphi_identifier( std::string const & fromName);
-    std::string input_arg_prefix( t_type* ttype);
-
-    std::string base_type_name(t_base_type* tbase);
-    std::string declare_field(t_field* tfield, bool init=false, std::string prefix="", bool is_xception_class = false);
-    std::string function_signature(t_function* tfunction, std::string full_cls="", bool is_xception = false);
-    std::string argument_list(t_struct* tstruct);
-    std::string constructor_argument_list(t_struct* tstruct, std::string current_indent);
-    std::string type_to_enum(t_type* ttype);
-    std::string prop_name(t_field* tfield, bool is_xception = false);
-    std::string prop_name(std::string name, bool is_xception = false);
-    std::string constructor_param_name(string name);
-
-    void write_enum(std::string line);
-    void write_forward_decr(std::string line);
-    void write_const(std::string line);
-    void write_struct(std::string line);
-    void write_service(std::string line);
-
-    virtual std::string autogen_comment() {
-      return
-        std::string("(**\n") +
-        " * Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-        " *\n" +
-        " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-        " *)\n";
-    }
-
-    string replace_all( string contents, string search, string replace);
-    string xml_encode( string contents);
-    string xmldoc_encode( string contents);
-    string xmlattrib_encode( string contents);
-    void generate_delphi_doc (std::ostream& out, t_field*    field);
-    void generate_delphi_doc (std::ostream& out, t_doc*      tdoc);
-    void generate_delphi_doc (std::ostream& out, t_function* tdoc);
-    void generate_delphi_docstring_comment (std::ostream &out, string contents);
-
-    bool type_can_be_null(t_type* ttype) {
-      while (ttype->is_typedef()) {
-        ttype = ((t_typedef*)ttype)->get_type();
-      }
+static const string endl = "\n"; // avoid ostream << std::endl flushes
+
+class t_delphi_generator : public t_oop_generator {
+public:
+  t_delphi_generator(t_program* program,
+                     const std::map<std::string, std::string>& parsed_options,
+                     const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
+    indent_impl_ = 0;
+    has_forward = false;
+    has_enum = false;
+    has_const = false;
+    std::map<std::string, std::string>::const_iterator iter;
+
+    iter = parsed_options.find("ansistr_binary");
+    ansistr_binary_ = (iter != parsed_options.end());
+    iter = parsed_options.find("register_types");
+    register_types_ = (iter != parsed_options.end());
+    iter = parsed_options.find("constprefix");
+    constprefix_ = (iter != parsed_options.end());
+    iter = parsed_options.find("events");
+    events_ = (iter != parsed_options.end());
+    iter = parsed_options.find("xmldoc");
+    xmldoc_ = (iter != parsed_options.end());
+
+    out_dir_base_ = "gen-delphi";
+    escape_.clear();
+    escape_['\''] = "''";
+  }
+
+  void init_generator();
+  void close_generator();
+
+  void generate_consts(std::vector<t_const*> consts);
+
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_forward_declaration(t_struct* tstruct);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+  void generate_property(ostream& out, t_field* tfield, bool isPublic, bool is_xception);
+  void generate_property_writer_(ostream& out, t_field* tfield, bool isPublic);
+
+  void generate_delphi_property(ostream& out,
+                                bool struct_is_exception,
+                                t_field* tfield,
+                                bool isPublic,
+                                std::string fieldPrefix = "");
+  void generate_delphi_isset_reader_definition(ostream& out, t_field* tfield, bool is_xception);
+  void generate_delphi_property_reader_definition(ostream& out,
+                                                  t_field* tfield,
+                                                  bool is_xception_class);
+  void generate_delphi_property_writer_definition(ostream& out,
+                                                  t_field* tfield,
+                                                  bool is_xception_class);
+  void generate_delphi_property_reader_impl(ostream& out,
+                                            std::string cls_prefix,
+                                            std::string name,
+                                            t_type* type,
+                                            t_field* tfield,
+                                            std::string fieldPrefix,
+                                            bool is_xception_class);
+  void generate_delphi_property_writer_impl(ostream& out,
+                                            std::string cls_prefix,
+                                            std::string name,
+                                            t_type* type,
+                                            t_field* tfield,
+                                            std::string fieldPrefix,
+                                            bool is_xception_class,
+                                            bool is_union,
+                                            bool is_xception_factory,
+                                            std::string xception_factroy_name);
+  void generate_delphi_clear_union_value(ostream& out,
+                                         std::string cls_prefix,
+                                         std::string name,
+                                         t_type* type,
+                                         t_field* tfield,
+                                         std::string fieldPrefix,
+                                         bool is_xception_class,
+                                         bool is_union,
+                                         bool is_xception_factory,
+                                         std::string xception_factroy_name);
+  void generate_delphi_isset_reader_impl(ostream& out,
+                                         std::string cls_prefix,
+                                         std::string name,
+                                         t_type* type,
+                                         t_field* tfield,
+                                         std::string fieldPrefix,
+                                         bool is_xception);
+  void generate_delphi_struct_writer_impl(ostream& out,
+                                          std::string cls_prefix,
+                                          t_struct* tstruct,
+                                          bool is_exception);
+  void generate_delphi_struct_result_writer_impl(ostream& out,
+                                                 std::string cls_prefix,
+                                                 t_struct* tstruct,
+                                                 bool is_exception);
+
+  void generate_delphi_struct_tostring_impl(ostream& out,
+                                            std::string cls_prefix,
+                                            t_struct* tstruct,
+                                            bool is_exception,
+                                            bool is_x_factory);
+
+  void add_delphi_uses_list(string unitname);
+
+  void generate_delphi_struct_reader_impl(ostream& out,
+                                          std::string cls_prefix,
+                                          t_struct* tstruct,
+                                          bool is_exception);
+  void generate_delphi_create_exception_impl(ostream& out,
+                                             string cls_prefix,
+                                             t_struct* tstruct,
+                                             bool is_exception);
+
+  bool const_needs_var(t_type* type);
+  void print_const_prop(std::ostream& out, string name, t_type* type, t_const_value* value);
+  void print_private_field(std::ostream& out, string name, t_type* type, t_const_value* value);
+  void print_const_value(std::ostream& vars,
+                         std::ostream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value);
+  void initialize_field(std::ostream& vars,
+                        std::ostream& out,
+                        std::string name,
+                        t_type* type,
+                        t_const_value* value);
+  void finalize_field(std::ostream& out,
+                      std::string name,
+                      t_type* type,
+                      t_const_value* value,
+                      std::string cls_nm = "");
+  std::string render_const_value(std::ostream& local_vars,
+                                 std::ostream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
+  void print_const_def_value(std::ostream& vars,
+                             std::ostream& out,
+                             std::string name,
+                             t_type* type,
+                             t_const_value* value,
+                             std::string cls_nm = "");
+  std::string make_constants_classname();
+
+  void generate_delphi_struct(t_struct* tstruct, bool is_exception);
+  void generate_delphi_struct_impl(ostream& out,
+                                   std::string cls_prefix,
+                                   t_struct* tstruct,
+                                   bool is_exception,
+                                   bool is_result = false,
+                                   bool is_x_factory = false);
+  void print_delphi_struct_type_factory_func(ostream& out, t_struct* tstruct);
+  void generate_delphi_struct_type_factory(ostream& out,
+                                           std::string cls_prefix,
+                                           t_struct* tstruct,
+                                           bool is_exception,
+                                           bool is_result = false,
+                                           bool is_x_factory = false);
+  void generate_delphi_struct_type_factory_registration(ostream& out,
+                                                        std::string cls_prefix,
+                                                        t_struct* tstruct,
+                                                        bool is_exception,
+                                                        bool is_result = false,
+                                                        bool is_x_factory = false);
+  void generate_delphi_struct_definition(std::ostream& out,
+                                         t_struct* tstruct,
+                                         bool is_xception = false,
+                                         bool in_class = false,
+                                         bool is_result = false,
+                                         bool is_x_factory = false);
+  void generate_delphi_struct_reader(std::ostream& out, t_struct* tstruct);
+  void generate_delphi_struct_result_writer(std::ostream& out, t_struct* tstruct);
+  void generate_delphi_struct_writer(std::ostream& out, t_struct* tstruct);
+  void generate_delphi_struct_tostring(std::ostream& out, t_struct* tstruct);
+
+  void generate_function_helpers(t_function* tfunction);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* function);
+
+  void generate_deserialize_field(std::ostream& out,
+                                  bool is_xception,
+                                  t_field* tfield,
+                                  std::string prefix,
+                                  std::ostream& local_vars);
+  void generate_deserialize_struct(std::ostream& out,
+                                   t_struct* tstruct,
+                                   std::string name,
+                                   std::string prefix);
+  void generate_deserialize_container(ostream& out,
+                                      bool is_xception,
+                                      t_type* ttype,
+                                      string name,
+                                      std::ostream& local_vars);
+
+  void generate_deserialize_set_element(std::ostream& out,
+                                        bool is_xception,
+                                        t_set* tset,
+                                        std::string prefix,
+                                        std::ostream& local_vars);
+  void generate_deserialize_map_element(std::ostream& out,
+                                        bool is_xception,
+                                        t_map* tmap,
+                                        std::string prefix,
+                                        std::ostream& local_vars);
+  void generate_deserialize_list_element(std::ostream& out,
+                                         bool is_xception,
+                                         t_list* list,
+                                         std::string prefix,
+                                         std::ostream& local_vars);
+
+  void generate_serialize_field(std::ostream& out,
+                                bool is_xception,
+                                t_field* tfield,
+                                std::string prefix,
+                                std::ostream& local_vars);
+  void generate_serialize_struct(std::ostream& out,
+                                 t_struct* tstruct,
+                                 std::string prefix,
+                                 std::ostream& local_vars);
+  void generate_serialize_container(std::ostream& out,
+                                    bool is_xception,
+                                    t_type* ttype,
+                                    std::string prefix,
+                                    std::ostream& local_vars);
+  void generate_serialize_map_element(std::ostream& out,
+                                      bool is_xception,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map,
+                                      std::ostream& local_vars);
+  void generate_serialize_set_element(std::ostream& out,
+                                      bool is_xception,
+                                      t_set* tmap,
+                                      std::string iter,
+                                      std::ostream& local_vars);
+  void generate_serialize_list_element(std::ostream& out,
+                                       bool is_xception,
+                                       t_list* tlist,
+                                       std::string iter,
+                                       std::ostream& local_vars);
+
+  void delphi_type_usings(std::ostream& out);
+  std::string delphi_thrift_usings();
+
+  std::string type_name(t_type* ttype,
+                        bool b_cls = false,
+                        bool b_no_postfix = false,
+                        bool b_exception_factory = false,
+                        bool b_full_exception_factory = false);
+  std::string normalize_clsnm(std::string name,
+                              std::string prefix,
+                              bool b_no_check_keyword = false);
+  std::string make_valid_delphi_identifier(std::string const& fromName);
+  std::string input_arg_prefix(t_type* ttype);
+
+  std::string base_type_name(t_base_type* tbase);
+  std::string declare_field(t_field* tfield,
+                            bool init = false,
+                            std::string prefix = "",
+                            bool is_xception_class = false);
+  std::string function_signature(t_function* tfunction,
+                                 std::string full_cls = "",
+                                 bool is_xception = false);
+  std::string argument_list(t_struct* tstruct);
+  std::string constructor_argument_list(t_struct* tstruct, std::string current_indent);
+  std::string type_to_enum(t_type* ttype);
+  std::string prop_name(t_field* tfield, bool is_xception = false);
+  std::string prop_name(std::string name, bool is_xception = false);
+  std::string constructor_param_name(string name);
+
+  void write_enum(std::string line);
+  void write_forward_decr(std::string line);
+  void write_const(std::string line);
+  void write_struct(std::string line);
+  void write_service(std::string line);
+
+  virtual std::string autogen_comment() {
+    return std::string("(**\n") + " * Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+           + " *\n" + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+           + " *)\n";
+  }
+
+  string replace_all(string contents, string search, string replace);
+  string xml_encode(string contents);
+  string xmldoc_encode(string contents);
+  string xmlattrib_encode(string contents);
+  void generate_delphi_doc(std::ostream& out, t_field* field);
+  void generate_delphi_doc(std::ostream& out, t_doc* tdoc);
+  void generate_delphi_doc(std::ostream& out, t_function* tdoc);
+  void generate_delphi_docstring_comment(std::ostream& out, string contents);
+
+  bool type_can_be_null(t_type* ttype) {
+    while (ttype->is_typedef()) {
+      ttype = ((t_typedef*)ttype)->get_type();
+    }
 
-      return ttype->is_container() ||
-        ttype->is_struct() ||
-        ttype->is_xception();
-    }
-
-  private:
-    std::string namespace_name_;
-    std::ostringstream s_forward_decr;
-    std::ostringstream s_enum;
-    std::ostringstream s_const;
-    std::ostringstream s_struct;
-    std::ostringstream s_service;
-    std::ostringstream s_const_impl;
-    std::ostringstream s_struct_impl;
-    std::ostringstream s_service_impl;
-    std::ostringstream s_type_factory_registration;
-    std::ostringstream s_type_factory_funcs;
-    bool has_forward;
-    bool has_enum;
-    bool has_const;
-    std::string namespace_dir_;
-    std::map<std::string, int> delphi_keywords;
-    std::map<std::string, int> delphi_reserved_method;
-    std::map<std::string, int> delphi_reserved_method_exception;
-    std::map<std::string, int> types_known;
-    std::list<t_typedef*> typedefs_pending;
-    std::vector<std::string> uses_list;
-    void create_keywords();
-    bool find_keyword( std::map<std::string, int>& keyword_map, std::string name);
-    std::string normalize_name( std::string name, bool b_method = false, bool b_exception_method = false);
-    std::string empty_value(t_type* type);
-    bool is_fully_defined_type( t_type* ttype);
-    void add_defined_type( t_type* ttype);
-    void init_known_types_list();
-    bool is_void( t_type* type );
-    int indent_impl_;
-    bool ansistr_binary_;
-    bool register_types_;
-    bool constprefix_;
-    bool events_;
-    bool xmldoc_;
-    void indent_up_impl(){
-      ++indent_impl_;
-    };
-    void indent_down_impl() {
-      --indent_impl_;
-    };
-    std::string indent_impl() {
-      std::string ind = "";
-      int i;
-      for (i = 0; i < indent_impl_; ++i) {
-        ind += "  ";
-      }
-      return ind;
-    };
-    std::ostream& indent_impl(std::ostream &os) {
-      return os << indent_impl();
-    };
+    return ttype->is_container() || ttype->is_struct() || ttype->is_xception();
+  }
+
+private:
+  std::string namespace_name_;
+  std::ostringstream s_forward_decr;
+  std::ostringstream s_enum;
+  std::ostringstream s_const;
+  std::ostringstream s_struct;
+  std::ostringstream s_service;
+  std::ostringstream s_const_impl;
+  std::ostringstream s_struct_impl;
+  std::ostringstream s_service_impl;
+  std::ostringstream s_type_factory_registration;
+  std::ostringstream s_type_factory_funcs;
+  bool has_forward;
+  bool has_enum;
+  bool has_const;
+  std::string namespace_dir_;
+  std::map<std::string, int> delphi_keywords;
+  std::map<std::string, int> delphi_reserved_method;
+  std::map<std::string, int> delphi_reserved_method_exception;
+  std::map<std::string, int> types_known;
+  std::list<t_typedef*> typedefs_pending;
+  std::vector<std::string> uses_list;
+  void create_keywords();
+  bool find_keyword(std::map<std::string, int>& keyword_map, std::string name);
+  std::string normalize_name(std::string name,
+                             bool b_method = false,
+                             bool b_exception_method = false);
+  std::string empty_value(t_type* type);
+  bool is_fully_defined_type(t_type* ttype);
+  void add_defined_type(t_type* ttype);
+  void init_known_types_list();
+  bool is_void(t_type* type);
+  int indent_impl_;
+  bool ansistr_binary_;
+  bool register_types_;
+  bool constprefix_;
+  bool events_;
+  bool xmldoc_;
+  void indent_up_impl() { ++indent_impl_; };
+  void indent_down_impl() { --indent_impl_; };
+  std::string indent_impl() {
+    std::string ind = "";
+    int i;
+    for (i = 0; i < indent_impl_; ++i) {
+      ind += "  ";
+    }
+    return ind;
+  };
+  std::ostream& indent_impl(std::ostream& os) { return os << indent_impl(); };
 };
 
-string t_delphi_generator::replace_all( string contents, string search, string repl) {
-  string str( contents);
+string t_delphi_generator::replace_all(string contents, string search, string repl) {
+  string str(contents);
 
   size_t slen = search.length();
   size_t rlen = repl.length();
   size_t incr = (rlen > 0) ? rlen : 1;
 
-  if( slen > 0) {
+  if (slen > 0) {
     size_t found = str.find(search);
-    while( (found != string::npos) && (found < str.length())) {
-      str.replace( found, slen, repl);
-      found = str.find(search, found+incr);
+    while ((found != string::npos) && (found < str.length())) {
+      str.replace(found, slen, repl);
+      found = str.find(search, found + incr);
     }
   }
 
@@ -282,57 +421,56 @@ string t_delphi_generator::replace_all( string contents, string search, string r
 }
 
 // XML encoding
-string t_delphi_generator::xml_encode( string contents) {
-  string str( contents);
+string t_delphi_generator::xml_encode(string contents) {
+  string str(contents);
 
   // escape the escape
-  str = replace_all( str, "&", "&amp;");
+  str = replace_all(str, "&", "&amp;");
 
   // other standard XML entities
-  str = replace_all( str, "<", "&lt;");
-  str = replace_all( str, ">", "&gt;");
+  str = replace_all(str, "<", "&lt;");
+  str = replace_all(str, ">", "&gt;");
 
   return str;
 }
 
 // XML attribute encoding
-string t_delphi_generator::xmlattrib_encode( string contents) {
-  string str( xml_encode( contents));
+string t_delphi_generator::xmlattrib_encode(string contents) {
+  string str(xml_encode(contents));
 
   // our attribs are enclosed in "
-  str = replace_all( str, "\"", "\\\"");
+  str = replace_all(str, "\"", "\\\"");
 
   return str;
 }
 
 // XML encoding for doc comments
-string t_delphi_generator::xmldoc_encode( string contents) {
-  string str( xml_encode( contents));
+string t_delphi_generator::xmldoc_encode(string contents) {
+  string str(xml_encode(contents));
 
   // XMLDoc specific: convert linebreaks into <para>graphs</para>
-  str = replace_all( str, "\r\n", "\r");
-  str = replace_all( str, "\n",   "\r");
-  str = replace_all( str, "\r",   "</para>\n<para>");
+  str = replace_all(str, "\r\n", "\r");
+  str = replace_all(str, "\n", "\r");
+  str = replace_all(str, "\r", "</para>\n<para>");
 
   return str;
 }
 
-void t_delphi_generator::generate_delphi_docstring_comment(ostream &out, string contents) {
-  if( xmldoc_) {
+void t_delphi_generator::generate_delphi_docstring_comment(ostream& out, string contents) {
+  if (xmldoc_) {
     generate_docstring_comment(out,
                                "{$REGION 'XMLDoc'}/// <summary>\n",
-                               "/// ", "<para>" + contents + "</para>",
+                               "/// ",
+                               "<para>" + contents + "</para>",
                                "/// </summary>\n{$ENDREGION}\n");
   }
 }
 
-void t_delphi_generator::generate_delphi_doc(ostream &out, t_field* field) {
-  if( xmldoc_) {
+void t_delphi_generator::generate_delphi_doc(ostream& out, t_field* field) {
+  if (xmldoc_) {
     if (field->get_type()->is_enum()) {
-      string combined_message = xmldoc_encode( field->get_doc())
-                              + "\n<seealso cref=\""
-                              + xmldoc_encode( type_name(field->get_type()))
-                              + "\"/>";
+      string combined_message = xmldoc_encode(field->get_doc()) + "\n<seealso cref=\""
+                                + xmldoc_encode(type_name(field->get_type())) + "\"/>";
       generate_delphi_docstring_comment(out, combined_message);
     } else {
       generate_delphi_doc(out, (t_doc*)field);
@@ -340,23 +478,24 @@ void t_delphi_generator::generate_delphi_doc(ostream &out, t_field* field) {
   }
 }
 
-void t_delphi_generator::generate_delphi_doc(ostream &out, t_doc* tdoc) {
+void t_delphi_generator::generate_delphi_doc(ostream& out, t_doc* tdoc) {
   if (tdoc->has_doc() && xmldoc_) {
-    generate_delphi_docstring_comment(out, xmldoc_encode( tdoc->get_doc()));
+    generate_delphi_docstring_comment(out, xmldoc_encode(tdoc->get_doc()));
   }
 }
 
-void t_delphi_generator::generate_delphi_doc(ostream &out, t_function* tfunction) {
+void t_delphi_generator::generate_delphi_doc(ostream& out, t_function* tfunction) {
   if (tfunction->has_doc() && xmldoc_) {
     stringstream ps;
     const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
     vector<t_field*>::const_iterator p_iter;
     for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter) {
       t_field* p = *p_iter;
-      ps << "\n<param name=\"" << xmlattrib_encode( p->get_name()) << "\">";
+      ps << "\n<param name=\"" << xmlattrib_encode(p->get_name()) << "\">";
       if (p->has_doc()) {
         std::string str = p->get_doc();
-        str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); // remove the newlines that appear from the parser
+        str.erase(std::remove(str.begin(), str.end(), '\n'),
+                  str.end()); // remove the newlines that appear from the parser
         ps << xmldoc_encode(str);
       }
       ps << "</param>";
@@ -364,40 +503,43 @@ void t_delphi_generator::generate_delphi_doc(ostream &out, t_function* tfunction
     generate_docstring_comment(out,
                                "{$REGION 'XMLDoc'}",
                                "/// ",
-                               "<summary><para>" + xmldoc_encode(tfunction->get_doc()) + "</para></summary>" + ps.str(),
+                               "<summary><para>" + xmldoc_encode(tfunction->get_doc())
+                               + "</para></summary>" + ps.str(),
                                "{$ENDREGION}\n");
   }
 }
 
-bool t_delphi_generator::find_keyword( std::map<std::string, int>& keyword_map, std::string name) {
+bool t_delphi_generator::find_keyword(std::map<std::string, int>& keyword_map, std::string name) {
   int len = name.length();
 
-  if ( len <= 0 ) {
+  if (len <= 0) {
     return false;
   }
 
   int nlast = name.find_last_of('_');
 
-  if ( nlast >= 1) {
+  if (nlast >= 1) {
     if (nlast == (len - 1)) {
-      string new_name( name, 0, nlast);
-      return find_keyword( keyword_map, new_name);
+      string new_name(name, 0, nlast);
+      return find_keyword(keyword_map, new_name);
     }
   }
   return (keyword_map[name] == 1);
 }
 
-std::string t_delphi_generator::normalize_name( std::string name, bool b_method, bool b_exception_method) {
-  string tmp( name );
+std::string t_delphi_generator::normalize_name(std::string name,
+                                               bool b_method,
+                                               bool b_exception_method) {
+  string tmp(name);
   std::transform(tmp.begin(), tmp.end(), tmp.begin(), static_cast<int (*)(int)>(std::tolower));
 
   bool b_found = false;
 
-  if ( find_keyword( delphi_keywords, tmp) ) {
+  if (find_keyword(delphi_keywords, tmp)) {
     b_found = true;
-  } else if ( b_method && find_keyword( delphi_reserved_method, tmp)) {
+  } else if (b_method && find_keyword(delphi_reserved_method, tmp)) {
     b_found = true;
-  } else if ( b_exception_method && find_keyword( delphi_reserved_method_exception, tmp)) {
+  } else if (b_exception_method && find_keyword(delphi_reserved_method_exception, tmp)) {
     b_found = true;
   }
 
@@ -542,17 +684,17 @@ void t_delphi_generator::create_keywords() {
   delphi_reserved_method_exception["throwouterexception"] = 1;
 }
 
-void t_delphi_generator::add_delphi_uses_list( string unitname){
+void t_delphi_generator::add_delphi_uses_list(string unitname) {
   vector<std::string>::const_iterator s_iter;
   bool found = false;
   for (s_iter = uses_list.begin(); s_iter != uses_list.end(); ++s_iter) {
-    if ((*s_iter) == unitname ) {
+    if ((*s_iter) == unitname) {
       found = true;
       break;
     }
   }
-  if (! found) {
-    uses_list.push_back( unitname );
+  if (!found) {
+    uses_list.push_back(unitname);
   }
 }
 
@@ -572,8 +714,7 @@ void t_delphi_generator::init_generator() {
   add_delphi_uses_list("Thrift.Protocol");
   add_delphi_uses_list("Thrift.Transport");
 
-  if (register_types_)
-  {
+  if (register_types_) {
     add_delphi_uses_list("Thrift.TypeRegistry");
   }
 
@@ -584,38 +725,37 @@ void t_delphi_generator::init_generator() {
   for (size_t i = 0; i < includes.size(); ++i) {
     unitname = includes[i]->get_name();
     nsname = includes[i]->get_namespace("delphi");
-    if ( "" != nsname) {
+    if ("" != nsname) {
       unitname = nsname;
     }
     add_delphi_uses_list(unitname);
   }
 
-
   MKDIR(get_out_dir().c_str());
 }
 
 void t_delphi_generator::close_generator() {
   std::string unitname = program_name_;
-  if( "" != namespace_name_) {
+  if ("" != namespace_name_) {
     unitname = namespace_name_;
   }
 
-  for ( int i = 0; i < (int)unitname.size(); i++) {
-    if ( unitname[i] == ' ' ) {
-      unitname.replace( i, 1, "_" );
+  for (int i = 0; i < (int)unitname.size(); i++) {
+    if (unitname[i] == ' ') {
+      unitname.replace(i, 1, "_");
     }
   }
 
   std::string f_name = get_out_dir() + "/" + unitname + ".pas";
   std::ofstream f_all;
 
-  f_all.open( f_name.c_str() );
+  f_all.open(f_name.c_str());
 
   f_all << autogen_comment() << endl;
   generate_delphi_doc(f_all, program_);
   f_all << "unit " << unitname << ";" << endl << endl;
   f_all << "interface" << endl << endl;
-  f_all  << "uses"  << endl;
+  f_all << "uses" << endl;
 
   indent_up();
 
@@ -632,89 +772,97 @@ void t_delphi_generator::close_generator() {
 
   indent_down();
 
-  string tmp_unit( unitname );
-  for ( int i = 0; i < (int)tmp_unit.size(); i++) {
-    if ( tmp_unit[i] == '.' ) {
-      tmp_unit.replace( i, 1, "_" );
+  string tmp_unit(unitname);
+  for (int i = 0; i < (int)tmp_unit.size(); i++) {
+    if (tmp_unit[i] == '.') {
+      tmp_unit.replace(i, 1, "_");
     }
   }
 
-  f_all  << "const"  << endl;
+  f_all << "const" << endl;
   indent_up();
-  indent(f_all)  << "c" << tmp_unit << "_Option_AnsiStr_Binary = " << ( ansistr_binary_ ? "True" : "False") << ";" << endl;
-  indent(f_all)  << "c" << tmp_unit << "_Option_Register_Types = " << ( register_types_ ? "True" : "False") << ";" << endl;
-  indent(f_all)  << "c" << tmp_unit << "_Option_ConstPrefix    = " << ( constprefix_    ? "True" : "False") << ";" << endl;
-  indent(f_all)  << "c" << tmp_unit << "_Option_Events         = " << ( events_         ? "True" : "False") << ";" << endl;
-  indent(f_all)  << "c" << tmp_unit << "_Option_XmlDoc         = " << ( xmldoc_         ? "True" : "False") << ";" << endl;
+  indent(f_all) << "c" << tmp_unit
+                << "_Option_AnsiStr_Binary = " << (ansistr_binary_ ? "True" : "False") << ";"
+                << endl;
+  indent(f_all) << "c" << tmp_unit
+                << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";"
+                << endl;
+  indent(f_all) << "c" << tmp_unit
+                << "_Option_ConstPrefix    = " << (constprefix_ ? "True" : "False") << ";" << endl;
+  indent(f_all) << "c" << tmp_unit << "_Option_Events         = " << (events_ ? "True" : "False")
+                << ";" << endl;
+  indent(f_all) << "c" << tmp_unit << "_Option_XmlDoc         = " << (xmldoc_ ? "True" : "False")
+                << ";" << endl;
   indent_down();
 
-  f_all  << endl;
-  f_all  << "type"  << endl;
-  if(has_forward) {
-    f_all  << s_forward_decr.str() << endl;
+  f_all << endl;
+  f_all << "type" << endl;
+  if (has_forward) {
+    f_all << s_forward_decr.str() << endl;
   }
   if (has_enum) {
     indent(f_all) << endl;
     indent(f_all) << "{$SCOPEDENUMS ON}" << endl << endl;
-    f_all  << s_enum.str();
+    f_all << s_enum.str();
     indent(f_all) << "{$SCOPEDENUMS OFF}" << endl << endl;
   }
-  f_all  << s_struct.str();
-  f_all  << s_service.str();
-  f_all  << s_const.str();
-  f_all  << "implementation"  << endl << endl;
-  f_all  << s_struct_impl.str();
-  f_all  << s_service_impl.str();
-  f_all  << s_const_impl.str();
-
+  f_all << s_struct.str();
+  f_all << s_service.str();
+  f_all << s_const.str();
+  f_all << "implementation" << endl << endl;
+  f_all << s_struct_impl.str();
+  f_all << s_service_impl.str();
+  f_all << s_const_impl.str();
 
-  if (register_types_)
-  {
-    f_all  << endl;
-    f_all  << "// Type factory methods and registration" << endl;
-    f_all  << s_type_factory_funcs.str();
+  if (register_types_) {
+    f_all << endl;
+    f_all << "// Type factory methods and registration" << endl;
+    f_all << s_type_factory_funcs.str();
     f_all << "procedure RegisterTypeFactories;" << endl;
     f_all << "begin" << endl;
     f_all << s_type_factory_registration.str();
     f_all << "end;" << endl;
   }
-  f_all  << endl;
+  f_all << endl;
 
   string constants_class = make_constants_classname();
 
-  f_all  << "initialization" << endl;
-  if ( has_const ) {
-    f_all  << "{$IF CompilerVersion < 21.0}  // D2010" << endl;
-    f_all  << "  " << constants_class.c_str() << "_Initialize;" << endl;
-    f_all  << "{$IFEND}" << endl;
+  f_all << "initialization" << endl;
+  if (has_const) {
+    f_all << "{$IF CompilerVersion < 21.0}  // D2010" << endl;
+    f_all << "  " << constants_class.c_str() << "_Initialize;" << endl;
+    f_all << "{$IFEND}" << endl;
   }
   if (register_types_) {
     f_all << "  RegisterTypeFactories;" << endl;
   }
-  f_all  << endl;
+  f_all << endl;
 
-  f_all  << "finalization" << endl;
-  if ( has_const ) {
-    f_all  << "{$IF CompilerVersion < 21.0}  // D2010" << endl;
-    f_all  << "  " << constants_class.c_str() << "_Finalize;" << endl;
-    f_all  << "{$IFEND}" << endl;
+  f_all << "finalization" << endl;
+  if (has_const) {
+    f_all << "{$IF CompilerVersion < 21.0}  // D2010" << endl;
+    f_all << "  " << constants_class.c_str() << "_Finalize;" << endl;
+    f_all << "{$IFEND}" << endl;
   }
-  f_all  << endl << endl;
+  f_all << endl << endl;
 
-  f_all  << "end." << endl;
+  f_all << "end." << endl;
   f_all.close();
 
-  if( ! typedefs_pending.empty()) {
+  if (!typedefs_pending.empty()) {
     pwarning(0, "%d typedefs with unresolved type references left:\n", typedefs_pending.size());
-    for( std::list<t_typedef*>::iterator iter = typedefs_pending.begin();  typedefs_pending.end() != iter;  ++iter) {
+    for (std::list<t_typedef*>::iterator iter = typedefs_pending.begin();
+         typedefs_pending.end() != iter;
+         ++iter) {
       pwarning(0, "- %s\n", (*iter)->get_symbolic().c_str());
     }
   }
 }
 
-void t_delphi_generator::delphi_type_usings( ostream& out) {
+void t_delphi_generator::delphi_type_usings(ostream& out) {
   indent_up();
-  indent(out) << "Classes, SysUtils, Generics.Collections, Thrift.Collections, Thrift.Protocol," << endl;
+  indent(out) << "Classes, SysUtils, Generics.Collections, Thrift.Collections, Thrift.Protocol,"
+              << endl;
   indent(out) << "Thrift.Transport;" << endl << endl;
   indent_down();
 }
@@ -727,8 +875,8 @@ void t_delphi_generator::generate_forward_declaration(t_struct* tstruct) {
   string what = tstruct->is_xception() ? "class" : "interface";
 
   indent_up();
-  indent(s_forward_decr) <<
-    type_name(tstruct,tstruct->is_xception(),true) << " = " << what << ";" << endl;
+  indent(s_forward_decr) << type_name(tstruct, tstruct->is_xception(), true) << " = " << what << ";"
+                         << endl;
   indent_down();
 
   add_defined_type(tstruct);
@@ -738,80 +886,77 @@ void t_delphi_generator::generate_typedef(t_typedef* ttypedef) {
   t_type* type = ttypedef->get_type();
 
   // write now or save for later?
-  if( ! is_fully_defined_type( type)) {
+  if (!is_fully_defined_type(type)) {
     pverbose("typedef %s: unresolved dependencies found\n", type_name(ttypedef).c_str());
-    typedefs_pending.push_back( ttypedef);
+    typedefs_pending.push_back(ttypedef);
     return;
   }
 
   indent_up();
   generate_delphi_doc(s_struct, ttypedef);
-  indent(s_struct) <<
-    type_name(ttypedef) << " = ";
+  indent(s_struct) << type_name(ttypedef) << " = ";
 
   // commented out: the benefit is not big enough to risk breaking existing code
-  //bool container = type->is_list() || type->is_map() || type->is_set();
-  //if( ! container)
+  // bool container = type->is_list() || type->is_map() || type->is_set();
+  // if( ! container)
   //  s_struct << "type ";  //the "type A = type B" syntax leads to E2574 with generics
 
-  s_struct << type_name(ttypedef->get_type()) << ";" << endl <<
-    endl;
+  s_struct << type_name(ttypedef->get_type()) << ";" << endl << endl;
   indent_down();
 
-  add_defined_type( ttypedef);
+  add_defined_type(ttypedef);
 }
 
-bool t_delphi_generator::is_fully_defined_type( t_type* ttype) {
-  if( (NULL != ttype->get_program()) && (ttype->get_program() != program_)) {
+bool t_delphi_generator::is_fully_defined_type(t_type* ttype) {
+  if ((NULL != ttype->get_program()) && (ttype->get_program() != program_)) {
     t_scope* scope = ttype->get_program()->scope();
-    if( NULL != scope->get_type( ttype->get_name())) {
-      //printf("type %s found in included scope %s\n", ttype->get_name().c_str(), ttype->get_program()->get_name().c_str());
+    if (NULL != scope->get_type(ttype->get_name())) {
+      // printf("type %s found in included scope %s\n", ttype->get_name().c_str(),
+      // ttype->get_program()->get_name().c_str());
       return true;
     }
   }
 
   if (ttype->is_typedef()) {
-    return (1 == types_known[ type_name(ttype)]);
+    return (1 == types_known[type_name(ttype)]);
   }
 
   if (ttype->is_base_type()) {
-    return (1 == types_known[ base_type_name((t_base_type*)ttype)]);
+    return (1 == types_known[base_type_name((t_base_type*)ttype)]);
   } else if (ttype->is_enum()) {
-    return true;  // enums are written first, before all other types
+    return true; // enums are written first, before all other types
   } else if (ttype->is_map()) {
-    t_map *tmap = (t_map*) ttype;
-    return is_fully_defined_type( tmap->get_key_type()) &&
-           is_fully_defined_type( tmap->get_val_type());
+    t_map* tmap = (t_map*)ttype;
+    return is_fully_defined_type(tmap->get_key_type())
+           && is_fully_defined_type(tmap->get_val_type());
   } else if (ttype->is_set()) {
-    t_set* tset = (t_set*) ttype;
-    return is_fully_defined_type( tset->get_elem_type());
+    t_set* tset = (t_set*)ttype;
+    return is_fully_defined_type(tset->get_elem_type());
   } else if (ttype->is_list()) {
-    t_list* tlist = (t_list*) ttype;
-    return is_fully_defined_type( tlist->get_elem_type());
+    t_list* tlist = (t_list*)ttype;
+    return is_fully_defined_type(tlist->get_elem_type());
   }
 
-  return (1 == types_known[ type_name(ttype)]);
+  return (1 == types_known[type_name(ttype)]);
 }
 
-void t_delphi_generator::add_defined_type( t_type* ttype) {
+void t_delphi_generator::add_defined_type(t_type* ttype) {
   // mark as known type
-  types_known[ type_name(ttype)] = 1;
+  types_known[type_name(ttype)] = 1;
 
   // check all pending typedefs
-  std::list<t_typedef*>::iterator  iter;
+  std::list<t_typedef*>::iterator iter;
   bool more = true;
-  while( more && (! typedefs_pending.empty()))
-  {
+  while (more && (!typedefs_pending.empty())) {
     more = false;
 
-    for( iter = typedefs_pending.begin(); typedefs_pending.end() != iter; ++iter)
-    {
+    for (iter = typedefs_pending.begin(); typedefs_pending.end() != iter; ++iter) {
       t_typedef* ttypedef = (*iter);
-      if( is_fully_defined_type( ttypedef->get_type()))
-      {
-        pverbose("typedef %s: all pending references are now resolved\n", type_name(ttypedef).c_str());
-        typedefs_pending.erase( iter);
-        generate_typedef( ttypedef);
+      if (is_fully_defined_type(ttypedef->get_type())) {
+        pverbose("typedef %s: all pending references are now resolved\n",
+                 type_name(ttypedef).c_str());
+        typedefs_pending.erase(iter);
+        generate_typedef(ttypedef);
         more = true;
         break;
       }
@@ -821,22 +966,22 @@ void t_delphi_generator::add_defined_type( t_type* ttype) {
 
 void t_delphi_generator::init_known_types_list() {
   // known base types
-  types_known[ type_name( g_type_string)] = 1;
-  types_known[ type_name( g_type_binary)] = 1;
-  types_known[ type_name( g_type_bool)] = 1;
-  types_known[ type_name( g_type_byte)] = 1;
-  types_known[ type_name( g_type_i16)] = 1;
-  types_known[ type_name( g_type_i32)] = 1;
-  types_known[ type_name( g_type_i64)] = 1;
-  types_known[ type_name( g_type_double)] = 1;
+  types_known[type_name(g_type_string)] = 1;
+  types_known[type_name(g_type_binary)] = 1;
+  types_known[type_name(g_type_bool)] = 1;
+  types_known[type_name(g_type_byte)] = 1;
+  types_known[type_name(g_type_i16)] = 1;
+  types_known[type_name(g_type_i32)] = 1;
+  types_known[type_name(g_type_i64)] = 1;
+  types_known[type_name(g_type_double)] = 1;
 }
 
 void t_delphi_generator::generate_enum(t_enum* tenum) {
   has_enum = true;
   indent_up();
-  generate_delphi_doc( s_enum, tenum);
-  indent(s_enum) <<
-    type_name(tenum,true,true) << " = " <<  "("  << endl;
+  generate_delphi_doc(s_enum, tenum);
+  indent(s_enum) << type_name(tenum, true, true) << " = "
+                 << "(" << endl;
   indent_up();
   vector<t_enum_value*> constants = tenum->get_constants();
   if (constants.empty()) {
@@ -859,48 +1004,43 @@ void t_delphi_generator::generate_enum(t_enum* tenum) {
   indent_down();
 }
 
+std::string t_delphi_generator::make_valid_delphi_identifier(std::string const& fromName) {
+  std::string str = fromName;
+  if (str.empty()) {
+    return str;
+  }
 
-std::string t_delphi_generator::make_valid_delphi_identifier( std::string const & fromName) {
-    std::string str = fromName;
-    if( str.empty()) {
-        return str;
-    }
-
-    // tests rely on this
-    assert( ('A' < 'Z') && ('a' < 'z') && ('0' < '9'));
+  // tests rely on this
+  assert(('A' < 'Z') && ('a' < 'z') && ('0' < '9'));
 
-    // if the first letter is a number, we add an additional underscore in front of it
-    char c = str.at(0);
-    if( ('0' <= c) && (c <= '9')) {
-        str = "_" + str;
-    }
+  // if the first letter is a number, we add an additional underscore in front of it
+  char c = str.at(0);
+  if (('0' <= c) && (c <= '9')) {
+    str = "_" + str;
+  }
 
-    // following chars: letter, number or underscore
-    for( size_t i = 0;  i < str.size();  ++i) {
-        c = str.at(i);
-        if( (('A' > c) || (c > 'Z')) &&
-            (('a' > c) || (c > 'z')) &&
-            (('0' > c) || (c > '9')) &&
-            ('_' != c) ) {
-            str.replace( i, 1, "_");
-        }
+  // following chars: letter, number or underscore
+  for (size_t i = 0; i < str.size(); ++i) {
+    c = str.at(i);
+    if ((('A' > c) || (c > 'Z')) && (('a' > c) || (c > 'z')) && (('0' > c) || (c > '9'))
+        && ('_' != c)) {
+      str.replace(i, 1, "_");
     }
+  }
 
-    return str;
+  return str;
 }
 
-
 std::string t_delphi_generator::make_constants_classname() {
-  if( constprefix_) {
-    return make_valid_delphi_identifier( "T" + program_name_ + "Constants");
+  if (constprefix_) {
+    return make_valid_delphi_identifier("T" + program_name_ + "Constants");
   } else {
-    return "TConstants";  // compatibility
+    return "TConstants"; // compatibility
   }
 }
 
-
 void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
-  if (consts.empty()){
+  if (consts.empty()) {
     return;
   }
 
@@ -908,15 +1048,16 @@ void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
   string constants_class = make_constants_classname();
 
   indent_up();
-  indent(s_const) <<
-    constants_class.c_str() << " = class" << endl;
+  indent(s_const) << constants_class.c_str() << " = class" << endl;
   indent(s_const) << "private" << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    if( const_needs_var((*c_iter)->get_type())) {
-      print_private_field(s_const, normalize_name((*c_iter)->get_name()),
-        (*c_iter)->get_type(), (*c_iter)->get_value());
+    if (const_needs_var((*c_iter)->get_type())) {
+      print_private_field(s_const,
+                          normalize_name((*c_iter)->get_name()),
+                          (*c_iter)->get_type(),
+                          (*c_iter)->get_value());
     }
   }
   indent_down();
@@ -924,8 +1065,10 @@ void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
   indent_up();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     generate_delphi_doc(s_const, *c_iter);
-    print_const_prop(s_const, normalize_name((*c_iter)->get_name()),
-      (*c_iter)->get_type(), (*c_iter)->get_value());
+    print_const_prop(s_const,
+                     normalize_name((*c_iter)->get_name()),
+                     (*c_iter)->get_type(),
+                     (*c_iter)->get_value());
   }
   indent(s_const) << "{$IF CompilerVersion >= 21.0}" << endl;
   indent(s_const) << "class constructor Create;" << endl;
@@ -935,34 +1078,41 @@ void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
   indent(s_const) << "end;" << endl << endl;
   indent_down();
 
-  std::ostringstream  vars, code;
+  std::ostringstream vars, code;
 
   indent_up_impl();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    initialize_field(vars, code, "F" + prop_name( (*c_iter)->get_name()),
-      (*c_iter)->get_type(), (*c_iter)->get_value());
+    initialize_field(vars,
+                     code,
+                     "F" + prop_name((*c_iter)->get_name()),
+                     (*c_iter)->get_type(),
+                     (*c_iter)->get_value());
   }
   indent_down_impl();
 
   indent_impl(s_const_impl) << "{$IF CompilerVersion >= 21.0}" << endl;
-  indent_impl(s_const_impl) << "class constructor " << constants_class.c_str() << ".Create;" << endl;
+  indent_impl(s_const_impl) << "class constructor " << constants_class.c_str() << ".Create;"
+                            << endl;
 
-  if ( ! vars.str().empty() ) {
+  if (!vars.str().empty()) {
     indent_impl(s_const_impl) << "var" << endl;
     s_const_impl << vars.str();
   }
   indent_impl(s_const_impl) << "begin" << endl;
-  if ( ! code.str().empty() ) {
+  if (!code.str().empty()) {
     s_const_impl << code.str();
   }
   indent_impl(s_const_impl) << "end;" << endl << endl;
-  indent_impl(s_const_impl) << "class destructor " << constants_class.c_str() << ".Destroy;" << endl;
+  indent_impl(s_const_impl) << "class destructor " << constants_class.c_str() << ".Destroy;"
+                            << endl;
   indent_impl(s_const_impl) << "begin" << endl;
   indent_up_impl();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    if( const_needs_var((*c_iter)->get_type())) {
-      finalize_field(s_const_impl, normalize_name( (*c_iter)->get_name()),
-        (*c_iter)->get_type(), (*c_iter)->get_value());
+    if (const_needs_var((*c_iter)->get_type())) {
+      finalize_field(s_const_impl,
+                     normalize_name((*c_iter)->get_name()),
+                     (*c_iter)->get_type(),
+                     (*c_iter)->get_value());
     }
   }
   indent_impl(s_const_impl) << "inherited;" << endl;
@@ -975,20 +1125,23 @@ void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
 
   indent_up_impl();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    if( const_needs_var((*c_iter)->get_type())) {
-      initialize_field( vars, code, constants_class + ".F" + prop_name( (*c_iter)->get_name()),
-        (*c_iter)->get_type(), (*c_iter)->get_value());
+    if (const_needs_var((*c_iter)->get_type())) {
+      initialize_field(vars,
+                       code,
+                       constants_class + ".F" + prop_name((*c_iter)->get_name()),
+                       (*c_iter)->get_type(),
+                       (*c_iter)->get_value());
     }
   }
   indent_down_impl();
 
   indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Initialize;" << endl;
-  if ( ! vars.str().empty() ) {
+  if (!vars.str().empty()) {
     indent_impl(s_const_impl) << "var" << endl;
     s_const_impl << vars.str();
   }
   indent_impl(s_const_impl) << "begin" << endl;
-  if ( ! code.str().empty() ) {
+  if (!code.str().empty()) {
     s_const_impl << code.str();
   }
   indent_impl(s_const_impl) << "end;" << endl << endl;
@@ -997,16 +1150,23 @@ void t_delphi_generator::generate_consts(std::vector<t_const*> consts) {
   indent_impl(s_const_impl) << "begin" << endl;
   indent_up_impl();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
-    finalize_field(s_const_impl, normalize_name( (*c_iter)->get_name()),
-      (*c_iter)->get_type(), (*c_iter)->get_value(), constants_class);
+    finalize_field(s_const_impl,
+                   normalize_name((*c_iter)->get_name()),
+                   (*c_iter)->get_type(),
+                   (*c_iter)->get_value(),
+                   constants_class);
   }
   indent_down_impl();
   indent_impl(s_const_impl) << "end;" << endl;
   indent_impl(s_const_impl) << "{$IFEND}" << endl << endl;
 }
 
-void t_delphi_generator::print_const_def_value(std::ostream& vars, std::ostream& out, string name, t_type* type, t_const_value* value, string cls_nm)
-{
+void t_delphi_generator::print_const_def_value(std::ostream& vars,
+                                               std::ostream& out,
+                                               string name,
+                                               t_type* type,
+                                               t_const_value* value,
+                                               string cls_nm) {
 
   string cls_prefix;
 
@@ -1031,8 +1191,10 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, std::ostream&
       if (field_type == NULL) {
         throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
       }
-      string val = render_const_value( vars, out, name, field_type, v_iter->second);
-      indent_impl(out) << cls_prefix << normalize_name(name) << "." << prop_name( v_iter->first->get_string(), type->is_xception()) << " := " << val << ";" << endl;
+      string val = render_const_value(vars, out, name, field_type, v_iter->second);
+      indent_impl(out) << cls_prefix << normalize_name(name) << "."
+                       << prop_name(v_iter->first->get_string(), type->is_xception())
+                       << " := " << val << ";" << endl;
     }
   } else if (type->is_map()) {
     t_type* ktype = ((t_map*)type)->get_key_type();
@@ -1040,9 +1202,10 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, std::ostream&
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string key = render_const_value( vars, out, name, ktype, v_iter->first);
-      string val = render_const_value( vars, out, name, vtype, v_iter->second);
-      indent_impl(out) << cls_prefix << normalize_name(name) << "[" << key << "]" << " := " << val << ";" << endl;
+      string key = render_const_value(vars, out, name, ktype, v_iter->first);
+      string val = render_const_value(vars, out, name, vtype, v_iter->second);
+      indent_impl(out) << cls_prefix << normalize_name(name) << "[" << key << "]"
+                       << " := " << val << ";" << endl;
     }
   } else if (type->is_list() || type->is_set()) {
     t_type* etype;
@@ -1055,39 +1218,48 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars, std::ostream&
     const vector<t_const_value*>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
-      string val = render_const_value( vars, out, name, etype, *v_iter);
+      string val = render_const_value(vars, out, name, etype, *v_iter);
       indent_impl(out) << cls_prefix << normalize_name(name) << ".Add(" << val << ");" << endl;
     }
   }
 }
 
-void t_delphi_generator::print_private_field(std::ostream& out, string name, t_type* type, t_const_value* value) {
-  (void) value;
+void t_delphi_generator::print_private_field(std::ostream& out,
+                                             string name,
+                                             t_type* type,
+                                             t_const_value* value) {
+  (void)value;
   indent(out) << "class var F" << name << ": " << type_name(type) << ";" << endl;
 }
 
-
 bool t_delphi_generator::const_needs_var(t_type* type) {
   t_type* truetype = type;
   while (truetype->is_typedef()) {
     truetype = ((t_typedef*)truetype)->get_type();
   }
-  return (! truetype->is_base_type());
+  return (!truetype->is_base_type());
 }
 
-
-void t_delphi_generator::print_const_prop(std::ostream& out, string name, t_type* type, t_const_value* value) {
-  (void) value;
+void t_delphi_generator::print_const_prop(std::ostream& out,
+                                          string name,
+                                          t_type* type,
+                                          t_const_value* value) {
+  (void)value;
   if (const_needs_var(type)) {
-    indent(out) << "class property " << name << ": " << type_name(type) << " read F" << name << ";" << endl;
+    indent(out) << "class property " << name << ": " << type_name(type) << " read F" << name << ";"
+                << endl;
   } else {
     std::ostringstream vars; // dummy
-    string v2 = render_const_value( vars, out, name, type, value);
+    string v2 = render_const_value(vars, out, name, type, value);
     indent(out) << "const " << name << " = " << v2 << ";" << endl;
   }
 }
 
-void t_delphi_generator::print_const_value( std::ostream& vars, std::ostream& out, string name, t_type* type, t_const_value* value) {
+void t_delphi_generator::print_const_value(std::ostream& vars,
+                                           std::ostream& out,
+                                           string name,
+                                           t_type* type,
+                                           t_const_value* value) {
   t_type* truetype = type;
   while (truetype->is_typedef()) {
     truetype = ((t_typedef*)truetype)->get_type();
@@ -1095,32 +1267,45 @@ void t_delphi_generator::print_const_value( std::ostream& vars, std::ostream& ou
 
   if (truetype->is_base_type()) {
     // already done
-    //string v2 = render_const_value( vars, out, name, type, value);
-    //indent_impl(out) << name << " := " << v2 << ";" << endl;
+    // string v2 = render_const_value( vars, out, name, type, value);
+    // indent_impl(out) << name << " := " << v2 << ";" << endl;
   } else if (truetype->is_enum()) {
-    indent_impl(out) << name << " := " << type_name(type) << "." << value->get_identifier_name() << ";" << endl;
+    indent_impl(out) << name << " := " << type_name(type) << "." << value->get_identifier_name()
+                     << ";" << endl;
   } else {
     string typname;
-    typname = type_name( truetype, true, false, type->is_xception(), type->is_xception());
+    typname = type_name(truetype, true, false, type->is_xception(), type->is_xception());
     indent_impl(out) << name << " := " << typname << ".Create;" << endl;
-    print_const_def_value( vars, out, name, truetype, value);
+    print_const_def_value(vars, out, name, truetype, value);
   }
 }
 
-void t_delphi_generator::initialize_field(std::ostream& vars, std::ostream& out, string name, t_type* type, t_const_value* value) {
-  print_const_value( vars, out, name, type, value );
+void t_delphi_generator::initialize_field(std::ostream& vars,
+                                          std::ostream& out,
+                                          string name,
+                                          t_type* type,
+                                          t_const_value* value) {
+  print_const_value(vars, out, name, type, value);
 }
 
-void t_delphi_generator::finalize_field(std::ostream& out, string name, t_type* type, t_const_value* value , string cls_nm) {
-  (void) out;
-  (void) name;
-  (void) type;
-  (void) value;
-  (void) cls_nm;
+void t_delphi_generator::finalize_field(std::ostream& out,
+                                        string name,
+                                        t_type* type,
+                                        t_const_value* value,
+                                        string cls_nm) {
+  (void)out;
+  (void)name;
+  (void)type;
+  (void)value;
+  (void)cls_nm;
 }
 
-string t_delphi_generator::render_const_value(ostream& vars, ostream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+string t_delphi_generator::render_const_value(ostream& vars,
+                                              ostream& out,
+                                              string name,
+                                              t_type* type,
+                                              t_const_value* value) {
+  (void)name;
 
   t_type* truetype = type;
   while (truetype->is_typedef()) {
@@ -1132,40 +1317,40 @@ string t_delphi_generator::render_const_value(ostream& vars, ostream& out, strin
   if (truetype->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)truetype)->get_base();
     switch (tbase) {
-      case t_base_type::TYPE_STRING:
-        render << "'" << get_escaped_string(value) << "'";
-        break;
-      case t_base_type::TYPE_BOOL:
-        render << ((value->get_integer() > 0) ? "True" : "False");
-        break;
-      case t_base_type::TYPE_BYTE:
-        render << "ShortInt( " << value->get_integer() << ")";
-        break;
-      case t_base_type::TYPE_I16:
-        render << "SmallInt( " << value->get_integer() << ")";
-        break;
-      case t_base_type::TYPE_I32:
-        render << "LongInt( " << value->get_integer() << ")";
-        break;
-      case t_base_type::TYPE_I64:
-        render << "Int64( " << value->get_integer() << ")";
-        break;
-      case t_base_type::TYPE_DOUBLE:
-        if (value->get_type() == t_const_value::CV_INTEGER) {
-          render << value->get_integer() << ".0";  // make it a double constant by adding ".0"
-        } else {
-          render << value->get_double();
-        }
-        break;
-      default:
-          throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    case t_base_type::TYPE_STRING:
+      render << "'" << get_escaped_string(value) << "'";
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() > 0) ? "True" : "False");
+      break;
+    case t_base_type::TYPE_BYTE:
+      render << "ShortInt( " << value->get_integer() << ")";
+      break;
+    case t_base_type::TYPE_I16:
+      render << "SmallInt( " << value->get_integer() << ")";
+      break;
+    case t_base_type::TYPE_I32:
+      render << "LongInt( " << value->get_integer() << ")";
+      break;
+    case t_base_type::TYPE_I64:
+      render << "Int64( " << value->get_integer() << ")";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        render << value->get_integer() << ".0"; // make it a double constant by adding ".0"
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (truetype->is_enum()) {
-    render << type_name( type, false) << "." << value->get_identifier_name();
+    render << type_name(type, false) << "." << value->get_identifier_name();
   } else {
     string t = tmp("tmp");
-    vars <<  "  " << t << " : " << type_name(type) << ";" << endl;
-    print_const_value( vars, out, t, type, value);
+    vars << "  " << t << " : " << type_name(type) << ";" << endl;
+    print_const_value(vars, out, t, type, value);
     render << t;
   }
 
@@ -1185,19 +1370,27 @@ void t_delphi_generator::generate_delphi_struct(t_struct* tstruct, bool is_excep
   generate_delphi_struct_definition(s_struct, tstruct, is_exception);
   indent_down();
 
-  add_defined_type( tstruct);
+  add_defined_type(tstruct);
 
   generate_delphi_struct_impl(s_struct_impl, "", tstruct, is_exception);
   if (register_types_) {
     generate_delphi_struct_type_factory(s_type_factory_funcs, "", tstruct, is_exception);
-    generate_delphi_struct_type_factory_registration(s_type_factory_registration, "", tstruct, is_exception);
+    generate_delphi_struct_type_factory_registration(s_type_factory_registration,
+                                                     "",
+                                                     tstruct,
+                                                     is_exception);
   }
 }
 
-void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
+void t_delphi_generator::generate_delphi_struct_impl(ostream& out,
+                                                     string cls_prefix,
+                                                     t_struct* tstruct,
+                                                     bool is_exception,
+                                                     bool is_result,
+                                                     bool is_x_factory) {
 
-  if (is_exception &&  (! is_x_factory)) {
-    generate_delphi_struct_impl( out,  cls_prefix, tstruct, is_exception, is_result, true);
+  if (is_exception && (!is_x_factory)) {
+    generate_delphi_struct_impl(out, cls_prefix, tstruct, is_exception, is_result, true);
   }
 
   string cls_nm;
@@ -1205,14 +1398,13 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
   string exception_factory_name;
 
   if (is_exception) {
-    exception_factory_name = normalize_clsnm( tstruct->get_name(), "", true ) + "Factory";
+    exception_factory_name = normalize_clsnm(tstruct->get_name(), "", true) + "Factory";
   }
 
   if (is_exception) {
-    cls_nm = type_name(tstruct,true,(! is_x_factory),is_x_factory,true);
-  }
-  else {
-    cls_nm = type_name(tstruct,true,false);
+    cls_nm = type_name(tstruct, true, (!is_x_factory), is_x_factory, true);
+  } else {
+    cls_nm = type_name(tstruct, true, false);
   }
 
   std::ostringstream vars, code;
@@ -1227,31 +1419,38 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
       t = ((t_typedef*)t)->get_type();
     }
     if ((*m_iter)->get_value() != NULL) {
-      initialize_field( vars, code, "F" + prop_name( (*m_iter)->get_name(), is_exception), t, (*m_iter)->get_value());
+      initialize_field(vars,
+                       code,
+                       "F" + prop_name((*m_iter)->get_name(), is_exception),
+                       t,
+                       (*m_iter)->get_value());
       if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
-        indent_impl(code) << "F__isset_" << prop_name((*m_iter), is_exception) << " := True;" << endl;
+        indent_impl(code) << "F__isset_" << prop_name((*m_iter), is_exception) << " := True;"
+                          << endl;
       }
     }
   }
   indent_down_impl();
 
-  indent_impl(out) << "constructor " << cls_prefix << cls_nm <<  "." << "Create;" << endl;
+  indent_impl(out) << "constructor " << cls_prefix << cls_nm << "."
+                   << "Create;" << endl;
 
-  if ( ! vars.str().empty()) {
+  if (!vars.str().empty()) {
     out << "var" << endl;
     out << vars.str();
   }
 
   indent_impl(out) << "begin" << endl;
   indent_up_impl();
-  if (is_exception && (! is_x_factory)) {
+  if (is_exception && (!is_x_factory)) {
     indent_impl(out) << "inherited Create('');" << endl;
-    indent_impl(out) << "F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << endl;
+    indent_impl(out) << "F" << exception_factory_name << " := T" << exception_factory_name
+                     << "Impl.Create;" << endl;
   } else {
     indent_impl(out) << "inherited;" << endl;
   }
 
-  if ( ! code.str().empty()) {
+  if (!code.str().empty()) {
     out << code.str();
   }
 
@@ -1259,13 +1458,15 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
   indent_impl(out) << "end;" << endl << endl;
 
   if ((members.size() > 0) && is_exception && (!is_x_factory)) {
-    indent_impl(out) << "constructor " << cls_prefix << cls_nm <<  "." << "Create(" << constructor_argument_list( tstruct, indent_impl()) << ");" << endl;
+    indent_impl(out) << "constructor " << cls_prefix << cls_nm << "."
+                     << "Create(" << constructor_argument_list(tstruct, indent_impl()) << ");"
+                     << endl;
     indent_impl(out) << "begin" << endl;
     indent_up_impl();
     indent_impl(out) << "Create;" << endl;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       string propname = prop_name((*m_iter)->get_name(), is_exception);
-      string param_name = constructor_param_name( (*m_iter)->get_name());
+      string param_name = constructor_param_name((*m_iter)->get_name());
       indent_impl(out) << propname << " := " << param_name << ";" << endl;
     }
     indent_impl(out) << "UpdateMessageProperty;" << endl;
@@ -1273,7 +1474,8 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
     indent_impl(out) << "end;" << endl << endl;
   }
 
-  indent_impl(out) << "destructor "  << cls_prefix << cls_nm <<  "." << "Destroy;" << endl;
+  indent_impl(out) << "destructor " << cls_prefix << cls_nm << "."
+                   << "Destroy;" << endl;
   indent_impl(out) << "begin" << endl;
   indent_up_impl();
 
@@ -1282,15 +1484,16 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
     while (t->is_typedef()) {
       t = ((t_typedef*)t)->get_type();
     }
-    finalize_field( out, prop_name(*m_iter, is_exception), t, (*m_iter)->get_value());
+    finalize_field(out, prop_name(*m_iter, is_exception), t, (*m_iter)->get_value());
   }
 
   indent_impl(out) << "inherited;" << endl;
   indent_down_impl();
   indent_impl(out) << "end;" << endl << endl;
 
-  if ( tstruct->is_union() ) {
-    indent_impl(out) << "procedure "  << cls_prefix << cls_nm <<  "." << "ClearUnionValues;" << endl;
+  if (tstruct->is_union()) {
+    indent_impl(out) << "procedure " << cls_prefix << cls_nm << "."
+                     << "ClearUnionValues;" << endl;
     indent_impl(out) << "begin" << endl;
     indent_up_impl();
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1299,7 +1502,16 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
         t = ((t_typedef*)t)->get_type();
       }
 
-      generate_delphi_clear_union_value( out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception, tstruct->is_union(), is_x_factory, exception_factory_name);
+      generate_delphi_clear_union_value(out,
+                                        cls_prefix,
+                                        cls_nm,
+                                        t,
+                                        *m_iter,
+                                        "F",
+                                        is_exception,
+                                        tstruct->is_union(),
+                                        is_x_factory,
+                                        exception_factory_name);
     }
     indent_down_impl();
     indent_impl(out) << "end;" << endl << endl;
@@ -1310,38 +1522,51 @@ void t_delphi_generator::generate_delphi_struct_impl( ostream& out, string cls_p
     while (t->is_typedef()) {
       t = ((t_typedef*)t)->get_type();
     }
-    generate_delphi_property_reader_impl( out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
-    generate_delphi_property_writer_impl( out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception, tstruct->is_union(), is_x_factory, exception_factory_name);
+    generate_delphi_property_reader_impl(out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
+    generate_delphi_property_writer_impl(out,
+                                         cls_prefix,
+                                         cls_nm,
+                                         t,
+                                         *m_iter,
+                                         "F",
+                                         is_exception,
+                                         tstruct->is_union(),
+                                         is_x_factory,
+                                         exception_factory_name);
     if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
-      generate_delphi_isset_reader_impl( out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
+      generate_delphi_isset_reader_impl(out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
     }
   }
 
-  if ((! is_exception) || is_x_factory) {
-    generate_delphi_struct_reader_impl( out, cls_prefix, tstruct, is_exception);
-    if ( is_result ) {
-      generate_delphi_struct_result_writer_impl( out, cls_prefix, tstruct, is_exception);
+  if ((!is_exception) || is_x_factory) {
+    generate_delphi_struct_reader_impl(out, cls_prefix, tstruct, is_exception);
+    if (is_result) {
+      generate_delphi_struct_result_writer_impl(out, cls_prefix, tstruct, is_exception);
     } else {
-      generate_delphi_struct_writer_impl( out, cls_prefix, tstruct, is_exception);
+      generate_delphi_struct_writer_impl(out, cls_prefix, tstruct, is_exception);
     }
   }
-  generate_delphi_struct_tostring_impl( out, cls_prefix, tstruct, is_exception, is_x_factory);
+  generate_delphi_struct_tostring_impl(out, cls_prefix, tstruct, is_exception, is_x_factory);
 
   if (is_exception && is_x_factory) {
-    generate_delphi_create_exception_impl( out, cls_prefix, tstruct, is_exception);
+    generate_delphi_create_exception_impl(out, cls_prefix, tstruct, is_exception);
   }
 }
 
-void t_delphi_generator::print_delphi_struct_type_factory_func(  ostream& out, t_struct* tstruct) {
+void t_delphi_generator::print_delphi_struct_type_factory_func(ostream& out, t_struct* tstruct) {
   string struct_intf_name = type_name(tstruct);
   out << "Create_";
   out << struct_intf_name;
   out << "_Impl";
 }
 
-
-void t_delphi_generator::generate_delphi_struct_type_factory( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
-  (void) cls_prefix;
+void t_delphi_generator::generate_delphi_struct_type_factory(ostream& out,
+                                                             string cls_prefix,
+                                                             t_struct* tstruct,
+                                                             bool is_exception,
+                                                             bool is_result,
+                                                             bool is_x_factory) {
+  (void)cls_prefix;
   if (is_exception)
     return;
   if (is_result)
@@ -1350,7 +1575,7 @@ void t_delphi_generator::generate_delphi_struct_type_factory( ostream& out, stri
     return;
 
   string struct_intf_name = type_name(tstruct);
-  string cls_nm = type_name(tstruct,true,false);
+  string cls_nm = type_name(tstruct, true, false);
 
   out << "function ";
   print_delphi_struct_type_factory_func(out, tstruct);
@@ -1364,8 +1589,13 @@ void t_delphi_generator::generate_delphi_struct_type_factory( ostream& out, stri
   out << "end;" << endl << endl;
 }
 
-void t_delphi_generator::generate_delphi_struct_type_factory_registration( ostream& out, string cls_prefix, t_struct* tstruct, bool is_exception, bool is_result, bool is_x_factory) {
-  (void) cls_prefix;
+void t_delphi_generator::generate_delphi_struct_type_factory_registration(ostream& out,
+                                                                          string cls_prefix,
+                                                                          t_struct* tstruct,
+                                                                          bool is_exception,
+                                                                          bool is_result,
+                                                                          bool is_x_factory) {
+  (void)cls_prefix;
   if (is_exception)
     return;
   if (is_result)
@@ -1381,7 +1611,12 @@ void t_delphi_generator::generate_delphi_struct_type_factory_registration( ostre
   out << endl;
 }
 
-void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struct* tstruct, bool is_exception, bool in_class, bool is_result, bool is_x_factory) {
+void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
+                                                           t_struct* tstruct,
+                                                           bool is_exception,
+                                                           bool in_class,
+                                                           bool is_result,
+                                                           bool is_x_factory) {
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
   string struct_intf_name;
   string struct_name;
@@ -1389,38 +1624,35 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  string exception_factory_name = normalize_clsnm( tstruct->get_name(), "", true ) + "Factory";
+  string exception_factory_name = normalize_clsnm(tstruct->get_name(), "", true) + "Factory";
 
   if (is_exception) {
-    struct_intf_name = type_name(tstruct,false,false,true);
-  }
-  else {
+    struct_intf_name = type_name(tstruct, false, false, true);
+  } else {
     struct_intf_name = type_name(tstruct);
   }
 
-
   if (is_exception) {
-    struct_name = type_name(tstruct, true, (! is_x_factory), is_x_factory);
-  }
-  else {
-    struct_name = type_name(tstruct,true);
+    struct_name = type_name(tstruct, true, (!is_x_factory), is_x_factory);
+  } else {
+    struct_name = type_name(tstruct, true);
   }
 
-  if ((! is_exception) || is_x_factory) {
+  if ((!is_exception) || is_x_factory) {
 
     generate_delphi_doc(out, tstruct);
     indent(out) << struct_intf_name << " = interface(IBase)" << endl;
     indent_up();
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-      generate_delphi_property_reader_definition( out, *m_iter, is_exception);
-      generate_delphi_property_writer_definition( out, *m_iter, is_exception);
+      generate_delphi_property_reader_definition(out, *m_iter, is_exception);
+      generate_delphi_property_writer_definition(out, *m_iter, is_exception);
     }
 
     if (is_x_factory) {
       out << endl;
       indent(out) << "// Create Exception Object" << endl;
-      indent(out) << "function CreateException: " << type_name(tstruct,true,true) << ";" << endl;
+      indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << endl;
     }
 
     if (members.size() > 0) {
@@ -1434,7 +1666,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
       out << endl;
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
         if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
-          generate_delphi_isset_reader_definition( out, *m_iter, is_exception);
+          generate_delphi_isset_reader_definition(out, *m_iter, is_exception);
         }
       }
     }
@@ -1444,7 +1676,8 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
         if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
           isset_name = "__isset_" + prop_name(*m_iter, is_exception);
-          indent(out) << "property " << isset_name << ": Boolean read Get" << isset_name << ";" << endl;
+          indent(out) << "property " << isset_name << ": Boolean read Get" << isset_name << ";"
+                      << endl;
         }
       }
     }
@@ -1459,19 +1692,19 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
     out << "sealed ";
   }
   out << "class(";
-  if ( is_exception && (! is_x_factory)) {
+  if (is_exception && (!is_x_factory)) {
     out << "TException";
   } else {
     out << "TInterfacedObject, IBase, " << struct_intf_name;
   }
   out << ")" << endl;
 
-  if (is_exception && (! is_x_factory)) {
+  if (is_exception && (!is_x_factory)) {
     indent(out) << "public" << endl;
     indent_up();
     indent(out) << "type" << endl;
     indent_up();
-    generate_delphi_struct_definition( out, tstruct, is_exception, in_class, is_result, true);
+    generate_delphi_struct_definition(out, tstruct, is_exception, in_class, is_result, true);
     indent_down();
     indent_down();
   }
@@ -1479,7 +1712,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   indent(out) << "private" << endl;
   indent_up();
 
-  if (is_exception && (! is_x_factory)) {
+  if (is_exception && (!is_x_factory)) {
     indent(out) << "F" << exception_factory_name << " :" << struct_intf_name << ";" << endl << endl;
   }
 
@@ -1500,8 +1733,8 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   indent(out) << endl;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    generate_delphi_property_reader_definition( out, *m_iter, is_exception);
-    generate_delphi_property_writer_definition( out, *m_iter, is_exception);
+    generate_delphi_property_reader_definition(out, *m_iter, is_exception);
+    generate_delphi_property_writer_definition(out, *m_iter, is_exception);
   }
 
   if (tstruct->is_union()) {
@@ -1525,35 +1758,37 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream &out, t_struc
   indent(out) << "public" << endl;
   indent_up();
 
-  if ((members.size() > 0) && is_exception && (! is_x_factory)) {
+  if ((members.size() > 0) && is_exception && (!is_x_factory)) {
     indent(out) << "constructor Create; overload;" << endl;
-    indent(out) << "constructor Create(" << constructor_argument_list( tstruct, indent()) << "); overload;" << endl;
+    indent(out) << "constructor Create(" << constructor_argument_list(tstruct, indent())
+                << "); overload;" << endl;
   } else {
     indent(out) << "constructor Create;" << endl;
   }
 
   indent(out) << "destructor Destroy; override;" << endl;
 
-  out  << endl;
+  out << endl;
   indent(out) << "function ToString: string; override;" << endl;
 
-  if (is_exception && (! is_x_factory)) {
-    out  << endl;
+  if (is_exception && (!is_x_factory)) {
+    out << endl;
     indent(out) << "// Exception Factory" << en

<TRUNCATED>

[25/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_hs_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_hs_generator.cc b/compiler/cpp/src/generate/t_hs_generator.cc
index c969619..b217ce6 100644
--- a/compiler/cpp/src/generate/t_hs_generator.cc
+++ b/compiler/cpp/src/generate/t_hs_generator.cc
@@ -39,21 +39,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Haskell code generator.
  *
  */
 class t_hs_generator : public t_oop_generator {
- public:
+public:
   t_hs_generator(t_program* program,
                  const map<string, string>& parsed_options,
                  const string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-hs";
   }
 
@@ -67,12 +66,12 @@ class t_hs_generator : public t_oop_generator {
   /**
    * Program-level generation functions
    */
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   string render_const_value(t_type* type, t_const_value* value);
 
@@ -80,95 +79,62 @@ class t_hs_generator : public t_oop_generator {
    * Struct generation code
    */
 
-  void generate_hs_struct            (t_struct* tstruct,
-                                      bool is_exception);
+  void generate_hs_struct(t_struct* tstruct, bool is_exception);
 
-  void generate_hs_struct_definition (ofstream &out,
-                                      t_struct* tstruct,
-                                      bool is_xception = false,
-                                      bool helper = false);
+  void generate_hs_struct_definition(ofstream& out,
+                                     t_struct* tstruct,
+                                     bool is_xception = false,
+                                     bool helper = false);
 
-  void generate_hs_struct_reader     (ofstream& out,
-                                      t_struct* tstruct);
+  void generate_hs_struct_reader(ofstream& out, t_struct* tstruct);
 
-  void generate_hs_struct_writer     (ofstream& out,
-                                      t_struct* tstruct);
+  void generate_hs_struct_writer(ofstream& out, t_struct* tstruct);
 
-  void generate_hs_struct_arbitrary  (ofstream& out,
-                                      t_struct* tstruct);
+  void generate_hs_struct_arbitrary(ofstream& out, t_struct* tstruct);
 
-  void generate_hs_function_helpers  (t_function* tfunction);
+  void generate_hs_function_helpers(t_function* tfunction);
 
-  void generate_hs_typemap           (ofstream& out,
-                                      t_struct* tstruct);
-
-  void generate_hs_default           (ofstream& out,
-                                      t_struct* tstruct);
+  void generate_hs_typemap(ofstream& out, t_struct* tstruct);
 
+  void generate_hs_default(ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice,
-                                   t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (ofstream &out,
-                                          t_field* tfield,
-                                          string prefix);
-
-  void generate_deserialize_struct       (ofstream &out,
-                                          t_struct* tstruct,
-                                          string name = "");
+  void generate_deserialize_field(ofstream& out, t_field* tfield, string prefix);
 
-  void generate_deserialize_container    (ofstream &out,
-                                          t_type* ttype,
-                                          string arg = "");
+  void generate_deserialize_struct(ofstream& out, t_struct* tstruct, string name = "");
 
-  void generate_deserialize_set_element  (ofstream &out,
-                                          t_set* tset);
+  void generate_deserialize_container(ofstream& out, t_type* ttype, string arg = "");
 
+  void generate_deserialize_set_element(ofstream& out, t_set* tset);
 
-  void generate_deserialize_list_element (ofstream &out,
-                                          t_list* tlist,
-                                          string prefix = "");
+  void generate_deserialize_list_element(ofstream& out, t_list* tlist, string prefix = "");
 
-  void generate_deserialize_type          (ofstream &out,
-                                           t_type* type,
-                                           string arg = "");
+  void generate_deserialize_type(ofstream& out, t_type* type, string arg = "");
 
-  void generate_serialize_type           (ofstream &out,
-                                          t_type* type,
-                                          string name = "");
+  void generate_serialize_type(ofstream& out, t_type* type, string name = "");
 
-  void generate_serialize_struct         (ofstream &out,
-                                          t_struct* tstruct,
-                                          string prefix = "");
+  void generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix = "");
 
-  void generate_serialize_container      (ofstream &out,
-                                          t_type* ttype,
-                                          string prefix = "");
+  void generate_serialize_container(ofstream& out, t_type* ttype, string prefix = "");
 
-  void generate_serialize_map_element    (ofstream &out,
-                                          t_map* tmap,
-                                          string kiter,
-                                          string viter);
+  void generate_serialize_map_element(ofstream& out, t_map* tmap, string kiter, string viter);
 
-  void generate_serialize_set_element    (ofstream &out,
-                                          t_set* tmap,
-                                          string iter);
+  void generate_serialize_set_element(ofstream& out, t_set* tmap, string iter);
 
-  void generate_serialize_list_element   (ofstream &out,
-                                          t_list* tlist,
-                                          string iter);
+  void generate_serialize_list_element(ofstream& out, t_list* tlist, string iter);
 
   /**
    * Helper rendering functions
@@ -178,8 +144,7 @@ class t_hs_generator : public t_oop_generator {
   string hs_language_pragma();
   string hs_imports();
 
-  string type_name(t_type* ttype,
-                   string function_prefix = "");
+  string type_name(t_type* ttype, string function_prefix = "");
 
   string field_name(string tname, string fname);
 
@@ -192,15 +157,13 @@ class t_hs_generator : public t_oop_generator {
 
   string type_to_default(t_type* ttype);
 
-  string render_hs_type(t_type* type,
-                        bool needs_parens);
+  string render_hs_type(t_type* type, bool needs_parens);
 
   string type_to_constructor(t_type* ttype);
 
-  string render_hs_type_for_function_name(t_type *type);
-
- private:
+  string render_hs_type_for_function_name(t_type* type);
 
+private:
   ofstream f_types_;
   ofstream f_consts_;
   ofstream f_service_;
@@ -240,24 +203,25 @@ void t_hs_generator::init_generator() {
 }
 
 string t_hs_generator::hs_language_pragma() {
-  return string("{-# LANGUAGE DeriveDataTypeable #-}\n"
-                "{-# LANGUAGE OverloadedStrings #-}\n"
-                "{-# OPTIONS_GHC -fno-warn-missing-fields #-}\n"
-                "{-# OPTIONS_GHC -fno-warn-missing-signatures #-}\n"
-                "{-# OPTIONS_GHC -fno-warn-name-shadowing #-}\n"
-                "{-# OPTIONS_GHC -fno-warn-unused-imports #-}\n"
-                "{-# OPTIONS_GHC -fno-warn-unused-matches #-}\n");
+  return string(
+      "{-# LANGUAGE DeriveDataTypeable #-}\n"
+      "{-# LANGUAGE OverloadedStrings #-}\n"
+      "{-# OPTIONS_GHC -fno-warn-missing-fields #-}\n"
+      "{-# OPTIONS_GHC -fno-warn-missing-signatures #-}\n"
+      "{-# OPTIONS_GHC -fno-warn-name-shadowing #-}\n"
+      "{-# OPTIONS_GHC -fno-warn-unused-imports #-}\n"
+      "{-# OPTIONS_GHC -fno-warn-unused-matches #-}\n");
 }
 
 /**
  * Autogen'd comment
  */
 string t_hs_generator::hs_autogen_comment() {
-  return string("-----------------------------------------------------------------\n") +
-                "-- Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")                      --\n" +
-                "--                                                             --\n" +
-                "-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --\n" +
-                "-----------------------------------------------------------------\n";
+  return string("-----------------------------------------------------------------\n")
+         + "-- Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")                      --\n"
+         + "--                                                             --\n"
+         + "-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --\n"
+         + "-----------------------------------------------------------------\n";
 }
 
 /**
@@ -355,7 +319,7 @@ void t_hs_generator::generate_enum(t_enum* tenum) {
   indent_down();
   indent(f_types_) << "toEnum t = case t of" << endl;
   indent_up();
-  for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
+  for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     string name = capitalize((*c_iter)->get_name());
     indent(f_types_) << value << " -> " << name << endl;
@@ -435,8 +399,7 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
   } else if (type->is_enum()) {
     t_enum* tenum = (t_enum*)type;
     vector<t_enum_value*> constants = tenum->get_constants();
-    for (vector<t_enum_value*>::iterator c_iter = constants.begin();
-         c_iter != constants.end();
+    for (vector<t_enum_value*>::iterator c_iter = constants.begin(); c_iter != constants.end();
          ++c_iter) {
       int val = (*c_iter)->get_value();
       if (val == value->get_integer()) {
@@ -461,8 +424,7 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
          ++v_iter) {
       t_field* field = NULL;
 
-      for (vector<t_field*>::const_iterator f_iter = fields.begin();
-           f_iter != fields.end();
+      for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end();
            ++f_iter)
         if ((*f_iter)->get_name() == v_iter->first->get_string())
           field = (*f_iter);
@@ -475,8 +437,7 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
 
       out << (first ? "" : ", ");
       out << field_name(cname, fname) << " = ";
-      if (field->get_req() == t_field::T_OPTIONAL ||
-         ((t_type*)field->get_type())->is_xception()) {
+      if (field->get_req() == t_field::T_OPTIONAL || ((t_type*)field->get_type())->is_xception()) {
         out << "P.Just ";
       }
       out << const_value;
@@ -505,9 +466,8 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
     out << "])";
 
   } else if (type->is_list() || type->is_set()) {
-    t_type* etype = type->is_list()
-        ? ((t_list*) type)->get_elem_type()
-        : ((t_set*) type)->get_elem_type();
+    t_type* etype = type->is_list() ? ((t_list*)type)->get_elem_type()
+                                    : ((t_set*)type)->get_elem_type();
 
     const vector<t_const_value*>& val = value->get_list();
     vector<t_const_value*>::const_iterator v_iter;
@@ -553,9 +513,8 @@ void t_hs_generator::generate_xception(t_struct* txception) {
 /**
  * Generates a Haskell struct
  */
-void t_hs_generator::generate_hs_struct(t_struct* tstruct,
-                                        bool is_exception) {
-  generate_hs_struct_definition(f_types_,tstruct, is_exception,false);
+void t_hs_generator::generate_hs_struct(t_struct* tstruct, bool is_exception) {
+  generate_hs_struct_definition(f_types_, tstruct, is_exception, false);
 }
 
 /**
@@ -567,7 +526,7 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out,
                                                    t_struct* tstruct,
                                                    bool is_exception,
                                                    bool helper) {
-  (void) helper;
+  (void)helper;
   string tname = type_name(tstruct);
   string name = tstruct->get_name();
   const vector<t_field*>& members = tstruct->get_members();
@@ -576,8 +535,7 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out,
   if (members.size() > 0) {
     indent_up();
     bool first = true;
-    for (vector<t_field*>::const_iterator m_iter = members.begin();
-         m_iter != members.end();
+    for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();
          ++m_iter) {
       if (first) {
         indent(out) << "{ ";
@@ -587,8 +545,8 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out,
       }
       string mname = (*m_iter)->get_name();
       out << field_name(tname, mname) << " :: ";
-      if ((*m_iter)->get_req() == t_field::T_OPTIONAL ||
-         ((t_type*)(*m_iter)->get_type())->is_xception()) {
+      if ((*m_iter)->get_req() == t_field::T_OPTIONAL
+          || ((t_type*)(*m_iter)->get_type())->is_xception()) {
         out << "P.Maybe ";
       }
       out << render_hs_type((*m_iter)->get_type(), true) << endl;
@@ -605,7 +563,8 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out,
   indent(out) << "instance H.Hashable " << tname << " where" << endl;
   indent_up();
   indent(out) << "hashWithSalt salt record = salt";
-  for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
+  for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();
+       ++m_iter) {
     string mname = (*m_iter)->get_name();
     indent(out) << " `H.hashWithSalt` " << field_name(tname, mname) << " record";
   }
@@ -625,38 +584,41 @@ void t_hs_generator::generate_hs_struct_arbitrary(ofstream& out, t_struct* tstru
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  indent(out) << "instance QC.Arbitrary " << tname << " where "<< endl;
+  indent(out) << "instance QC.Arbitrary " << tname << " where " << endl;
   indent_up();
   if (members.size() > 0) {
     indent(out) << "arbitrary = M.liftM " << tname;
-    indent_up(); indent_up(); indent_up(); indent_up();
-    bool first=true;
-    for (vector<t_field*>::const_iterator m_iter = members.begin();
-         m_iter != members.end();
+    indent_up();
+    indent_up();
+    indent_up();
+    indent_up();
+    bool first = true;
+    for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();
          ++m_iter) {
-      if(first) {
-        first=false;
+      if (first) {
+        first = false;
         out << " ";
-      }
-      else {
+      } else {
         indent(out) << "`M.ap`";
       }
       out << "(";
-      if ((*m_iter)->get_req() == t_field::T_OPTIONAL ||
-         ((t_type*)(*m_iter)->get_type())->is_xception()) {
+      if ((*m_iter)->get_req() == t_field::T_OPTIONAL
+          || ((t_type*)(*m_iter)->get_type())->is_xception()) {
         out << "M.liftM P.Just ";
       }
       out << "QC.arbitrary)" << endl;
     }
-    indent_down(); indent_down(); indent_down(); indent_down();
+    indent_down();
+    indent_down();
+    indent_down();
+    indent_down();
 
     // Shrink
     indent(out) << "shrink obj | obj == default_" << tname << " = []" << endl;
     indent(out) << "           | P.otherwise = M.catMaybes" << endl;
     indent_up();
     first = true;
-    for (vector<t_field*>::const_iterator m_iter = members.begin();
-         m_iter != members.end();
+    for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();
          ++m_iter) {
       if (first) {
         first = false;
@@ -674,7 +636,7 @@ void t_hs_generator::generate_hs_struct_arbitrary(ofstream& out, t_struct* tstru
     indent(out) << "]" << endl;
     indent_down();
   } else { /* 0 == members.size() */
-     indent(out) << "arbitrary = QC.elements [" <<tname<< "]" << endl;
+    indent(out) << "arbitrary = QC.elements [" << tname << "]" << endl;
   }
   indent_down();
 }
@@ -697,9 +659,7 @@ void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct)
   bool first = true;
 
   // Generate deserialization code for known cases
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     int32_t key = (*f_iter)->get_key();
     string etype = type_to_enum((*f_iter)->get_type());
     string fname = (*f_iter)->get_name();
@@ -717,9 +677,8 @@ void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct)
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
       out << "P.error \"Missing required field: " << fname << "\"";
     } else {
-      if (((*f_iter)->get_req() == t_field::T_OPTIONAL ||
-         ((t_type*)(*f_iter)->get_type())->is_xception()) &&
-         (*f_iter)->get_value() == NULL) {
+      if (((*f_iter)->get_req() == t_field::T_OPTIONAL
+           || ((t_type*)(*f_iter)->get_type())->is_xception()) && (*f_iter)->get_value() == NULL) {
         out << "P.Nothing";
       } else {
         out << field_name(sname, fname) << " default_" << sname;
@@ -728,13 +687,12 @@ void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct)
     out << ") ";
 
     out << "(\\(_," << val << ") -> ";
-    if ((*f_iter)->get_req() == t_field::T_OPTIONAL ||
-       ((t_type*)(*f_iter)->get_type())->is_xception())
+    if ((*f_iter)->get_req() == t_field::T_OPTIONAL
+        || ((t_type*)(*f_iter)->get_type())->is_xception())
       out << "P.Just ";
     generate_deserialize_field(out, *f_iter, val);
     out << ")";
     out << " (Map.lookup (" << key << ") fields)";
-
   }
 
   out << endl;
@@ -745,19 +703,18 @@ void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct)
   string tmap = type_name(tstruct, "typemap_");
   indent(out) << "to_" << sname << " _ = P.error \"not a struct\"" << endl;
 
-  indent(out) << "read_" << sname <<
-    " :: (T.Transport t, T.Protocol p) => p t -> P.IO " << sname << endl;
+  indent(out) << "read_" << sname << " :: (T.Transport t, T.Protocol p) => p t -> P.IO " << sname
+              << endl;
   indent(out) << "read_" << sname << " iprot = to_" << sname;
   out << " <$> T.readVal iprot (T.T_STRUCT " << tmap << ")" << endl;
 
-  indent(out) << "decode_" << sname <<
-    " :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> " << sname << endl;
+  indent(out) << "decode_" << sname
+              << " :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> " << sname << endl;
   indent(out) << "decode_" << sname << " iprot bs = to_" << sname << " $ ";
   out << "T.deserializeVal iprot (T.T_STRUCT " << tmap << ") bs" << endl;
 }
 
-void t_hs_generator::generate_hs_struct_writer(ofstream& out,
-                                               t_struct* tstruct) {
+void t_hs_generator::generate_hs_struct_writer(ofstream& out, t_struct* tstruct) {
   string name = type_name(tstruct);
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
@@ -771,9 +728,7 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
 
   // Get Exceptions
   bool hasExn = false;
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (((t_type*)(*f_iter)->get_type())->is_xception()) {
       hasExn = true;
       break;
@@ -785,8 +740,7 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
     out << endl;
     indent(out) << "(let exns = M.catMaybes ";
     indent_up();
-    for (vector<t_field*>::const_iterator f_iter = fields.begin();
-         f_iter != fields.end();
+    for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end();
          ++f_iter) {
       if (((t_type*)(*f_iter)->get_type())->is_xception()) {
         if (isfirst) {
@@ -797,7 +751,7 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
         }
         string mname = (*f_iter)->get_name();
         int32_t key = (*f_iter)->get_key();
-         out << "(\\" << v << " -> (" << key << ", (\"" << mname << "\",";
+        out << "(\\" << v << " -> (" << key << ", (\"" << mname << "\",";
         generate_serialize_type(out, (*f_iter)->get_type(), v);
         out << "))) <$> " << field_name(name, mname) << " record";
       }
@@ -815,9 +769,7 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
   out << "M.catMaybes" << endl;
   // Get the Rest
   isfirst = true;
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     // Write field header
     if (isfirst) {
       indent(out) << "[ ";
@@ -829,15 +781,15 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
     int32_t key = (*f_iter)->get_key();
     out << "(\\";
     out << v << " -> ";
-    if ((*f_iter)->get_req() != t_field::T_OPTIONAL &&
-       !((t_type*)(*f_iter)->get_type())->is_xception()) {
+    if ((*f_iter)->get_req() != t_field::T_OPTIONAL
+        && !((t_type*)(*f_iter)->get_type())->is_xception()) {
       out << "P.Just ";
     }
     out << "(" << key << ", (\"" << mname << "\",";
     generate_serialize_type(out, (*f_iter)->get_type(), v);
     out << "))) ";
-    if ((*f_iter)->get_req() != t_field::T_OPTIONAL &&
-       !((t_type*)(*f_iter)->get_type())->is_xception()) {
+    if ((*f_iter)->get_req() != t_field::T_OPTIONAL
+        && !((t_type*)(*f_iter)->get_type())->is_xception()) {
       out << "$";
     } else {
       out << "<$>";
@@ -858,14 +810,14 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out,
   indent_down();
 
   // write
-  indent(out) << "write_" << name << " :: (T.Protocol p, T.Transport t) => p t -> "
-              << name << " -> P.IO ()" << endl;
+  indent(out) << "write_" << name << " :: (T.Protocol p, T.Transport t) => p t -> " << name
+              << " -> P.IO ()" << endl;
   indent(out) << "write_" << name << " oprot record = T.writeVal oprot $ from_";
   out << name << " record" << endl;
 
   // encode
-  indent(out) << "encode_" << name << " :: (T.Protocol p, T.Transport t) => p t -> "
-              << name << " -> LBS.ByteString" << endl;
+  indent(out) << "encode_" << name << " :: (T.Protocol p, T.Transport t) => p t -> " << name
+              << " -> LBS.ByteString" << endl;
   indent(out) << "encode_" << name << " oprot record = T.serializeVal oprot $ ";
   out << "from_" << name << " record" << endl;
 }
@@ -915,7 +867,7 @@ void t_hs_generator::generate_service_helpers(t_service* tservice) {
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_struct* ts = (*f_iter)->get_arglist();
-    generate_hs_struct_definition(f_service_,ts, false);
+    generate_hs_struct_definition(f_service_, ts, false);
     generate_hs_function_helpers(*f_iter);
   }
 }
@@ -939,15 +891,14 @@ void t_hs_generator::generate_hs_function_helpers(t_function* tfunction) {
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
     result.append(*f_iter);
 
-  generate_hs_struct_definition(f_service_,&result, false);
+  generate_hs_struct_definition(f_service_, &result, false);
 }
 
 /**
  * Generate the map from field names to (type, id)
  * @param tstruct the Struct
  */
-void t_hs_generator::generate_hs_typemap(ofstream& out,
-                                         t_struct* tstruct) {
+void t_hs_generator::generate_hs_typemap(ofstream& out, t_struct* tstruct) {
   string name = type_name(tstruct);
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator f_iter;
@@ -955,9 +906,7 @@ void t_hs_generator::generate_hs_typemap(ofstream& out,
   indent(out) << "typemap_" << name << " :: T.TypeMap" << endl;
   indent(out) << "typemap_" << name << " = Map.fromList [";
   bool first = true;
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     string mname = (*f_iter)->get_name();
     if (!first) {
       out << ",";
@@ -975,8 +924,7 @@ void t_hs_generator::generate_hs_typemap(ofstream& out,
  * generate the struct with default values filled in
  * @param tstruct the Struct
  */
-void t_hs_generator::generate_hs_default(ofstream& out,
-                                         t_struct* tstruct) {
+void t_hs_generator::generate_hs_default(ofstream& out, t_struct* tstruct) {
   string name = type_name(tstruct);
   string fname = type_name(tstruct, "default_");
   const vector<t_field*>& fields = tstruct->get_sorted_members();
@@ -985,9 +933,7 @@ void t_hs_generator::generate_hs_default(ofstream& out,
   indent(out) << fname << " = " << name << "{" << endl;
   indent_up();
   bool first = true;
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     string mname = (*f_iter)->get_name();
     if (first) {
       first = false;
@@ -998,8 +944,8 @@ void t_hs_generator::generate_hs_default(ofstream& out,
     t_type* type = get_true_type((*f_iter)->get_type());
     t_const_value* value = (*f_iter)->get_value();
     indent(out) << field_name(name, mname) << " = ";
-    if ((*f_iter)->get_req() == t_field::T_OPTIONAL ||
-       ((t_type*)(*f_iter)->get_type())->is_xception()) {
+    if ((*f_iter)->get_req() == t_field::T_OPTIONAL
+        || ((t_type*)(*f_iter)->get_type())->is_xception()) {
       if (value == NULL) {
         out << "P.Nothing";
       } else {
@@ -1048,7 +994,7 @@ void t_hs_generator::generate_service_interface(t_service* tservice) {
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     string ft = function_type(*f_iter, true, true, true);
-    indent(f_iface_) << decapitalize((*f_iter)->get_name()) << " :: a -> " << ft  << endl;
+    indent(f_iface_) << decapitalize((*f_iter)->get_name()) << " :: a -> " << ft << endl;
   }
 
   indent_down();
@@ -1056,7 +1002,8 @@ void t_hs_generator::generate_service_interface(t_service* tservice) {
 }
 
 /**
- * Generates a service client definition. Note that in Haskell, the client doesn't implement iface. This is because
+ * Generates a service client definition. Note that in Haskell, the client doesn't implement iface.
+ *This is because
  * The client does not (and should not have to) deal with arguments being Nothing.
  *
  * @param tservice The service to generate a server for.
@@ -1109,16 +1056,15 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
       fargs += " arg_" + (*fld_iter)->get_name();
 
     // Open function
-    indent(f_client_) << decapitalize(funname) << " (ip,op)" <<  fargs << " = do" << endl;
+    indent(f_client_) << decapitalize(funname) << " (ip,op)" << fargs << " = do" << endl;
     indent_up();
-    indent(f_client_) <<  "send_" << funname << " op" << fargs;
+    indent(f_client_) << "send_" << funname << " op" << fargs;
 
     f_client_ << endl;
 
     if (!(*f_iter)->is_oneway())
       indent(f_client_) << "recv_" << funname << " ip" << endl;
 
-
     indent_down();
 
     indent(f_client_) << "send_" << funname << " op" << fargs << " = do" << endl;
@@ -1131,18 +1077,18 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
     // Serialize the request header
     string fname = (*f_iter)->get_name();
     string msgType = (*f_iter)->is_oneway() ? "T.M_ONEWAY" : "T.M_CALL";
-    indent(f_client_) << "T.writeMessageBegin op (\"" << fname << "\", " << msgType << ", seqn)" << endl;
+    indent(f_client_) << "T.writeMessageBegin op (\"" << fname << "\", " << msgType << ", seqn)"
+                      << endl;
     indent(f_client_) << "write_" << argsname << " op (" << argsname << "{";
 
     bool first = true;
-    for (vector<t_field*>::const_iterator fld_iter = fields.begin();
-         fld_iter != fields.end();
+    for (vector<t_field*>::const_iterator fld_iter = fields.begin(); fld_iter != fields.end();
          ++fld_iter) {
       string fieldname = (*fld_iter)->get_name();
       f_client_ << (first ? "" : ",");
       f_client_ << field_name(argsname, fieldname) << "=";
-      if ((*fld_iter)->get_req() == t_field::T_OPTIONAL ||
-         ((t_type*)(*fld_iter)->get_type())->is_xception())
+      if ((*fld_iter)->get_req() == t_field::T_OPTIONAL
+          || ((t_type*)(*fld_iter)->get_type())->is_xception())
         f_client_ << "P.Just ";
       f_client_ << "arg_" << fieldname;
       first = false;
@@ -1161,13 +1107,13 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
       string funname = string("recv_") + (*f_iter)->get_name();
       t_function recv_function((*f_iter)->get_returntype(), funname, &noargs);
 
-
       // Open function
       indent(f_client_) << funname << " ip = do" << endl;
       indent_up();
 
       indent(f_client_) << "(fname, mtype, rseqid) <- T.readMessageBegin ip" << endl;
-      indent(f_client_) << "M.when (mtype == T.M_EXCEPTION) $ do { exn <- T.readAppExn ip ; T.readMessageEnd ip ; X.throw exn }" << endl;
+      indent(f_client_) << "M.when (mtype == T.M_EXCEPTION) $ do { exn <- T.readAppExn ip ; "
+                           "T.readMessageEnd ip ; X.throw exn }" << endl;
 
       indent(f_client_) << "res <- read_" << resultname << " ip" << endl;
       indent(f_client_) << "T.readMessageEnd ip" << endl;
@@ -1175,12 +1121,10 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
       t_struct* xs = (*f_iter)->get_xceptions();
       const vector<t_field*>& xceptions = xs->get_members();
 
-      for (vector<t_field*>::const_iterator x_iter = xceptions.begin();
-           x_iter != xceptions.end();
+      for (vector<t_field*>::const_iterator x_iter = xceptions.begin(); x_iter != xceptions.end();
            ++x_iter) {
         indent(f_client_) << "P.maybe (P.return ()) X.throw ("
-          << field_name(resultname, (*x_iter)->get_name())
-          << " res)" << endl;
+                          << field_name(resultname, (*x_iter)->get_name()) << " res)" << endl;
       }
 
       if (!(*f_iter)->get_returntype()->is_void())
@@ -1215,19 +1159,22 @@ void t_hs_generator::generate_service_server(t_service* tservice) {
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     string fname = (*f_iter)->get_name();
-    indent(f_service_) << "\"" << fname << "\" -> process_" << decapitalize(fname) << " (seqid,iprot,oprot,handler)" << endl;
+    indent(f_service_) << "\"" << fname << "\" -> process_" << decapitalize(fname)
+                       << " (seqid,iprot,oprot,handler)" << endl;
   }
 
   indent(f_service_) << "_ -> ";
   if (tservice->get_extends() != NULL) {
-    f_service_ << type_name(tservice->get_extends()) << ".proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
+    f_service_ << type_name(tservice->get_extends())
+               << ".proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
 
   } else {
     f_service_ << "do" << endl;
     indent_up();
     indent(f_service_) << "_ <- T.readVal iprot (T.T_STRUCT Map.empty)" << endl;
     indent(f_service_) << "T.writeMessageBegin oprot (name,T.M_EXCEPTION,seqid)" << endl;
-    indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN_METHOD (\"Unknown function \" ++ LT.unpack name))" << endl;
+    indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN_METHOD (\"Unknown function "
+                          "\" ++ LT.unpack name))" << endl;
     indent(f_service_) << "T.writeMessageEnd oprot" << endl;
     indent(f_service_) << "T.tFlush (T.getTransport oprot)" << endl;
     indent_down();
@@ -1247,25 +1194,25 @@ void t_hs_generator::generate_service_server(t_service* tservice) {
 }
 
 bool hasNoArguments(t_function* func) {
-    return (func->get_arglist()->get_members().empty());
+  return (func->get_arglist()->get_members().empty());
 }
 
 string t_hs_generator::render_hs_type_for_function_name(t_type* type) {
-    string type_str = render_hs_type(type, false);
-    int found = -1;
+  string type_str = render_hs_type(type, false);
+  int found = -1;
 
-    while (true) {
-        found = type_str.find_first_of("[]. ", found + 1);
-        if (string::npos == size_t(found)) {
-            break;
-        }
-
-        if (type_str[found] == '.')
-            type_str[found] = '_';
-        else
-            type_str[found] = 'Z';
+  while (true) {
+    found = type_str.find_first_of("[]. ", found + 1);
+    if (string::npos == size_t(found)) {
+      break;
     }
-    return type_str;
+
+    if (type_str[found] == '.')
+      type_str[found] = '_';
+    else
+      type_str[found] = 'Z';
+  }
+  return type_str;
 }
 
 /**
@@ -1273,9 +1220,8 @@ string t_hs_generator::render_hs_type_for_function_name(t_type* type) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_hs_generator::generate_process_function(t_service* tservice,
-                                               t_function* tfunction) {
-  (void) tservice;
+void t_hs_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open function
   string funname = decapitalize(tfunction->get_name());
   indent(f_service_) << "process_" << funname << " (seqid, iprot, oprot, handler) = do" << endl;
@@ -1298,7 +1244,7 @@ void t_hs_generator::generate_process_function(t_service* tservice,
   size_t n = xceptions.size() + 1;
   // Try block for a function with exceptions
   if (n > 0) {
-    for(size_t i = 0; i < n; i++) {
+    for (size_t i = 0; i < n; i++) {
       indent(f_service_) << "(X.catch" << endl;
       indent_up();
     }
@@ -1315,13 +1261,12 @@ void t_hs_generator::generate_process_function(t_service* tservice,
 
   f_service_ << "Iface." << decapitalize(tfunction->get_name()) << " handler";
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
-    f_service_ << " (" <<
-      field_name(argsname, (*f_iter)->get_name()) << " args)";
+    f_service_ << " (" << field_name(argsname, (*f_iter)->get_name()) << " args)";
 
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << endl;
-    indent(f_service_) << "let res = default_" << resultname << "{" <<
-      field_name(resultname, "success") << " = val}";
+    indent(f_service_) << "let res = default_" << resultname << "{"
+                       << field_name(resultname, "success") << " = val}";
 
   } else if (!tfunction->is_oneway()) {
     f_service_ << endl;
@@ -1333,7 +1278,8 @@ void t_hs_generator::generate_process_function(t_service* tservice,
   if (tfunction->is_oneway()) {
     indent(f_service_) << "P.return ()";
   } else {
-    indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name() << "\", T.M_REPLY, seqid)" << endl;
+    indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
+                       << "\", T.M_REPLY, seqid)" << endl;
     indent(f_service_) << "write_" << resultname << " oprot res" << endl;
     indent(f_service_) << "T.writeMessageEnd oprot" << endl;
     indent(f_service_) << "T.tFlush (T.getTransport oprot)";
@@ -1351,11 +1297,13 @@ void t_hs_generator::generate_process_function(t_service* tservice,
 
       if (!tfunction->is_oneway()) {
         indent(f_service_) << "let res = default_" << resultname << "{"
-          << field_name(resultname, (*x_iter)->get_name()) << " = P.Just e}" << endl;
-        indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name() << "\", T.M_REPLY, seqid)" << endl;
-        indent(f_service_ ) << "write_" << resultname << " oprot res" << endl;
+                           << field_name(resultname, (*x_iter)->get_name()) << " = P.Just e}"
+                           << endl;
+        indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
+                           << "\", T.M_REPLY, seqid)" << endl;
+        indent(f_service_) << "write_" << resultname << " oprot res" << endl;
         indent(f_service_) << "T.writeMessageEnd oprot" << endl;
-        indent(f_service_ ) << "T.tFlush (T.getTransport oprot)";
+        indent(f_service_) << "T.tFlush (T.getTransport oprot)";
       } else {
         indent(f_service_) << "P.return ()";
       }
@@ -1368,10 +1316,11 @@ void t_hs_generator::generate_process_function(t_service* tservice,
     indent_up();
 
     if (!tfunction->is_oneway()) {
-      indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name() << "\", T.M_EXCEPTION, seqid)" << endl;
-      indent(f_service_ ) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN \"\")" << endl;
+      indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
+                         << "\", T.M_EXCEPTION, seqid)" << endl;
+      indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN \"\")" << endl;
       indent(f_service_) << "T.writeMessageEnd oprot" << endl;
-      indent(f_service_ ) << "T.tFlush (T.getTransport oprot)";
+      indent(f_service_) << "T.tFlush (T.getTransport oprot)";
     } else {
       indent(f_service_) << "P.return ()";
     }
@@ -1379,30 +1328,24 @@ void t_hs_generator::generate_process_function(t_service* tservice,
     f_service_ << ") :: X.SomeException -> P.IO ()))" << endl;
     indent_down();
     indent_down();
-
   }
   // Close function
   indent_down();
-
 }
 
 /**
  * Deserializes a field of any type.
  */
-void t_hs_generator::generate_deserialize_field(ofstream &out,
-                                                t_field* tfield,
-                                                string prefix) {
-  (void) prefix;
+void t_hs_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
+  (void)prefix;
   t_type* type = tfield->get_type();
-  generate_deserialize_type(out,type, prefix);
+  generate_deserialize_type(out, type, prefix);
 }
 
 /**
  * Deserializes a field of any type.
  */
-void t_hs_generator::generate_deserialize_type(ofstream &out,
-                                               t_type* type,
-                                               string arg) {
+void t_hs_generator::generate_deserialize_type(ofstream& out, t_type* type, string arg) {
   type = get_true_type(type);
   string val = tmp("_val");
   out << "(case " << arg << " of {" << type_to_constructor(type) << " " << val << " -> ";
@@ -1431,13 +1374,10 @@ void t_hs_generator::generate_deserialize_type(ofstream &out,
   out << "; _ -> P.error \"wrong type\"})";
 }
 
-
 /**
  * Generates an unserializer for a struct, calling read()
  */
-void t_hs_generator::generate_deserialize_struct(ofstream &out,
-                                                 t_struct* tstruct,
-                                                 string name) {
+void t_hs_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string name) {
 
   out << "(" << type_name(tstruct, "to_") << " (T.TStruct " << name << "))";
 }
@@ -1446,30 +1386,28 @@ void t_hs_generator::generate_deserialize_struct(ofstream &out,
  * Serialize a container by writing out the header followed by
  * data and then a footer.
  */
-void t_hs_generator::generate_deserialize_container(ofstream &out,
-                                                    t_type* ttype,
-                                                    string arg) {
+void t_hs_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string arg) {
 
   string val = tmp("_v");
   // Declare variables, read header
   if (ttype->is_map()) {
     string key = tmp("_k");
     out << "(Map.fromList $ P.map (\\(" << key << "," << val << ") -> (";
-    generate_deserialize_type(out,((t_map*)ttype)->get_key_type(),key);
+    generate_deserialize_type(out, ((t_map*)ttype)->get_key_type(), key);
 
     out << ",";
-    generate_deserialize_type(out,((t_map*)ttype)->get_val_type(),val);
+    generate_deserialize_type(out, ((t_map*)ttype)->get_val_type(), val);
 
     out << ")) " << arg << ")";
 
   } else if (ttype->is_set()) {
     out << "(Set.fromList $ P.map (\\" << val << " -> ";
-    generate_deserialize_type(out,((t_map*)ttype)->get_key_type(),val);
+    generate_deserialize_type(out, ((t_map*)ttype)->get_key_type(), val);
     out << ") " << arg << ")";
 
   } else if (ttype->is_list()) {
     out << "(Vector.fromList $ P.map (\\" << val << " -> ";
-    generate_deserialize_type(out,((t_map*)ttype)->get_key_type(),val);
+    generate_deserialize_type(out, ((t_map*)ttype)->get_key_type(), val);
     out << ") " << arg << ")";
   }
 }
@@ -1480,9 +1418,7 @@ void t_hs_generator::generate_deserialize_container(ofstream &out,
  * @param tfield The field to serialize
  * @param prefix Name to prepend to field name
  */
-void t_hs_generator::generate_serialize_type(ofstream &out,
-                                              t_type* type,
-                                              string name) {
+void t_hs_generator::generate_serialize_type(ofstream& out, t_type* type, string name) {
 
   type = get_true_type(type);
   // Do nothing for void types
@@ -1520,15 +1456,11 @@ void t_hs_generator::generate_serialize_type(ofstream &out,
  * @param tstruct The struct to serialize
  * @param prefix  String prefix to attach to all fields
  */
-void t_hs_generator::generate_serialize_struct(ofstream &out,
-                                               t_struct* tstruct,
-                                               string prefix) {
+void t_hs_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
   out << type_name(tstruct, "from_") << " " << prefix;
 }
 
-void t_hs_generator::generate_serialize_container(ofstream &out,
-                                                  t_type* ttype,
-                                                  string prefix) {
+void t_hs_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
   string k = tmp("_k");
   string v = tmp("_v");
 
@@ -1544,28 +1476,25 @@ void t_hs_generator::generate_serialize_container(ofstream &out,
 
   } else if (ttype->is_set()) {
     out << "T.TSet " << type_to_enum(((t_list*)ttype)->get_elem_type());
-    out <<" $ P.map (\\" << v << " -> ";
+    out << " $ P.map (\\" << v << " -> ";
     generate_serialize_type(out, ((t_list*)ttype)->get_elem_type(), v);
     out << ") $ Set.toList " << prefix;
 
   } else if (ttype->is_list()) {
     out << "T.TList " << type_to_enum(((t_list*)ttype)->get_elem_type());
-    out <<" $ P.map (\\" << v << " -> ";
+    out << " $ P.map (\\" << v << " -> ";
     generate_serialize_type(out, ((t_list*)ttype)->get_elem_type(), v);
     out << ") $ Vector.toList " << prefix;
   }
-
 }
 
 string t_hs_generator::function_type(t_function* tfunc, bool options, bool io, bool method) {
   string result = "";
 
   const vector<t_field*>& fields = tfunc->get_arglist()->get_members();
-  for (vector<t_field*>::const_iterator f_iter = fields.begin();
-       f_iter != fields.end();
-       ++f_iter) {
-    if ((*f_iter)->get_req() == t_field::T_OPTIONAL ||
-       ((t_type*)(*f_iter)->get_type())->is_xception())
+  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    if ((*f_iter)->get_req() == t_field::T_OPTIONAL
+        || ((t_type*)(*f_iter)->get_type())->is_xception())
       result += "P.Maybe ";
     result += render_hs_type((*f_iter)->get_type(), options);
     result += " -> ";
@@ -1581,7 +1510,6 @@ string t_hs_generator::function_type(t_function* tfunc, bool options, bool io, b
   return result;
 }
 
-
 string t_hs_generator::type_name(t_type* ttype, string function_prefix) {
   string prefix = "";
   t_program* program = ttype->get_program();
@@ -1606,14 +1534,22 @@ string t_hs_generator::type_to_enum(t_type* type) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-    case t_base_type::TYPE_VOID:   return "T.T_VOID";
-    case t_base_type::TYPE_STRING: return "T.T_STRING";
-    case t_base_type::TYPE_BOOL:   return "T.T_BOOL";
-    case t_base_type::TYPE_BYTE:   return "T.T_BYTE";
-    case t_base_type::TYPE_I16:    return "T.T_I16";
-    case t_base_type::TYPE_I32:    return "T.T_I32";
-    case t_base_type::TYPE_I64:    return "T.T_I64";
-    case t_base_type::TYPE_DOUBLE: return "T.T_DOUBLE";
+    case t_base_type::TYPE_VOID:
+      return "T.T_VOID";
+    case t_base_type::TYPE_STRING:
+      return "T.T_STRING";
+    case t_base_type::TYPE_BOOL:
+      return "T.T_BOOL";
+    case t_base_type::TYPE_BYTE:
+      return "T.T_BYTE";
+    case t_base_type::TYPE_I16:
+      return "T.T_I16";
+    case t_base_type::TYPE_I32:
+      return "T.T_I32";
+    case t_base_type::TYPE_I64:
+      return "T.T_I64";
+    case t_base_type::TYPE_DOUBLE:
+      return "T.T_DOUBLE";
     }
 
   } else if (type->is_enum()) {
@@ -1646,14 +1582,22 @@ string t_hs_generator::type_to_default(t_type* type) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-    case t_base_type::TYPE_VOID:   return "P.error \"No default value for type T_VOID\"";
-    case t_base_type::TYPE_STRING: return "\"\"";
-    case t_base_type::TYPE_BOOL:   return "P.False";
-    case t_base_type::TYPE_BYTE:   return "0";
-    case t_base_type::TYPE_I16:    return "0";
-    case t_base_type::TYPE_I32:    return "0";
-    case t_base_type::TYPE_I64:    return "0";
-    case t_base_type::TYPE_DOUBLE: return "0";
+    case t_base_type::TYPE_VOID:
+      return "P.error \"No default value for type T_VOID\"";
+    case t_base_type::TYPE_STRING:
+      return "\"\"";
+    case t_base_type::TYPE_BOOL:
+      return "P.False";
+    case t_base_type::TYPE_BYTE:
+      return "0";
+    case t_base_type::TYPE_I16:
+      return "0";
+    case t_base_type::TYPE_I32:
+      return "0";
+    case t_base_type::TYPE_I64:
+      return "0";
+    case t_base_type::TYPE_DOUBLE:
+      return "0";
     }
 
   } else if (type->is_enum()) {
@@ -1675,7 +1619,6 @@ string t_hs_generator::type_to_default(t_type* type) {
   throw "INVALID TYPE IN type_to_default: " + type->get_name();
 }
 
-
 /**
  * Converts the parse type to an haskell type
  */
@@ -1686,14 +1629,22 @@ string t_hs_generator::render_hs_type(t_type* type, bool needs_parens) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-    case t_base_type::TYPE_VOID:   return "()";
-    case t_base_type::TYPE_STRING: return (((t_base_type*)type)->is_binary() ? "LBS.ByteString" : "LT.Text");
-    case t_base_type::TYPE_BOOL:   return "P.Bool";
-    case t_base_type::TYPE_BYTE:   return "I.Int8";
-    case t_base_type::TYPE_I16:    return "I.Int16";
-    case t_base_type::TYPE_I32:    return "I.Int32";
-    case t_base_type::TYPE_I64:    return "I.Int64";
-    case t_base_type::TYPE_DOUBLE: return "P.Double";
+    case t_base_type::TYPE_VOID:
+      return "()";
+    case t_base_type::TYPE_STRING:
+      return (((t_base_type*)type)->is_binary() ? "LBS.ByteString" : "LT.Text");
+    case t_base_type::TYPE_BOOL:
+      return "P.Bool";
+    case t_base_type::TYPE_BYTE:
+      return "I.Int8";
+    case t_base_type::TYPE_I16:
+      return "I.Int16";
+    case t_base_type::TYPE_I32:
+      return "I.Int32";
+    case t_base_type::TYPE_I64:
+      return "I.Int64";
+    case t_base_type::TYPE_DOUBLE:
+      return "P.Double";
     }
 
   } else if (type->is_enum()) {
@@ -1709,7 +1660,7 @@ string t_hs_generator::render_hs_type(t_type* type, bool needs_parens) {
 
   } else if (type->is_set()) {
     t_type* etype = ((t_set*)type)->get_elem_type();
-    type_repr = "Set.HashSet " + render_hs_type(etype, true) ;
+    type_repr = "Set.HashSet " + render_hs_type(etype, true);
 
   } else if (type->is_list()) {
     t_type* etype = ((t_list*)type)->get_elem_type();
@@ -1731,14 +1682,22 @@ string t_hs_generator::type_to_constructor(t_type* type) {
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-    case t_base_type::TYPE_VOID:   throw "invalid type: T_VOID";
-    case t_base_type::TYPE_STRING: return "T.TString";
-    case t_base_type::TYPE_BOOL:   return "T.TBool";
-    case t_base_type::TYPE_BYTE:   return "T.TByte";
-    case t_base_type::TYPE_I16:    return "T.TI16";
-    case t_base_type::TYPE_I32:    return "T.TI32";
-    case t_base_type::TYPE_I64:    return "T.TI64";
-    case t_base_type::TYPE_DOUBLE: return "T.TDouble";
+    case t_base_type::TYPE_VOID:
+      throw "invalid type: T_VOID";
+    case t_base_type::TYPE_STRING:
+      return "T.TString";
+    case t_base_type::TYPE_BOOL:
+      return "T.TBool";
+    case t_base_type::TYPE_BYTE:
+      return "T.TByte";
+    case t_base_type::TYPE_I16:
+      return "T.TI16";
+    case t_base_type::TYPE_I32:
+      return "T.TI32";
+    case t_base_type::TYPE_I64:
+      return "T.TI64";
+    case t_base_type::TYPE_DOUBLE:
+      return "T.TDouble";
     }
 
   } else if (type->is_enum()) {
@@ -1759,5 +1718,4 @@ string t_hs_generator::type_to_constructor(t_type* type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 THRIFT_REGISTER_GENERATOR(hs, "Haskell", "")


[13/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TDispatchProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TDispatchProcessor.h b/lib/cpp/src/thrift/TDispatchProcessor.h
index 33ec22e..fd1dce7 100644
--- a/lib/cpp/src/thrift/TDispatchProcessor.h
+++ b/lib/cpp/src/thrift/TDispatchProcessor.h
@@ -21,7 +21,8 @@
 
 #include <thrift/TProcessor.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 /**
  * TDispatchProcessor is a helper class to parse the message header then call
@@ -31,7 +32,7 @@ namespace apache { namespace thrift {
  */
 template <class Protocol_>
 class TDispatchProcessorT : public TProcessor {
- public:
+public:
   virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
                        boost::shared_ptr<protocol::TProtocol> out,
                        void* connectionContext) {
@@ -60,15 +61,14 @@ class TDispatchProcessorT : public TProcessor {
     // (The old generated processor code used to try to skip a T_STRUCT and
     // continue.  However, that seems unsafe.)
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       return false;
     }
 
     return this->dispatchCall(inRaw, outRaw, fname, seqid, connectionContext);
   }
 
- protected:
+protected:
   bool processFast(Protocol_* in, Protocol_* out, void* connectionContext) {
     std::string fname;
     protocol::TMessageType mtype;
@@ -76,13 +76,11 @@ class TDispatchProcessorT : public TProcessor {
     in->readMessageBegin(fname, mtype, seqid);
 
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       return false;
     }
 
-    return this->dispatchCallTemplated(in, out, fname,
-                                       seqid, connectionContext);
+    return this->dispatchCallTemplated(in, out, fname, seqid, connectionContext);
   }
 
   /**
@@ -90,11 +88,14 @@ class TDispatchProcessorT : public TProcessor {
    */
   virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in,
                             apache::thrift::protocol::TProtocol* out,
-                            const std::string& fname, int32_t seqid,
+                            const std::string& fname,
+                            int32_t seqid,
                             void* callContext) = 0;
 
-  virtual bool dispatchCallTemplated(Protocol_* in, Protocol_* out,
-                                     const std::string& fname, int32_t seqid,
+  virtual bool dispatchCallTemplated(Protocol_* in,
+                                     Protocol_* out,
+                                     const std::string& fname,
+                                     int32_t seqid,
                                      void* callContext) = 0;
 };
 
@@ -103,7 +104,7 @@ class TDispatchProcessorT : public TProcessor {
  * perform a dynamic_cast.
  */
 class TDispatchProcessor : public TProcessor {
- public:
+public:
   virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
                        boost::shared_ptr<protocol::TProtocol> out,
                        void* connectionContext) {
@@ -113,30 +114,28 @@ class TDispatchProcessor : public TProcessor {
     in->readMessageBegin(fname, mtype, seqid);
 
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       return false;
     }
 
     return dispatchCall(in.get(), out.get(), fname, seqid, connectionContext);
   }
 
- protected:
+protected:
   virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in,
                             apache::thrift::protocol::TProtocol* out,
-                            const std::string& fname, int32_t seqid,
+                            const std::string& fname,
+                            int32_t seqid,
                             void* callContext) = 0;
 };
 
 // Specialize TDispatchProcessorT for TProtocol and TDummyProtocol just to use
 // the generic TDispatchProcessor.
 template <>
-class TDispatchProcessorT<protocol::TDummyProtocol> :
-  public TDispatchProcessor {};
+class TDispatchProcessorT<protocol::TDummyProtocol> : public TDispatchProcessor {};
 template <>
-class TDispatchProcessorT<protocol::TProtocol> :
-  public TDispatchProcessor {};
-
-}} // apache::thrift
+class TDispatchProcessorT<protocol::TProtocol> : public TDispatchProcessor {};
+}
+} // apache::thrift
 
 #endif // _THRIFT_TDISPATCHPROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TLogging.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TLogging.h b/lib/cpp/src/thrift/TLogging.h
index 4c8bddc..096054c 100644
--- a/lib/cpp/src/thrift/TLogging.h
+++ b/lib/cpp/src/thrift/TLogging.h
@@ -39,13 +39,11 @@
  */
 #define T_GLOBAL_DEBUGGING_LEVEL 0
 
-
 /**
  * T_GLOBAL_LOGGING_LEVEL = 0: all logging turned off, logging macros undefined
  * T_GLOBAL_LOGGING_LEVEL = 1: all logging turned on
  */
-#define T_GLOBAL_LOGGING_LEVEL   1
-
+#define T_GLOBAL_LOGGING_LEVEL 1
 
 /**
  * Standard wrapper around fprintf what will prefix the file name and line
@@ -55,37 +53,40 @@
  * @param format_string
  */
 #if T_GLOBAL_DEBUGGING_LEVEL > 0
-  #define T_DEBUG(format_string,...)                                        \
-    if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                     \
-      fprintf(stderr,"[%s,%d] " format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \
+#define T_DEBUG(format_string, ...)                                                                \
+  if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                                              \
+    fprintf(stderr, "[%s,%d] " format_string " \n", __FILE__, __LINE__, ##__VA_ARGS__);            \
   }
 #else
-  #define T_DEBUG(format_string,...)
+#define T_DEBUG(format_string, ...)
 #endif
 
-
 /**
  * analagous to T_DEBUG but also prints the time
  *
  * @param string  format_string input: printf style format string
  */
 #if T_GLOBAL_DEBUGGING_LEVEL > 0
-  #define T_DEBUG_T(format_string,...)                                    \
-    {                                                                     \
-      if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                 \
-        time_t now;                                                       \
-        char dbgtime[26] ;                                                \
-        time(&now);                                                       \
-        THRIFT_CTIME_R(&now, dbgtime);                                           \
-        dbgtime[24] = '\0';                                               \
-        fprintf(stderr,"[%s,%d] [%s] " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
-      }                                                                   \
-    }
+#define T_DEBUG_T(format_string, ...)                                                              \
+  {                                                                                                \
+    if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                                            \
+      time_t now;                                                                                  \
+      char dbgtime[26];                                                                            \
+      time(&now);                                                                                  \
+      THRIFT_CTIME_R(&now, dbgtime);                                                               \
+      dbgtime[24] = '\0';                                                                          \
+      fprintf(stderr,                                                                              \
+              "[%s,%d] [%s] " format_string " \n",                                                 \
+              __FILE__,                                                                            \
+              __LINE__,                                                                            \
+              dbgtime,                                                                             \
+              ##__VA_ARGS__);                                                                      \
+    }                                                                                              \
+  }
 #else
-  #define T_DEBUG_T(format_string,...)
+#define T_DEBUG_T(format_string, ...)
 #endif
 
-
 /**
  * analagous to T_DEBUG but uses input level to determine whether or not the string
  * should be logged.
@@ -93,68 +94,74 @@
  * @param int     level: specified debug level
  * @param string  format_string input: format string
  */
-#define T_DEBUG_L(level, format_string,...)                               \
-  if ((level) > 0) {                                                      \
-    fprintf(stderr,"[%s,%d] " format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \
+#define T_DEBUG_L(level, format_string, ...)                                                       \
+  if ((level) > 0) {                                                                               \
+    fprintf(stderr, "[%s,%d] " format_string " \n", __FILE__, __LINE__, ##__VA_ARGS__);            \
   }
 
-
 /**
  * Explicit error logging. Prints time, file name and line number
  *
  * @param string  format_string input: printf style format string
  */
-#define T_ERROR(format_string,...)                                      \
-  {                                                                     \
-    time_t now;                                                         \
-    char dbgtime[26] ;                                                  \
-    time(&now);                                                         \
-    THRIFT_CTIME_R(&now, dbgtime);                                             \
-    dbgtime[24] = '\0';                                                 \
-    fprintf(stderr,"[%s,%d] [%s] ERROR: " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
+#define T_ERROR(format_string, ...)                                                                \
+  {                                                                                                \
+    time_t now;                                                                                    \
+    char dbgtime[26];                                                                              \
+    time(&now);                                                                                    \
+    THRIFT_CTIME_R(&now, dbgtime);                                                                 \
+    dbgtime[24] = '\0';                                                                            \
+    fprintf(stderr,                                                                                \
+            "[%s,%d] [%s] ERROR: " format_string " \n",                                            \
+            __FILE__,                                                                              \
+            __LINE__,                                                                              \
+            dbgtime,                                                                               \
+            ##__VA_ARGS__);                                                                        \
   }
 
-
 /**
  * Analagous to T_ERROR, additionally aborting the process.
  * WARNING: macro calls abort(), ending program execution
  *
  * @param string  format_string input: printf style format string
  */
-#define T_ERROR_ABORT(format_string,...)                                \
-  {                                                                     \
-    time_t now;                                                         \
-    char dbgtime[26] ;                                                  \
-    time(&now);                                                         \
-    THRIFT_CTIME_R(&now, dbgtime);                                             \
-    dbgtime[24] = '\0';                                                 \
-    fprintf(stderr,"[%s,%d] [%s] ERROR: Going to abort " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
-    exit(1);                                                            \
+#define T_ERROR_ABORT(format_string, ...)                                                          \
+  {                                                                                                \
+    time_t now;                                                                                    \
+    char dbgtime[26];                                                                              \
+    time(&now);                                                                                    \
+    THRIFT_CTIME_R(&now, dbgtime);                                                                 \
+    dbgtime[24] = '\0';                                                                            \
+    fprintf(stderr,                                                                                \
+            "[%s,%d] [%s] ERROR: Going to abort " format_string " \n",                             \
+            __FILE__,                                                                              \
+            __LINE__,                                                                              \
+            dbgtime,                                                                               \
+            ##__VA_ARGS__);                                                                        \
+    exit(1);                                                                                       \
   }
 
-
 /**
  * Log input message
  *
  * @param string  format_string input: printf style format string
  */
 #if T_GLOBAL_LOGGING_LEVEL > 0
-  #define T_LOG_OPER(format_string,...)                                       \
-    {                                                                         \
-      if (T_GLOBAL_LOGGING_LEVEL > 0) {                                       \
-        time_t now;                                                           \
-        char dbgtime[26] ;                                                    \
-        time(&now);                                                           \
-        THRIFT_CTIME_R(&now, dbgtime);                                               \
-        dbgtime[24] = '\0';                                                   \
-        fprintf(stderr,"[%s] " format_string " \n", dbgtime,##__VA_ARGS__);  \
-      }                                                                       \
-    }
+#define T_LOG_OPER(format_string, ...)                                                             \
+  {                                                                                                \
+    if (T_GLOBAL_LOGGING_LEVEL > 0) {                                                              \
+      time_t now;                                                                                  \
+      char dbgtime[26];                                                                            \
+      time(&now);                                                                                  \
+      THRIFT_CTIME_R(&now, dbgtime);                                                               \
+      dbgtime[24] = '\0';                                                                          \
+      fprintf(stderr, "[%s] " format_string " \n", dbgtime, ##__VA_ARGS__);                        \
+    }                                                                                              \
+  }
 #else
-  #define T_LOG_OPER(format_string,...)
+#define T_LOG_OPER(format_string, ...)
 #endif
 
-
 /**
  * T_GLOBAL_DEBUG_VIRTUAL = 0 or unset: normal operation,
  *                                      virtual call debug messages disabled
@@ -165,29 +172,24 @@
  *                                      apache::thrift::profile_print_info()
  */
 #if T_GLOBAL_DEBUG_VIRTUAL > 1
-  #define T_VIRTUAL_CALL()                                                \
-    ::apache::thrift::profile_virtual_call(typeid(*this))
-  #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
-    do {                                                                  \
-      if (!(specific_prot)) {                                             \
-        ::apache::thrift::profile_generic_protocol(                     \
-            typeid(*template_class), typeid(*generic_prot));              \
-      }                                                                   \
-    } while (0)
+#define T_VIRTUAL_CALL() ::apache::thrift::profile_virtual_call(typeid(*this))
+#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)                            \
+  do {                                                                                             \
+    if (!(specific_prot)) {                                                                        \
+      ::apache::thrift::profile_generic_protocol(typeid(*template_class), typeid(*generic_prot));  \
+    }                                                                                              \
+  } while (0)
 #elif T_GLOBAL_DEBUG_VIRTUAL == 1
-  #define T_VIRTUAL_CALL()                                                \
-    fprintf(stderr,"[%s,%d] virtual call\n", __FILE__, __LINE__)
-  #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
-    do {                                                                  \
-      if (!(specific_prot)) {                                             \
-        fprintf(stderr,                                                   \
-                "[%s,%d] failed to cast to specific protocol type\n",     \
-                __FILE__, __LINE__);                                      \
-      }                                                                   \
-    } while (0)
+#define T_VIRTUAL_CALL() fprintf(stderr, "[%s,%d] virtual call\n", __FILE__, __LINE__)
+#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)                            \
+  do {                                                                                             \
+    if (!(specific_prot)) {                                                                        \
+      fprintf(stderr, "[%s,%d] failed to cast to specific protocol type\n", __FILE__, __LINE__);   \
+    }                                                                                              \
+  } while (0)
 #else
-  #define T_VIRTUAL_CALL()
-  #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)
+#define T_VIRTUAL_CALL()
+#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)
 #endif
 
 #endif // #ifndef _THRIFT_TLOGGING_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TProcessor.h b/lib/cpp/src/thrift/TProcessor.h
index b4a4657..d8f86c4 100644
--- a/lib/cpp/src/thrift/TProcessor.h
+++ b/lib/cpp/src/thrift/TProcessor.h
@@ -24,7 +24,8 @@
 #include <thrift/protocol/TProtocol.h>
 #include <boost/shared_ptr.hpp>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 /**
  * Virtual interface class that can handle events from the processor. To
@@ -34,8 +35,7 @@ namespace apache { namespace thrift {
  * instance's state).
  */
 class TProcessorEventHandler {
- public:
-
+public:
   virtual ~TProcessorEventHandler() {}
 
   /**
@@ -45,8 +45,8 @@ class TProcessorEventHandler {
    * for that function invocation.
    */
   virtual void* getContext(const char* fn_name, void* serverContext) {
-    (void) fn_name;
-    (void) serverContext;
+    (void)fn_name;
+    (void)serverContext;
     return NULL;
   }
 
@@ -54,61 +54,61 @@ class TProcessorEventHandler {
    * Expected to free resources associated with a context.
    */
   virtual void freeContext(void* ctx, const char* fn_name) {
-    (void) ctx;
-    (void) fn_name;
+    (void)ctx;
+    (void)fn_name;
   }
 
   /**
    * Called before reading arguments.
    */
   virtual void preRead(void* ctx, const char* fn_name) {
-    (void) ctx;
-    (void) fn_name;
+    (void)ctx;
+    (void)fn_name;
   }
 
   /**
    * Called between reading arguments and calling the handler.
    */
   virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) ctx;
-    (void) fn_name;
-    (void) bytes;
+    (void)ctx;
+    (void)fn_name;
+    (void)bytes;
   }
 
   /**
    * Called between calling the handler and writing the response.
    */
   virtual void preWrite(void* ctx, const char* fn_name) {
-    (void) ctx;
-    (void) fn_name;
+    (void)ctx;
+    (void)fn_name;
   }
 
   /**
    * Called after writing the response.
    */
   virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) ctx;
-    (void) fn_name;
-    (void) bytes;
+    (void)ctx;
+    (void)fn_name;
+    (void)bytes;
   }
 
   /**
    * Called when an async function call completes successfully.
    */
   virtual void asyncComplete(void* ctx, const char* fn_name) {
-    (void) ctx;
-    (void) fn_name;
+    (void)ctx;
+    (void)fn_name;
   }
 
   /**
    * Called if the handler throws an undeclared exception.
    */
   virtual void handlerError(void* ctx, const char* fn_name) {
-    (void) ctx;
-    (void) fn_name;
+    (void)ctx;
+    (void)fn_name;
   }
 
- protected:
+protected:
   TProcessorEventHandler() {}
 };
 
@@ -116,12 +116,16 @@ class TProcessorEventHandler {
  * A helper class used by the generated code to free each context.
  */
 class TProcessorContextFreer {
- public:
-  TProcessorContextFreer(TProcessorEventHandler* handler, void* context, const char* method) :
-    handler_(handler), context_(context), method_(method) {}
-  ~TProcessorContextFreer() { if (handler_ != NULL) handler_->freeContext(context_, method_); }
+public:
+  TProcessorContextFreer(TProcessorEventHandler* handler, void* context, const char* method)
+    : handler_(handler), context_(context), method_(method) {}
+  ~TProcessorContextFreer() {
+    if (handler_ != NULL)
+      handler_->freeContext(context_, method_);
+  }
   void unregister() { handler_ = NULL; }
- private:
+
+private:
   apache::thrift::TProcessorEventHandler* handler_;
   void* context_;
   const char* method_;
@@ -135,27 +139,24 @@ class TProcessorContextFreer {
  *
  */
 class TProcessor {
- public:
+public:
   virtual ~TProcessor() {}
 
   virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
                        boost::shared_ptr<protocol::TProtocol> out,
                        void* connectionContext) = 0;
 
-  bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> io,
-               void* connectionContext) {
+  bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> io, void* connectionContext) {
     return process(io, io, connectionContext);
   }
 
-  boost::shared_ptr<TProcessorEventHandler> getEventHandler() {
-    return eventHandler_;
-  }
+  boost::shared_ptr<TProcessorEventHandler> getEventHandler() { return eventHandler_; }
 
   void setEventHandler(boost::shared_ptr<TProcessorEventHandler> eventHandler) {
     eventHandler_ = eventHandler;
   }
 
- protected:
+protected:
   TProcessor() {}
 
   boost::shared_ptr<TProcessorEventHandler> eventHandler_;
@@ -173,20 +174,20 @@ class TProcessor {
  * parameter to a shared_ptr, so that factory->releaseHandler() will be called
  * when the object is no longer needed, instead of deleting the pointer.
  */
-template<typename HandlerFactory_>
+template <typename HandlerFactory_>
 class ReleaseHandler {
- public:
-   ReleaseHandler(const boost::shared_ptr<HandlerFactory_>& handlerFactory) :
-       handlerFactory_(handlerFactory) {}
-
-   void operator()(typename HandlerFactory_::Handler* handler) {
-     if (handler) {
-       handlerFactory_->releaseHandler(handler);
-     }
-   }
-
- private:
-   boost::shared_ptr<HandlerFactory_> handlerFactory_;
+public:
+  ReleaseHandler(const boost::shared_ptr<HandlerFactory_>& handlerFactory)
+    : handlerFactory_(handlerFactory) {}
+
+  void operator()(typename HandlerFactory_::Handler* handler) {
+    if (handler) {
+      handlerFactory_->releaseHandler(handler);
+    }
+  }
+
+private:
+  boost::shared_ptr<HandlerFactory_> handlerFactory_;
 };
 
 struct TConnectionInfo {
@@ -201,7 +202,7 @@ struct TConnectionInfo {
 };
 
 class TProcessorFactory {
- public:
+public:
   virtual ~TProcessorFactory() {}
 
   /**
@@ -211,23 +212,19 @@ class TProcessorFactory {
    * accepted on.  This generally means that this call does not need to be
    * thread safe, as it will always be invoked from a single thread.
    */
-  virtual boost::shared_ptr<TProcessor> getProcessor(
-      const TConnectionInfo& connInfo) = 0;
+  virtual boost::shared_ptr<TProcessor> getProcessor(const TConnectionInfo& connInfo) = 0;
 };
 
 class TSingletonProcessorFactory : public TProcessorFactory {
- public:
-  TSingletonProcessorFactory(boost::shared_ptr<TProcessor> processor) :
-      processor_(processor) {}
+public:
+  TSingletonProcessorFactory(boost::shared_ptr<TProcessor> processor) : processor_(processor) {}
 
-  boost::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) {
-    return processor_;
-  }
+  boost::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) { return processor_; }
 
- private:
+private:
   boost::shared_ptr<TProcessor> processor_;
 };
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // #ifndef _THRIFT_TPROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TReflectionLocal.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TReflectionLocal.h b/lib/cpp/src/thrift/TReflectionLocal.h
index 2ef7511..2fc53c8 100644
--- a/lib/cpp/src/thrift/TReflectionLocal.h
+++ b/lib/cpp/src/thrift/TReflectionLocal.h
@@ -31,7 +31,10 @@
  *
  */
 
-namespace apache { namespace thrift { namespace reflection { namespace local {
+namespace apache {
+namespace thrift {
+namespace reflection {
+namespace local {
 
 using apache::thrift::protocol::TType;
 
@@ -47,7 +50,7 @@ struct FieldMeta {
 
 struct TypeSpec {
   TType ttype;
-  uint8_t    fp_prefix[FP_PREFIX_LEN];
+  uint8_t fp_prefix[FP_PREFIX_LEN];
 
   // Use an anonymous union here so we can fit two TypeSpecs in one cache line.
   union {
@@ -57,8 +60,8 @@ struct TypeSpec {
       TypeSpec** specs;
     } tstruct;
     struct {
-      TypeSpec *subtype1;
-      TypeSpec *subtype2;
+      TypeSpec* subtype1;
+      TypeSpec* subtype2;
     } tcontainer;
   };
 
@@ -66,31 +69,24 @@ struct TypeSpec {
   // so take the plunge and use constructors.
   // Hopefully they'll be evaluated at compile time.
 
-  TypeSpec(TType ttype) : ttype(ttype) {
-    std::memset(fp_prefix, 0, FP_PREFIX_LEN);
-  }
+  TypeSpec(TType ttype) : ttype(ttype) { std::memset(fp_prefix, 0, FP_PREFIX_LEN); }
 
-  TypeSpec(TType ttype,
-           const uint8_t* fingerprint,
-           FieldMeta* metas,
-           TypeSpec** specs) :
-    ttype(ttype)
-  {
+  TypeSpec(TType ttype, const uint8_t* fingerprint, FieldMeta* metas, TypeSpec** specs)
+    : ttype(ttype) {
     std::memcpy(fp_prefix, fingerprint, FP_PREFIX_LEN);
     tstruct.metas = metas;
     tstruct.specs = specs;
   }
 
-  TypeSpec(TType ttype, TypeSpec* subtype1, TypeSpec* subtype2) :
-    ttype(ttype)
-  {
+  TypeSpec(TType ttype, TypeSpec* subtype1, TypeSpec* subtype2) : ttype(ttype) {
     std::memset(fp_prefix, 0, FP_PREFIX_LEN);
     tcontainer.subtype1 = subtype1;
     tcontainer.subtype2 = subtype2;
   }
-
 };
-
-}}}} // apache::thrift::reflection::local
+}
+}
+}
+} // apache::thrift::reflection::local
 
 #endif // #ifndef _THRIFT_TREFLECTIONLOCAL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/TToString.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/TToString.h b/lib/cpp/src/thrift/TToString.h
index c160e09..5023869 100644
--- a/lib/cpp/src/thrift/TToString.h
+++ b/lib/cpp/src/thrift/TToString.h
@@ -28,7 +28,8 @@
 #include <string>
 #include <sstream>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 template <typename T>
 std::string to_string(const T& t) {
@@ -52,8 +53,7 @@ std::string to_string(const typename std::pair<K, V>& v) {
 }
 
 template <typename T>
-std::string to_string(const T& beg, const T& end)
-{
+std::string to_string(const T& beg, const T& end) {
   std::ostringstream o;
   for (T it = beg; it != end; ++it) {
     if (it != beg)
@@ -83,7 +83,7 @@ std::string to_string(const std::set<T>& s) {
   o << "{" << to_string(s.begin(), s.end()) << "}";
   return o.str();
 }
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // _THRIFT_TOSTRING_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/Thrift.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/Thrift.cpp b/lib/cpp/src/thrift/Thrift.cpp
index b1e1386..5739d0f 100644
--- a/lib/cpp/src/thrift/Thrift.cpp
+++ b/lib/cpp/src/thrift/Thrift.cpp
@@ -24,11 +24,12 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 TOutput GlobalOutput;
 
-void TOutput::printf(const char *message, ...) {
+void TOutput::printf(const char* message, ...) {
 #ifndef THRIFT_SQUELCH_CONSOLE_OUTPUT
   // Try to reduce heap usage, even if printf is called rarely.
   static const int STACK_BUF_SIZE = 256;
@@ -58,7 +59,7 @@ void TOutput::printf(const char *message, ...) {
   }
 #endif
 
-  char *heap_buf = (char*)malloc((need+1) * sizeof(char));
+  char* heap_buf = (char*)malloc((need + 1) * sizeof(char));
   if (heap_buf == NULL) {
 #ifdef _MSC_VER
     va_start(ap, message);
@@ -71,7 +72,7 @@ void TOutput::printf(const char *message, ...) {
   }
 
   va_start(ap, message);
-  int rval = vsnprintf(heap_buf, need+1, message, ap);
+  int rval = vsnprintf(heap_buf, need + 1, message, ap);
   va_end(ap);
   // TODO(shigin): inform user
   if (rval != -1) {
@@ -92,7 +93,7 @@ void TOutput::errorTimeWrapper(const char* msg) {
 #endif
 }
 
-void TOutput::perror(const char *message, int errno_copy) {
+void TOutput::perror(const char* message, int errno_copy) {
   std::string out = message + strerror_s(errno_copy);
   f_(out.c_str());
 }
@@ -100,18 +101,18 @@ void TOutput::perror(const char *message, int errno_copy) {
 std::string TOutput::strerror_s(int errno_copy) {
 #ifndef HAVE_STRERROR_R
   return "errno = " + boost::lexical_cast<std::string>(errno_copy);
-#else  // HAVE_STRERROR_R
+#else // HAVE_STRERROR_R
 
-  char b_errbuf[1024] = { '\0' };
+  char b_errbuf[1024] = {'\0'};
 #ifdef STRERROR_R_CHAR_P
-  char *b_error = strerror_r(errno_copy, b_errbuf, sizeof(b_errbuf));
+  char* b_error = strerror_r(errno_copy, b_errbuf, sizeof(b_errbuf));
 #else
-  char *b_error = b_errbuf;
+  char* b_error = b_errbuf;
   int rv = strerror_r(errno_copy, b_errbuf, sizeof(b_errbuf));
   if (rv == -1) {
     // strerror_r failed.  omgwtfbbq.
-    return "XSI-compliant strerror_r() failed with errno = " +
-      boost::lexical_cast<std::string>(errno_copy);
+    return "XSI-compliant strerror_r() failed with errno = "
+           + boost::lexical_cast<std::string>(errno_copy);
   }
 #endif
   // Can anyone prove that explicit cast is probably not necessary
@@ -119,7 +120,7 @@ std::string TOutput::strerror_s(int errno_copy) {
   // b_error becomes invalid?
   return std::string(b_error);
 
-#endif  // HAVE_STRERROR_R
+#endif // HAVE_STRERROR_R
 }
-
-}} // apache::thrift
+}
+} // apache::thrift

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/Thrift.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/Thrift.h b/lib/cpp/src/thrift/Thrift.h
index 4d8d87c..9ddf946 100644
--- a/lib/cpp/src/thrift/Thrift.h
+++ b/lib/cpp/src/thrift/Thrift.h
@@ -62,40 +62,33 @@
  * THRIFT_OVERLOAD_IF_DEFN should be used in the function definition, if it is
  * defined separately from where it is declared.
  */
-#define THRIFT_OVERLOAD_IF_DEFN(T, Y) \
-  typename ::boost::enable_if<typename ::boost::is_convertible<T*, Y*>::type, \
-                              void*>::type
+#define THRIFT_OVERLOAD_IF_DEFN(T, Y)                                                              \
+  typename ::boost::enable_if<typename ::boost::is_convertible<T*, Y*>::type, void*>::type
 
-#define THRIFT_OVERLOAD_IF(T, Y) \
-  THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL
+#define THRIFT_OVERLOAD_IF(T, Y) THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL
 
 #define THRIFT_UNUSED_VARIABLE(x) ((void)(x))
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
-class TEnumIterator : public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > {
- public:
-  TEnumIterator(int n,
-                int* enums,
-                const char** names) :
-      ii_(0), n_(n), enums_(enums), names_(names) {
-  }
+class TEnumIterator
+    : public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > {
+public:
+  TEnumIterator(int n, int* enums, const char** names)
+    : ii_(0), n_(n), enums_(enums), names_(names) {}
 
-  int operator ++() {
-    return ++ii_;
-  }
+  int operator++() { return ++ii_; }
 
-  bool operator !=(const TEnumIterator& end) {
-    (void)end;  // avoid "unused" warning with NDEBUG
+  bool operator!=(const TEnumIterator& end) {
+    (void)end; // avoid "unused" warning with NDEBUG
     assert(end.n_ == -1);
     return (ii_ != n_);
   }
 
-  std::pair<int, const char*> operator*() const {
-    return std::make_pair(enums_[ii_], names_[ii_]);
-  }
+  std::pair<int, const char*> operator*() const { return std::make_pair(enums_[ii_], names_[ii_]); }
 
- private:
+private:
   int ii_;
   const int n_;
   int* enums_;
@@ -103,46 +96,40 @@ class TEnumIterator : public std::iterator<std::forward_iterator_tag, std::pair<
 };
 
 class TOutput {
- public:
+public:
   TOutput() : f_(&errorTimeWrapper) {}
 
-  inline void setOutputFunction(void (*function)(const char *)){
-    f_ = function;
-  }
+  inline void setOutputFunction(void (*function)(const char*)) { f_ = function; }
 
-  inline void operator()(const char *message){
-    f_(message);
-  }
+  inline void operator()(const char* message) { f_(message); }
 
   // It is important to have a const char* overload here instead of
   // just the string version, otherwise errno could be corrupted
   // if there is some problem allocating memory when constructing
   // the string.
-  void perror(const char *message, int errno_copy);
-  inline void perror(const std::string &message, int errno_copy) {
+  void perror(const char* message, int errno_copy);
+  inline void perror(const std::string& message, int errno_copy) {
     perror(message.c_str(), errno_copy);
   }
 
-  void printf(const char *message, ...);
+  void printf(const char* message, ...);
 
   static void errorTimeWrapper(const char* msg);
 
   /** Just like strerror_r but returns a C++ string object. */
   static std::string strerror_s(int errno_copy);
 
- private:
-  void (*f_)(const char *);
+private:
+  void (*f_)(const char*);
 };
 
 extern TOutput GlobalOutput;
 
 class TException : public std::exception {
- public:
-  TException():
-    message_() {}
+public:
+  TException() : message_() {}
 
-  TException(const std::string& message) :
-    message_(message) {}
+  TException(const std::string& message) : message_(message) {}
 
   virtual ~TException() throw() {}
 
@@ -154,33 +141,36 @@ class TException : public std::exception {
     }
   }
 
- protected:
+protected:
   std::string message_;
-
 };
 
-
 // Forward declare this structure used by TDenseProtocol
-namespace reflection { namespace local {
+namespace reflection {
+namespace local {
 struct TypeSpec;
-}}
+}
+}
 
 class TDelayedException {
- public:
-  template <class E> static TDelayedException* delayException(const E& e);
+public:
+  template <class E>
+  static TDelayedException* delayException(const E& e);
   virtual void throw_it() = 0;
-  virtual ~TDelayedException() {};
+  virtual ~TDelayedException(){};
 };
 
-template <class E> class TExceptionWrapper : public TDelayedException {
- public:
+template <class E>
+class TExceptionWrapper : public TDelayedException {
+public:
   TExceptionWrapper(const E& e) : e_(e) {}
   virtual void throw_it() {
     E temp(e_);
     delete this;
     throw temp;
   }
- private:
+
+private:
   E e_;
 };
 
@@ -191,13 +181,12 @@ TDelayedException* TDelayedException::delayException(const E& e) {
 
 #if T_GLOBAL_DEBUG_VIRTUAL > 1
 void profile_virtual_call(const std::type_info& info);
-void profile_generic_protocol(const std::type_info& template_type,
-                              const std::type_info& prot_type);
-void profile_print_info(FILE *f);
+void profile_generic_protocol(const std::type_info& template_type, const std::type_info& prot_type);
+void profile_print_info(FILE* f);
 void profile_print_info();
 void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f);
 #endif
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // #ifndef _THRIFT_THRIFT_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/VirtualProfiling.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/VirtualProfiling.cpp b/lib/cpp/src/thrift/VirtualProfiling.cpp
index 180cfb7..6ce346b 100644
--- a/lib/cpp/src/thrift/VirtualProfiling.cpp
+++ b/lib/cpp/src/thrift/VirtualProfiling.cpp
@@ -35,14 +35,14 @@
 #error "Thrift virtual function profiling currently requires glibc"
 #endif // !__GLIBC__
 
-
 #include <thrift/concurrency/Mutex.h>
 
 #include <ext/hash_map>
 #include <execinfo.h>
 #include <stdio.h>
 
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 
 using ::apache::thrift::concurrency::Mutex;
 using ::apache::thrift::concurrency::Guard;
@@ -53,20 +53,18 @@ static const unsigned int MAX_STACK_DEPTH = 15;
  * A stack trace
  */
 class Backtrace {
- public:
+public:
   Backtrace(int skip = 0);
-  Backtrace(Backtrace const &bt);
+  Backtrace(Backtrace const& bt);
 
-  void operator=(Backtrace const &bt) {
+  void operator=(Backtrace const& bt) {
     numCallers_ = bt.numCallers_;
     if (numCallers_ >= 0) {
       memcpy(callers_, bt.callers_, numCallers_ * sizeof(void*));
     }
   }
 
-  bool operator==(Backtrace const &bt) const {
-    return (cmp(bt) == 0);
-  }
+  bool operator==(Backtrace const& bt) const { return (cmp(bt) == 0); }
 
   size_t hash() const {
     intptr_t ret = 0;
@@ -83,8 +81,8 @@ class Backtrace {
     }
 
     for (int n = 0; n < numCallers_; ++n) {
-      int diff = reinterpret_cast<intptr_t>(callers_[n]) -
-        reinterpret_cast<intptr_t>(bt.callers_[n]);
+      int diff = reinterpret_cast<intptr_t>(callers_[n])
+                 - reinterpret_cast<intptr_t>(bt.callers_[n]);
       if (diff != 0) {
         return diff;
       }
@@ -93,8 +91,8 @@ class Backtrace {
     return 0;
   }
 
-  void print(FILE *f, int indent=0, int start=0) const {
-    char **strings = backtrace_symbols(callers_, numCallers_);
+  void print(FILE* f, int indent = 0, int start = 0) const {
+    char** strings = backtrace_symbols(callers_, numCallers_);
     if (strings) {
       start += skip_;
       if (start < 0) {
@@ -109,11 +107,9 @@ class Backtrace {
     }
   }
 
-  int getDepth() const {
-    return numCallers_ - skip_;
-  }
+  int getDepth() const { return numCallers_ - skip_; }
 
-  void *getFrame(int index) const {
+  void* getFrame(int index) const {
     int adjusted_index = index + skip_;
     if (adjusted_index < 0 || adjusted_index >= numCallers_) {
       return NULL;
@@ -121,8 +117,8 @@ class Backtrace {
     return callers_[adjusted_index];
   }
 
- private:
-  void *callers_[MAX_STACK_DEPTH];
+private:
+  void* callers_[MAX_STACK_DEPTH];
   int numCallers_;
   int skip_;
 };
@@ -138,9 +134,7 @@ Backtrace::Backtrace(int skip)
   }
 }
 
-Backtrace::Backtrace(Backtrace const &bt)
-  : numCallers_(bt.numCallers_)
-  , skip_(bt.skip_) {
+Backtrace::Backtrace(Backtrace const& bt) : numCallers_(bt.numCallers_), skip_(bt.skip_) {
   if (numCallers_ >= 0) {
     memcpy(callers_, bt.callers_, numCallers_ * sizeof(void*));
   }
@@ -150,32 +144,20 @@ Backtrace::Backtrace(Backtrace const &bt)
  * A backtrace, plus one or two type names
  */
 class Key {
- public:
+public:
   class Hash {
-   public:
-    size_t operator()(Key const& k) const {
-      return k.hash();
-    }
+  public:
+    size_t operator()(Key const& k) const { return k.hash(); }
   };
 
   Key(const Backtrace* bt, const std::type_info& type_info)
-    : backtrace_(bt)
-    , typeName1_(type_info.name())
-    , typeName2_(NULL) {
-  }
+    : backtrace_(bt), typeName1_(type_info.name()), typeName2_(NULL) {}
 
-  Key(const Backtrace* bt, const std::type_info& type_info1,
-      const std::type_info& type_info2)
-    : backtrace_(bt)
-    , typeName1_(type_info1.name())
-    , typeName2_(type_info2.name()) {
-  }
+  Key(const Backtrace* bt, const std::type_info& type_info1, const std::type_info& type_info2)
+    : backtrace_(bt), typeName1_(type_info1.name()), typeName2_(type_info2.name()) {}
 
   Key(const Key& k)
-    : backtrace_(k.backtrace_)
-    , typeName1_(k.typeName1_)
-    , typeName2_(k.typeName2_) {
-  }
+    : backtrace_(k.backtrace_), typeName1_(k.typeName1_), typeName2_(k.typeName2_) {}
 
   void operator=(const Key& k) {
     backtrace_ = k.backtrace_;
@@ -183,17 +165,11 @@ class Key {
     typeName2_ = k.typeName2_;
   }
 
-  const Backtrace* getBacktrace() const {
-    return backtrace_;
-  }
+  const Backtrace* getBacktrace() const { return backtrace_; }
 
-  const char* getTypeName() const {
-    return typeName1_;
-  }
+  const char* getTypeName() const { return typeName1_; }
 
-  const char* getTypeName2() const {
-    return typeName2_;
-  }
+  const char* getTypeName2() const { return typeName2_; }
 
   void makePersistent() {
     // Copy the Backtrace object
@@ -233,20 +209,17 @@ class Key {
     return k.typeName2_ - typeName2_;
   }
 
-  bool operator==(const Key& k) const {
-    return cmp(k) == 0;
-  }
+  bool operator==(const Key& k) const { return cmp(k) == 0; }
 
   size_t hash() const {
     // NOTE: As above, we just use the name pointer value.
     // Works with GNU libstdc++, but not guaranteed to be correct on all
     // implementations.
-    return backtrace_->hash() ^
-      reinterpret_cast<size_t>(typeName1_) ^
-      reinterpret_cast<size_t>(typeName2_);
+    return backtrace_->hash() ^ reinterpret_cast<size_t>(typeName1_)
+           ^ reinterpret_cast<size_t>(typeName2_);
   }
 
- private:
+private:
   const Backtrace* backtrace_;
   const char* typeName1_;
   const char* typeName2_;
@@ -257,9 +230,8 @@ class Key {
  * has a higher count.
  */
 class CountGreater {
- public:
-  bool operator()(std::pair<Key, size_t> bt1,
-                  std::pair<Key, size_t> bt2) const {
+public:
+  bool operator()(std::pair<Key, size_t> bt1, std::pair<Key, size_t> bt2) const {
     return bt1.second > bt2.second;
   }
 };
@@ -278,8 +250,7 @@ Mutex virtual_calls_mutex;
 BacktraceMap generic_calls;
 Mutex generic_calls_mutex;
 
-
-void _record_backtrace(BacktraceMap* map, const Mutex& mutex, Key *k) {
+void _record_backtrace(BacktraceMap* map, const Mutex& mutex, Key* k) {
   Guard guard(mutex);
 
   BacktraceMap::iterator it = map->find(*k);
@@ -324,7 +295,7 @@ void profile_generic_protocol(const std::type_info& template_type,
  * Print the recorded profiling information to the specified file.
  */
 void profile_print_info(FILE* f) {
-  typedef std::vector< std::pair<Key, size_t> > BacktraceVector;
+  typedef std::vector<std::pair<Key, size_t> > BacktraceVector;
 
   CountGreater is_greater;
 
@@ -342,13 +313,14 @@ void profile_print_info(FILE* f) {
   BacktraceVector gp_sorted(generic_calls.begin(), generic_calls.end());
   std::sort(gp_sorted.begin(), gp_sorted.end(), is_greater);
 
-  for (BacktraceVector::const_iterator it = gp_sorted.begin();
-       it != gp_sorted.end();
-       ++it) {
-    Key const &key = it->first;
+  for (BacktraceVector::const_iterator it = gp_sorted.begin(); it != gp_sorted.end(); ++it) {
+    Key const& key = it->first;
     size_t const count = it->second;
-    fprintf(f, "T_GENERIC_PROTOCOL: %zu calls to %s with a %s:\n",
-            count, key.getTypeName(), key.getTypeName2());
+    fprintf(f,
+            "T_GENERIC_PROTOCOL: %zu calls to %s with a %s:\n",
+            count,
+            key.getTypeName(),
+            key.getTypeName2());
     key.getBacktrace()->print(f, 2);
     fprintf(f, "\n");
   }
@@ -357,10 +329,8 @@ void profile_print_info(FILE* f) {
   BacktraceVector vc_sorted(virtual_calls.begin(), virtual_calls.end());
   std::sort(vc_sorted.begin(), vc_sorted.end(), is_greater);
 
-  for (BacktraceVector::const_iterator it = vc_sorted.begin();
-       it != vc_sorted.end();
-       ++it) {
-    Key const &key = it->first;
+  for (BacktraceVector::const_iterator it = vc_sorted.begin(); it != vc_sorted.end(); ++it) {
+    Key const& key = it->first;
     size_t const count = it->second;
     fprintf(f, "T_VIRTUAL_CALL: %zu calls on %s:\n", count, key.getTypeName());
     key.getBacktrace()->print(f, 2);
@@ -380,7 +350,7 @@ void profile_print_info() {
  */
 static void profile_write_pprof_file(FILE* f, BacktraceMap const& map) {
   // Write the header
-  uintptr_t header[5] = { 0, 3, 0, 0, 0 };
+  uintptr_t header[5] = {0, 3, 0, 0, 0};
   fwrite(&header, sizeof(header), 1, f);
 
   // Write the profile records
@@ -399,12 +369,12 @@ static void profile_write_pprof_file(FILE* f, BacktraceMap const& map) {
   }
 
   // Write the trailer
-  uintptr_t trailer[3] = { 0, 1, 0 };
+  uintptr_t trailer[3] = {0, 1, 0};
   fwrite(&trailer, sizeof(trailer), 1, f);
 
   // Write /proc/self/maps
   // TODO(simpkins): This only works on linux
-  FILE *proc_maps = fopen("/proc/self/maps", "r");
+  FILE* proc_maps = fopen("/proc/self/maps", "r");
   if (proc_maps) {
     uint8_t buf[4096];
     while (true) {
@@ -434,7 +404,7 @@ static void profile_write_pprof_file(FILE* f, BacktraceMap const& map) {
  *                        profile_virtual_call() will be written to this file.
  */
 void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f) {
-  typedef std::vector< std::pair<Key, size_t> > BacktraceVector;
+  typedef std::vector<std::pair<Key, size_t> > BacktraceVector;
 
   CountGreater is_greater;
 
@@ -449,7 +419,7 @@ void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f) {
   // write the info from virtual_calls
   profile_write_pprof_file(virtual_calls_f, virtual_calls);
 }
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // T_GLOBAL_PROFILE_VIRTUAL > 0

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
index ad7c639..3c957a6 100644
--- a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
@@ -25,22 +25,24 @@
 
 #include <thrift/transport/TBufferTransports.h>
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 class TAsyncBufferProcessor {
- public:
+public:
   // Process data in "in", putting the result in "out".
   // Call _return(true) when done, or _return(false) to
   // forcefully close the connection (if applicable).
   // "in" and "out" should be TMemoryBuffer or similar,
   // not a wrapper around a socket.
-  virtual void process(
-      apache::thrift::stdcxx::function<void(bool healthy)> _return,
-      boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
-      boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf) = 0;
+  virtual void process(apache::thrift::stdcxx::function<void(bool healthy)> _return,
+                       boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
+                       boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf) = 0;
   virtual ~TAsyncBufferProcessor() {}
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_TASYNC_BUFFER_PROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncChannel.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.cpp b/lib/cpp/src/thrift/async/TAsyncChannel.cpp
index 64dfe5f..4716af2 100644
--- a/lib/cpp/src/thrift/async/TAsyncChannel.cpp
+++ b/lib/cpp/src/thrift/async/TAsyncChannel.cpp
@@ -20,15 +20,18 @@
 #include <thrift/async/TAsyncChannel.h>
 #include <thrift/cxxfunctional.h>
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 void TAsyncChannel::sendAndRecvMessage(const VoidCallback& cob,
                                        TMemoryBuffer* sendBuf,
                                        TMemoryBuffer* recvBuf) {
-  apache::thrift::stdcxx::function<void()> send_done =
-    apache::thrift::stdcxx::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf);
+  apache::thrift::stdcxx::function<void()> send_done
+      = apache::thrift::stdcxx::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf);
 
   sendMessage(send_done, sendBuf);
 }
-
-}}}  // apache::thrift::async
+}
+}
+} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncChannel.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.h b/lib/cpp/src/thrift/async/TAsyncChannel.h
index 0f202fd..eb3ce2a 100644
--- a/lib/cpp/src/thrift/async/TAsyncChannel.h
+++ b/lib/cpp/src/thrift/async/TAsyncChannel.h
@@ -23,15 +23,21 @@
 #include <thrift/cxxfunctional.h>
 #include <thrift/Thrift.h>
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 class TMemoryBuffer;
-}}}
+}
+}
+}
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 using apache::thrift::transport::TMemoryBuffer;
 
 class TAsyncChannel {
- public:
+public:
   typedef apache::thrift::stdcxx::function<void()> VoidCallback;
 
   virtual ~TAsyncChannel() {}
@@ -45,22 +51,23 @@ class TAsyncChannel {
    * Send a message over the channel.
    */
   virtual void sendMessage(const VoidCallback& cob,
-    apache::thrift::transport::TMemoryBuffer* message) = 0;
+                           apache::thrift::transport::TMemoryBuffer* message) = 0;
 
   /**
    * Receive a message from the channel.
    */
   virtual void recvMessage(const VoidCallback& cob,
-    apache::thrift::transport::TMemoryBuffer* message) = 0;
+                           apache::thrift::transport::TMemoryBuffer* message) = 0;
 
   /**
    * Send a message over the channel and receive a response.
    */
   virtual void sendAndRecvMessage(const VoidCallback& cob,
-    apache::thrift::transport::TMemoryBuffer* sendBuf,
-    apache::thrift::transport::TMemoryBuffer* recvBuf);
+                                  apache::thrift::transport::TMemoryBuffer* sendBuf,
+                                  apache::thrift::transport::TMemoryBuffer* recvBuf);
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_ASYNC_TASYNCCHANNEL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
index 15b5bce..e79c57d 100644
--- a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
@@ -21,7 +21,9 @@
 
 #include <thrift/async/TAsyncProcessor.h>
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 /**
  * TAsyncDispatchProcessor is a helper class to parse the message header then
@@ -31,7 +33,7 @@ namespace apache { namespace thrift { namespace async {
  */
 template <class Protocol_>
 class TAsyncDispatchProcessorT : public TAsyncProcessor {
- public:
+public:
   virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return,
                        boost::shared_ptr<protocol::TProtocol> in,
                        boost::shared_ptr<protocol::TProtocol> out) {
@@ -60,8 +62,7 @@ class TAsyncDispatchProcessorT : public TAsyncProcessor {
     // (The old generated processor code used to try to skip a T_STRUCT and
     // continue.  However, that seems unsafe.)
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       _return(false);
       return;
     }
@@ -70,15 +71,15 @@ class TAsyncDispatchProcessorT : public TAsyncProcessor {
   }
 
   void processFast(apache::thrift::stdcxx::function<void(bool success)> _return,
-                   Protocol_* in, Protocol_* out) {
+                   Protocol_* in,
+                   Protocol_* out) {
     std::string fname;
     protocol::TMessageType mtype;
     int32_t seqid;
     in->readMessageBegin(fname, mtype, seqid);
 
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       _return(false);
       return;
     }
@@ -89,10 +90,12 @@ class TAsyncDispatchProcessorT : public TAsyncProcessor {
   virtual void dispatchCall(apache::thrift::stdcxx::function<void(bool ok)> _return,
                             apache::thrift::protocol::TProtocol* in,
                             apache::thrift::protocol::TProtocol* out,
-                            const std::string& fname, int32_t seqid) = 0;
+                            const std::string& fname,
+                            int32_t seqid) = 0;
 
   virtual void dispatchCallTemplated(apache::thrift::stdcxx::function<void(bool ok)> _return,
-                                     Protocol_* in, Protocol_* out,
+                                     Protocol_* in,
+                                     Protocol_* out,
                                      const std::string& fname,
                                      int32_t seqid) = 0;
 };
@@ -102,7 +105,7 @@ class TAsyncDispatchProcessorT : public TAsyncProcessor {
  * that doesn't bother trying to perform a dynamic_cast.
  */
 class TAsyncDispatchProcessor : public TAsyncProcessor {
- public:
+public:
   virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return,
                        boost::shared_ptr<protocol::TProtocol> in,
                        boost::shared_ptr<protocol::TProtocol> out) {
@@ -120,8 +123,7 @@ class TAsyncDispatchProcessor : public TAsyncProcessor {
     // (The old generated processor code used to try to skip a T_STRUCT and
     // continue.  However, that seems unsafe.)
     if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
-      GlobalOutput.printf("received invalid message type %d from client",
-                          mtype);
+      GlobalOutput.printf("received invalid message type %d from client", mtype);
       _return(false);
       return;
     }
@@ -132,18 +134,18 @@ class TAsyncDispatchProcessor : public TAsyncProcessor {
   virtual void dispatchCall(apache::thrift::stdcxx::function<void(bool ok)> _return,
                             apache::thrift::protocol::TProtocol* in,
                             apache::thrift::protocol::TProtocol* out,
-                            const std::string& fname, int32_t seqid) = 0;
+                            const std::string& fname,
+                            int32_t seqid) = 0;
 };
 
 // Specialize TAsyncDispatchProcessorT for TProtocol and TDummyProtocol just to
 // use the generic TDispatchProcessor.
 template <>
-class TAsyncDispatchProcessorT<protocol::TDummyProtocol> :
-  public TAsyncDispatchProcessor {};
+class TAsyncDispatchProcessorT<protocol::TDummyProtocol> : public TAsyncDispatchProcessor {};
 template <>
-class TAsyncDispatchProcessorT<protocol::TProtocol> :
-  public TAsyncDispatchProcessor {};
-
-}}} // apache::thrift::async
+class TAsyncDispatchProcessorT<protocol::TProtocol> : public TAsyncDispatchProcessor {};
+}
+}
+} // apache::thrift::async
 
 #endif // _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncProcessor.h b/lib/cpp/src/thrift/async/TAsyncProcessor.h
index a03d1dc..033f7d9 100644
--- a/lib/cpp/src/thrift/async/TAsyncProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncProcessor.h
@@ -25,7 +25,9 @@
 #include <thrift/protocol/TProtocol.h>
 #include <thrift/TProcessor.h>
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 /**
  * Async version of a TProcessor.  It is not expected to complete by the time
@@ -35,7 +37,7 @@ namespace apache { namespace thrift { namespace async {
 class TEventServer; // forward declaration
 
 class TAsyncProcessor {
- public:
+public:
   virtual ~TAsyncProcessor() {}
 
   virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return,
@@ -47,31 +49,27 @@ class TAsyncProcessor {
     return process(_return, io, io);
   }
 
-  boost::shared_ptr<TProcessorEventHandler> getEventHandler() {
-    return eventHandler_;
-  }
+  boost::shared_ptr<TProcessorEventHandler> getEventHandler() { return eventHandler_; }
 
   void setEventHandler(boost::shared_ptr<TProcessorEventHandler> eventHandler) {
     eventHandler_ = eventHandler;
   }
 
-  const TEventServer* getAsyncServer() {
-    return asyncServer_;
-  }
- protected:
+  const TEventServer* getAsyncServer() { return asyncServer_; }
+
+protected:
   TAsyncProcessor() {}
 
   boost::shared_ptr<TProcessorEventHandler> eventHandler_;
   const TEventServer* asyncServer_;
- private:
+
+private:
   friend class TEventServer;
-  void setAsyncServer(const TEventServer* server) {
-    asyncServer_ = server;
-  }
+  void setAsyncServer(const TEventServer* server) { asyncServer_ = server; }
 };
 
 class TAsyncProcessorFactory {
- public:
+public:
   virtual ~TAsyncProcessorFactory() {}
 
   /**
@@ -81,17 +79,17 @@ class TAsyncProcessorFactory {
    * accepted on.  This generally means that this call does not need to be
    * thread safe, as it will always be invoked from a single thread.
    */
-  virtual boost::shared_ptr<TAsyncProcessor> getProcessor(
-      const TConnectionInfo& connInfo) = 0;
+  virtual boost::shared_ptr<TAsyncProcessor> getProcessor(const TConnectionInfo& connInfo) = 0;
 };
-
-
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 // XXX I'm lazy for now
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
 using apache::thrift::async::TAsyncProcessor;
-}}
+}
+}
 
 #endif // #ifndef _THRIFT_TASYNCPROCESSOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp
index 2096289..5a4f347 100644
--- a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp
+++ b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.cpp
@@ -22,30 +22,32 @@
 using apache::thrift::transport::TBufferBase;
 using apache::thrift::protocol::TProtocol;
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
-void TAsyncProtocolProcessor::process(
-    apache::thrift::stdcxx::function<void(bool healthy)> _return,
-    boost::shared_ptr<TBufferBase> ibuf,
-    boost::shared_ptr<TBufferBase> obuf) {
+void TAsyncProtocolProcessor::process(apache::thrift::stdcxx::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(
-      apache::thrift::stdcxx::bind(
-        &TAsyncProtocolProcessor::finish,
-        _return,
-        oprot,
-        apache::thrift::stdcxx::placeholders::_1),
-      iprot, oprot);
+  return underlying_
+      ->process(apache::thrift::stdcxx::bind(&TAsyncProtocolProcessor::finish,
+                                             _return,
+                                             oprot,
+                                             apache::thrift::stdcxx::placeholders::_1),
+                iprot,
+                oprot);
 }
 
 /* static */ void TAsyncProtocolProcessor::finish(
     apache::thrift::stdcxx::function<void(bool healthy)> _return,
     boost::shared_ptr<TProtocol> oprot,
     bool healthy) {
-  (void) oprot;
+  (void)oprot;
   // This is a stub function to hold a reference to oprot.
   return _return(healthy);
 }
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
index 840b4dd..3f2b394 100644
--- a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
@@ -24,34 +24,32 @@
 #include <thrift/async/TAsyncBufferProcessor.h>
 #include <thrift/protocol/TProtocol.h>
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 class TAsyncProtocolProcessor : public TAsyncBufferProcessor {
- public:
-  TAsyncProtocolProcessor(
-      boost::shared_ptr<TAsyncProcessor> underlying,
-      boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact)
-    : underlying_(underlying)
-    , pfact_(pfact)
-  {}
-
-  virtual void process(
-      apache::thrift::stdcxx::function<void(bool healthy)> _return,
-      boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
-      boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf);
+public:
+  TAsyncProtocolProcessor(boost::shared_ptr<TAsyncProcessor> underlying,
+                          boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact)
+    : underlying_(underlying), pfact_(pfact) {}
+
+  virtual void process(apache::thrift::stdcxx::function<void(bool healthy)> _return,
+                       boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
+                       boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf);
 
   virtual ~TAsyncProtocolProcessor() {}
 
- private:
-  static void finish(
-      apache::thrift::stdcxx::function<void(bool healthy)> _return,
-      boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot,
-      bool healthy);
+private:
+  static void finish(apache::thrift::stdcxx::function<void(bool healthy)> _return,
+                     boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot,
+                     bool healthy);
 
   boost::shared_ptr<TAsyncProcessor> underlying_;
   boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_;
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_TNAME_ME_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
index 7ad7537..bcb87cd 100644
--- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
@@ -28,20 +28,16 @@
 using namespace apache::thrift::protocol;
 using apache::thrift::transport::TTransportException;
 
-namespace apache { namespace thrift { namespace async {
-
-
-TEvhttpClientChannel::TEvhttpClientChannel(
-    const std::string& host,
-    const std::string& path,
-    const char* address,
-    int port,
-    struct event_base* eb)
-  : host_(host)
-  , path_(path)
-  , recvBuf_(NULL)
-  , conn_(NULL)
-{
+namespace apache {
+namespace thrift {
+namespace async {
+
+TEvhttpClientChannel::TEvhttpClientChannel(const std::string& host,
+                                           const std::string& path,
+                                           const char* address,
+                                           int port,
+                                           struct event_base* eb)
+  : host_(host), path_(path), recvBuf_(NULL), conn_(NULL) {
   conn_ = evhttp_connection_new(address, port);
   if (conn_ == NULL) {
     throw TException("evhttp_connection_new failed");
@@ -49,18 +45,15 @@ TEvhttpClientChannel::TEvhttpClientChannel(
   evhttp_connection_set_base(conn_, eb);
 }
 
-
 TEvhttpClientChannel::~TEvhttpClientChannel() {
   if (conn_ != NULL) {
     evhttp_connection_free(conn_);
   }
 }
 
-
-void TEvhttpClientChannel::sendAndRecvMessage(
-    const VoidCallback& cob,
-    apache::thrift::transport::TMemoryBuffer* sendBuf,
-    apache::thrift::transport::TMemoryBuffer* recvBuf) {
+void TEvhttpClientChannel::sendAndRecvMessage(const VoidCallback& cob,
+                                              apache::thrift::transport::TMemoryBuffer* sendBuf,
+                                              apache::thrift::transport::TMemoryBuffer* recvBuf) {
   cob_ = cob;
   recvBuf_ = recvBuf;
 
@@ -95,68 +88,64 @@ void TEvhttpClientChannel::sendAndRecvMessage(
   }
 }
 
-
-void TEvhttpClientChannel::sendMessage(
-    const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message) {
-  (void) cob;
-  (void) message;
+void TEvhttpClientChannel::sendMessage(const VoidCallback& cob,
+                                       apache::thrift::transport::TMemoryBuffer* message) {
+  (void)cob;
+  (void)message;
   throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
-			   "Unexpected call to TEvhttpClientChannel::sendMessage");
+                           "Unexpected call to TEvhttpClientChannel::sendMessage");
 }
 
-
-void TEvhttpClientChannel::recvMessage(
-    const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message) {
-  (void) cob;
-  (void) message;
+void TEvhttpClientChannel::recvMessage(const VoidCallback& cob,
+                                       apache::thrift::transport::TMemoryBuffer* message) {
+  (void)cob;
+  (void)message;
   throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
-			   "Unexpected call to TEvhttpClientChannel::recvMessage");
+                           "Unexpected call to TEvhttpClientChannel::recvMessage");
 }
 
-
 void TEvhttpClientChannel::finish(struct evhttp_request* req) {
   if (req == NULL) {
-  try {
-    cob_();
-  } catch(const TTransportException& e) {
-    if(e.getType() == TTransportException::END_OF_FILE)
-      throw TException("connect failed");
-    else
-      throw;
-  }
-  return;
+    try {
+      cob_();
+    } catch (const TTransportException& e) {
+      if (e.getType() == TTransportException::END_OF_FILE)
+        throw TException("connect failed");
+      else
+        throw;
+    }
+    return;
   } else if (req->response_code != 200) {
-  try {
-    cob_();
-  } catch(const TTransportException& e) {
-    std::stringstream ss;
-    ss << "server returned code " << req->response_code;
-	if(req->response_code_line)
-		ss << ": " << req->response_code_line;
-    if(e.getType() == TTransportException::END_OF_FILE)
-      throw TException(ss.str());
-    else
-      throw;
-  }
-  return;
+    try {
+      cob_();
+    } catch (const TTransportException& e) {
+      std::stringstream ss;
+      ss << "server returned code " << req->response_code;
+      if (req->response_code_line)
+        ss << ": " << req->response_code_line;
+      if (e.getType() == TTransportException::END_OF_FILE)
+        throw TException(ss.str());
+      else
+        throw;
+    }
+    return;
   }
-  recvBuf_->resetBuffer(
-      EVBUFFER_DATA(req->input_buffer),
-      static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)));
+  recvBuf_->resetBuffer(EVBUFFER_DATA(req->input_buffer),
+                        static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)));
   cob_();
   return;
 }
 
-
 /* static */ void TEvhttpClientChannel::response(struct evhttp_request* req, void* arg) {
   TEvhttpClientChannel* self = (TEvhttpClientChannel*)arg;
   try {
     self->finish(req);
-  } catch(std::exception& e) {
+  } catch (std::exception& e) {
     // don't propagate a C++ exception in C code (e.g. libevent)
-    std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what() << std::endl;
+    std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what()
+              << std::endl;
   }
 }
-
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
index a7229e9..72ed40f 100644
--- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
+++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
@@ -28,39 +28,46 @@ struct event_base;
 struct evhttp_connection;
 struct evhttp_request;
 
-namespace apache { namespace thrift { namespace transport {
+namespace apache {
+namespace thrift {
+namespace transport {
 class TMemoryBuffer;
-}}}
+}
+}
+}
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 class TEvhttpClientChannel : public TAsyncChannel {
- public:
+public:
   using TAsyncChannel::VoidCallback;
 
-  TEvhttpClientChannel(
-      const std::string& host,
-      const std::string& path,
-      const char* address,
-      int port,
-      struct event_base* eb);
+  TEvhttpClientChannel(const std::string& host,
+                       const std::string& path,
+                       const char* address,
+                       int port,
+                       struct event_base* eb);
   ~TEvhttpClientChannel();
 
   virtual void sendAndRecvMessage(const VoidCallback& cob,
                                   apache::thrift::transport::TMemoryBuffer* sendBuf,
                                   apache::thrift::transport::TMemoryBuffer* recvBuf);
 
-  virtual void sendMessage(const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message);
-  virtual void recvMessage(const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message);
+  virtual void sendMessage(const VoidCallback& cob,
+                           apache::thrift::transport::TMemoryBuffer* message);
+  virtual void recvMessage(const VoidCallback& cob,
+                           apache::thrift::transport::TMemoryBuffer* message);
 
   void finish(struct evhttp_request* req);
 
-  //XXX
+  // XXX
   virtual bool good() const { return true; }
   virtual bool error() const { return false; }
   virtual bool timedOut() const { return false; }
 
- private:
+private:
   static void response(struct evhttp_request* req, void* arg);
 
   std::string host_;
@@ -68,9 +75,9 @@ class TEvhttpClientChannel : public TAsyncChannel {
   VoidCallback cob_;
   apache::thrift::transport::TMemoryBuffer* recvBuf_;
   struct evhttp_connection* conn_;
-
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_TEVHTTP_CLIENT_CHANNEL_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TEvhttpServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
index fa8d782..93fb479 100644
--- a/lib/cpp/src/thrift/async/TEvhttpServer.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
@@ -30,8 +30,9 @@
 
 using apache::thrift::transport::TMemoryBuffer;
 
-namespace apache { namespace thrift { namespace async {
-
+namespace apache {
+namespace thrift {
+namespace async {
 
 struct TEvhttpServer::RequestContext {
   struct evhttp_request* req;
@@ -41,19 +42,12 @@ struct TEvhttpServer::RequestContext {
   RequestContext(struct evhttp_request* req);
 };
 
-
 TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor)
-  : processor_(processor)
-  , eb_(NULL)
-  , eh_(NULL)
-{}
-
+  : processor_(processor), eb_(NULL), eh_(NULL) {
+}
 
 TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port)
-  : processor_(processor)
-  , eb_(NULL)
-  , eh_(NULL)
-{
+  : processor_(processor), eb_(NULL), eh_(NULL) {
   // Create event_base and evhttp.
   eb_ = event_base_new();
   if (eb_ == NULL) {
@@ -70,7 +64,7 @@ TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor,
   if (ret < 0) {
     evhttp_free(eh_);
     event_base_free(eb_);
-	throw TException("evhttp_bind_socket failed");
+    throw TException("evhttp_bind_socket failed");
   }
 
   // Register a handler.  If you use the other constructor,
@@ -79,7 +73,6 @@ TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor,
   evhttp_set_cb(eh_, "/", request, (void*)this);
 }
 
-
 TEvhttpServer::~TEvhttpServer() {
   if (eh_ != NULL) {
     evhttp_free(eh_);
@@ -89,7 +82,6 @@ TEvhttpServer::~TEvhttpServer() {
   }
 }
 
-
 int TEvhttpServer::serve() {
   if (eb_ == NULL) {
     throw TException("Unexpected call to TEvhttpServer::serve");
@@ -97,37 +89,33 @@ int TEvhttpServer::serve() {
   return event_base_dispatch(eb_);
 }
 
-
-TEvhttpServer::RequestContext::RequestContext(struct evhttp_request* req) : req(req)
-  , ibuf(new TMemoryBuffer(EVBUFFER_DATA(req->input_buffer), static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer))))
-  , obuf(new TMemoryBuffer())
-{}
-
+TEvhttpServer::RequestContext::RequestContext(struct evhttp_request* req)
+  : req(req),
+    ibuf(new TMemoryBuffer(EVBUFFER_DATA(req->input_buffer),
+                           static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)))),
+    obuf(new TMemoryBuffer()) {
+}
 
 void TEvhttpServer::request(struct evhttp_request* req, void* self) {
   try {
     static_cast<TEvhttpServer*>(self)->process(req);
-  } catch(std::exception& e) {
+  } catch (std::exception& e) {
     evhttp_send_reply(req, HTTP_INTERNAL, e.what(), 0);
   }
 }
 
-
 void TEvhttpServer::process(struct evhttp_request* req) {
   RequestContext* ctx = new RequestContext(req);
-  return processor_->process(
-      apache::thrift::stdcxx::bind(
-        &TEvhttpServer::complete,
-        this,
-        ctx,
-        apache::thrift::stdcxx::placeholders::_1),
-      ctx->ibuf,
-      ctx->obuf);
+  return processor_->process(apache::thrift::stdcxx::bind(&TEvhttpServer::complete,
+                                                          this,
+                                                          ctx,
+                                                          apache::thrift::stdcxx::placeholders::_1),
+                             ctx->ibuf,
+                             ctx->obuf);
 }
 
-
 void TEvhttpServer::complete(RequestContext* ctx, bool success) {
-  (void) success;
+  (void)success;
   std::auto_ptr<RequestContext> ptr(ctx);
 
   int code = success ? 200 : 400;
@@ -142,7 +130,7 @@ void TEvhttpServer::complete(RequestContext* ctx, bool success) {
   struct evbuffer* buf = evbuffer_new();
   if (buf == NULL) {
     // TODO: Log an error.
-      std::cerr << "evbuffer_new failed " << __FILE__ << ":" <<  __LINE__ << std::endl;
+    std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << std::endl;
   } else {
     uint8_t* obuf;
     uint32_t sz;
@@ -150,7 +138,8 @@ void TEvhttpServer::complete(RequestContext* ctx, bool success) {
     int ret = evbuffer_add(buf, obuf, sz);
     if (ret != 0) {
       // TODO: Log an error.
-      std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" <<  __LINE__ << std::endl;
+      std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__
+                << std::endl;
     }
   }
 
@@ -160,10 +149,9 @@ void TEvhttpServer::complete(RequestContext* ctx, bool success) {
   }
 }
 
-
 struct event_base* TEvhttpServer::getEventBase() {
   return eb_;
 }
-
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/async/TEvhttpServer.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.h b/lib/cpp/src/thrift/async/TEvhttpServer.h
index edc6ffb..89bf337 100644
--- a/lib/cpp/src/thrift/async/TEvhttpServer.h
+++ b/lib/cpp/src/thrift/async/TEvhttpServer.h
@@ -26,12 +26,14 @@ struct event_base;
 struct evhttp;
 struct evhttp_request;
 
-namespace apache { namespace thrift { namespace async {
+namespace apache {
+namespace thrift {
+namespace async {
 
 class TAsyncBufferProcessor;
 
 class TEvhttpServer {
- public:
+public:
   /**
    * Create a TEvhttpServer for use with an external evhttp instance.
    * Must be manually installed with evhttp_set_cb, using
@@ -55,7 +57,7 @@ class TEvhttpServer {
 
   struct event_base* getEventBase();
 
- private:
+private:
   struct RequestContext;
 
   void process(struct evhttp_request* req);
@@ -65,7 +67,8 @@ class TEvhttpServer {
   struct event_base* eb_;
   struct evhttp* eh_;
 };
-
-}}} // apache::thrift::async
+}
+}
+} // apache::thrift::async
 
 #endif // #ifndef _THRIFT_TEVHTTP_SERVER_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp b/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp
index 1027157..6c24d82 100644
--- a/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp
+++ b/lib/cpp/src/thrift/concurrency/BoostMonitor.cpp
@@ -29,7 +29,9 @@
 #include <boost/thread.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Monitor implementation using the boost thread library
@@ -38,23 +40,12 @@ namespace apache { namespace thrift { namespace concurrency {
  */
 class Monitor::Impl : public boost::condition_variable_any {
 
- public:
+public:
+  Impl() : ownedMutex_(new Mutex()), mutex_(NULL) { init(ownedMutex_.get()); }
 
-  Impl()
-     : ownedMutex_(new Mutex()),
-       mutex_(NULL) {
-    init(ownedMutex_.get());
-  }
-
-  Impl(Mutex* mutex)
-     : mutex_(NULL) {
-    init(mutex);
-  }
+  Impl(Mutex* mutex) : mutex_(NULL) { init(mutex); }
 
-  Impl(Monitor* monitor)
-     : mutex_(NULL) {
-    init(&(monitor->mutex()));
-  }
+  Impl(Monitor* monitor) : mutex_(NULL) { init(&(monitor->mutex())); }
 
   Mutex& mutex() { return *mutex_; }
   void lock() { mutex().lock(); }
@@ -72,8 +63,7 @@ class Monitor::Impl : public boost::condition_variable_any {
     if (result == THRIFT_ETIMEDOUT) {
       throw TimedOutException();
     } else if (result != 0) {
-      throw TException(
-        "Monitor::wait() failed");
+      throw TException("Monitor::wait() failed");
     }
   }
 
@@ -89,14 +79,17 @@ class Monitor::Impl : public boost::condition_variable_any {
     }
 
     assert(mutex_);
-	boost::timed_mutex* mutexImpl =
-      reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
+    boost::timed_mutex* mutexImpl
+        = reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
-	boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
-	int res = timed_wait(lock, boost::get_system_time()+boost::posix_time::milliseconds(timeout_ms)) ? 0 : THRIFT_ETIMEDOUT;
-	lock.release();
-	return res;
+    boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
+    int res
+        = timed_wait(lock, boost::get_system_time() + boost::posix_time::milliseconds(timeout_ms))
+              ? 0
+              : THRIFT_ETIMEDOUT;
+    lock.release();
+    return res;
   }
 
   /**
@@ -105,7 +98,7 @@ class Monitor::Impl : public boost::condition_variable_any {
    */
   int waitForTime(const THRIFT_TIMESPEC* abstime) {
     struct timeval temp;
-    temp.tv_sec  = static_cast<long>(abstime->tv_sec);
+    temp.tv_sec = static_cast<long>(abstime->tv_sec);
     temp.tv_usec = static_cast<long>(abstime->tv_nsec) / 1000;
     return waitForTime(&temp);
   }
@@ -116,27 +109,27 @@ class Monitor::Impl : public boost::condition_variable_any {
    */
   int waitForTime(const struct timeval* abstime) {
     assert(mutex_);
-    boost::timed_mutex* mutexImpl =
-      static_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
+    boost::timed_mutex* mutexImpl = static_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
     struct timeval currenttime;
     Util::toTimeval(currenttime, Util::currentTime());
 
-	long tv_sec = static_cast<long>(abstime->tv_sec - currenttime.tv_sec);
-	long tv_usec = static_cast<long>(abstime->tv_usec - currenttime.tv_usec);
-	if(tv_sec < 0)
-		tv_sec = 0;
-	if(tv_usec < 0)
-		tv_usec = 0;
-
-	boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
-	int res = timed_wait(lock, boost::get_system_time() +
-		boost::posix_time::seconds(tv_sec) +
-		boost::posix_time::microseconds(tv_usec)
-		) ? 0 : THRIFT_ETIMEDOUT;
-	lock.release();
-	return res;
+    long tv_sec = static_cast<long>(abstime->tv_sec - currenttime.tv_sec);
+    long tv_usec = static_cast<long>(abstime->tv_usec - currenttime.tv_usec);
+    if (tv_sec < 0)
+      tv_sec = 0;
+    if (tv_usec < 0)
+      tv_usec = 0;
+
+    boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
+    int res = timed_wait(lock,
+                         boost::get_system_time() + boost::posix_time::seconds(tv_sec)
+                         + boost::posix_time::microseconds(tv_usec))
+                  ? 0
+                  : THRIFT_ETIMEDOUT;
+    lock.release();
+    return res;
   }
 
   /**
@@ -145,48 +138,53 @@ class Monitor::Impl : public boost::condition_variable_any {
    */
   int waitForever() {
     assert(mutex_);
-    boost::timed_mutex* mutexImpl =
-      reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
+    boost::timed_mutex* mutexImpl
+        = reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl());
     assert(mutexImpl);
 
-	boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
-	((boost::condition_variable_any*)this)->wait(lock);
-	lock.release();
+    boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock);
+    ((boost::condition_variable_any*)this)->wait(lock);
+    lock.release();
     return 0;
   }
 
+  void notify() { notify_one(); }
 
-  void notify() {
-	  notify_one();
-  }
+  void notifyAll() { notify_all(); }
 
-  void notifyAll() {
-	  notify_all();
-  }
-
- private:
-
-  void init(Mutex* mutex) {
-    mutex_ = mutex;
-  }
+private:
+  void init(Mutex* mutex) { mutex_ = mutex; }
 
   boost::scoped_ptr<Mutex> ownedMutex_;
   Mutex* mutex_;
 };
 
-Monitor::Monitor() : impl_(new Monitor::Impl()) {}
-Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {}
-Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {}
+Monitor::Monitor() : impl_(new Monitor::Impl()) {
+}
+Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {
+}
+Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {
+}
 
-Monitor::~Monitor() { delete impl_; }
+Monitor::~Monitor() {
+  delete impl_;
+}
 
-Mutex& Monitor::mutex() const { return const_cast<Monitor::Impl*>(impl_)->mutex(); }
+Mutex& Monitor::mutex() const {
+  return const_cast<Monitor::Impl*>(impl_)->mutex();
+}
 
-void Monitor::lock() const { const_cast<Monitor::Impl*>(impl_)->lock(); }
+void Monitor::lock() const {
+  const_cast<Monitor::Impl*>(impl_)->lock();
+}
 
-void Monitor::unlock() const { const_cast<Monitor::Impl*>(impl_)->unlock(); }
+void Monitor::unlock() const {
+  const_cast<Monitor::Impl*>(impl_)->unlock();
+}
 
-void Monitor::wait(int64_t timeout) const { const_cast<Monitor::Impl*>(impl_)->wait(timeout); }
+void Monitor::wait(int64_t timeout) const {
+  const_cast<Monitor::Impl*>(impl_)->wait(timeout);
+}
 
 int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const {
   return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime);
@@ -204,8 +202,13 @@ int Monitor::waitForever() const {
   return const_cast<Monitor::Impl*>(impl_)->waitForever();
 }
 
-void Monitor::notify() const { const_cast<Monitor::Impl*>(impl_)->notify(); }
-
-void Monitor::notifyAll() const { const_cast<Monitor::Impl*>(impl_)->notifyAll(); }
+void Monitor::notify() const {
+  const_cast<Monitor::Impl*>(impl_)->notify();
+}
 
-}}} // apache::thrift::concurrency
+void Monitor::notifyAll() const {
+  const_cast<Monitor::Impl*>(impl_)->notifyAll();
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/concurrency/BoostMutex.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/BoostMutex.cpp b/lib/cpp/src/thrift/concurrency/BoostMutex.cpp
index 59c3618..f7cadab 100644
--- a/lib/cpp/src/thrift/concurrency/BoostMutex.cpp
+++ b/lib/cpp/src/thrift/concurrency/BoostMutex.cpp
@@ -28,31 +28,44 @@
 #include <boost/thread/mutex.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
-namespace apache { namespace thrift { namespace concurrency {
+namespace apache {
+namespace thrift {
+namespace concurrency {
 
 /**
  * Implementation of Mutex class using boost interprocess mutex
  *
  * @version $Id:$
  */
-class Mutex::impl : public boost::timed_mutex {
-};
+class Mutex::impl : public boost::timed_mutex {};
 
-Mutex::Mutex(Initializer init) : impl_(new Mutex::impl())
-{ THRIFT_UNUSED_VARIABLE(init); }
+Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {
+  THRIFT_UNUSED_VARIABLE(init);
+}
 
-void* Mutex::getUnderlyingImpl() const { return impl_.get(); }
+void* Mutex::getUnderlyingImpl() const {
+  return impl_.get();
+}
 
-void Mutex::lock() const { impl_->lock(); }
+void Mutex::lock() const {
+  impl_->lock();
+}
 
-bool Mutex::trylock() const { return impl_->try_lock(); }
+bool Mutex::trylock() const {
+  return impl_->try_lock();
+}
 
-bool Mutex::timedlock(int64_t ms) const { return impl_->timed_lock(boost::get_system_time()+boost::posix_time::milliseconds(ms)); }
+bool Mutex::timedlock(int64_t ms) const {
+  return impl_->timed_lock(boost::get_system_time() + boost::posix_time::milliseconds(ms));
+}
 
-void Mutex::unlock() const { impl_->unlock(); }
+void Mutex::unlock() const {
+  impl_->unlock();
+}
 
 void Mutex::DEFAULT_INITIALIZER(void* arg) {
   THRIFT_UNUSED_VARIABLE(arg);
 }
-
-}}} // apache::thrift::concurrency
+}
+}
+} // apache::thrift::concurrency


[37/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
THRIFT-2729: C++ - .clang-format created and applied

Client: C++
Patch: Konrad Grochowski

make style command added


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/74260aa9
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/74260aa9
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/74260aa9

Branch: refs/heads/master
Commit: 74260aa9099c3bb209bc8e524b0e8ba603f62c41
Parents: ca7e97e
Author: Konrad Grochowski <hc...@apache.org>
Authored: Thu Nov 13 15:33:38 2014 +0100
Committer: Konrad Grochowski <hc...@apache.org>
Committed: Tue Nov 18 10:02:08 2014 +0100

----------------------------------------------------------------------
 .clang-format                                   |   56 +
 compiler/cpp/Makefile.am                        |    3 +
 compiler/cpp/src/generate/t_as3_generator.cc    | 1328 ++---
 compiler/cpp/src/generate/t_c_glib_generator.cc | 4568 ++++++---------
 compiler/cpp/src/generate/t_cocoa_generator.cc  | 1138 ++--
 compiler/cpp/src/generate/t_cpp_generator.cc    | 3182 ++++------
 compiler/cpp/src/generate/t_csharp_generator.cc | 2049 ++++---
 compiler/cpp/src/generate/t_d_generator.cc      |  329 +-
 compiler/cpp/src/generate/t_delphi_generator.cc | 2491 ++++----
 compiler/cpp/src/generate/t_erl_generator.cc    |  344 +-
 compiler/cpp/src/generate/t_generator.cc        |   38 +-
 compiler/cpp/src/generate/t_generator.h         |   59 +-
 .../cpp/src/generate/t_generator_registry.h     |   43 +-
 compiler/cpp/src/generate/t_go_generator.cc     | 5429 ++++++++----------
 compiler/cpp/src/generate/t_gv_generator.cc     |  228 +-
 compiler/cpp/src/generate/t_haxe_generator.cc   | 1517 +++--
 compiler/cpp/src/generate/t_hs_generator.cc     |  548 +-
 compiler/cpp/src/generate/t_html_generator.cc   |  449 +-
 compiler/cpp/src/generate/t_html_generator.h    |  416 +-
 compiler/cpp/src/generate/t_java_generator.cc   | 2583 +++++----
 compiler/cpp/src/generate/t_javame_generator.cc | 1578 +++--
 compiler/cpp/src/generate/t_js_generator.cc     | 1367 ++---
 compiler/cpp/src/generate/t_json_generator.cc   |  189 +-
 compiler/cpp/src/generate/t_lua_generator.cc    |  701 +--
 compiler/cpp/src/generate/t_ocaml_generator.cc  |  931 ++-
 compiler/cpp/src/generate/t_oop_generator.h     |   45 +-
 compiler/cpp/src/generate/t_perl_generator.cc   |  809 +--
 compiler/cpp/src/generate/t_php_generator.cc    | 1523 ++---
 compiler/cpp/src/generate/t_py_generator.cc     | 1465 ++---
 compiler/cpp/src/generate/t_rb_generator.cc     |  399 +-
 compiler/cpp/src/generate/t_st_generator.cc     |  368 +-
 compiler/cpp/src/generate/t_xsd_generator.cc    |  128 +-
 compiler/cpp/src/globals.h                      |   18 +-
 compiler/cpp/src/logging.h                      |    1 -
 compiler/cpp/src/main.cc                        |  153 +-
 compiler/cpp/src/main.h                         |    8 +-
 compiler/cpp/src/md5.h                          |   31 +-
 compiler/cpp/src/parse/parse.cc                 |    2 +-
 compiler/cpp/src/parse/t_base_type.h            |  100 +-
 compiler/cpp/src/parse/t_const.h                |   23 +-
 compiler/cpp/src/parse/t_const_value.h          |   83 +-
 compiler/cpp/src/parse/t_container.h            |   21 +-
 compiler/cpp/src/parse/t_doc.h                  |   18 +-
 compiler/cpp/src/parse/t_enum.h                 |   34 +-
 compiler/cpp/src/parse/t_enum_value.h           |   16 +-
 compiler/cpp/src/parse/t_field.h                |  117 +-
 compiler/cpp/src/parse/t_function.h             |   51 +-
 compiler/cpp/src/parse/t_list.h                 |   16 +-
 compiler/cpp/src/parse/t_map.h                  |   24 +-
 compiler/cpp/src/parse/t_program.h              |  173 +-
 compiler/cpp/src/parse/t_scope.h                |   66 +-
 compiler/cpp/src/parse/t_service.h              |   24 +-
 compiler/cpp/src/parse/t_set.h                  |   15 +-
 compiler/cpp/src/parse/t_struct.h               |  107 +-
 compiler/cpp/src/parse/t_type.h                 |   70 +-
 compiler/cpp/src/parse/t_typedef.h              |   36 +-
 compiler/cpp/src/windows/config.h               |    5 +-
 configure.ac                                    |    3 +
 lib/cpp/Makefile.am                             |    3 +
 lib/cpp/src/thrift/TApplicationException.cpp    |    7 +-
 lib/cpp/src/thrift/TApplicationException.h      |   74 +-
 lib/cpp/src/thrift/TDispatchProcessor.h         |   45 +-
 lib/cpp/src/thrift/TLogging.h                   |  158 +-
 lib/cpp/src/thrift/TProcessor.h                 |  115 +-
 lib/cpp/src/thrift/TReflectionLocal.h           |   34 +-
 lib/cpp/src/thrift/TToString.h                  |   10 +-
 lib/cpp/src/thrift/Thrift.cpp                   |   29 +-
 lib/cpp/src/thrift/Thrift.h                     |   99 +-
 lib/cpp/src/thrift/VirtualProfiling.cpp         |  126 +-
 .../src/thrift/async/TAsyncBufferProcessor.h    |   18 +-
 lib/cpp/src/thrift/async/TAsyncChannel.cpp      |   13 +-
 lib/cpp/src/thrift/async/TAsyncChannel.h        |   27 +-
 .../src/thrift/async/TAsyncDispatchProcessor.h  |   40 +-
 lib/cpp/src/thrift/async/TAsyncProcessor.h      |   42 +-
 .../thrift/async/TAsyncProtocolProcessor.cpp    |   32 +-
 .../src/thrift/async/TAsyncProtocolProcessor.h  |   38 +-
 .../src/thrift/async/TEvhttpClientChannel.cpp   |  117 +-
 lib/cpp/src/thrift/async/TEvhttpClientChannel.h |   41 +-
 lib/cpp/src/thrift/async/TEvhttpServer.cpp      |   66 +-
 lib/cpp/src/thrift/async/TEvhttpServer.h        |   13 +-
 lib/cpp/src/thrift/concurrency/BoostMonitor.cpp |  143 +-
 lib/cpp/src/thrift/concurrency/BoostMutex.cpp   |   37 +-
 .../thrift/concurrency/BoostThreadFactory.cpp   |   84 +-
 .../src/thrift/concurrency/BoostThreadFactory.h |   17 +-
 lib/cpp/src/thrift/concurrency/Exception.h      |   24 +-
 lib/cpp/src/thrift/concurrency/FunctionRunner.h |   39 +-
 lib/cpp/src/thrift/concurrency/Monitor.cpp      |   87 +-
 lib/cpp/src/thrift/concurrency/Monitor.h        |   25 +-
 lib/cpp/src/thrift/concurrency/Mutex.cpp        |  133 +-
 lib/cpp/src/thrift/concurrency/Mutex.h          |   69 +-
 .../thrift/concurrency/PlatformThreadFactory.h  |   12 +-
 .../thrift/concurrency/PosixThreadFactory.cpp   |  135 +-
 .../src/thrift/concurrency/PosixThreadFactory.h |   25 +-
 lib/cpp/src/thrift/concurrency/StdMonitor.cpp   |  112 +-
 lib/cpp/src/thrift/concurrency/StdMutex.cpp     |   36 +-
 .../src/thrift/concurrency/StdThreadFactory.cpp |   80 +-
 .../src/thrift/concurrency/StdThreadFactory.h   |   14 +-
 lib/cpp/src/thrift/concurrency/Thread.h         |   40 +-
 .../src/thrift/concurrency/ThreadManager.cpp    |  224 +-
 lib/cpp/src/thrift/concurrency/ThreadManager.h  |   37 +-
 lib/cpp/src/thrift/concurrency/TimerManager.cpp |   81 +-
 lib/cpp/src/thrift/concurrency/TimerManager.h   |   24 +-
 lib/cpp/src/thrift/concurrency/Util.cpp         |   11 +-
 lib/cpp/src/thrift/concurrency/Util.h           |   37 +-
 lib/cpp/src/thrift/cxxfunctional.h              |    2 +
 lib/cpp/src/thrift/processor/PeekProcessor.cpp  |   33 +-
 lib/cpp/src/thrift/processor/PeekProcessor.h    |   23 +-
 lib/cpp/src/thrift/processor/StatsProcessor.h   |  298 +-
 .../thrift/processor/TMultiplexedProcessor.h    |  357 +-
 lib/cpp/src/thrift/protocol/TBase64Utils.cpp    |  304 +-
 lib/cpp/src/thrift/protocol/TBase64Utils.h      |   13 +-
 lib/cpp/src/thrift/protocol/TBinaryProtocol.h   |  143 +-
 lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc |   52 +-
 lib/cpp/src/thrift/protocol/TCompactProtocol.h  |  133 +-
 lib/cpp/src/thrift/protocol/TDebugProtocol.cpp  |  218 +-
 lib/cpp/src/thrift/protocol/TDebugProtocol.h    |   77 +-
 lib/cpp/src/thrift/protocol/TDenseProtocol.cpp  |  126 +-
 lib/cpp/src/thrift/protocol/TDenseProtocol.h    |   84 +-
 lib/cpp/src/thrift/protocol/TJSONProtocol.cpp   |  337 +-
 lib/cpp/src/thrift/protocol/TJSONProtocol.h     |   99 +-
 .../thrift/protocol/TMultiplexedProtocol.cpp    |   39 +-
 .../src/thrift/protocol/TMultiplexedProtocol.h  |  138 +-
 lib/cpp/src/thrift/protocol/TProtocol.h         |  254 +-
 .../src/thrift/protocol/TProtocolDecorator.h    |  228 +-
 .../src/thrift/protocol/TProtocolException.h    |   74 +-
 lib/cpp/src/thrift/protocol/TProtocolTap.h      |   39 +-
 lib/cpp/src/thrift/protocol/TVirtualProtocol.h  |  223 +-
 lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp   |   66 +-
 lib/cpp/src/thrift/qt/TQIODeviceTransport.h     |   24 +-
 lib/cpp/src/thrift/qt/TQTcpServer.cpp           |   61 +-
 lib/cpp/src/thrift/qt/TQTcpServer.h             |   25 +-
 .../src/thrift/server/TNonblockingServer.cpp    |  415 +-
 lib/cpp/src/thrift/server/TNonblockingServer.h  |  284 +-
 lib/cpp/src/thrift/server/TServer.cpp           |   17 +-
 lib/cpp/src/thrift/server/TServer.h             |  188 +-
 lib/cpp/src/thrift/server/TSimpleServer.cpp     |   71 +-
 lib/cpp/src/thrift/server/TSimpleServer.h       |  103 +-
 lib/cpp/src/thrift/server/TThreadPoolServer.cpp |   92 +-
 lib/cpp/src/thrift/server/TThreadPoolServer.h   |  144 +-
 lib/cpp/src/thrift/server/TThreadedServer.cpp   |  100 +-
 lib/cpp/src/thrift/server/TThreadedServer.h     |   92 +-
 lib/cpp/src/thrift/thrift-config.h              |    4 +-
 lib/cpp/src/thrift/transport/PlatformSocket.h   |    2 +
 .../src/thrift/transport/TBufferTransports.cpp  |   44 +-
 .../src/thrift/transport/TBufferTransports.h    |  239 +-
 lib/cpp/src/thrift/transport/TFDTransport.cpp   |   34 +-
 lib/cpp/src/thrift/transport/TFDTransport.h     |   27 +-
 lib/cpp/src/thrift/transport/TFileTransport.cpp |  293 +-
 lib/cpp/src/thrift/transport/TFileTransport.h   |  162 +-
 lib/cpp/src/thrift/transport/THttpClient.cpp    |   43 +-
 lib/cpp/src/thrift/transport/THttpClient.h      |   19 +-
 lib/cpp/src/thrift/transport/THttpServer.cpp    |   65 +-
 lib/cpp/src/thrift/transport/THttpServer.h      |   18 +-
 lib/cpp/src/thrift/transport/THttpTransport.cpp |   52 +-
 lib/cpp/src/thrift/transport/THttpTransport.h   |   30 +-
 lib/cpp/src/thrift/transport/TPipe.cpp          |  224 +-
 lib/cpp/src/thrift/transport/TPipe.h            |   36 +-
 lib/cpp/src/thrift/transport/TPipeServer.cpp    |  280 +-
 lib/cpp/src/thrift/transport/TPipeServer.h      |   42 +-
 .../src/thrift/transport/TSSLServerSocket.cpp   |   23 +-
 lib/cpp/src/thrift/transport/TSSLServerSocket.h |   20 +-
 lib/cpp/src/thrift/transport/TSSLSocket.cpp     |  124 +-
 lib/cpp/src/thrift/transport/TSSLSocket.h       |  202 +-
 lib/cpp/src/thrift/transport/TServerSocket.cpp  |  275 +-
 lib/cpp/src/thrift/transport/TServerSocket.h    |   21 +-
 lib/cpp/src/thrift/transport/TServerTransport.h |   14 +-
 .../src/thrift/transport/TShortReadTransport.h  |   59 +-
 .../thrift/transport/TSimpleFileTransport.cpp   |   20 +-
 .../src/thrift/transport/TSimpleFileTransport.h |   15 +-
 lib/cpp/src/thrift/transport/TSocket.cpp        |  274 +-
 lib/cpp/src/thrift/transport/TSocket.h          |   22 +-
 lib/cpp/src/thrift/transport/TSocketPool.cpp    |  114 +-
 lib/cpp/src/thrift/transport/TSocketPool.h      |  251 +-
 lib/cpp/src/thrift/transport/TTransport.h       |   49 +-
 .../thrift/transport/TTransportException.cpp    |   49 +-
 .../src/thrift/transport/TTransportException.h  |   61 +-
 .../src/thrift/transport/TTransportUtils.cpp    |   47 +-
 lib/cpp/src/thrift/transport/TTransportUtils.h  |  142 +-
 .../src/thrift/transport/TVirtualTransport.h    |   46 +-
 lib/cpp/src/thrift/transport/TZlibTransport.cpp |   74 +-
 lib/cpp/src/thrift/transport/TZlibTransport.h   |   91 +-
 lib/cpp/src/thrift/windows/GetTimeOfDay.cpp     |  116 +-
 lib/cpp/src/thrift/windows/GetTimeOfDay.h       |    4 +-
 lib/cpp/src/thrift/windows/Operators.h          |   16 +-
 .../windows/OverlappedSubmissionThread.cpp      |   99 +-
 .../thrift/windows/OverlappedSubmissionThread.h |   38 +-
 lib/cpp/src/thrift/windows/SocketPair.cpp       |  108 +-
 lib/cpp/src/thrift/windows/Sync.h               |   36 +-
 .../src/thrift/windows/TWinsockSingleton.cpp    |   48 +-
 lib/cpp/src/thrift/windows/TWinsockSingleton.h  |   34 +-
 lib/cpp/src/thrift/windows/WinFcntl.cpp         |   80 +-
 lib/cpp/src/thrift/windows/WinFcntl.h           |   10 +-
 lib/cpp/src/thrift/windows/config.h             |   48 +-
 lib/cpp/test/AllProtocolTests.cpp               |    4 +-
 lib/cpp/test/AllProtocolTests.tcc               |   28 +-
 lib/cpp/test/Base64Test.cpp                     |    5 +-
 lib/cpp/test/Benchmark.cpp                      |   30 +-
 lib/cpp/test/DebugProtoTest.cpp                 |   32 +-
 lib/cpp/test/DebugProtoTest_extras.cpp          |   12 +-
 lib/cpp/test/DenseProtoTest.cpp                 |   58 +-
 lib/cpp/test/EnumTest.cpp                       |    6 +-
 lib/cpp/test/GenericHelpers.h                   |   60 +-
 lib/cpp/test/JSONProtoTest.cpp                  |   36 +-
 lib/cpp/test/OpenSSLManualInitTest.cpp          |    3 +-
 lib/cpp/test/OptionalRequiredTest.cpp           |   29 +-
 lib/cpp/test/RWMutexStarveTest.cpp              |   35 +-
 lib/cpp/test/RecursiveTest.cpp                  |    3 +-
 lib/cpp/test/SpecializationTest.cpp             |   31 +-
 lib/cpp/test/TFDTransportTest.cpp               |    8 +-
 lib/cpp/test/TFileTransportTest.cpp             |   83 +-
 lib/cpp/test/TMemoryBufferTest.cpp              |  152 +-
 lib/cpp/test/TPipedTransportTest.cpp            |   11 +-
 lib/cpp/test/ThriftTest_extras.cpp              |    8 +-
 lib/cpp/test/ToStringTest.cpp                   |   34 +-
 lib/cpp/test/TransportTest.cpp                  |  450 +-
 lib/cpp/test/ZlibTest.cpp                       |  115 +-
 lib/cpp/test/concurrency/Tests.cpp              |   21 +-
 lib/cpp/test/concurrency/ThreadFactoryTests.h   |  145 +-
 lib/cpp/test/concurrency/ThreadManagerTests.h   |  128 +-
 lib/cpp/test/concurrency/TimerManagerTests.h    |   55 +-
 lib/cpp/test/processor/EventLog.cpp             |   17 +-
 lib/cpp/test/processor/EventLog.h               |   31 +-
 lib/cpp/test/processor/Handlers.h               |  127 +-
 lib/cpp/test/processor/ProcessorTest.cpp        |  218 +-
 lib/cpp/test/processor/ServerThread.cpp         |   18 +-
 lib/cpp/test/processor/ServerThread.h           |   49 +-
 test/cpp/Makefile.am                            |    3 +
 test/cpp/src/StressTest.cpp                     |  252 +-
 test/cpp/src/StressTestNonBlocking.cpp          |  223 +-
 test/cpp/src/TestClient.cpp                     |  197 +-
 test/cpp/src/TestServer.cpp                     |  260 +-
 test/cpp/src/ThriftTest_extras.cpp              |    8 +-
 tutorial/cpp/CppClient.cpp                      |    1 -
 tutorial/cpp/CppServer.cpp                      |   19 +-
 tutorial/cpp/Makefile.am                        |    3 +
 235 files changed, 24382 insertions(+), 28035 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/.clang-format
----------------------------------------------------------------------
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a62eef8
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,56 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+ConstructorInitializerIndentWidth: 2
+AlignEscapedNewlinesLeft: false
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
+AlwaysBreakTemplateDeclarations: true
+AlwaysBreakBeforeMultilineStrings: true
+BreakBeforeBinaryOperators: true
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BinPackParameters: false
+ColumnLimit:     100
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+DerivePointerAlignment: false
+IndentCaseLabels: false
+IndentWrappedFunctionNames: false
+IndentFunctionDeclarationAfterType: false
+MaxEmptyLinesToKeep: 1
+KeepEmptyLinesAtTheStartOfBlocks: true
+NamespaceIndentation: None
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 190
+PenaltyBreakComment: 300
+PenaltyBreakString: 10000
+PenaltyBreakFirstLessLess: 120
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 1200
+PointerAlignment: Left
+SpacesBeforeTrailingComments: 1
+Cpp11BracedListStyle: true
+Standard:        Auto
+IndentWidth:     2
+TabWidth:        4
+UseTab:          Never
+BreakBeforeBraces: Attach
+SpacesInParentheses: false
+SpacesInAngles:  false
+SpaceInEmptyParentheses: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: true
+SpaceBeforeAssignmentOperators: true
+ContinuationIndentWidth: 4
+CommentPragmas:  '^ IWYU pragma:'
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+SpaceBeforeParens: ControlStatements
+DisableFormat:   false
+...
+

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index d3dadab..559a839 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -117,3 +117,6 @@ clean-local:
 	$(RM) thriftl.cc thrifty.cc thrifty.h thrifty.hh version.h windows/version.h
 
 src/main.cc: version.h
+
+style-local:
+	$(CPPSTYLE_CMD)


[15/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_rb_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index 0a15500..49708c7 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -43,22 +43,26 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * A subclass of std::ofstream that includes indenting functionality.
  */
 class t_rb_ofstream : public std::ofstream {
-  private:
-    int indent_;
+private:
+  int indent_;
 
-  public:
-    t_rb_ofstream() : std::ofstream(), indent_(0) { }
-    explicit t_rb_ofstream(const char* filename, ios_base::openmode mode = ios_base::out, int indent = 0) :
-      std::ofstream(filename, mode), indent_(indent) { }
+public:
+  t_rb_ofstream() : std::ofstream(), indent_(0) {}
+  explicit t_rb_ofstream(const char* filename,
+                         ios_base::openmode mode = ios_base::out,
+                         int indent = 0)
+    : std::ofstream(filename, mode), indent_(indent) {}
 
   t_rb_ofstream& indent() {
-    for (int i = 0; i < indent_; ++i) { *this << "  "; }
+    for (int i = 0; i < indent_; ++i) {
+      *this << "  ";
+    }
     return *this;
   }
 
@@ -71,14 +75,12 @@ class t_rb_ofstream : public std::ofstream {
  *
  */
 class t_rb_generator : public t_oop_generator {
- public:
-  t_rb_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_rb_generator(t_program* program,
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     out_dir_base_ = "gen-rb";
 
     require_rubygems_ = (parsed_options.find("rubygems") != parsed_options.end());
@@ -96,13 +98,13 @@ class t_rb_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef     (t_typedef*  ttypedef);
-  void generate_enum        (t_enum*     tenum);
-  void generate_const       (t_const*    tconst);
-  void generate_struct      (t_struct*   tstruct);
-  void generate_union        (t_struct*   tunion);
-  void generate_xception    (t_struct*   txception);
-  void generate_service     (t_service*  tservice);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_union(t_struct* tunion);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
 
   t_rb_ofstream& render_const_value(t_rb_ofstream& out, t_type* type, t_const_value* value);
 
@@ -117,77 +119,62 @@ class t_rb_generator : public t_oop_generator {
   void generate_rb_function_helpers(t_function* tfunction);
   void generate_rb_simple_constructor(t_rb_ofstream& out, t_struct* tstruct);
   void generate_rb_simple_exception_constructor(t_rb_ofstream& out, t_struct* tstruct);
-  void generate_field_constants (t_rb_ofstream& out, t_struct* tstruct);
-  void generate_field_constructors (t_rb_ofstream& out, t_struct* tstruct);
-  void generate_field_defns (t_rb_ofstream& out, t_struct* tstruct);
-  void generate_field_data  (t_rb_ofstream& out, t_type* field_type, const std::string& field_name, t_const_value* field_value, bool optional);
+  void generate_field_constants(t_rb_ofstream& out, t_struct* tstruct);
+  void generate_field_constructors(t_rb_ofstream& out, t_struct* tstruct);
+  void generate_field_defns(t_rb_ofstream& out, t_struct* tstruct);
+  void generate_field_data(t_rb_ofstream& out,
+                           t_type* field_type,
+                           const std::string& field_name,
+                           t_const_value* field_value,
+                           bool optional);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service*  tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (t_rb_ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="",
-                                          bool inclass=false);
+  void generate_deserialize_field(t_rb_ofstream& out,
+                                  t_field* tfield,
+                                  std::string prefix = "",
+                                  bool inclass = false);
 
-  void generate_deserialize_struct       (t_rb_ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(t_rb_ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (t_rb_ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(t_rb_ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (t_rb_ofstream &out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(t_rb_ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (t_rb_ofstream &out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(t_rb_ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (t_rb_ofstream &out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(t_rb_ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (t_rb_ofstream &out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(t_rb_ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (t_rb_ofstream &out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(t_rb_ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (t_rb_ofstream &out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(t_rb_ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (t_rb_ofstream &out,
-                                          t_map*      tmap,
-                                          std::string kiter,
-                                          std::string viter);
+  void generate_serialize_map_element(t_rb_ofstream& out,
+                                      t_map* tmap,
+                                      std::string kiter,
+                                      std::string viter);
 
-  void generate_serialize_set_element    (t_rb_ofstream &out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(t_rb_ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (t_rb_ofstream &out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(t_rb_ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_rdoc                     (t_rb_ofstream& out,
-                                          t_doc* tdoc);
+  void generate_rdoc(t_rb_ofstream& out, t_doc* tdoc);
 
   /**
    * Helper rendering functions
@@ -199,12 +186,11 @@ class t_rb_generator : public t_oop_generator {
   std::string declare_field(t_field* tfield);
   std::string type_name(t_type* ttype);
   std::string full_type_name(t_type* ttype);
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
   std::string rb_namespace_to_path_prefix(std::string rb_namespace);
 
-
   std::vector<std::string> ruby_modules(t_program* p) {
     std::string ns = p->get_namespace("rb");
     std::vector<std::string> modules;
@@ -229,8 +215,7 @@ class t_rb_generator : public t_oop_generator {
   void begin_namespace(t_rb_ofstream&, std::vector<std::string>);
   void end_namespace(t_rb_ofstream&, std::vector<std::string>);
 
- private:
-
+private:
   /**
    * File streams
    */
@@ -249,7 +234,6 @@ class t_rb_generator : public t_oop_generator {
   bool namespaced_;
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -271,31 +255,26 @@ void t_rb_generator::init_generator() {
     while ((loc = dir.find("/")) != string::npos) {
       subdir = subdir + dir.substr(0, loc) + "/";
       MKDIR(subdir.c_str());
-      dir = dir.substr(loc+1);
+      dir = dir.substr(loc + 1);
     }
   }
 
   namespace_dir_ = subdir;
 
   // Make output file
-  string f_types_name = namespace_dir_+underscore(program_name_)+"_types.rb";
+  string f_types_name = namespace_dir_ + underscore(program_name_) + "_types.rb";
   f_types_.open(f_types_name.c_str());
 
-  string f_consts_name = namespace_dir_+underscore(program_name_)+"_constants.rb";
+  string f_consts_name = namespace_dir_ + underscore(program_name_) + "_constants.rb";
   f_consts_.open(f_consts_name.c_str());
 
   // Print header
-  f_types_ <<
-    rb_autogen_comment() << endl << render_require_thrift() <<
-    render_includes() << endl;
-    begin_namespace(f_types_, ruby_modules(program_));
-
-  f_consts_ <<
-    rb_autogen_comment() << endl << render_require_thrift() <<
-    "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl <<
-    endl;
-    begin_namespace(f_consts_, ruby_modules(program_));
+  f_types_ << rb_autogen_comment() << endl << render_require_thrift() << render_includes() << endl;
+  begin_namespace(f_types_, ruby_modules(program_));
 
+  f_consts_ << rb_autogen_comment() << endl << render_require_thrift() << "require '"
+            << require_prefix_ << underscore(program_name_) << "_types'" << endl << endl;
+  begin_namespace(f_consts_, ruby_modules(program_));
 }
 
 /**
@@ -317,7 +296,8 @@ string t_rb_generator::render_includes() {
   string result = "";
   for (size_t i = 0; i < includes.size(); ++i) {
     t_program* included = includes[i];
-    std::string included_require_prefix = rb_namespace_to_path_prefix(included->get_namespace("rb"));
+    std::string included_require_prefix
+        = rb_namespace_to_path_prefix(included->get_namespace("rb"));
     std::string included_name = included->get_name();
     result += "require '" + included_require_prefix + underscore(included_name) + "_types'\n";
   }
@@ -331,12 +311,8 @@ string t_rb_generator::render_includes() {
  * Autogen'd comment
  */
 string t_rb_generator::rb_autogen_comment() {
-  return
-    std::string("#\n") +
-    "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "#\n" +
-    "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-    "#\n";
+  return std::string("#\n") + "# Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         + "#\n" + "# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "#\n";
 }
 
 /**
@@ -356,7 +332,7 @@ void t_rb_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_rb_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -366,8 +342,7 @@ void t_rb_generator::generate_typedef(t_typedef* ttypedef) {
  * @param tenum The enumeration
  */
 void t_rb_generator::generate_enum(t_enum* tenum) {
-  f_types_.indent() <<
-    "module " << capitalize(tenum->get_name()) << endl;
+  f_types_.indent() << "module " << capitalize(tenum->get_name()) << endl;
   f_types_.indent_up();
 
   vector<t_enum_value*> constants = tenum->get_constants();
@@ -384,12 +359,14 @@ void t_rb_generator::generate_enum(t_enum* tenum) {
     f_types_.indent() << name << " = " << value << endl;
   }
 
-  // Create a hash mapping values back to their names (as strings) since ruby has no native enum type
+  // Create a hash mapping values back to their names (as strings) since ruby has no native enum
+  // type
   f_types_.indent() << "VALUE_MAP = {";
-  for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
+  for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     // Populate the hash
     int value = (*c_iter)->get_value();
-    if (c_iter != constants.begin()) f_types_ << ", ";
+    if (c_iter != constants.begin())
+      f_types_ << ", ";
     f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\"";
   }
   f_types_ << "}" << endl;
@@ -398,14 +375,14 @@ void t_rb_generator::generate_enum(t_enum* tenum) {
   f_types_.indent() << "VALID_VALUES = Set.new([";
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     // Populate the set
-    if (c_iter != constants.begin()) f_types_ << ", ";
+    if (c_iter != constants.begin())
+      f_types_ << ", ";
     f_types_ << capitalize((*c_iter)->get_name());
   }
   f_types_ << "]).freeze" << endl;
 
   f_types_.indent_down();
-  f_types_.indent() <<
-    "end" << endl << endl;
+  f_types_.indent() << "end" << endl << endl;
 }
 
 /**
@@ -427,7 +404,9 @@ void t_rb_generator::generate_const(t_const* tconst) {
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out, t_type* type, t_const_value* value) {
+t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out,
+                                                  t_type* type,
+                                                  t_const_value* value) {
   type = get_true_type(type);
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
@@ -548,7 +527,9 @@ void t_rb_generator::generate_xception(t_struct* txception) {
 /**
  * Generates a ruby struct
  */
-void t_rb_generator::generate_rb_struct(t_rb_ofstream& out, t_struct* tstruct, bool is_exception = false) {
+void t_rb_generator::generate_rb_struct(t_rb_ofstream& out,
+                                        t_struct* tstruct,
+                                        bool is_exception = false) {
   generate_rdoc(out, tstruct);
   out.indent() << "class " << type_name(tstruct);
   if (is_exception) {
@@ -573,12 +554,13 @@ void t_rb_generator::generate_rb_struct(t_rb_ofstream& out, t_struct* tstruct, b
   out.indent() << "end" << endl << endl;
 }
 
-
 /**
  * Generates a ruby union
  */
-void t_rb_generator::generate_rb_union(t_rb_ofstream& out, t_struct* tstruct, bool is_exception = false) {
-  (void) is_exception;
+void t_rb_generator::generate_rb_union(t_rb_ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_exception = false) {
+  (void)is_exception;
   generate_rdoc(out, tstruct);
   out.indent() << "class " << type_name(tstruct) << " < ::Thrift::Union" << endl;
 
@@ -622,7 +604,8 @@ void t_rb_generator::generate_field_constructors(t_rb_ofstream& out, t_struct* t
   out << endl;
 }
 
-void t_rb_generator::generate_rb_simple_exception_constructor(t_rb_ofstream& out, t_struct* tstruct) {
+void t_rb_generator::generate_rb_simple_exception_constructor(t_rb_ofstream& out,
+                                                              t_struct* tstruct) {
   const vector<t_field*>& members = tstruct->get_members();
 
   if (members.size() == 1) {
@@ -674,19 +657,24 @@ void t_rb_generator::generate_field_defns(t_rb_ofstream& out, t_struct* tstruct)
 
     out.indent() << upcase_string((*f_iter)->get_name()) << " => ";
 
-    generate_field_data(out, (*f_iter)->get_type(), (*f_iter)->get_name(), (*f_iter)->get_value(),
-      (*f_iter)->get_req() == t_field::T_OPTIONAL);
+    generate_field_data(out,
+                        (*f_iter)->get_type(),
+                        (*f_iter)->get_name(),
+                        (*f_iter)->get_value(),
+                        (*f_iter)->get_req() == t_field::T_OPTIONAL);
   }
   out.indent_down();
   out << endl;
   out.indent() << "}" << endl << endl;
 
   out.indent() << "def struct_fields; FIELDS; end" << endl << endl;
-
 }
 
-void t_rb_generator::generate_field_data(t_rb_ofstream& out, t_type* field_type,
-    const std::string& field_name = "", t_const_value* field_value = NULL, bool optional = false) {
+void t_rb_generator::generate_field_data(t_rb_ofstream& out,
+                                         t_type* field_type,
+                                         const std::string& field_name = "",
+                                         t_const_value* field_value = NULL,
+                                         bool optional = false) {
   field_type = get_true_type(field_type);
 
   // Begin this field's defn
@@ -722,7 +710,7 @@ void t_rb_generator::generate_field_data(t_rb_ofstream& out, t_type* field_type,
     }
   }
 
-  if(optional) {
+  if (optional) {
     out << ", :optional => true";
   }
 
@@ -742,33 +730,31 @@ void t_rb_generator::begin_namespace(t_rb_ofstream& out, vector<std::string> mod
 }
 
 void t_rb_generator::end_namespace(t_rb_ofstream& out, vector<std::string> modules) {
-  for (vector<std::string>::reverse_iterator m_iter = modules.rbegin(); m_iter != modules.rend(); ++m_iter) {
+  for (vector<std::string>::reverse_iterator m_iter = modules.rbegin(); m_iter != modules.rend();
+       ++m_iter) {
     out.indent_down();
     out.indent() << "end" << endl;
   }
 }
 
-
 /**
  * Generates a thrift service.
  *
  * @param tservice The service definition
  */
 void t_rb_generator::generate_service(t_service* tservice) {
-  string f_service_name = namespace_dir_+underscore(service_name_)+".rb";
+  string f_service_name = namespace_dir_ + underscore(service_name_) + ".rb";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    rb_autogen_comment() << endl << render_require_thrift();
+  f_service_ << rb_autogen_comment() << endl << render_require_thrift();
 
   if (tservice->get_extends() != NULL) {
-    f_service_ <<
-      "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name()) << "'" << endl;
+    f_service_ << "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name())
+               << "'" << endl;
   }
 
-  f_service_ <<
-    "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl <<
-    endl;
+  f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl
+             << endl;
 
   begin_namespace(f_service_, ruby_modules(tservice->get_program()));
 
@@ -858,46 +844,43 @@ void t_rb_generator::generate_service_client(t_service* tservice) {
     // Open function
     f_service_.indent() << "def " << function_signature(*f_iter) << endl;
     f_service_.indent_up();
-      f_service_.indent() <<
-        "send_" << funname << "(";
-
-      bool first = true;
-      for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-        if (first) {
-          first = false;
-        } else {
-          f_service_ << ", ";
-        }
-        f_service_ << (*fld_iter)->get_name();
+    f_service_.indent() << "send_" << funname << "(";
+
+    bool first = true;
+    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
+      if (first) {
+        first = false;
+      } else {
+        f_service_ << ", ";
       }
-      f_service_ << ")" << endl;
+      f_service_ << (*fld_iter)->get_name();
+    }
+    f_service_ << ")" << endl;
 
-      if (!(*f_iter)->is_oneway()) {
-        f_service_.indent();
-        if (!(*f_iter)->get_returntype()->is_void()) {
-          f_service_ << "return ";
-        }
-        f_service_ <<
-          "recv_" << funname << "()" << endl;
+    if (!(*f_iter)->is_oneway()) {
+      f_service_.indent();
+      if (!(*f_iter)->get_returntype()->is_void()) {
+        f_service_ << "return ";
       }
+      f_service_ << "recv_" << funname << "()" << endl;
+    }
     f_service_.indent_down();
     f_service_.indent() << "end" << endl;
     f_service_ << endl;
 
-    f_service_.indent() <<
-      "def send_" << function_signature(*f_iter) << endl;
+    f_service_.indent() << "def send_" << function_signature(*f_iter) << endl;
     f_service_.indent_up();
 
-      std::string argsname = capitalize((*f_iter)->get_name() + "_args");
-      std::string messageSendProc = (*f_iter)->is_oneway() ? "send_oneway_message" : "send_message";
+    std::string argsname = capitalize((*f_iter)->get_name() + "_args");
+    std::string messageSendProc = (*f_iter)->is_oneway() ? "send_oneway_message" : "send_message";
 
-      f_service_.indent() << messageSendProc << "('" << funname << "', " << argsname;
+    f_service_.indent() << messageSendProc << "('" << funname << "', " << argsname;
 
-      for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-        f_service_ << ", :" << (*fld_iter)->get_name() << " => " << (*fld_iter)->get_name();
-      }
+    for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
+      f_service_ << ", :" << (*fld_iter)->get_name() << " => " << (*fld_iter)->get_name();
+    }
 
-      f_service_ << ")" << endl;
+    f_service_ << ")" << endl;
 
     f_service_.indent_down();
     f_service_.indent() << "end" << endl;
@@ -927,19 +910,18 @@ void t_rb_generator::generate_service_client(t_service* tservice) {
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_.indent() <<
-          "raise result." << (*x_iter)->get_name() <<
-            " unless result." << (*x_iter)->get_name() << ".nil?" << endl;
+        f_service_.indent() << "raise result." << (*x_iter)->get_name() << " unless result."
+                            << (*x_iter)->get_name() << ".nil?" << endl;
       }
 
       // Careful, only return _result if not a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        f_service_.indent() <<
-          "return" << endl;
+        f_service_.indent() << "return" << endl;
       } else {
-        f_service_.indent() <<
-          "raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, '" <<
-          (*f_iter)->get_name() << " failed: unknown result')" << endl;
+        f_service_.indent() << "raise "
+                               "::Thrift::ApplicationException.new(::Thrift::ApplicationException::"
+                               "MISSING_RESULT, '" << (*f_iter)->get_name()
+                            << " failed: unknown result')" << endl;
       }
 
       // Close function
@@ -970,8 +952,7 @@ void t_rb_generator::generate_service_server(t_service* tservice) {
   }
 
   // Generate the header portion
-  f_service_.indent() <<
-    "class Processor" << extends_processor << endl;
+  f_service_.indent() << "class Processor" << extends_processor << endl;
   f_service_.indent_up();
 
   f_service_.indent() << "include ::Thrift::Processor" << endl << endl;
@@ -990,13 +971,10 @@ void t_rb_generator::generate_service_server(t_service* tservice) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_rb_generator::generate_process_function(t_service* tservice,
-                                               t_function* tfunction) {
-  (void) tservice;
+void t_rb_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open function
-  f_service_.indent() <<
-    "def process_" << tfunction->get_name() <<
-    "(seqid, iprot, oprot)" << endl;
+  f_service_.indent() << "def process_" << tfunction->get_name() << "(seqid, iprot, oprot)" << endl;
   f_service_.indent_up();
 
   string argsname = capitalize(tfunction->get_name()) + "_args";
@@ -1028,8 +1006,7 @@ void t_rb_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
     f_service_ << "result.success = ";
   }
-  f_service_ <<
-    "@handler." << tfunction->get_name() << "(";
+  f_service_ << "@handler." << tfunction->get_name() << "(";
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
@@ -1044,11 +1021,12 @@ void t_rb_generator::generate_process_function(t_service* tservice,
   if (!tfunction->is_oneway() && xceptions.size() > 0) {
     f_service_.indent_down();
     for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-      f_service_.indent() << "rescue " << full_type_name((*x_iter)->get_type()) << " => " <<
-        (*x_iter)->get_name() << endl;
+      f_service_.indent() << "rescue " << full_type_name((*x_iter)->get_type()) << " => "
+                          << (*x_iter)->get_name() << endl;
       if (!tfunction->is_oneway()) {
         f_service_.indent_up();
-        f_service_.indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
+        f_service_.indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name()
+                            << endl;
         f_service_.indent_down();
       }
     }
@@ -1063,7 +1041,8 @@ void t_rb_generator::generate_process_function(t_service* tservice,
     return;
   }
 
-  f_service_.indent() << "write_result(result, oprot, '" << tfunction->get_name() << "', seqid)" << endl;
+  f_service_.indent() << "write_result(result, oprot, '" << tfunction->get_name() << "', seqid)"
+                      << endl;
 
   // Close function
   f_service_.indent_down();
@@ -1076,12 +1055,9 @@ void t_rb_generator::generate_process_function(t_service* tservice,
  * @param tfunction Function definition
  * @return String of rendered function definition
  */
-string t_rb_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
+string t_rb_generator::function_signature(t_function* tfunction, string prefix) {
   // TODO(mcslee): Nitpicky, no ',' if argument_list is empty
-  return
-    prefix + tfunction->get_name() +
-    "(" +  argument_list(tfunction->get_arglist()) + ")";
+  return prefix + tfunction->get_name() + "(" + argument_list(tfunction->get_arglist()) + ")";
 }
 
 /**
@@ -1118,8 +1094,7 @@ string t_rb_generator::type_name(t_type* ttype) {
 string t_rb_generator::full_type_name(t_type* ttype) {
   string prefix = "::";
   vector<std::string> modules = ruby_modules(ttype->get_program());
-  for (vector<std::string>::iterator m_iter = modules.begin();
-       m_iter != modules.end(); ++m_iter) {
+  for (vector<std::string>::iterator m_iter = modules.begin(); m_iter != modules.end(); ++m_iter) {
     prefix += *m_iter + "::";
   }
   return prefix + type_name(ttype);
@@ -1174,7 +1149,7 @@ string t_rb_generator::rb_namespace_to_path_prefix(string rb_namespace) {
 
   while ((loc = namespaces_left.find(".")) != string::npos) {
     path_prefix = path_prefix + underscore(namespaces_left.substr(0, loc)) + "/";
-    namespaces_left = namespaces_left.substr(loc+1);
+    namespaces_left = namespaces_left.substr(loc + 1);
   }
   if (namespaces_left.size() > 0) {
     path_prefix = path_prefix + underscore(namespaces_left) + "/";
@@ -1182,17 +1157,14 @@ string t_rb_generator::rb_namespace_to_path_prefix(string rb_namespace) {
   return path_prefix;
 }
 
-
 void t_rb_generator::generate_rdoc(t_rb_ofstream& out, t_doc* tdoc) {
   if (tdoc->has_doc()) {
     out.indent();
-    generate_docstring_comment(out,
-      "", "# ", tdoc->get_doc(), "");
+    generate_docstring_comment(out, "", "# ", tdoc->get_doc(), "");
   }
 }
 
-void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out,
-                                                           t_struct* tstruct) {
+void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out, t_struct* tstruct) {
   out.indent() << "def validate" << endl;
   out.indent_up();
 
@@ -1202,9 +1174,8 @@ void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     t_field* field = (*f_iter);
     if (field->get_req() == t_field::T_REQUIRED) {
-      out.indent() <<
-        "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field " <<
-        field->get_name() << " is unset!')";
+      out.indent() << "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, "
+                      "'Required field " << field->get_name() << " is unset!')";
       if (field->get_type()->is_bool()) {
         out << " if @" << field->get_name() << ".nil?";
       } else {
@@ -1218,14 +1189,13 @@ void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     t_field* field = (*f_iter);
 
-    if (field->get_type()->is_enum()){
-      out.indent() << "unless @" << field->get_name() << ".nil? || " <<
-        full_type_name(field->get_type()) << "::VALID_VALUES.include?(@" <<
-        field->get_name() << ")" << endl;
+    if (field->get_type()->is_enum()) {
+      out.indent() << "unless @" << field->get_name() << ".nil? || "
+                   << full_type_name(field->get_type()) << "::VALID_VALUES.include?(@"
+                   << field->get_name() << ")" << endl;
       out.indent_up();
-      out.indent() <<
-        "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field " <<
-        field->get_name() << "!')" << endl;
+      out.indent() << "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, "
+                      "'Invalid value of field " << field->get_name() << "!')" << endl;
       out.indent_down();
       out.indent() << "end" << endl;
     }
@@ -1235,27 +1205,28 @@ void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out,
   out.indent() << "end" << endl << endl;
 }
 
-void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out,
-                                                 t_struct* tstruct) {
+void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out, t_struct* tstruct) {
   out.indent() << "def validate" << endl;
   out.indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
-  out.indent() <<
-    "raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?" << endl;
+  out.indent()
+      << "raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?"
+      << endl;
 
   // if field is an enum, check that its value is valid
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     const t_field* field = (*f_iter);
 
-    if (field->get_type()->is_enum()){
+    if (field->get_type()->is_enum()) {
       out.indent() << "if get_set_field == :" << field->get_name() << endl;
-      out.indent() <<
-        "  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field " <<
-        field->get_name() << "!') unless " << full_type_name(field->get_type()) <<
-        "::VALID_VALUES.include?(get_value)" << endl;
+      out.indent() << "  raise "
+                      "::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, "
+                      "'Invalid value of field " << field->get_name() << "!') unless "
+                   << full_type_name(field->get_type()) << "::VALID_VALUES.include?(get_value)"
+                   << endl;
       out.indent() << "end" << endl;
     }
   }
@@ -1264,6 +1235,8 @@ void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out,
   out.indent() << "end" << endl << endl;
 }
 
-THRIFT_REGISTER_GENERATOR(rb, "Ruby",
-"    rubygems:        Add a \"require 'rubygems'\" line to the top of each generated file.\n"
-"    namespaced:      Generate files in idiomatic namespaced directories.\n")
+THRIFT_REGISTER_GENERATOR(
+    rb,
+    "Ruby",
+    "    rubygems:        Add a \"require 'rubygems'\" line to the top of each generated file.\n"
+    "    namespaced:      Generate files in idiomatic namespaced directories.\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_st_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_st_generator.cc b/compiler/cpp/src/generate/t_st_generator.cc
index 32ffd88..9235f68 100644
--- a/compiler/cpp/src/generate/t_st_generator.cc
+++ b/compiler/cpp/src/generate/t_st_generator.cc
@@ -43,22 +43,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Smalltalk code generator.
  *
  */
 class t_st_generator : public t_oop_generator {
- public:
-  t_st_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_st_generator(t_program* program,
+                 const std::map<std::string, std::string>& parsed_options,
+                 const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-st";
   }
 
@@ -73,15 +71,14 @@ class t_st_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef     (t_typedef*  ttypedef);
-  void generate_enum        (t_enum*     tenum);
-  void generate_const       (t_const*    tconst);
-  void generate_struct      (t_struct*   tstruct);
-  void generate_xception    (t_struct*   txception);
-  void generate_service     (t_service*  tservice);
-  void generate_class_side_definition ();
-  void generate_force_consts ();
-
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+  void generate_class_side_definition();
+  void generate_force_consts();
 
   std::string render_const_value(t_type* type, t_const_value* value);
 
@@ -89,30 +86,30 @@ class t_st_generator : public t_oop_generator {
    * Struct generation code
    */
 
-  void generate_st_struct (std::ofstream& out, t_struct* tstruct, bool is_exception);
-  void generate_accessors   (std::ofstream& out, t_struct* tstruct);
+  void generate_st_struct(std::ofstream& out, t_struct* tstruct, bool is_exception);
+  void generate_accessors(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_client    (t_service* tservice);
+  void generate_service_client(t_service* tservice);
 
-  void generate_send_method (t_function* tfunction);
-  void generate_recv_method (t_function* tfunction);
+  void generate_send_method(t_function* tfunction);
+  void generate_recv_method(t_function* tfunction);
 
-  std::string map_reader (t_map *tmap);
-  std::string list_reader (t_list *tlist);
-  std::string set_reader (t_set *tset);
-  std::string struct_reader (t_struct *tstruct, std::string clsName);
+  std::string map_reader(t_map* tmap);
+  std::string list_reader(t_list* tlist);
+  std::string set_reader(t_set* tset);
+  std::string struct_reader(t_struct* tstruct, std::string clsName);
 
-  std::string map_writer (t_map *tmap, std::string name);
-  std::string list_writer (t_list *tlist, std::string name);
-  std::string set_writer (t_set *tset, std::string name);
-  std::string struct_writer (t_struct *tstruct, std::string fname);
+  std::string map_writer(t_map* tmap, std::string name);
+  std::string list_writer(t_list* tlist, std::string name);
+  std::string set_writer(t_set* tset, std::string name);
+  std::string struct_writer(t_struct* tstruct, std::string fname);
 
-  std::string write_val (t_type *t, std::string fname);
-  std::string read_val (t_type *t);
+  std::string write_val(t_type* t, std::string fname);
+  std::string read_val(t_type* t);
 
   /**
    * Helper rendering functions
@@ -120,15 +117,15 @@ class t_st_generator : public t_oop_generator {
 
   std::string st_autogen_comment();
 
-  void st_class_def(std::ofstream &out, std::string name);
-  void st_method(std::ofstream &out, std::string cls, std::string name);
-  void st_method(std::ofstream &out, std::string cls, std::string name, std::string category);
-  void st_close_method(std::ofstream &out);
-  void st_class_method(std::ofstream &out, std::string cls, std::string name);
-  void st_class_method(std::ofstream &out, std::string cls, std::string name, std::string category);
-  void st_setter(std::ofstream &out, std::string cls, std::string name, std::string type);
-  void st_getter(std::ofstream &out, std::string cls, std::string name);
-  void st_accessors(std::ofstream &out, std::string cls, std::string name, std::string type);
+  void st_class_def(std::ofstream& out, std::string name);
+  void st_method(std::ofstream& out, std::string cls, std::string name);
+  void st_method(std::ofstream& out, std::string cls, std::string name, std::string category);
+  void st_close_method(std::ofstream& out);
+  void st_class_method(std::ofstream& out, std::string cls, std::string name);
+  void st_class_method(std::ofstream& out, std::string cls, std::string name, std::string category);
+  void st_setter(std::ofstream& out, std::string cls, std::string name, std::string type);
+  void st_getter(std::ofstream& out, std::string cls, std::string name);
+  void st_accessors(std::ofstream& out, std::string cls, std::string name, std::string type);
 
   std::string class_name();
   static bool is_valid_namespace(const std::string& sub_namespace);
@@ -147,17 +144,14 @@ class t_st_generator : public t_oop_generator {
   std::string temp_name();
   std::string generated_category();
 
- private:
-
+private:
   /**
    * File streams
    */
   int temporary_var;
   std::ofstream f_;
-
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -171,7 +165,7 @@ void t_st_generator::init_generator() {
   temporary_var = 0;
 
   // Make output file
-  string f_name = get_out_dir()+"/"+program_name_+".st";
+  string f_name = get_out_dir() + "/" + program_name_ + ".st";
   f_.open(f_name.c_str());
 
   // Print header
@@ -180,7 +174,7 @@ void t_st_generator::init_generator() {
   st_class_def(f_, program_name_);
   generate_class_side_definition();
 
-  //Generate enums
+  // Generate enums
   vector<t_enum*> enums = program_->get_enums();
   vector<t_enum*>::iterator en_iter;
   for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) {
@@ -211,21 +205,16 @@ string t_st_generator::client_class_name() {
  * Autogen'd comment
  */
 string t_st_generator::st_autogen_comment() {
-  return
-    std::string("'") +
-    "Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "\n" +
-    "DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-    "'!\n";
+  return std::string("'") + "Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" + "\n"
+         + "DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" + "'!\n";
 }
 
 void t_st_generator::generate_force_consts() {
-  f_ << prefix(class_name()) << " enums keysAndValuesDo: [:k :v | " <<
-    prefix(class_name()) << " enums at: k put: v value].!" << endl;
-
-  f_ << prefix(class_name()) << " constants keysAndValuesDo: [:k :v | " <<
-    prefix(class_name()) << " constants at: k put: v value].!" << endl;
+  f_ << prefix(class_name()) << " enums keysAndValuesDo: [:k :v | " << prefix(class_name())
+     << " enums at: k put: v value].!" << endl;
 
+  f_ << prefix(class_name()) << " constants keysAndValuesDo: [:k :v | " << prefix(class_name())
+     << " constants at: k put: v value].!" << endl;
 }
 
 void t_st_generator::close_generator() {
@@ -251,72 +240,76 @@ string t_st_generator::generated_category() {
  * @param ttypedef The type definition
  */
 void t_st_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
-void t_st_generator::st_class_def(std::ofstream &out, string name) {
+void t_st_generator::st_class_def(std::ofstream& out, string name) {
   out << "Object subclass: #" << prefix(name) << endl;
   indent_up();
-  out << indent() << "instanceVariableNames: ''" << endl <<
-    indent() << "classVariableNames: ''" << endl <<
-    indent() << "poolDictionaries: ''" << endl <<
-    indent() << "category: '" << generated_category() << "'!" << endl << endl;
+  out << indent() << "instanceVariableNames: ''" << endl << indent() << "classVariableNames: ''"
+      << endl << indent() << "poolDictionaries: ''" << endl << indent() << "category: '"
+      << generated_category() << "'!" << endl << endl;
 }
 
-void t_st_generator::st_method(std::ofstream &out, string cls, string name) {
+void t_st_generator::st_method(std::ofstream& out, string cls, string name) {
   st_method(out, cls, name, "as yet uncategorized");
 }
 
-void t_st_generator::st_class_method(std::ofstream &out, string cls, string name) {
+void t_st_generator::st_class_method(std::ofstream& out, string cls, string name) {
   st_method(out, cls + " class", name);
 }
 
-void t_st_generator::st_class_method(std::ofstream &out, string cls, string name, string category) {
+void t_st_generator::st_class_method(std::ofstream& out, string cls, string name, string category) {
   st_method(out, cls, name, category);
 }
 
-void t_st_generator::st_method(std::ofstream &out, string cls, string name, string category) {
+void t_st_generator::st_method(std::ofstream& out, string cls, string name, string category) {
   char timestr[50];
   time_t rawtime;
-  struct tm *tinfo;
+  struct tm* tinfo;
 
   time(&rawtime);
   tinfo = localtime(&rawtime);
   strftime(timestr, 50, "%m/%d/%Y %H:%M", tinfo);
 
-  out << "!" << prefix(cls) <<
-    " methodsFor: '"+category+"' stamp: 'thrift " << timestr << "'!\n" <<
-    name << endl;
+  out << "!" << prefix(cls) << " methodsFor: '" + category + "' stamp: 'thrift " << timestr
+      << "'!\n" << name << endl;
 
   indent_up();
   out << indent();
 }
 
-void t_st_generator::st_close_method(std::ofstream &out) {
+void t_st_generator::st_close_method(std::ofstream& out) {
   out << "! !" << endl << endl;
   indent_down();
 }
 
-void t_st_generator::st_setter(std::ofstream &out, string cls, string name, string type = "anObject") {
+void t_st_generator::st_setter(std::ofstream& out,
+                               string cls,
+                               string name,
+                               string type = "anObject") {
   st_method(out, cls, name + ": " + type);
   out << name << " := " + type;
   st_close_method(out);
 }
 
-void t_st_generator::st_getter(std::ofstream &out, string cls, string name) {
+void t_st_generator::st_getter(std::ofstream& out, string cls, string name) {
   st_method(out, cls, name + "");
   out << "^ " << name;
   st_close_method(out);
 }
 
-void t_st_generator::st_accessors(std::ofstream &out, string cls, string name, string type = "anObject") {
+void t_st_generator::st_accessors(std::ofstream& out,
+                                  string cls,
+                                  string name,
+                                  string type = "anObject") {
   st_setter(out, cls, name, type);
   st_getter(out, cls, name);
 }
 
 void t_st_generator::generate_class_side_definition() {
-  f_ << prefix(class_name()) << " class" << endl <<
-    "\tinstanceVariableNames: 'constants enums'!" << endl << endl;
+  f_ << prefix(class_name()) << " class" << endl << "\tinstanceVariableNames: 'constants enums'!"
+     << endl << endl;
 
   st_accessors(f_, class_name() + " class", "enums");
   st_accessors(f_, class_name() + " class", "constants");
@@ -336,8 +329,8 @@ void t_st_generator::generate_class_side_definition() {
 void t_st_generator::generate_enum(t_enum* tenum) {
   string cls_name = program_name_ + capitalize(tenum->get_name());
 
-  f_ << prefix(class_name()) << " enums at: '" << tenum->get_name() << "' put: [" <<
-    "(Dictionary new " << endl;
+  f_ << prefix(class_name()) << " enums at: '" << tenum->get_name() << "' put: ["
+     << "(Dictionary new " << endl;
 
   vector<t_enum_value*> constants = tenum->get_constants();
   vector<t_enum_value*>::iterator c_iter;
@@ -357,8 +350,8 @@ void t_st_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
   t_const_value* value = tconst->get_value();
 
-  f_ << prefix(class_name()) << " constants at: '" << name << "' put: [" <<
-    render_const_value(type, value) << "]!" << endl << endl;
+  f_ << prefix(class_name()) << " constants at: '" << name << "' put: ["
+     << render_const_value(type, value) << "]!" << endl << endl;
 }
 
 /**
@@ -416,8 +409,8 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) {
         throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
       }
 
-      out << indent() << v_iter->first->get_string() << ": " <<
-        render_const_value(field_type, v_iter->second) << ";" << endl;
+      out << indent() << v_iter->first->get_string() << ": "
+          << render_const_value(field_type, v_iter->second) << ";" << endl;
     }
     out << indent() << "yourself)";
 
@@ -490,7 +483,9 @@ void t_st_generator::generate_xception(t_struct* txception) {
 /**
  * Generates a smalltalk class to represent a struct
  */
-void t_st_generator::generate_st_struct(std::ofstream& out, t_struct* tstruct, bool is_exception = false) {
+void t_st_generator::generate_st_struct(std::ofstream& out,
+                                        t_struct* tstruct,
+                                        bool is_exception = false) {
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
@@ -499,27 +494,31 @@ void t_st_generator::generate_st_struct(std::ofstream& out, t_struct* tstruct, b
   else
     out << "Object";
 
-  out << " subclass: #" << prefix(type_name(tstruct)) << endl <<
-    "\tinstanceVariableNames: '";
+  out << " subclass: #" << prefix(type_name(tstruct)) << endl << "\tinstanceVariableNames: '";
 
   if (members.size() > 0) {
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-      if (m_iter != members.begin()) out << " ";
+      if (m_iter != members.begin())
+        out << " ";
       out << camelcase((*m_iter)->get_name());
     }
   }
 
-  out << "'\n" <<
-    "\tclassVariableNames: ''\n" <<
-    "\tpoolDictionaries: ''\n" <<
-    "\tcategory: '" << generated_category() << "'!\n\n";
+  out << "'\n"
+      << "\tclassVariableNames: ''\n"
+      << "\tpoolDictionaries: ''\n"
+      << "\tcategory: '" << generated_category() << "'!\n\n";
 
   generate_accessors(out, tstruct);
 }
 
 bool t_st_generator::is_vowel(char c) {
-  switch(tolower(c)) {
-    case 'a': case 'e': case 'i': case 'o': case 'u':
+  switch (tolower(c)) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
     return true;
   }
   return false;
@@ -569,30 +568,30 @@ string t_st_generator::temp_name() {
   return out.str();
 }
 
-string t_st_generator::map_writer(t_map *tmap, string fname) {
+string t_st_generator::map_writer(t_map* tmap, string fname) {
   std::ostringstream out;
   string key = temp_name();
   string val = temp_name();
 
-  out << "[oprot writeMapBegin: (TMap new keyType: " << type_to_enum(tmap->get_key_type()) <<
-    "; valueType: " << type_to_enum(tmap->get_val_type()) << "; size: " << fname << " size)." << endl;
+  out << "[oprot writeMapBegin: (TMap new keyType: " << type_to_enum(tmap->get_key_type())
+      << "; valueType: " << type_to_enum(tmap->get_val_type()) << "; size: " << fname << " size)."
+      << endl;
   indent_up();
 
   out << indent() << fname << " keysAndValuesDo: [:" << key << " :" << val << " |" << endl;
   indent_up();
 
-  out << indent() << write_val(tmap->get_key_type(), key) << "." << endl <<
-    indent() << write_val(tmap->get_val_type(), val);
+  out << indent() << write_val(tmap->get_key_type(), key) << "." << endl << indent()
+      << write_val(tmap->get_val_type(), val);
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "oprot writeMapEnd] value";
+  out << "]." << endl << indent() << "oprot writeMapEnd] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::map_reader(t_map *tmap) {
+string t_st_generator::map_reader(t_map* tmap) {
   std::ostringstream out;
   string desc = temp_name();
   string val = temp_name();
@@ -600,29 +599,26 @@ string t_st_generator::map_reader(t_map *tmap) {
   out << "[|" << desc << " " << val << "| " << endl;
   indent_up();
 
-  out << indent() << desc << " := iprot readMapBegin." << endl <<
-    indent() << val << " := Dictionary new." << endl <<
-    indent() << desc << " size timesRepeat: [" << endl;
+  out << indent() << desc << " := iprot readMapBegin." << endl << indent() << val
+      << " := Dictionary new." << endl << indent() << desc << " size timesRepeat: [" << endl;
 
   indent_up();
-  out << indent() << val << " at: " << read_val(tmap->get_key_type()) <<
-    " put: " << read_val(tmap->get_val_type());
+  out << indent() << val << " at: " << read_val(tmap->get_key_type())
+      << " put: " << read_val(tmap->get_val_type());
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "iprot readMapEnd." << endl <<
-  indent() << val << "] value";
+  out << "]." << endl << indent() << "iprot readMapEnd." << endl << indent() << val << "] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::list_writer(t_list *tlist, string fname) {
+string t_st_generator::list_writer(t_list* tlist, string fname) {
   std::ostringstream out;
   string val = temp_name();
 
-  out << "[oprot writeListBegin: (TList new elemType: " <<
-    type_to_enum(tlist->get_elem_type()) << "; size: " << fname << " size)." << endl;
+  out << "[oprot writeListBegin: (TList new elemType: " << type_to_enum(tlist->get_elem_type())
+      << "; size: " << fname << " size)." << endl;
   indent_up();
 
   out << indent() << fname << " do: [:" << val << "|" << endl;
@@ -631,14 +627,13 @@ string t_st_generator::list_writer(t_list *tlist, string fname) {
   out << indent() << write_val(tlist->get_elem_type(), val) << endl;
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "oprot writeListEnd] value";
+  out << "]." << endl << indent() << "oprot writeListEnd] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::list_reader(t_list *tlist) {
+string t_st_generator::list_reader(t_list* tlist) {
   std::ostringstream out;
   string desc = temp_name();
   string val = temp_name();
@@ -646,27 +641,25 @@ string t_st_generator::list_reader(t_list *tlist) {
   out << "[|" << desc << " " << val << "| " << desc << " := iprot readListBegin." << endl;
   indent_up();
 
-  out << indent() << val << " := OrderedCollection new." << endl <<
-    indent() << desc << " size timesRepeat: [" << endl;
+  out << indent() << val << " := OrderedCollection new." << endl << indent() << desc
+      << " size timesRepeat: [" << endl;
 
   indent_up();
   out << indent() << val << " add: " << read_val(tlist->get_elem_type());
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "iprot readListEnd." << endl <<
-  indent() << val << "] value";
+  out << "]." << endl << indent() << "iprot readListEnd." << endl << indent() << val << "] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::set_writer(t_set *tset, string fname) {
+string t_st_generator::set_writer(t_set* tset, string fname) {
   std::ostringstream out;
   string val = temp_name();
 
-  out << "[oprot writeSetBegin: (TSet new elemType: " << type_to_enum(tset->get_elem_type()) <<
-    "; size: " << fname << " size)." << endl;
+  out << "[oprot writeSetBegin: (TSet new elemType: " << type_to_enum(tset->get_elem_type())
+      << "; size: " << fname << " size)." << endl;
   indent_up();
 
   out << indent() << fname << " do: [:" << val << "|" << endl;
@@ -675,14 +668,13 @@ string t_st_generator::set_writer(t_set *tset, string fname) {
   out << indent() << write_val(tset->get_elem_type(), val) << endl;
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "oprot writeSetEnd] value";
+  out << "]." << endl << indent() << "oprot writeSetEnd] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::set_reader(t_set *tset) {
+string t_st_generator::set_reader(t_set* tset) {
   std::ostringstream out;
   string desc = temp_name();
   string val = temp_name();
@@ -690,28 +682,26 @@ string t_st_generator::set_reader(t_set *tset) {
   out << "[|" << desc << " " << val << "| " << desc << " := iprot readSetBegin." << endl;
   indent_up();
 
-  out << indent() << val << " := Set new." << endl <<
-    indent() << desc << " size timesRepeat: [" << endl;
+  out << indent() << val << " := Set new." << endl << indent() << desc << " size timesRepeat: ["
+      << endl;
 
   indent_up();
   out << indent() << val << " add: " << read_val(tset->get_elem_type());
   indent_down();
 
-  out << "]." << endl <<
-    indent() << "iprot readSetEnd." << endl <<
-  indent() << val << "] value";
+  out << "]." << endl << indent() << "iprot readSetEnd." << endl << indent() << val << "] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::struct_writer(t_struct *tstruct, string sname) {
+string t_st_generator::struct_writer(t_struct* tstruct, string sname) {
   std::ostringstream out;
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   vector<t_field*>::const_iterator fld_iter;
 
-  out << "[oprot writeStructBegin: " <<
-    "(TStruct new name: '" + tstruct->get_name() +"')." << endl;
+  out << "[oprot writeStructBegin: "
+      << "(TStruct new name: '" + tstruct->get_name() + "')." << endl;
   indent_up();
 
   for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -724,12 +714,12 @@ string t_st_generator::struct_writer(t_struct *tstruct, string sname) {
       indent_up();
     }
 
-    out << indent() << "oprot writeFieldBegin: (TField new name: '" << fname <<
-      "'; type: " << type_to_enum((*fld_iter)->get_type()) <<
-      "; id: " << (*fld_iter)->get_key() << ")." << endl;
+    out << indent() << "oprot writeFieldBegin: (TField new name: '" << fname
+        << "'; type: " << type_to_enum((*fld_iter)->get_type())
+        << "; id: " << (*fld_iter)->get_key() << ")." << endl;
 
-    out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << endl <<
-      indent() << "oprot writeFieldEnd";
+    out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << endl << indent()
+        << "oprot writeFieldEnd";
 
     if (optional) {
       out << "]";
@@ -745,7 +735,7 @@ string t_st_generator::struct_writer(t_struct *tstruct, string sname) {
   return out.str();
 }
 
-string t_st_generator::struct_reader(t_struct *tstruct, string clsName = "") {
+string t_st_generator::struct_reader(t_struct* tstruct, string clsName = "") {
   std::ostringstream out;
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator fld_iter;
@@ -760,23 +750,21 @@ string t_st_generator::struct_reader(t_struct *tstruct, string clsName = "") {
   out << "[|" << desc << " " << val << "|" << endl;
   indent_up();
 
-  //This is nasty, but without it we'll break things by prefixing TResult.
+  // This is nasty, but without it we'll break things by prefixing TResult.
   string name = ((capitalize(clsName) == "TResult") ? capitalize(clsName) : prefix(clsName));
   out << indent() << val << " := " << name << " new." << endl;
 
-  out << indent() << "iprot readStructBegin." << endl <<
-    indent() << "[" << desc << " := iprot readFieldBegin." << endl <<
-    indent() << desc << " type = TType stop] whileFalse: [|" << found << "|" << endl;
+  out << indent() << "iprot readStructBegin." << endl << indent() << "[" << desc
+      << " := iprot readFieldBegin." << endl << indent() << desc
+      << " type = TType stop] whileFalse: [|" << found << "|" << endl;
   indent_up();
 
   for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-    out << indent() << desc << " id = " << (*fld_iter)->get_key() <<
-      " ifTrue: [" << endl;
+    out << indent() << desc << " id = " << (*fld_iter)->get_key() << " ifTrue: [" << endl;
     indent_up();
 
-    out << indent() << found << " := true." << endl <<
-      indent() << val << " " << camelcase((*fld_iter)->get_name()) << ": " <<
-      read_val((*fld_iter)->get_type());
+    out << indent() << found << " := true." << endl << indent() << val << " "
+        << camelcase((*fld_iter)->get_name()) << ": " << read_val((*fld_iter)->get_type());
     indent_down();
 
     out << "]." << endl;
@@ -785,19 +773,18 @@ string t_st_generator::struct_reader(t_struct *tstruct, string clsName = "") {
   out << indent() << found << " ifNil: [iprot skip: " << desc << " type]]." << endl;
   indent_down();
 
-  out << indent() << "oprot readStructEnd." << endl <<
-    indent() << val << "] value";
+  out << indent() << "oprot readStructEnd." << endl << indent() << val << "] value";
   indent_down();
 
   return out.str();
 }
 
-string t_st_generator::write_val(t_type *t, string fname) {
+string t_st_generator::write_val(t_type* t, string fname) {
   t = get_true_type(t);
 
   if (t->is_base_type()) {
-    t_base_type::t_base tbase = ((t_base_type*) t)->get_base();
-    switch(tbase) {
+    t_base_type::t_base tbase = ((t_base_type*)t)->get_base();
+    switch (tbase) {
     case t_base_type::TYPE_DOUBLE:
       return "iprot writeDouble: " + fname + " asFloat";
       break;
@@ -810,13 +797,13 @@ string t_st_generator::write_val(t_type *t, string fname) {
       return "iprot write" + capitalize(type_name(t)) + ": " + fname;
     }
   } else if (t->is_map()) {
-    return map_writer((t_map*) t, fname);
+    return map_writer((t_map*)t, fname);
   } else if (t->is_struct() || t->is_xception()) {
-    return struct_writer((t_struct*) t, fname);
+    return struct_writer((t_struct*)t, fname);
   } else if (t->is_list()) {
-    return list_writer((t_list*) t, fname);
+    return list_writer((t_list*)t, fname);
   } else if (t->is_set()) {
-    return set_writer((t_set*) t, fname);
+    return set_writer((t_set*)t, fname);
   } else if (t->is_enum()) {
     return "iprot writeI32: " + fname;
   } else {
@@ -824,19 +811,19 @@ string t_st_generator::write_val(t_type *t, string fname) {
   }
 }
 
-string t_st_generator::read_val(t_type *t) {
+string t_st_generator::read_val(t_type* t) {
   t = get_true_type(t);
 
   if (t->is_base_type()) {
     return "iprot read" + capitalize(type_name(t));
   } else if (t->is_map()) {
-    return map_reader((t_map*) t);
+    return map_reader((t_map*)t);
   } else if (t->is_struct() || t->is_xception()) {
-    return struct_reader((t_struct*) t);
+    return struct_reader((t_struct*)t);
   } else if (t->is_list()) {
-    return list_reader((t_list*) t);
+    return list_reader((t_list*)t);
   } else if (t->is_set()) {
-    return set_reader((t_set*) t);
+    return set_reader((t_set*)t);
   } else if (t->is_enum()) {
     return "iprot readI32";
   } else {
@@ -858,23 +845,23 @@ void t_st_generator::generate_send_method(t_function* function) {
   f_ << indent() << "(TCallMessage new" << endl;
   indent_up();
 
-  f_ << indent() << "name: '" << funname << "'; " << endl <<
-    indent() << "seqid: self nextSeqid)." << endl;
+  f_ << indent() << "name: '" << funname << "'; " << endl << indent() << "seqid: self nextSeqid)."
+     << endl;
   indent_down();
   indent_down();
 
-  f_ << indent() << "oprot writeStructBegin: " <<
-    "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << endl;
+  f_ << indent() << "oprot writeStructBegin: "
+     << "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << endl;
 
   for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
     string fname = camelcase((*fld_iter)->get_name());
 
-    f_ << indent() << "oprot writeFieldBegin: (TField new name: '" << fname <<
-      "'; type: " << type_to_enum((*fld_iter)->get_type()) <<
-      "; id: " << (*fld_iter)->get_key() << ")." << endl;
+    f_ << indent() << "oprot writeFieldBegin: (TField new name: '" << fname
+       << "'; type: " << type_to_enum((*fld_iter)->get_type()) << "; id: " << (*fld_iter)->get_key()
+       << ")." << endl;
 
-    f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << endl <<
-      indent() << "oprot writeFieldEnd." << endl;
+    f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << endl << indent()
+       << "oprot writeFieldEnd." << endl;
   }
 
   f_ << indent() << "oprot writeFieldStop; writeStructEnd; writeMessageEnd." << endl;
@@ -897,19 +884,16 @@ void t_st_generator::generate_recv_method(t_function* function) {
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     // duplicate the field, but call it "exception"... we don't need a dynamic name
-    t_field *exception = new t_field((*f_iter)->get_type(), "exception", (*f_iter)->get_key());
+    t_field* exception = new t_field((*f_iter)->get_type(), "exception", (*f_iter)->get_key());
     result.append(exception);
   }
 
   st_method(f_, client_class_name(), "recv" + capitalize(funname));
-  f_ << "| f msg res | " << endl <<
-    indent() << "msg := oprot readMessageBegin." << endl <<
-    indent() << "self validateRemoteMessage: msg." << endl <<
-    indent() << "res := " << struct_reader(&result) << "." << endl <<
-    indent() << "oprot readMessageEnd." << endl <<
-    indent() << "oprot transport flush." << endl <<
-    indent() << "res exception ifNotNil: [res exception signal]." << endl <<
-    indent() << "^ res";
+  f_ << "| f msg res | " << endl << indent() << "msg := oprot readMessageBegin." << endl << indent()
+     << "self validateRemoteMessage: msg." << endl << indent()
+     << "res := " << struct_reader(&result) << "." << endl << indent() << "oprot readMessageEnd."
+     << endl << indent() << "oprot transport flush." << endl << indent()
+     << "res exception ifNotNil: [res exception signal]." << endl << indent() << "^ res";
   st_close_method(f_);
 }
 
@@ -948,19 +932,19 @@ void t_st_generator::generate_service_client(t_service* tservice) {
     extends_client = extends + "Client";
   }
 
-  f_ << extends_client << " subclass: #" << prefix(client_class_name()) << endl <<
-    "\tinstanceVariableNames: ''\n" <<
-    "\tclassVariableNames: ''\n" <<
-    "\tpoolDictionaries: ''\n" <<
-    "\tcategory: '" << generated_category() << "'!\n\n";
+  f_ << extends_client << " subclass: #" << prefix(client_class_name()) << endl
+     << "\tinstanceVariableNames: ''\n"
+     << "\tclassVariableNames: ''\n"
+     << "\tpoolDictionaries: ''\n"
+     << "\tcategory: '" << generated_category() << "'!\n\n";
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     string funname = camelcase((*f_iter)->get_name());
     string signature = function_signature(*f_iter);
 
     st_method(f_, client_class_name(), signature);
-    f_ << function_types_comment(*f_iter) << endl <<
-      indent() << "self send" << capitalize(signature) << "." << endl;
+    f_ << function_types_comment(*f_iter) << endl << indent() << "self send"
+       << capitalize(signature) << "." << endl;
 
     if (!(*f_iter)->is_oneway()) {
       f_ << indent() << "^ self recv" << capitalize(funname) << " success " << endl;
@@ -1062,6 +1046,4 @@ string t_st_generator::type_to_enum(t_type* type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 THRIFT_REGISTER_GENERATOR(st, "Smalltalk", "")
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_xsd_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_xsd_generator.cc b/compiler/cpp/src/generate/t_xsd_generator.cc
index 7135f6a..ed76bec 100644
--- a/compiler/cpp/src/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/generate/t_xsd_generator.cc
@@ -35,22 +35,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * XSD generator, creates an XSD for the base types etc.
  *
  */
 class t_xsd_generator : public t_generator {
- public:
-  t_xsd_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_xsd_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-xsd";
   }
 
@@ -68,24 +66,23 @@ class t_xsd_generator : public t_generator {
    */
 
   void generate_typedef(t_typedef* ttypedef);
-  void generate_enum(t_enum* tenum) {
-    (void) tenum;
-  }
+  void generate_enum(t_enum* tenum) { (void)tenum; }
 
   void generate_service(t_service* tservice);
   void generate_struct(t_struct* tstruct);
 
- private:
+private:
+  void generate_element(std::ostream& out,
+                        std::string name,
+                        t_type* ttype,
+                        t_struct* attrs = NULL,
+                        bool optional = false,
+                        bool nillable = false,
+                        bool list_element = false);
 
-  void generate_element(std::ostream& out, std::string name, t_type* ttype, t_struct* attrs=NULL, bool optional=false, bool nillable=false, bool list_element=false);
+  std::string ns(std::string in, std::string ns) { return ns + ":" + in; }
 
-  std::string ns(std::string in, std::string ns) {
-    return ns + ":" + in;
-  }
-
-  std::string xsd(std::string in) {
-    return ns(in, "xsd");
-  }
+  std::string xsd(std::string in) { return ns(in, "xsd"); }
 
   std::string type_name(t_type* ttype);
   std::string base_type_name(t_base_type::t_base tbase);
@@ -100,21 +97,17 @@ class t_xsd_generator : public t_generator {
    * Output string stream
    */
   std::ostringstream s_xsd_types_;
-
 };
 
-
 void t_xsd_generator::init_generator() {
   // Make output directory
   MKDIR(get_out_dir().c_str());
 
   // Make output file
-  string f_php_name = get_out_dir()+program_->get_name()+"_xsd.php";
+  string f_php_name = get_out_dir() + program_->get_name() + "_xsd.php";
   f_php_.open(f_php_name.c_str());
 
-  f_php_ <<
-    "<?php" << endl;
-
+  f_php_ << "<?php" << endl;
 }
 
 void t_xsd_generator::close_generator() {
@@ -123,29 +116,25 @@ void t_xsd_generator::close_generator() {
 }
 
 void t_xsd_generator::generate_typedef(t_typedef* ttypedef) {
-  indent(s_xsd_types_) <<
-    "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << endl;
+  indent(s_xsd_types_) << "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << endl;
   indent_up();
   if (ttypedef->get_type()->is_string() && ((t_base_type*)ttypedef->get_type())->is_string_enum()) {
-    indent(s_xsd_types_) <<
-      "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\">" << endl;
+    indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\">"
+                         << endl;
     indent_up();
     const vector<string>& values = ((t_base_type*)ttypedef->get_type())->get_string_enum_vals();
     vector<string>::const_iterator v_iter;
     for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
-      indent(s_xsd_types_) <<
-        "<xsd:enumeration value=\"" << (*v_iter) << "\" />" << endl;
+      indent(s_xsd_types_) << "<xsd:enumeration value=\"" << (*v_iter) << "\" />" << endl;
     }
     indent_down();
-    indent(s_xsd_types_) <<
-      "</xsd:restriction>" << endl;
+    indent(s_xsd_types_) << "</xsd:restriction>" << endl;
   } else {
-    indent(s_xsd_types_) <<
-      "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />" << endl;
+    indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
+                         << endl;
   }
   indent_down();
-  indent(s_xsd_types_) <<
-    "</xsd:simpleType>" << endl << endl;
+  indent(s_xsd_types_) << "</xsd:simpleType>" << endl << endl;
 }
 
 void t_xsd_generator::generate_struct(t_struct* tstruct) {
@@ -163,7 +152,12 @@ void t_xsd_generator::generate_struct(t_struct* tstruct) {
   indent_up();
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    generate_element(s_xsd_types_, (*m_iter)->get_name(), (*m_iter)->get_type(), (*m_iter)->get_xsd_attrs(), (*m_iter)->get_xsd_optional() || xsd_all, (*m_iter)->get_xsd_nillable());
+    generate_element(s_xsd_types_,
+                     (*m_iter)->get_name(),
+                     (*m_iter)->get_type(),
+                     (*m_iter)->get_xsd_attrs(),
+                     (*m_iter)->get_xsd_optional() || xsd_all,
+                     (*m_iter)->get_xsd_nillable());
   }
 
   indent_down();
@@ -173,9 +167,7 @@ void t_xsd_generator::generate_struct(t_struct* tstruct) {
     indent(s_xsd_types_) << "</xsd:sequence>" << endl;
   }
   indent_down();
-  indent(s_xsd_types_) <<
-    "</xsd:complexType>" << endl <<
-    endl;
+  indent(s_xsd_types_) << "</xsd:complexType>" << endl << endl;
 }
 
 void t_xsd_generator::generate_element(ostream& out,
@@ -191,15 +183,12 @@ void t_xsd_generator::generate_element(ostream& out,
   string snillable = nillable ? " nillable=\"true\"" : "";
 
   if (ttype->is_void() || ttype->is_list()) {
-    indent(out) <<
-      "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << endl;
+    indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << endl;
     indent_up();
     if (attrs == NULL && ttype->is_void()) {
-      indent(out) <<
-        "<xsd:complexType />" << endl;
+      indent(out) << "<xsd:complexType />" << endl;
     } else {
-      indent(out) <<
-        "<xsd:complexType>" << endl;
+      indent(out) << "<xsd:complexType>" << endl;
       indent_up();
       if (ttype->is_list()) {
         indent(out) << "<xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">" << endl;
@@ -211,7 +200,8 @@ void t_xsd_generator::generate_element(ostream& out,
         } else {
           subname = type_name(subtype);
         }
-        f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname << "';" << endl;
+        f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname
+               << "';" << endl;
         generate_element(out, subname, subtype, NULL, false, false, true);
         indent_down();
         indent(out) << "</xsd:sequence>" << endl;
@@ -221,23 +211,24 @@ void t_xsd_generator::generate_element(ostream& out,
         const vector<t_field*>& members = attrs->get_members();
         vector<t_field*>::const_iterator a_iter;
         for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) {
-          indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\"" << type_name((*a_iter)->get_type()) << "\" />" << endl;
+          indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\""
+                      << type_name((*a_iter)->get_type()) << "\" />" << endl;
         }
       }
       indent_down();
-      indent(out) <<
-        "</xsd:complexType>" << endl;
+      indent(out) << "</xsd:complexType>" << endl;
     }
     indent_down();
-    indent(out) <<
-      "</xsd:element>" << endl;
+    indent(out) << "</xsd:element>" << endl;
   } else {
     if (attrs == NULL) {
-      indent(out) <<
-        "<xsd:element name=\"" << name << "\"" << " type=\"" << type_name(ttype) << "\"" << soptional << snillable << " />" << endl;
+      indent(out) << "<xsd:element name=\"" << name << "\""
+                  << " type=\"" << type_name(ttype) << "\"" << soptional << snillable << " />"
+                  << endl;
     } else {
       // Wow, all this work for a SIMPLE TYPE with attributes?!?!?!
-      indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << endl;
+      indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">"
+                  << endl;
       indent_up();
       indent(out) << "<xsd:complexType>" << endl;
       indent_up();
@@ -248,7 +239,8 @@ void t_xsd_generator::generate_element(ostream& out,
       const vector<t_field*>& members = attrs->get_members();
       vector<t_field*>::const_iterator a_iter;
       for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) {
-        indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\"" << type_name((*a_iter)->get_type()) << "\" />" << endl;
+        indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\""
+                    << type_name((*a_iter)->get_type()) << "\" />" << endl;
       }
       indent_down();
       indent(out) << "</xsd:extension>" << endl;
@@ -264,22 +256,19 @@ void t_xsd_generator::generate_element(ostream& out,
 
 void t_xsd_generator::generate_service(t_service* tservice) {
   // Make output file
-  string f_xsd_name = get_out_dir()+tservice->get_name()+".xsd";
+  string f_xsd_name = get_out_dir() + tservice->get_name() + ".xsd";
   f_xsd_.open(f_xsd_name.c_str());
 
   string ns = program_->get_namespace("xsd");
   if (ns.size() > 0) {
-    ns = " targetNamespace=\"" + ns + "\" xmlns=\"" + ns + "\" " +
-      "elementFormDefault=\"qualified\"";
+    ns = " targetNamespace=\"" + ns + "\" xmlns=\"" + ns + "\" "
+         + "elementFormDefault=\"qualified\"";
   }
 
   // Print the XSD header
-  f_xsd_ <<
-    "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl <<
-    "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" << ns << ">" << endl <<
-    endl <<
-    "<!-- Yo yo yo, this XSD woz be generated by Thrift. -->" << endl <<
-    endl;
+  f_xsd_ << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl
+         << "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" << ns << ">" << endl
+         << endl << "<!-- Yo yo yo, this XSD woz be generated by Thrift. -->" << endl << endl;
 
   // Print out the type definitions
   indent(f_xsd_) << s_xsd_types_.str();
@@ -364,4 +353,3 @@ string t_xsd_generator::base_type_name(t_base_type::t_base tbase) {
 }
 
 THRIFT_REGISTER_GENERATOR(xsd, "XSD", "")
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/globals.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/globals.h b/compiler/cpp/src/globals.h
index cf924f1..93d11aa 100644
--- a/compiler/cpp/src/globals.h
+++ b/compiler/cpp/src/globals.h
@@ -48,10 +48,7 @@ class t_type;
  * Parsing mode, two passes up in this gin rummy!
  */
 
-enum PARSE_MODE {
-  INCLUDES = 1,
-  PROGRAM = 2
-};
+enum PARSE_MODE { INCLUDES = 1, PROGRAM = 2 };
 
 /**
  * Strictness level
@@ -119,19 +116,18 @@ extern int g_doctext_lineno;
  */
 enum PROGDOCTEXT_STATUS {
   INVALID = 0,
-  STILL_CANDIDATE = 1,      // the text may or may not be the program doctext
-  ALREADY_PROCESSED = 2,    // doctext has been used and is no longer available
-  ABSOLUTELY_SURE = 3,      // this is the program doctext
-  NO_PROGRAM_DOCTEXT = 4    // there is no program doctext
+  STILL_CANDIDATE = 1,   // the text may or may not be the program doctext
+  ALREADY_PROCESSED = 2, // doctext has been used and is no longer available
+  ABSOLUTELY_SURE = 3,   // this is the program doctext
+  NO_PROGRAM_DOCTEXT = 4 // there is no program doctext
 };
 
-
 /**
  * The program level doctext. Stored seperately to make parsing easier.
  */
 extern char* g_program_doctext_candidate;
-extern int   g_program_doctext_lineno;
-extern PROGDOCTEXT_STATUS  g_program_doctext_status;
+extern int g_program_doctext_lineno;
+extern PROGDOCTEXT_STATUS g_program_doctext_status;
 
 /**
  * Whether or not negative field keys are accepted.

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/logging.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/logging.h b/compiler/cpp/src/logging.h
index 097469d..3f1fce8 100644
--- a/compiler/cpp/src/logging.h
+++ b/compiler/cpp/src/logging.h
@@ -42,5 +42,4 @@ void pverbose(const char* fmt, ...);
  */
 void failure(const char* fmt, ...);
 
-
 #endif


[29/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_erl_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_erl_generator.cc b/compiler/cpp/src/generate/t_erl_generator.cc
index 0735ad1..8c8a2c7 100644
--- a/compiler/cpp/src/generate/t_erl_generator.cc
+++ b/compiler/cpp/src/generate/t_erl_generator.cc
@@ -38,22 +38,20 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const std::string endl = "\n";  // avoid ostream << std::endl flushes
+static const std::string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Erlang code generator.
  *
  */
 class t_erl_generator : public t_generator {
- public:
-  t_erl_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_generator(program)
-  {
-    (void) parsed_options;
-    (void) option_string;
+public:
+  t_erl_generator(t_program* program,
+                  const std::map<std::string, std::string>& parsed_options,
+                  const std::string& option_string)
+    : t_generator(program) {
+    (void)parsed_options;
+    (void)option_string;
     out_dir_base_ = "gen-erl";
 
     legacy_names_ = (parsed_options.find("legacynames") != parsed_options.end());
@@ -70,21 +68,21 @@ class t_erl_generator : public t_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef  (t_typedef*  ttypedef);
-  void generate_enum     (t_enum*     tenum);
-  void generate_const    (t_const*    tconst);
-  void generate_struct   (t_struct*   tstruct);
-  void generate_xception (t_struct*   txception);
-  void generate_service  (t_service*  tservice);
-  void generate_member_type(std::ostream & out, t_type* type);
-  void generate_member_value(std::ostream & out, t_type* type, t_const_value* value);
-
-  std::string render_member_type(t_field * field);
-  std::string render_member_value(t_field * field);
-  std::string render_member_requiredness(t_field * field);
-
-//  std::string render_default_value(t_type* type);
-  std::string render_default_value(t_field * field);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_const(t_const* tconst);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+  void generate_member_type(std::ostream& out, t_type* type);
+  void generate_member_value(std::ostream& out, t_type* type, t_const_value* value);
+
+  std::string render_member_type(t_field* field);
+  std::string render_member_value(t_field* field);
+  std::string render_member_requiredness(t_field* field);
+
+  //  std::string render_default_value(t_type* type);
+  std::string render_default_value(t_field* field);
   std::string render_const_value(t_type* type, t_const_value* value);
   std::string render_type_term(t_type* ttype, bool expand_structs, bool extended_info = false);
 
@@ -94,7 +92,7 @@ class t_erl_generator : public t_generator {
 
   void generate_erl_struct(t_struct* tstruct, bool is_exception);
   void generate_erl_struct_definition(std::ostream& out, t_struct* tstruct);
-  void generate_erl_struct_member(std::ostream& out, t_field * tmember);
+  void generate_erl_struct_member(std::ostream& out, t_field* tmember);
   void generate_erl_struct_info(std::ostream& out, t_struct* tstruct);
   void generate_erl_extended_struct_info(std::ostream& out, t_struct* tstruct);
   void generate_erl_function_helpers(t_function* tfunction);
@@ -103,9 +101,9 @@ class t_erl_generator : public t_generator {
    * Service-level generation functions
    */
 
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_interface (t_service* tservice);
-  void generate_function_info     (t_service* tservice, t_function* tfunction);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_interface(t_service* tservice);
+  void generate_function_info(t_service* tservice, t_function* tfunction);
 
   /**
    * Helper rendering functions
@@ -116,14 +114,14 @@ class t_erl_generator : public t_generator {
   std::string render_includes();
   std::string type_name(t_type* ttype);
 
-  std::string function_signature(t_function* tfunction, std::string prefix="");
+  std::string function_signature(t_function* tfunction, std::string prefix = "");
 
   std::string argument_list(t_struct* tstruct);
   std::string type_to_enum(t_type* ttype);
   std::string type_module(t_type* ttype);
 
   std::string make_safe_for_module_name(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return decapitalize(in);
     } else {
       return underscore(in);
@@ -131,7 +129,7 @@ class t_erl_generator : public t_generator {
   }
 
   std::string atomify(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return "'" + decapitalize(in) + "'";
     } else {
       return "'" + in + "'";
@@ -139,7 +137,7 @@ class t_erl_generator : public t_generator {
   }
 
   std::string constify(std::string in) {
-    if(legacy_names_) {
+    if (legacy_names_) {
       return capitalize(in);
     } else {
       return uppercase(in);
@@ -148,9 +146,8 @@ class t_erl_generator : public t_generator {
 
   static std::string comment(string in);
 
- private:
-
-  bool has_default_value(t_field *);
+private:
+  bool has_default_value(t_field*);
 
   /* if true retain pre 0.9.2 naming scheme for functions, atoms and consts */
   bool legacy_names_;
@@ -159,10 +156,10 @@ class t_erl_generator : public t_generator {
    * add function to export list
    */
 
-  void export_function(t_function* tfunction, std::string prefix="");
+  void export_function(t_function* tfunction, std::string prefix = "");
   void export_string(std::string name, int num);
 
-  void export_types_function(t_function* tfunction, std::string prefix="");
+  void export_types_function(t_function* tfunction, std::string prefix = "");
   void export_types_string(std::string name, int num);
 
   /**
@@ -196,10 +193,8 @@ class t_erl_generator : public t_generator {
   std::ostringstream f_service_;
   std::ofstream f_service_file_;
   std::ofstream f_service_hrl_;
-
 };
 
-
 /**
  * UI for file generation by opening up the necessary file output
  * streams.
@@ -223,38 +218,34 @@ void t_erl_generator::init_generator() {
 
   hrl_header(f_types_hrl_file_, make_safe_for_module_name(program_name_) + "_types");
 
-  f_types_file_ <<
-    erl_autogen_comment() << endl <<
-    "-module(" << make_safe_for_module_name(program_name_) << "_types)." << endl <<
-    erl_imports() << endl;
+  f_types_file_ << erl_autogen_comment() << endl << "-module("
+                << make_safe_for_module_name(program_name_) << "_types)." << endl << erl_imports()
+                << endl;
 
-  f_types_file_ <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_types_file_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
+                << endl << endl;
 
   f_types_hrl_file_ << render_includes() << endl;
 
   // consts file
-  string f_consts_name = get_out_dir() + make_safe_for_module_name(program_name_) + "_constants.hrl";
+  string f_consts_name = get_out_dir() + make_safe_for_module_name(program_name_)
+                         + "_constants.hrl";
   f_consts_.open(f_consts_name.c_str());
 
-  f_consts_ <<
-    erl_autogen_comment() << endl <<
-    erl_imports() << endl <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_consts_ << erl_autogen_comment() << endl << erl_imports() << endl << "-include(\""
+            << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl << endl;
 }
 
 /**
  * Boilerplate at beginning and end of header files
  */
 void t_erl_generator::hrl_header(ostream& out, string name) {
-  out << "-ifndef(_" << name << "_included)." << endl <<
-    "-define(_" << name << "_included, yeah)." << endl;
+  out << "-ifndef(_" << name << "_included)." << endl << "-define(_" << name << "_included, yeah)."
+      << endl;
 }
 
 void t_erl_generator::hrl_footer(ostream& out, string name) {
-  (void) name;
+  (void)name;
   out << "-endif." << endl;
 }
 
@@ -265,7 +256,8 @@ string t_erl_generator::render_includes() {
   const vector<t_program*>& includes = program_->get_includes();
   string result = "";
   for (size_t i = 0; i < includes.size(); ++i) {
-    result += "-include(\"" + make_safe_for_module_name(includes[i]->get_name()) + "_types.hrl\").\n";
+    result += "-include(\"" + make_safe_for_module_name(includes[i]->get_name())
+              + "_types.hrl\").\n";
   }
   if (includes.size() > 0) {
     result += "\n";
@@ -277,24 +269,19 @@ string t_erl_generator::render_includes() {
  * Autogen'd comment
  */
 string t_erl_generator::erl_autogen_comment() {
-  return
-    std::string("%%\n") +
-    "%% Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n" +
-    "%%\n" +
-    "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
-    "%%\n";
+  return std::string("%%\n") + "%% Autogenerated by Thrift Compiler (" + THRIFT_VERSION + ")\n"
+         + "%%\n" + "%% DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n"
+         + "%%\n";
 }
 
 /**
  * Comment out text
  */
 
-string t_erl_generator::comment(string in)
-{
+string t_erl_generator::comment(string in) {
   size_t pos = 0;
   in.insert(pos, "%% ");
-  while ( (pos = in.find_first_of('\n', pos)) != string::npos )
-  {
+  while ((pos = in.find_first_of('\n', pos)) != string::npos) {
     in.insert(++pos, "%% ");
   }
   return in;
@@ -335,7 +322,7 @@ void t_erl_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_erl_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -351,13 +338,9 @@ void t_erl_generator::generate_enum(t_enum* tenum) {
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     string name = (*c_iter)->get_name();
-    indent(f_types_hrl_file_) <<
-      "-define(" <<
-      constify(make_safe_for_module_name(program_name_)) <<
-      "_" << constify(tenum->get_name()) <<
-      "_" << constify(name) <<
-      ", " << value << ")." <<
-    endl;
+    indent(f_types_hrl_file_) << "-define(" << constify(make_safe_for_module_name(program_name_))
+                              << "_" << constify(tenum->get_name()) << "_" << constify(name) << ", "
+                              << value << ")." << endl;
   }
 
   f_types_hrl_file_ << endl;
@@ -371,12 +354,8 @@ void t_erl_generator::generate_const(t_const* tconst) {
   string name = tconst->get_name();
   t_const_value* value = tconst->get_value();
 
-  f_consts_ <<
-    "-define(" << constify(make_safe_for_module_name(program_name_)) <<
-    "_" << constify(name) <<
-    ", " << render_const_value(type, value) <<
-    ")." << endl <<
-  endl;
+  f_consts_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_"
+            << constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl;
 }
 
 /**
@@ -454,10 +433,9 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     out << "dict:from_list([";
     map<t_const_value*, t_const_value*>::const_iterator i, end = value->get_map().end();
     for (i = value->get_map().begin(); i != end;) {
-      out << "{"
-          << render_const_value(ktype, i->first)  << ","
+      out << "{" << render_const_value(ktype, i->first) << ","
           << render_const_value(vtype, i->second) << "}";
-      if ( ++i != end ) {
+      if (++i != end) {
         out << ",";
       }
     }
@@ -466,9 +444,9 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     t_type* etype = ((t_set*)type)->get_elem_type();
     out << "sets:from_list([";
     vector<t_const_value*>::const_iterator i, end = value->get_list().end();
-    for( i = value->get_list().begin(); i != end; ) {
-      out << render_const_value(etype, *i) ;
-      if ( ++i != end ) {
+    for (i = value->get_list().begin(); i != end;) {
+      out << render_const_value(etype, *i);
+      if (++i != end) {
         out << ",";
       }
     }
@@ -483,7 +461,7 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
     vector<t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       if (first) {
-        first=false;
+        first = false;
       } else {
         out << ",";
       }
@@ -496,9 +474,8 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
   return out.str();
 }
 
-
 string t_erl_generator::render_default_value(t_field* field) {
-  t_type *type = field->get_type();
+  t_type* type = field->get_type();
   if (type->is_struct() || type->is_xception()) {
     return "#" + atomify(type->get_name()) + "{}";
   } else if (type->is_map()) {
@@ -512,8 +489,8 @@ string t_erl_generator::render_default_value(t_field* field) {
   }
 }
 
-string t_erl_generator::render_member_type(t_field * field) {
-  t_type * type = get_true_type(field->get_type());
+string t_erl_generator::render_member_type(t_field* field) {
+  t_type* type = get_true_type(field->get_type());
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
@@ -546,12 +523,15 @@ string t_erl_generator::render_member_type(t_field * field) {
   }
 }
 
-string t_erl_generator::render_member_requiredness(t_field * field) {
-    switch(field->get_req()) {
-        case t_field::T_REQUIRED:       return "required";
-        case t_field::T_OPTIONAL:       return "optional";
-        default:                        return "undefined";
-    }
+string t_erl_generator::render_member_requiredness(t_field* field) {
+  switch (field->get_req()) {
+  case t_field::T_REQUIRED:
+    return "required";
+  case t_field::T_OPTIONAL:
+    return "optional";
+  default:
+    return "undefined";
+  }
 }
 
 /**
@@ -575,7 +555,7 @@ void t_erl_generator::generate_xception(t_struct* txception) {
  * Generates a struct
  */
 void t_erl_generator::generate_erl_struct(t_struct* tstruct, bool is_exception) {
-  (void) is_exception;
+  (void)is_exception;
   generate_erl_struct_definition(f_types_hrl_file_, tstruct);
   generate_erl_struct_info(f_info_, tstruct);
   generate_erl_extended_struct_info(f_info_ext_, tstruct);
@@ -586,8 +566,7 @@ void t_erl_generator::generate_erl_struct(t_struct* tstruct, bool is_exception)
  *
  * @param tstruct The struct definition
  */
-void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct)
-{
+void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct) {
   indent(out) << "%% struct " << type_name(tstruct) << endl << endl;
 
   std::stringstream buf;
@@ -597,36 +576,33 @@ void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tst
   const vector<t_field*>& members = tstruct->get_members();
   for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();) {
     generate_erl_struct_member(buf, *m_iter);
-    if ( ++m_iter != members.end() ) {
+    if (++m_iter != members.end()) {
       buf << "," << endl << field_indent;
     }
   }
   buf << "}).";
 
   out << buf.str() << endl;
-  out <<
-    "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}."
-      << endl << endl;
+  out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << endl << endl;
 }
 
 /**
  * Generates the record field definition
  */
 
-void t_erl_generator::generate_erl_struct_member(ostream & out, t_field * tmember)
-{
+void t_erl_generator::generate_erl_struct_member(ostream& out, t_field* tmember) {
   out << atomify(tmember->get_name());
   if (has_default_value(tmember))
-    out << " = "  << render_member_value(tmember);
+    out << " = " << render_member_value(tmember);
   out << " :: " << render_member_type(tmember);
 }
 
-bool t_erl_generator::has_default_value(t_field * field) {
-  t_type *type = field->get_type();
+bool t_erl_generator::has_default_value(t_field* field) {
+  t_type* type = field->get_type();
   if (!field->get_value()) {
-    if ( field->get_req() == t_field::T_REQUIRED) {
-      if (type->is_struct() || type->is_xception() || type->is_map() ||
-          type->is_set() || type->is_list()) {
+    if (field->get_req() == t_field::T_REQUIRED) {
+      if (type->is_struct() || type->is_xception() || type->is_map() || type->is_set()
+          || type->is_list()) {
         return true;
       } else {
         return false;
@@ -639,7 +615,7 @@ bool t_erl_generator::has_default_value(t_field * field) {
   }
 }
 
-string t_erl_generator::render_member_value(t_field * field) {
+string t_erl_generator::render_member_value(t_field* field) {
   if (!field->get_value()) {
     return render_default_value(field);
   } else {
@@ -647,8 +623,6 @@ string t_erl_generator::render_member_value(t_field * field) {
   }
 }
 
-
-
 /**
  * Generates the read method for a struct
  */
@@ -689,13 +663,13 @@ void t_erl_generator::generate_service(t_service* tservice) {
   hrl_header(f_service_hrl_, service_name_);
 
   if (tservice->get_extends() != NULL) {
-    f_service_hrl_ << "-include(\"" <<
-      make_safe_for_module_name(tservice->get_extends()->get_name()) << "_thrift.hrl\"). % inherit " << endl;
+    f_service_hrl_ << "-include(\""
+                   << make_safe_for_module_name(tservice->get_extends()->get_name())
+                   << "_thrift.hrl\"). % inherit " << endl;
   }
 
-  f_service_hrl_ <<
-    "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl <<
-    endl;
+  f_service_hrl_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
+                 << endl << endl;
 
   // Generate the three main parts of the service (well, two for now in PHP)
   generate_service_helpers(tservice); // cpiro: New Erlang Order
@@ -704,13 +678,11 @@ void t_erl_generator::generate_service(t_service* tservice) {
 
   // indent_down();
 
-  f_service_file_ <<
-    erl_autogen_comment() << endl <<
-    "-module(" << service_name_ << "_thrift)." << endl <<
-    "-behaviour(thrift_service)." << endl << endl <<
-    erl_imports() << endl;
+  f_service_file_ << erl_autogen_comment() << endl << "-module(" << service_name_ << "_thrift)."
+                  << endl << "-behaviour(thrift_service)." << endl << endl << erl_imports() << endl;
 
-  f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name()) << "_thrift.hrl\")." << endl << endl;
+  f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name())
+                  << "_thrift.hrl\")." << endl << endl;
 
   f_service_file_ << "-export([" << export_lines_.str() << "])." << endl << endl;
 
@@ -740,7 +712,7 @@ void t_erl_generator::generate_service_helpers(t_service* tservice) {
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     generate_erl_function_helpers(*f_iter);
   }
-  f_service_    << "struct_info(_) -> erlang:error(function_clause)." << endl;
+  f_service_ << "struct_info(_) -> erlang:error(function_clause)." << endl;
 }
 
 /**
@@ -749,7 +721,7 @@ void t_erl_generator::generate_service_helpers(t_service* tservice) {
  * @param tfunction The function
  */
 void t_erl_generator::generate_erl_function_helpers(t_function* tfunction) {
-  (void) tfunction;
+  (void)tfunction;
 }
 
 /**
@@ -765,23 +737,21 @@ void t_erl_generator::generate_service_interface(t_service* tservice) {
   vector<t_function*>::iterator f_iter;
   f_service_ << "%%% interface" << endl;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "% " << function_signature(*f_iter) << endl;
+    f_service_ << indent() << "% " << function_signature(*f_iter) << endl;
 
     generate_function_info(tservice, *f_iter);
   }
 
   // Inheritance - pass unknown functions to base class
   if (tservice->get_extends() != NULL) {
-      indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
-      indent_up();
-      indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
-                         << "_thrift:function_info(Function, InfoType)." << endl;
-      indent_down();
+    indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
+    indent_up();
+    indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
+                       << "_thrift:function_info(Function, InfoType)." << endl;
+    indent_down();
   } else {
-      // return function_clause error for non-existent functions
-      indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)."
-                         << endl;
+    // return function_clause error for non-existent functions
+    indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << endl;
   }
 
   indent(f_service_) << endl;
@@ -791,17 +761,15 @@ void t_erl_generator::generate_service_interface(t_service* tservice) {
  * Generates a function_info(FunctionName, params_type) and
  * function_info(FunctionName, reply_type)
  */
-void t_erl_generator::generate_function_info(t_service* tservice,
-                                                t_function* tfunction) {
-  (void) tservice;
+void t_erl_generator::generate_function_info(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   string name_atom = atomify(tfunction->get_name());
 
   t_struct* xs = tfunction->get_xceptions();
   t_struct* arg_struct = tfunction->get_arglist();
 
   // function_info(Function, params_type):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", params_type) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << endl;
   indent_up();
 
   indent(f_service_) << render_type_term(arg_struct, true) << ";" << endl;
@@ -809,22 +777,20 @@ void t_erl_generator::generate_function_info(t_service* tservice,
   indent_down();
 
   // function_info(Function, reply_type):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", reply_type) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << endl;
   indent_up();
 
   if (!tfunction->get_returntype()->is_void())
-    indent(f_service_) <<
-        render_type_term(tfunction->get_returntype(), false) << ";" << endl;
+    indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << endl;
   else if (tfunction->is_oneway())
     indent(f_service_) << "oneway_void;" << endl;
   else
-    indent(f_service_) << "{struct, []}" << ";" << endl;
+    indent(f_service_) << "{struct, []}"
+                       << ";" << endl;
   indent_down();
 
   // function_info(Function, exceptions):
-  indent(f_service_) <<
-    "function_info(" << name_atom << ", exceptions) ->" << endl;
+  indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << endl;
   indent_up();
   indent(f_service_) << render_type_term(xs, true) << ";" << endl;
   indent_down();
@@ -836,11 +802,9 @@ void t_erl_generator::generate_function_info(t_service* tservice,
  * @param tfunction Function definition
  * @return String of rendered function definition
  */
-string t_erl_generator::function_signature(t_function* tfunction,
-                                           string prefix) {
-  return
-    prefix + tfunction->get_name() +
-    "(This" +  capitalize(argument_list(tfunction->get_arglist())) + ")";
+string t_erl_generator::function_signature(t_function* tfunction, string prefix) {
+  return prefix + tfunction->get_name() + "(This"
+         + capitalize(argument_list(tfunction->get_arglist())) + ")";
 }
 
 /**
@@ -855,13 +819,11 @@ void t_erl_generator::export_string(string name, int num) {
   export_lines_ << name << "/" << num;
 }
 
-void t_erl_generator::export_types_function(t_function* tfunction,
-                                               string prefix) {
+void t_erl_generator::export_types_function(t_function* tfunction, string prefix) {
 
   export_types_string(prefix + tfunction->get_name(),
                       1 // This
-                      + ((tfunction->get_arglist())->get_members()).size()
-                      );
+                      + ((tfunction->get_arglist())->get_members()).size());
 }
 
 void t_erl_generator::export_types_string(string name, int num) {
@@ -873,16 +835,13 @@ void t_erl_generator::export_types_string(string name, int num) {
   export_types_lines_ << name << "/" << num;
 }
 
-void t_erl_generator::export_function(t_function* tfunction,
-                                      string prefix) {
+void t_erl_generator::export_function(t_function* tfunction, string prefix) {
 
   export_string(prefix + tfunction->get_name(),
                 1 // This
-                + ((tfunction->get_arglist())->get_members()).size()
-                );
+                + ((tfunction->get_arglist())->get_members()).size());
 }
 
-
 /**
  * Renders a field list
  */
@@ -956,12 +915,13 @@ string t_erl_generator::type_to_enum(t_type* type) {
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
 
-
 /**
  * Generate an Erlang term which represents a thrift type
  */
-std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs, bool extended_info) {
-    type = get_true_type(type);
+std::string t_erl_generator::render_type_term(t_type* type,
+                                              bool expand_structs,
+                                              bool extended_info) {
+  type = get_true_type(type);
 
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
@@ -994,30 +954,24 @@ std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs,
 
       t_struct::members_type const& fields = static_cast<t_struct*>(type)->get_members();
       t_struct::members_type::const_iterator i, end = fields.end();
-      for( i = fields.begin(); i != end; )
-      {
+      for (i = fields.begin(); i != end;) {
         t_struct::members_type::value_type member = *i;
-        int32_t key  = member->get_key();
-        string  type = render_type_term(member->get_type(), false, false); // recursive call
+        int32_t key = member->get_key();
+        string type = render_type_term(member->get_type(), false, false); // recursive call
 
-        if ( !extended_info ) {
+        if (!extended_info) {
           // Convert to format: {struct, [{Fid, Type}|...]}
-          buf << "{" << key << ", "  << type << "}";
+          buf << "{" << key << ", " << type << "}";
         } else {
           // Convert to format: {struct, [{Fid, Req, Type, Name, Def}|...]}
-          string  name         = member->get_name();
-          string  value        = render_member_value(member);
-          string  requiredness = render_member_requiredness(member);
-          buf <<
-            "{" << key <<
-            ", "  << requiredness <<
-            ", "  << type <<
-            ", " << atomify(name) <<
-            ", "  << value <<
-          "}";
+          string name = member->get_name();
+          string value = render_member_value(member);
+          string requiredness = render_member_requiredness(member);
+          buf << "{" << key << ", " << requiredness << ", " << type << ", " << atomify(name) << ", "
+              << value << "}";
         }
 
-        if ( ++i != end ) {
+        if (++i != end) {
           buf << "," << endl << field_indent;
         }
       }
@@ -1029,19 +983,19 @@ std::string t_erl_generator::render_type_term(t_type* type, bool expand_structs,
     }
   } else if (type->is_map()) {
     // {map, KeyType, ValType}
-    t_type *key_type = ((t_map*)type)->get_key_type();
-    t_type *val_type = ((t_map*)type)->get_val_type();
+    t_type* key_type = ((t_map*)type)->get_key_type();
+    t_type* val_type = ((t_map*)type)->get_val_type();
 
-    return "{map, " + render_type_term(key_type, false) + ", " +
-      render_type_term(val_type, false) + "}";
+    return "{map, " + render_type_term(key_type, false) + ", " + render_type_term(val_type, false)
+           + "}";
 
   } else if (type->is_set()) {
-    t_type *elem_type = ((t_set*)type)->get_elem_type();
+    t_type* elem_type = ((t_set*)type)->get_elem_type();
 
     return "{set, " + render_type_term(elem_type, false) + "}";
 
   } else if (type->is_list()) {
-    t_type *elem_type = ((t_list*)type)->get_elem_type();
+    t_type* elem_type = ((t_list*)type)->get_elem_type();
 
     return "{list, " + render_type_term(elem_type, false) + "}";
   }
@@ -1053,7 +1007,7 @@ std::string t_erl_generator::type_module(t_type* ttype) {
   return make_safe_for_module_name(ttype->get_program()->get_name()) + "_types";
 }
 
-THRIFT_REGISTER_GENERATOR(erl, "Erlang",
-"    legacynames: Output files retain naming conventions of Thrift 0.9.1 and earlier.\n"
-)
-
+THRIFT_REGISTER_GENERATOR(
+    erl,
+    "Erlang",
+    "    legacynames: Output files retain naming conventions of Thrift 0.9.1 and earlier.\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator.cc b/compiler/cpp/src/generate/t_generator.cc
index f04c65a..e7760d7 100644
--- a/compiler/cpp/src/generate/t_generator.cc
+++ b/compiler/cpp/src/generate/t_generator.cc
@@ -76,7 +76,7 @@ void t_generator::generate_program() {
   close_generator();
 }
 
-string t_generator::escape_string(const string &in) const {
+string t_generator::escape_string(const string& in) const {
   string result = "";
   for (string::const_iterator it = in.begin(); it < in.end(); it++) {
     std::map<char, std::string>::const_iterator res = escape_.find(*it);
@@ -101,23 +101,24 @@ void t_generator::generate_docstring_comment(ostream& out,
                                              const string& line_prefix,
                                              const string& contents,
                                              const string& comment_end) {
-  if (comment_start != "") indent(out) << comment_start;
+  if (comment_start != "")
+    indent(out) << comment_start;
   stringstream docs(contents, ios_base::in);
-  while ( ! (docs.eof() || docs.fail())) {
+  while (!(docs.eof() || docs.fail())) {
     char line[1024];
     docs.getline(line, 1024);
 
     // Just prnt a newline when the line & prefix are empty.
     if (strlen(line) == 0 && line_prefix == "" && !docs.eof()) {
-        out << std::endl;
-    } else if (strlen(line) > 0 || !docs.eof()) {  // skip the empty last line
+      out << std::endl;
+    } else if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line
       indent(out) << line_prefix << line << std::endl;
     }
   }
-  if (comment_end != "") indent(out) << comment_end;
+  if (comment_end != "")
+    indent(out) << comment_end;
 }
 
-
 void t_generator_registry::register_generator(t_generator_factory* factory) {
   gen_map_t& the_map = get_generator_map();
   if (the_map.find(factory->get_short_name()) != the_map.end()) {
@@ -126,18 +127,17 @@ void t_generator_registry::register_generator(t_generator_factory* factory) {
   the_map[factory->get_short_name()] = factory;
 }
 
-t_generator* t_generator_registry::get_generator(t_program* program,
-                                                 const string& options) {
+t_generator* t_generator_registry::get_generator(t_program* program, const string& options) {
   string::size_type colon = options.find(':');
   string language = options.substr(0, colon);
 
   map<string, string> parsed_options;
   if (colon != string::npos) {
-    string::size_type pos = colon+1;
+    string::size_type pos = colon + 1;
     while (pos != string::npos && pos < options.size()) {
       string::size_type next_pos = options.find(',', pos);
-      string option = options.substr(pos, next_pos-pos);
-      pos = ((next_pos == string::npos) ? next_pos : next_pos+1);
+      string option = options.substr(pos, next_pos - pos);
+      pos = ((next_pos == string::npos) ? next_pos : next_pos + 1);
 
       string::size_type separator = option.find('=');
       string key, value;
@@ -146,7 +146,7 @@ t_generator* t_generator_registry::get_generator(t_program* program,
         value = "";
       } else {
         key = option.substr(0, separator);
-        value = option.substr(separator+1);
+        value = option.substr(separator + 1);
       }
 
       parsed_options[key] = value;
@@ -169,13 +169,9 @@ t_generator_registry::gen_map_t& t_generator_registry::get_generator_map() {
   return *the_map;
 }
 
-t_generator_factory::t_generator_factory(
-    const std::string& short_name,
-    const std::string& long_name,
-    const std::string& documentation)
-  : short_name_(short_name)
-  , long_name_(long_name)
-  , documentation_(documentation)
-{
+t_generator_factory::t_generator_factory(const std::string& short_name,
+                                         const std::string& long_name,
+                                         const std::string& documentation)
+  : short_name_(short_name), long_name_(long_name), documentation_(documentation) {
   t_generator_registry::register_generator(this);
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator.h b/compiler/cpp/src/generate/t_generator.h
index 04d88d9..99d878a 100644
--- a/compiler/cpp/src/generate/t_generator.h
+++ b/compiler/cpp/src/generate/t_generator.h
@@ -35,7 +35,7 @@
  *
  */
 class t_generator {
- public:
+public:
   t_generator(t_program* program) {
     tmp_ = 0;
     indent_ = 0;
@@ -44,7 +44,7 @@ class t_generator {
     escape_['\n'] = "\\n";
     escape_['\r'] = "\\r";
     escape_['\t'] = "\\t";
-    escape_['"']  = "\\\"";
+    escape_['"'] = "\\\"";
     escape_['\\'] = "\\\\";
   }
 
@@ -74,21 +74,20 @@ class t_generator {
    * will be called for the above example.
    */
   static bool is_valid_namespace(const std::string& sub_namespace) {
-    (void) sub_namespace;
+    (void)sub_namespace;
     return false;
   }
 
   /**
    * Escape string to use one in generated sources.
    */
-  virtual std::string escape_string(const std::string &in) const;
+  virtual std::string escape_string(const std::string& in) const;
 
   std::string get_escaped_string(t_const_value* constval) {
     return escape_string(constval->get_string());
   }
 
- protected:
-
+protected:
   /**
    * Optional methods that may be imlemented by subclasses to take necessary
    * steps at the beginning or end of code generation.
@@ -103,15 +102,13 @@ class t_generator {
    * Pure virtual methods implemented by the generator subclasses.
    */
 
-  virtual void generate_typedef  (t_typedef*  ttypedef)  = 0;
-  virtual void generate_enum     (t_enum*     tenum)     = 0;
-  virtual void generate_const    (t_const*    tconst) {
-    (void) tconst;
-  }
-  virtual void generate_struct   (t_struct*   tstruct)   = 0;
-  virtual void generate_service  (t_service*  tservice)  = 0;
-  virtual void generate_forward_declaration (t_struct*) {}
-  virtual void generate_xception (t_struct*   txception) {
+  virtual void generate_typedef(t_typedef* ttypedef) = 0;
+  virtual void generate_enum(t_enum* tenum) = 0;
+  virtual void generate_const(t_const* tconst) { (void)tconst; }
+  virtual void generate_struct(t_struct* tstruct) = 0;
+  virtual void generate_service(t_service* tservice) = 0;
+  virtual void generate_forward_declaration(t_struct*) {}
+  virtual void generate_xception(t_struct* txception) {
     // By default exceptions are the same as structs
     generate_struct(txception);
   }
@@ -119,16 +116,12 @@ class t_generator {
   /**
    * Method to get the program name, may be overridden
    */
-  virtual std::string get_program_name(t_program* tprogram) {
-    return tprogram->get_name();
-  }
+  virtual std::string get_program_name(t_program* tprogram) { return tprogram->get_name(); }
 
   /**
    * Method to get the service name, may be overridden
    */
-  virtual std::string get_service_name(t_service* tservice) {
-    return tservice->get_name();
-  }
+  virtual std::string get_service_name(t_service* tservice) { return tservice->get_name(); }
 
   /**
    * Get the current output directory
@@ -155,13 +148,9 @@ class t_generator {
    * Indentation level modifiers
    */
 
-  void indent_up(){
-    ++indent_;
-  }
+  void indent_up() { ++indent_; }
 
-  void indent_down() {
-    --indent_;
-  }
+  void indent_down() { --indent_; }
 
   /**
    * Indentation print function
@@ -178,9 +167,7 @@ class t_generator {
   /**
    * Indentation utility wrapper
    */
-  std::ostream& indent(std::ostream &os) {
-    return os << indent();
-  }
+  std::ostream& indent(std::ostream& os) { return os << indent(); }
 
   /**
    * Capitalization helpers
@@ -239,7 +226,7 @@ class t_generator {
         continue;
       }
       if (underscore) {
-        out << (char) toupper(in[i]);
+        out << (char)toupper(in[i]);
         underscore = false;
         continue;
       }
@@ -249,15 +236,13 @@ class t_generator {
     return out.str();
   }
 
- public:
+public:
   /**
    * Get the true type behind a series of typedefs.
    */
-  static t_type* get_true_type(t_type* type) {
-    return type->get_true_type();
-  }
+  static t_type* get_true_type(t_type* type) { return type->get_true_type(); }
 
- protected:
+protected:
   /**
    * The program being generated
    */
@@ -285,7 +270,7 @@ class t_generator {
    */
   std::map<char, std::string> escape_;
 
- private:
+private:
   /**
    * Current code indentation level
    */

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_generator_registry.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator_registry.h b/compiler/cpp/src/generate/t_generator_registry.h
index 0010e94..a852385 100644
--- a/compiler/cpp/src/generate/t_generator_registry.h
+++ b/compiler/cpp/src/generate/t_generator_registry.h
@@ -30,7 +30,7 @@ class t_generator;
  *  - Providing documentation for the generators it produces.
  */
 class t_generator_factory {
- public:
+public:
   t_generator_factory(const std::string& short_name,
                       const std::string& long_name,
                       const std::string& documentation);
@@ -43,8 +43,7 @@ class t_generator_factory {
       // Note: parsed_options will not exist beyond the call to get_generator.
       const std::map<std::string, std::string>& parsed_options,
       // Note: option_string might not exist beyond the call to get_generator.
-      const std::string& option_string)
-    = 0;
+      const std::string& option_string) = 0;
 
   virtual bool is_valid_namespace(const std::string& sub_namespace) = 0;
 
@@ -52,7 +51,7 @@ class t_generator_factory {
   std::string get_long_name() { return long_name_; }
   std::string get_documentation() { return documentation_; }
 
- private:
+private:
   std::string short_name_;
   std::string long_name_;
   std::string documentation_;
@@ -60,17 +59,15 @@ class t_generator_factory {
 
 template <typename generator>
 class t_generator_factory_impl : public t_generator_factory {
- public:
+public:
   t_generator_factory_impl(const std::string& short_name,
                            const std::string& long_name,
                            const std::string& documentation)
-    : t_generator_factory(short_name, long_name, documentation)
-  {}
+    : t_generator_factory(short_name, long_name, documentation) {}
 
-  virtual t_generator* get_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string) {
+  virtual t_generator* get_generator(t_program* program,
+                                     const std::map<std::string, std::string>& parsed_options,
+                                     const std::string& option_string) {
     return new generator(program, parsed_options, option_string);
   }
 
@@ -80,30 +77,26 @@ class t_generator_factory_impl : public t_generator_factory {
 };
 
 class t_generator_registry {
- public:
+public:
   static void register_generator(t_generator_factory* factory);
 
-  static t_generator* get_generator(t_program* program,
-                                    const std::string& options);
+  static t_generator* get_generator(t_program* program, const std::string& options);
 
   typedef std::map<std::string, t_generator_factory*> gen_map_t;
   static gen_map_t& get_generator_map();
 
- private:
+private:
   t_generator_registry();
   t_generator_registry(const t_generator_registry&);
 };
 
-#define THRIFT_REGISTER_GENERATOR(language, long_name, doc)        \
-  class t_##language##_generator_factory_impl                      \
-    : public t_generator_factory_impl<t_##language##_generator>    \
-  {                                                                \
-   public:                                                         \
-    t_##language##_generator_factory_impl()                        \
-      : t_generator_factory_impl<t_##language##_generator>(        \
-          #language, long_name, doc)                               \
-    {}                                                             \
-  };                                                               \
+#define THRIFT_REGISTER_GENERATOR(language, long_name, doc)                                        \
+  class t_##language##_generator_factory_impl                                                      \
+      : public t_generator_factory_impl<t_##language##_generator> {                                \
+  public:                                                                                          \
+    t_##language##_generator_factory_impl()                                                        \
+      : t_generator_factory_impl<t_##language##_generator>(#language, long_name, doc) {}           \
+  };                                                                                               \
   static t_##language##_generator_factory_impl _registerer;
 
 #endif


[26/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

Posted by hc...@apache.org.
http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/compiler/cpp/src/generate/t_haxe_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_haxe_generator.cc b/compiler/cpp/src/generate/t_haxe_generator.cc
index bd22e59..504bea9 100644
--- a/compiler/cpp/src/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/generate/t_haxe_generator.cc
@@ -37,23 +37,21 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n";  // avoid ostream << std::endl flushes
+static const string endl = "\n"; // avoid ostream << std::endl flushes
 
 /**
  * Haxe code generator.
  *
  */
 class t_haxe_generator : public t_oop_generator {
- public:
-  t_haxe_generator(
-      t_program* program,
-      const std::map<std::string, std::string>& parsed_options,
-      const std::string& option_string)
-    : t_oop_generator(program)
-  {
-    (void) option_string;
+public:
+  t_haxe_generator(t_program* program,
+                   const std::map<std::string, std::string>& parsed_options,
+                   const std::string& option_string)
+    : t_oop_generator(program) {
+    (void)option_string;
     std::map<std::string, std::string>::const_iterator iter;
-    
+
     iter = parsed_options.find("callbacks");
     callbacks_ = (iter != parsed_options.end());
 
@@ -73,14 +71,22 @@ class t_haxe_generator : public t_oop_generator {
    * Program-level generation functions
    */
 
-  void generate_typedef (t_typedef*  ttypedef);
-  void generate_enum    (t_enum*     tenum);
-  void generate_struct  (t_struct*   tstruct);
-  void generate_xception(t_struct*   txception);
-  void generate_service (t_service*  tservice);
-
-  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
-  std::string render_const_value(ofstream& out, std::string name, t_type* type, t_const_value* value);
+  void generate_typedef(t_typedef* ttypedef);
+  void generate_enum(t_enum* tenum);
+  void generate_struct(t_struct* tstruct);
+  void generate_xception(t_struct* txception);
+  void generate_service(t_service* tservice);
+
+  void print_const_value(std::ofstream& out,
+                         std::string name,
+                         t_type* type,
+                         t_const_value* value,
+                         bool in_static,
+                         bool defval = false);
+  std::string render_const_value(ofstream& out,
+                                 std::string name,
+                                 t_type* type,
+                                 t_const_value* value);
 
   /**
    * Service-level generation functions
@@ -88,8 +94,11 @@ class t_haxe_generator : public t_oop_generator {
 
   void generate_haxe_struct(t_struct* tstruct, bool is_exception, bool is_result = false);
 
-  void generate_haxe_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool is_result=false);
-  //removed -- equality,compare_to
+  void generate_haxe_struct_definition(std::ofstream& out,
+                                       t_struct* tstruct,
+                                       bool is_xception = false,
+                                       bool is_result = false);
+  // removed -- equality,compare_to
   void generate_haxe_struct_reader(std::ofstream& out, t_struct* tstruct);
   void generate_haxe_validator(std::ofstream& out, t_struct* tstruct);
   void generate_haxe_struct_result_writer(std::ofstream& out, t_struct* tstruct);
@@ -98,8 +107,14 @@ class t_haxe_generator : public t_oop_generator {
   void generate_haxe_meta_data_map(std::ofstream& out, t_struct* tstruct);
   void generate_field_value_meta_data(std::ofstream& out, t_type* type);
   std::string get_haxe_type_string(t_type* type);
-  void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
-  void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
+  void generate_reflection_setters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
+  void generate_reflection_getters(std::ostringstream& out,
+                                   t_type* type,
+                                   std::string field_name,
+                                   std::string cap_name);
   void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
   void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
   void generate_property_getters_setters(std::ofstream& out, t_struct* tstruct);
@@ -109,73 +124,51 @@ class t_haxe_generator : public t_oop_generator {
   std::string generate_isset_check(t_field* field);
   std::string generate_isset_check(std::string field);
   void generate_isset_set(ofstream& out, t_field* field);
-  //removed std::string isset_field_id(t_field* field);
-  
-  void generate_service_interface (t_service* tservice);
-  void generate_service_helpers   (t_service* tservice);
-  void generate_service_client    (t_service* tservice);
-  void generate_service_server    (t_service* tservice);
-  void generate_process_function  (t_service* tservice, t_function* tfunction);
+  // removed std::string isset_field_id(t_field* field);
+
+  void generate_service_interface(t_service* tservice);
+  void generate_service_helpers(t_service* tservice);
+  void generate_service_client(t_service* tservice);
+  void generate_service_server(t_service* tservice);
+  void generate_process_function(t_service* tservice, t_function* tfunction);
   void generate_service_method_signature(t_function* tfunction, bool is_interface);
-  
+
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field        (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_deserialize_struct       (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_deserialize_container    (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_deserialize_set_element  (std::ofstream& out,
-                                          t_set*      tset,
-                                          std::string prefix="");
+  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
 
-  void generate_deserialize_map_element  (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string prefix="");
+  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
 
-  void generate_deserialize_list_element (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string prefix="");
+  void generate_deserialize_list_element(std::ofstream& out,
+                                         t_list* tlist,
+                                         std::string prefix = "");
 
-  void generate_serialize_field          (std::ofstream& out,
-                                          t_field*    tfield,
-                                          std::string prefix="");
+  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
 
-  void generate_serialize_struct         (std::ofstream& out,
-                                          t_struct*   tstruct,
-                                          std::string prefix="");
+  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
 
-  void generate_serialize_container      (std::ofstream& out,
-                                          t_type*     ttype,
-                                          std::string prefix="");
+  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
 
-  void generate_serialize_map_element    (std::ofstream& out,
-                                          t_map*      tmap,
-                                          std::string iter,
-                                          std::string map);
+  void generate_serialize_map_element(std::ofstream& out,
+                                      t_map* tmap,
+                                      std::string iter,
+                                      std::string map);
 
-  void generate_serialize_set_element    (std::ofstream& out,
-                                          t_set*      tmap,
-                                          std::string iter);
+  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
 
-  void generate_serialize_list_element   (std::ofstream& out,
-                                          t_list*     tlist,
-                                          std::string iter);
+  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
 
-  void generate_haxe_doc                 (std::ofstream& out,
-                                          t_doc*     tdoc);
+  void generate_haxe_doc(std::ofstream& out, t_doc* tdoc);
 
-  void generate_haxe_doc                 (std::ofstream& out,
-                                          t_function* tdoc);
+  void generate_haxe_doc(std::ofstream& out, t_function* tdoc);
 
   /**
    * Helper rendering functions
@@ -184,11 +177,11 @@ class t_haxe_generator : public t_oop_generator {
   std::string haxe_package();
   std::string haxe_type_imports();
   std::string haxe_thrift_imports();
-  std::string haxe_thrift_gen_imports(t_struct* tstruct, string& imports); 
-  std::string haxe_thrift_gen_imports(t_service* tservice); 
-  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false);
-  std::string base_type_name(t_base_type* tbase, bool in_container=false);
-  std::string declare_field(t_field* tfield, bool init=false);
+  std::string haxe_thrift_gen_imports(t_struct* tstruct, string& imports);
+  std::string haxe_thrift_gen_imports(t_service* tservice);
+  std::string type_name(t_type* ttype, bool in_container = false, bool in_init = false);
+  std::string base_type_name(t_base_type* tbase, bool in_container = false);
+  std::string declare_field(t_field* tfield, bool init = false);
   std::string function_signature_callback(t_function* tfunction);
   std::string function_signature_normal(t_function* tfunction);
   std::string argument_list(t_struct* tstruct);
@@ -221,9 +214,9 @@ class t_haxe_generator : public t_oop_generator {
 
   std::string constant_name(std::string name);
 
- private:
+private:
   bool callbacks_;
-  
+
   /**
    * File streams
    */
@@ -231,10 +224,8 @@ class t_haxe_generator : public t_oop_generator {
   std::string package_name_;
   std::ofstream f_service_;
   std::string package_dir_;
-  
 };
 
-
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -264,7 +255,7 @@ void t_haxe_generator::init_generator() {
   while ((loc = dir.find(".")) != string::npos) {
     subdir = subdir + "/" + dir.substr(0, loc);
     MKDIR(subdir.c_str());
-    dir = dir.substr(loc+1);
+    dir = dir.substr(loc + 1);
   }
   if (dir.size() > 0) {
     subdir = subdir + "/" + dir;
@@ -292,18 +283,10 @@ string t_haxe_generator::haxe_package() {
  * @return List of imports for haxe types that are used in here
  */
 string t_haxe_generator::haxe_type_imports() {
-  return
-    string() +
-    "import org.apache.thrift.helper.*;\n" +
-    "import haxe.io.Bytes;\n" +
-    "import haxe.ds.IntMap;\n" +
-    "import haxe.ds.StringMap;\n" +
-    "import haxe.ds.ObjectMap;\n" +
-    "\n" +
-    "#if flash\n" +
-    "import flash.errors.ArgumentError;\n" +
-    "#end\n" +
-    "\n";
+  return string() + "import org.apache.thrift.helper.*;\n" + "import haxe.io.Bytes;\n"
+         + "import haxe.ds.IntMap;\n" + "import haxe.ds.StringMap;\n"
+         + "import haxe.ds.ObjectMap;\n" + "\n" + "#if flash\n"
+         + "import flash.errors.ArgumentError;\n" + "#end\n" + "\n";
 }
 
 /**
@@ -312,12 +295,8 @@ string t_haxe_generator::haxe_type_imports() {
  * @return List of imports necessary for thrift
  */
 string t_haxe_generator::haxe_thrift_imports() {
-  return
-    string() +
-    "import org.apache.thrift.*;\n" +
-    "import org.apache.thrift.meta_data.*;\n" +
-    "import org.apache.thrift.protocol.*;\n" +
-    "\n";
+  return string() + "import org.apache.thrift.*;\n" + "import org.apache.thrift.meta_data.*;\n"
+         + "import org.apache.thrift.protocol.*;\n" + "\n";
 }
 
 /**
@@ -330,7 +309,7 @@ string t_haxe_generator::haxe_thrift_gen_imports(t_struct* tstruct, string& impo
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
-  //For each type check if it is from a different namespace
+  // For each type check if it is from a different namespace
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_program* program = (*m_iter)->get_type()->get_program();
     if (program != NULL && program != program_) {
@@ -342,10 +321,9 @@ string t_haxe_generator::haxe_thrift_gen_imports(t_struct* tstruct, string& impo
       }
     }
   }
-  return imports;  
+  return imports;
 }
 
-
 /**
  * Prints imports needed for a given type
  *
@@ -356,31 +334,31 @@ string t_haxe_generator::haxe_thrift_gen_imports(t_service* tservice) {
   const vector<t_function*>& functions = tservice->get_functions();
   vector<t_function*>::const_iterator f_iter;
 
-  //For each type check if it is from a different namespace
+  // For each type check if it is from a different namespace
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     t_program* program = (*f_iter)->get_returntype()->get_program();
     if (program != NULL && program != program_) {
       string package = program->get_namespace("haxe");
       if (!package.empty()) {
         if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) {
-          imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name() + ";\n");
+          imports.append("import " + package + "." + (*f_iter)->get_returntype()->get_name()
+                         + ";\n");
         }
       }
     }
 
-    haxe_thrift_gen_imports((*f_iter)->get_arglist(), imports);        
-    haxe_thrift_gen_imports((*f_iter)->get_xceptions(), imports);        
-
+    haxe_thrift_gen_imports((*f_iter)->get_arglist(), imports);
+    haxe_thrift_gen_imports((*f_iter)->get_xceptions(), imports);
   }
- 
-  return imports;
 
+  return imports;
 }
 
 /**
  * Nothing in haxe
  */
-void t_haxe_generator::close_generator() {}
+void t_haxe_generator::close_generator() {
+}
 
 /**
  * Generates a typedef. This is not done in haxe, since it does
@@ -390,7 +368,7 @@ void t_haxe_generator::close_generator() {}
  * @param ttypedef The type definition
  */
 void t_haxe_generator::generate_typedef(t_typedef* ttypedef) {
-  (void) ttypedef;
+  (void)ttypedef;
 }
 
 /**
@@ -405,31 +383,25 @@ void t_haxe_generator::generate_enum(t_enum* tenum) {
   f_enum.open(f_enum_name.c_str());
 
   // Comment and package it
-  f_enum <<
-    autogen_comment() <<
-    haxe_package() << ";" << endl << endl;
-  
+  f_enum << autogen_comment() << haxe_package() << ";" << endl << endl;
+
   // Add haxe imports
-  f_enum << string() +
-  "import org.apache.thrift.helper.*;" << endl <<
-  endl;
-  
-  indent(f_enum) <<
-    "class " << get_cap_name(tenum->get_name()) << " ";
+  f_enum << string() + "import org.apache.thrift.helper.*;" << endl << endl;
+
+  indent(f_enum) << "class " << get_cap_name(tenum->get_name()) << " ";
   scope_up(f_enum);
 
   vector<t_enum_value*> constants = tenum->get_constants();
   vector<t_enum_value*>::iterator c_iter;
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
-    indent(f_enum) <<
-      "public static inline var " << (*c_iter)->get_name() <<
-      " : Int = " << value << ";" << endl;
+    indent(f_enum) << "public static inline var " << (*c_iter)->get_name() << " : Int = " << value
+                   << ";" << endl;
   }
-  
+
   // Create a static Set with all valid values for this enum
   f_enum << endl;
-  
+
   indent(f_enum) << "public static var VALID_VALUES = { new IntSet( [";
   indent_up();
   bool firstValue = true;
@@ -454,7 +426,7 @@ void t_haxe_generator::generate_enum(t_enum* tenum) {
   indent(f_enum) << "]; };" << endl;
 
   scope_down(f_enum); // end class
-  
+
   f_enum.close();
 }
 
@@ -471,18 +443,13 @@ void t_haxe_generator::generate_consts(std::vector<t_const*> consts) {
   f_consts.open(f_consts_name.c_str());
 
   // Print header
-  f_consts <<
-    autogen_comment() << haxe_package() << ";" << endl << endl;
-  
+  f_consts << autogen_comment() << haxe_package() << ";" << endl << endl;
+
   f_consts << endl;
-  
+
   f_consts << haxe_type_imports();
 
- 
-  
-  indent(f_consts) <<
-    "class " << get_cap_name(program_name_) <<
-    "Constants {" << endl << endl;
+  indent(f_consts) << "class " << get_cap_name(program_name_) << "Constants {" << endl << endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -493,18 +460,21 @@ void t_haxe_generator::generate_consts(std::vector<t_const*> consts) {
                       false);
   }
   indent_down();
-  indent(f_consts) <<
-    "}" << endl;
+  indent(f_consts) << "}" << endl;
   f_consts.close();
 }
 
-void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
+void t_haxe_generator::print_const_value(std::ofstream& out,
+                                         string name,
+                                         t_type* type,
+                                         t_const_value* value,
+                                         bool in_static,
+                                         bool defval) {
   type = get_true_type(type);
-  
+
   indent(out);
   if (!defval) {
-    out <<
-    (in_static ? "var " : "public static inline var  ");
+    out << (in_static ? "var " : "public static inline var  ");
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
@@ -515,7 +485,7 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
     out << " = " << v2 << ";" << endl << endl;
   } else if (type->is_enum()) {
     out << name;
-    if(!defval) {
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = " << value->get_integer() << ";" << endl << endl;
@@ -524,7 +494,8 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
     vector<t_field*>::const_iterator f_iter;
     const map<t_const_value*, t_const_value*>& val = value->get_map();
     map<t_const_value*, t_const_value*>::const_iterator v_iter;
-    out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();" << endl;
+    out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();"
+        << endl;
     if (!in_static) {
       indent(out) << "{" << endl;
       indent_up();
@@ -554,7 +525,7 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
     out << endl;
   } else if (type->is_map()) {
     out << name;
-    if(!defval){
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = new " << type_name(type, false, true) << "();" << endl;
@@ -582,7 +553,7 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
     out << endl;
   } else if (type->is_list() || type->is_set()) {
     out << name;
-    if(!defval) {
+    if (!defval) {
       out << ":" << type_name(type);
     }
     out << " = new " << type_name(type, false, true) << "();" << endl;
@@ -602,7 +573,8 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
     vector<t_const_value*>::const_iterator v_iter;
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string val = render_const_value(out, name, etype, *v_iter);
-      indent(out) << name << "." << (type->is_list() ? "push" : "add") << "(" << val << ");" << endl;
+      indent(out) << name << "." << (type->is_list() ? "push" : "add") << "(" << val << ");"
+                  << endl;
     }
     if (!in_static) {
       indent_down();
@@ -616,41 +588,44 @@ void t_haxe_generator::print_const_value(std::ofstream& out, string name, t_type
   }
 }
 
-string t_haxe_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
-  (void) name;
+string t_haxe_generator::render_const_value(ofstream& out,
+                                            string name,
+                                            t_type* type,
+                                            t_const_value* value) {
+  (void)name;
   type = get_true_type(type);
   std::ostringstream render;
-  
+
   if (type->is_base_type()) {
     t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
     switch (tbase) {
-        case t_base_type::TYPE_STRING:
-          render << '"' << get_escaped_string(value) << '"';
-          break;
-        case t_base_type::TYPE_BOOL:
-          render << ((value->get_integer() > 0) ? "true" : "false");
-          break;
-        case t_base_type::TYPE_BYTE:
-          render << "(byte)" << value->get_integer();
-          break;
-        case t_base_type::TYPE_I16:
-          render << "(short)" << value->get_integer();
-          break;
-        case t_base_type::TYPE_I32:
-          render << value->get_integer();
-          break;
-        case t_base_type::TYPE_I64:
-          render << value->get_integer() << "L";
-          break;
-        case t_base_type::TYPE_DOUBLE:
-          if (value->get_type() == t_const_value::CV_INTEGER) {
-            render << "(double)" << value->get_integer();
-          } else {
-            render << value->get_double();
-          }
-          break;
-        default:
-          throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
+    case t_base_type::TYPE_STRING:
+      render << '"' << get_escaped_string(value) << '"';
+      break;
+    case t_base_type::TYPE_BOOL:
+      render << ((value->get_integer() > 0) ? "true" : "false");
+      break;
+    case t_base_type::TYPE_BYTE:
+      render << "(byte)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I16:
+      render << "(short)" << value->get_integer();
+      break;
+    case t_base_type::TYPE_I32:
+      render << value->get_integer();
+      break;
+    case t_base_type::TYPE_I64:
+      render << value->get_integer() << "L";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      if (value->get_type() == t_const_value::CV_INTEGER) {
+        render << "(double)" << value->get_integer();
+      } else {
+        render << value->get_double();
+      }
+      break;
+    default:
+      throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
     }
   } else if (type->is_enum()) {
     render << value->get_integer();
@@ -659,11 +634,10 @@ string t_haxe_generator::render_const_value(ofstream& out, string name, t_type*
     print_const_value(out, t, type, value, true);
     render << t;
   }
-  
+
   return render.str();
 }
 
-
 /**
  * Generates a struct definition for a thrift data type. This is a class
  * with data members, read(), write(), and an inner Isset class.
@@ -683,35 +657,28 @@ void t_haxe_generator::generate_xception(t_struct* txception) {
   generate_haxe_struct(txception, true);
 }
 
-
 /**
  * Haxe struct definition.
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_struct(t_struct* tstruct,
-                                            bool is_exception,
-                                            bool is_result) {
+void t_haxe_generator::generate_haxe_struct(t_struct* tstruct, bool is_exception, bool is_result) {
   // Make output file
   string f_struct_name = package_dir_ + "/" + get_cap_name(tstruct->get_name()) + ".hx";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct <<
-    autogen_comment() <<
-  haxe_package() << ";" << endl;
-  
+  f_struct << autogen_comment() << haxe_package() << ";" << endl;
+
   f_struct << endl;
-  
+
   string imports;
 
-  f_struct <<
-    haxe_type_imports() <<
-    haxe_thrift_imports() << 
-    haxe_thrift_gen_imports(tstruct, imports) << endl;
-  
+  f_struct << haxe_type_imports() << haxe_thrift_imports()
+           << haxe_thrift_gen_imports(tstruct, imports) << endl;
+
   generate_haxe_struct_definition(f_struct, tstruct, is_exception, is_result);
-  
+
   f_struct.close();
 }
 
@@ -725,16 +692,15 @@ void t_haxe_generator::generate_haxe_struct(t_struct* tstruct,
  * @param in_class     If inside a class, needs to be static class
  * @param is_result    If this is a result it needs a different writer
  */
-void t_haxe_generator::generate_haxe_struct_definition(ofstream &out,
+void t_haxe_generator::generate_haxe_struct_definition(ofstream& out,
                                                        t_struct* tstruct,
                                                        bool is_exception,
                                                        bool is_result) {
   generate_haxe_doc(out, tstruct);
 
-  string clsname = get_cap_name( tstruct->get_name());
-  
-  indent(out) << 
-     "class " << clsname << " ";
+  string clsname = get_cap_name(tstruct->get_name());
+
+  indent(out) << "class " << clsname << " ";
 
   if (is_exception) {
     out << "extends TException ";
@@ -744,78 +710,79 @@ void t_haxe_generator::generate_haxe_struct_definition(ofstream &out,
   scope_up(out);
   indent(out) << endl;
 
-  indent(out) <<
-    "static var STRUCT_DESC = { new TStruct(\"" << tstruct->get_name() << "\"); };" << endl;
+  indent(out) << "static var STRUCT_DESC = { new TStruct(\"" << tstruct->get_name() << "\"); };"
+              << endl;
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) <<
-      "static var " << constant_name((*m_iter)->get_name()) <<
-      "_FIELD_DESC = { new TField(\"" << (*m_iter)->get_name() << "\", " <<
-      type_to_enum((*m_iter)->get_type()) << ", " <<
-      (*m_iter)->get_key() << "); };" << endl;
+    indent(out) << "static var " << constant_name((*m_iter)->get_name())
+                << "_FIELD_DESC = { new TField(\"" << (*m_iter)->get_name() << "\", "
+                << type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << "); };"
+                << endl;
   }
   out << endl;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     generate_haxe_doc(out, *m_iter);
-    //indent(out) << "private var _" << (*m_iter)->get_name() + " : " + type_name((*m_iter)->get_type()) << ";" << endl;
+    // indent(out) << "private var _" << (*m_iter)->get_name() + " : " +
+    // type_name((*m_iter)->get_type()) << ";" << endl;
     indent(out) << "@:isVar" << endl;
-    indent(out) << "public var " << (*m_iter)->get_name() + "(get,set) : " + get_cap_name(type_name((*m_iter)->get_type())) << ";" << endl;
+    indent(out) << "public var "
+                << (*m_iter)->get_name() + "(get,set) : "
+                   + get_cap_name(type_name((*m_iter)->get_type())) << ";" << endl;
   }
-  
+
   out << endl;
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) << "inline static var " << upcase_string((*m_iter)->get_name()) << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << endl;
+    indent(out) << "inline static var " << upcase_string((*m_iter)->get_name())
+                << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << endl;
   }
-  
+
   out << endl;
-  
+
   // Inner Isset class
   if (members.size() > 0) {
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        if (!type_can_be_null((*m_iter)->get_type())){
-          indent(out) <<
-            "private var __isset_" << (*m_iter)->get_name() << " : Bool = false;" <<  endl;
-        }
+      if (!type_can_be_null((*m_iter)->get_type())) {
+        indent(out) << "private var __isset_" << (*m_iter)->get_name() << " : Bool = false;"
+                    << endl;
       }
+    }
   }
-  
+
   out << endl;
-  
-  
+
   // Static initializer to populate global class to struct metadata map
-  if( false) {
+  if (false) {
     // TODO: reactivate when needed
     generate_haxe_meta_data_map(out, tstruct);
     indent(out) << "{" << endl;
     indent_up();
-    indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);" << endl;
+    indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);"
+                << endl;
     indent_down();
     indent(out) << "}" << endl;
     indent(out) << "}" << endl;
   }
-  
+
   // Default constructor
-  indent(out) <<
-    "public function new() {" << endl;
+  indent(out) << "public function new() {" << endl;
   indent_up();
-  if( is_exception) {
-    indent(out) <<
-      "super();" << endl;
+  if (is_exception) {
+    indent(out) << "super();" << endl;
   }
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     if ((*m_iter)->get_value() != NULL) {
-      indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_value()->get_integer() << ";" <<
-      endl;
+      indent(out) << "this." << (*m_iter)->get_name() << " = "
+                  << (*m_iter)->get_value()->get_integer() << ";" << endl;
     }
   }
   indent_down();
   indent(out) << "}" << endl << endl;
-  
+
   generate_property_getters_setters(out, tstruct);
   generate_generic_field_getters_setters(out, tstruct);
   generate_generic_isset_method(out, tstruct);
@@ -837,139 +804,129 @@ void t_haxe_generator::generate_haxe_struct_definition(ofstream &out,
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_struct_reader(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public function read( iprot : TProtocol) : Void {" << endl;
+void t_haxe_generator::generate_haxe_struct_reader(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function read( iprot : TProtocol) : Void {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables and read struct header
-  out <<
-    indent() << "var field : TField;" << endl <<
-    indent() << "iprot.readStructBegin();" << endl;
+  out << indent() << "var field : TField;" << endl << indent() << "iprot.readStructBegin();"
+      << endl;
 
   // Loop over reading in fields
-  indent(out) <<
-    "while (true)" << endl;
-    scope_up(out);
+  indent(out) << "while (true)" << endl;
+  scope_up(out);
 
-    // Read beginning field marker
-    indent(out) <<
-      "field = iprot.readFieldBegin();" << endl;
+  // Read beginning field marker
+  indent(out) << "field = iprot.readFieldBegin();" << endl;
 
-    // Check for field STOP marker and break
-    indent(out) <<
-      "if (field.type == TType.STOP) { " << endl;
-    indent_up();
-    indent(out) <<
-      "break;" << endl;
-    indent_down();
-    indent(out) <<
-      "}" << endl;
+  // Check for field STOP marker and break
+  indent(out) << "if (field.type == TType.STOP) { " << endl;
+  indent_up();
+  indent(out) << "break;" << endl;
+  indent_down();
+  indent(out) << "}" << endl;
 
-    // Switch statement on the field we are reading
-    indent(out) <<
-      "switch (field.id)" << endl;
+  // Switch statement on the field we are reading
+  indent(out) << "switch (field.id)" << endl;
 
-      scope_up(out);
+  scope_up(out);
 
-      // Generate deserialization code for known cases
-      for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-        indent(out) <<
-          "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << endl;
-        indent_up();
-        indent(out) <<
-          "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-        indent_up();
+  // Generate deserialization code for known cases
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    indent(out) << "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << endl;
+    indent_up();
+    indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+    indent_up();
 
-        generate_deserialize_field(out, *f_iter, "this.");
-        generate_isset_set(out, *f_iter);
-        indent_down();
-        out <<
-          indent() << "} else { " << endl <<
-          indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl <<
-          indent() << "}" << endl;
-        indent_down();
-      }
+    generate_deserialize_field(out, *f_iter, "this.");
+    generate_isset_set(out, *f_iter);
+    indent_down();
+    out << indent() << "} else { " << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
+        << endl << indent() << "}" << endl;
+    indent_down();
+  }
 
-      // In the default case we skip the field
-      out <<
-        indent() << "default:" << endl <<
-        indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl;
+  // In the default case we skip the field
+  out << indent() << "default:" << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
+      << endl;
 
-      scope_down(out);
+  scope_down(out);
 
-    // Read field end marker
-    indent(out) <<
-      "iprot.readFieldEnd();" << endl;
+  // Read field end marker
+  indent(out) << "iprot.readFieldEnd();" << endl;
 
-    scope_down(out);
+  scope_down(out);
 
-    out <<
-      indent() << "iprot.readStructEnd();" << endl << endl;
-    
-    // check for required fields of primitive type
-    // (which can be checked here but not in the general validate method)
-    out << endl << indent() << "// check for required fields of primitive type, which can't be checked in the validate method" << endl;
-    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-      if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
-        out <<
-          indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl <<
-          indent() << "  throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl <<
-          indent() << "}" << endl;
-      }
+  out << indent() << "iprot.readStructEnd();" << endl << endl;
+
+  // check for required fields of primitive type
+  // (which can be checked here but not in the general validate method)
+  out << endl << indent() << "// check for required fields of primitive type, which can't be "
+                             "checked in the validate method" << endl;
+  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+    if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
+      out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl << indent()
+          << "  throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '"
+          << (*f_iter)->get_name()
+          << "' was not found in serialized data! Struct: \" + toString());" << endl << indent()
+          << "}" << endl;
     }
+  }
 
-    // performs various checks (e.g. check that all required fields are set)
-    indent(out) << "validate();" << endl;
+  // performs various checks (e.g. check that all required fields are set)
+  indent(out) << "validate();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 // generates haxe method to perform various checks
 // (e.g. check that all required fields are set)
-void t_haxe_generator::generate_haxe_validator(ofstream& out,
-                                                   t_struct* tstruct){
+void t_haxe_generator::generate_haxe_validator(ofstream& out, t_struct* tstruct) {
   indent(out) << "public function validate() : Void {" << endl;
-  indent_up();  
-  
+  indent_up();
+
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
-  
+
   out << indent() << "// check for required fields" << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
       if (type_can_be_null((*f_iter)->get_type())) {
         indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
-        indent(out) << "  throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
+        indent(out)
+            << "  throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '"
+            << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
         indent(out) << "}" << endl;
       } else {
-        indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive." << endl;
+        indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
+                    << "' because it's a primitive." << endl;
       }
     }
   }
-  
+
   // check that fields of type enum have valid values
   out << indent() << "// check that fields of type enum have valid values" << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     t_field* field = (*f_iter);
     t_type* type = field->get_type();
     // if field is an enum, check that its value is valid
-    if (type->is_enum()){
-      indent(out) << "if (" << generate_isset_check(field) << " && !" << get_cap_name(get_enum_class_name(type)) << ".VALID_VALUES.contains(" << field->get_name() << ")){" << endl;
+    if (type->is_enum()) {
+      indent(out) << "if (" << generate_isset_check(field) << " && !"
+                  << get_cap_name(get_enum_class_name(type)) << ".VALID_VALUES.contains("
+                  << field->get_name() << ")){" << endl;
       indent_up();
-      indent(out) << "throw new TProtocolException(TProtocolException.UNKNOWN, \"The field '" << field->get_name() << "' has been assigned the invalid value \" + " << field->get_name() << ");" << endl;
+      indent(out) << "throw new TProtocolException(TProtocolException.UNKNOWN, \"The field '"
+                  << field->get_name() << "' has been assigned the invalid value \" + "
+                  << field->get_name() << ");" << endl;
       indent_down();
       indent(out) << "}" << endl;
-    } 
-  }  
-  
+    }
+  }
+
   indent_down();
   indent(out) << "}" << endl << endl;
 }
@@ -979,10 +936,8 @@ void t_haxe_generator::generate_haxe_validator(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_struct_writer(ofstream& out,
-                                                   t_struct* tstruct) {
-  out <<
-    indent() << "public function write(oprot:TProtocol) : Void {" << endl;
+void t_haxe_generator::generate_haxe_struct_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -997,19 +952,18 @@ void t_haxe_generator::generate_haxe_struct_writer(ofstream& out,
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out <<
-        indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+      out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
       indent_up();
     }
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     if (null_allowed) {
       indent_down();
@@ -1017,14 +971,11 @@ void t_haxe_generator::generate_haxe_struct_writer(ofstream& out,
     }
   }
   // Write the struct map
-  out <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
+      << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1035,10 +986,8 @@ void t_haxe_generator::generate_haxe_struct_writer(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_struct_result_writer(ofstream& out,
-                                                          t_struct* tstruct) {
-  out <<
-    indent() << "public function write(oprot:TProtocol) : Void {" << endl;
+void t_haxe_generator::generate_haxe_struct_result_writer(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1046,14 +995,12 @@ void t_haxe_generator::generate_haxe_struct_result_writer(ofstream& out,
   vector<t_field*>::const_iterator f_iter;
 
   indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
-  
+
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out <<
-        endl <<
-        indent() << "if ";
+      out << endl << indent() << "if ";
     } else {
       out << " else if ";
     }
@@ -1061,43 +1008,45 @@ void t_haxe_generator::generate_haxe_struct_result_writer(ofstream& out,
     out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
 
     indent_up();
-    
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
+
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
+                << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) <<
-      "oprot.writeFieldEnd();" << endl;
+    indent(out) << "oprot.writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}";
   }
   // Write the struct map
-  out <<
-    endl <<
-    indent() << "oprot.writeFieldStop();" << endl <<
-    indent() << "oprot.writeStructEnd();" << endl;
+  out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
+      << "oprot.writeStructEnd();" << endl;
 
   indent_down();
-  out <<
-    indent() << "}" << endl <<
-    endl;
+  out << indent() << "}" << endl << endl;
 }
 
-void t_haxe_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
-  (void) type;
-  (void) cap_name;
+void t_haxe_generator::generate_reflection_getters(ostringstream& out,
+                                                   t_type* type,
+                                                   string field_name,
+                                                   string cap_name) {
+  (void)type;
+  (void)cap_name;
   indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl;
   indent_up();
   indent(out) << "return this." << field_name << ";" << endl;
   indent_down();
 }
 
-void t_haxe_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
-  (void) type;
-  (void) cap_name;
+void t_haxe_generator::generate_reflection_setters(ostringstream& out,
+                                                   t_type* type,
+                                                   string field_name,
+                                                   string cap_name) {
+  (void)type;
+  (void)cap_name;
   indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
@@ -1109,7 +1058,8 @@ void t_haxe_generator::generate_reflection_setters(ostringstream& out, t_type* t
   indent_down();
 }
 
-void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
+void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out,
+                                                              t_struct* tstruct) {
 
   std::ostringstream getter_stream;
   std::ostringstream setter_stream;
@@ -1129,7 +1079,6 @@ void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out
     indent_down();
   }
 
-
   // create the setter
   indent(out) << "public function setFieldValue(fieldID : Int, value : Dynamic) : Void {" << endl;
   indent_up();
@@ -1143,7 +1092,7 @@ void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out
   } else {
     indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
   }
-  
+
   indent_down();
   indent(out) << "}" << endl << endl;
 
@@ -1167,12 +1116,13 @@ void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out
 }
 
 // Creates a generic isSet method that takes the field number as argument
-void t_haxe_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct){
+void t_haxe_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // create the isSet method
-  indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise" << endl;
+  indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a "
+                 "value) and false otherwise" << endl;
   indent(out) << "public function isSet(fieldID : Int) : Bool {" << endl;
   indent_up();
   if (fields.size() > 0) {
@@ -1202,8 +1152,7 @@ void t_haxe_generator::generate_generic_isset_method(std::ofstream& out, t_struc
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_property_getters_setters(ofstream& out,
-                                                      t_struct* tstruct) {
+void t_haxe_generator::generate_property_getters_setters(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1211,32 +1160,29 @@ void t_haxe_generator::generate_property_getters_setters(ofstream& out,
     t_type* type = get_true_type(field->get_type());
     std::string field_name = field->get_name();
     std::string cap_name = get_cap_name(field_name);
-        
+
     // Simple getter
     generate_haxe_doc(out, field);
-    indent(out) << "public function get_" << field_name << "() : " <<
-      get_cap_name(type_name(type)) << " {" << endl;
+    indent(out) << "public function get_" << field_name << "() : " << get_cap_name(type_name(type))
+                << " {" << endl;
     indent_up();
     indent(out) << "return this." << field_name << ";" << endl;
     indent_down();
     indent(out) << "}" << endl << endl;
-    
+
     // Simple setter
     generate_haxe_doc(out, field);
-    indent(out) << 
-      "public function set_" << field_name << 
-      "(" << field_name << ":" << get_cap_name(type_name(type)) << ") : " <<
-      get_cap_name(type_name(type)) << " {" << endl;
+    indent(out) << "public function set_" << field_name << "(" << field_name << ":"
+                << get_cap_name(type_name(type)) << ") : " << get_cap_name(type_name(type)) << " {"
+                << endl;
     indent_up();
-    indent(out) << 
-      "this." << field_name << " = " << field_name << ";" << endl;
+    indent(out) << "this." << field_name << " = " << field_name << ";" << endl;
     generate_isset_set(out, field);
-    indent(out) << 
-      "return this." << field_name << ";" << endl;
-    
+    indent(out) << "return this." << field_name << ";" << endl;
+
     indent_down();
     indent(out) << "}" << endl << endl;
-    
+
     // Unsetter
     indent(out) << "public function unset" << cap_name << "() : Void {" << endl;
     indent_up();
@@ -1247,9 +1193,10 @@ void t_haxe_generator::generate_property_getters_setters(ofstream& out,
     }
     indent_down();
     indent(out) << "}" << endl << endl;
-    
+
     // isSet method
-    indent(out) << "// Returns true if field " << field_name << " is set (has been assigned a value) and false otherwise" << endl;
+    indent(out) << "// Returns true if field " << field_name
+                << " is set (has been assigned a value) and false otherwise" << endl;
     indent(out) << "public function is" << get_cap_name("set") << cap_name << "() : Bool {" << endl;
     indent_up();
     if (type_can_be_null(type)) {
@@ -1267,13 +1214,12 @@ void t_haxe_generator::generate_property_getters_setters(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out,
-                                                     t_struct* tstruct) {
-  out << indent() << "public " << "function toString() : String {" << endl;
+void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out, t_struct* tstruct) {
+  out << indent() << "public "
+      << "function toString() : String {" << endl;
   indent_up();
 
-  out <<
-    indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << endl;
+  out << indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << endl;
   out << indent() << "var first : Bool = true;" << endl << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1281,7 +1227,7 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out,
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
       indent_up();
     }
@@ -1299,11 +1245,13 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out,
       indent(out) << "} else {" << endl;
       indent_up();
     }
-    
+
     if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
       indent(out) << "  ret += \"BINARY\";" << endl;
-    } else if(field->get_type()->is_enum()) {
-      indent(out) << "var " << field->get_name() << "_name : String = " << get_cap_name(get_enum_class_name(field->get_type())) << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];"<< endl;
+    } else if (field->get_type()->is_enum()) {
+      indent(out) << "var " << field->get_name()
+                  << "_name : String = " << get_cap_name(get_enum_class_name(field->get_type()))
+                  << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << endl;
       indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
       indent(out) << "  ret += " << field->get_name() << "_name;" << endl;
       indent(out) << "  ret += \" (\";" << endl;
@@ -1315,26 +1263,23 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out,
     } else {
       indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << endl;
     }
-    
+
     if (can_be_null) {
       indent_down();
       indent(out) << "}" << endl;
     }
     indent(out) << "first = false;" << endl;
 
-    if(could_be_unset) {
+    if (could_be_unset) {
       indent_down();
       indent(out) << "}" << endl;
     }
     first = false;
   }
-  out <<
-    indent() << "ret += \")\";" << endl <<
-    indent() << "return ret;" << endl;
+  out << indent() << "ret += \")\";" << endl << indent() << "return ret;" << endl;
 
   indent_down();
-  indent(out) << "}" << endl <<
-    endl;
+  indent(out) << "}" << endl << endl;
 }
 
 /**
@@ -1343,8 +1288,7 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_haxe_generator::generate_haxe_meta_data_map(ofstream& out,
-                                                   t_struct* tstruct) {
+void t_haxe_generator::generate_haxe_meta_data_map(ofstream& out, t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
@@ -1357,7 +1301,8 @@ void t_haxe_generator::generate_haxe_meta_data_map(ofstream& out,
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       t_field* field = *f_iter;
       std::string field_name = field->get_name();
-      indent(out) << "metaDataMap[" << upcase_string(field_name) << "_FIELD_ID] = new FieldMetaData(\"" << field_name << "\", ";
+      indent(out) << "metaDataMap[" << upcase_string(field_name)
+                  << "_FIELD_ID] = new FieldMetaData(\"" << field_name << "\", ";
 
       // Set field requirement type (required, optional, etc.)
       if (field->get_req() == t_field::T_REQUIRED) {
@@ -1368,20 +1313,20 @@ void t_haxe_generator::generate_haxe_meta_data_map(ofstream& out,
         out << "TFieldRequirementType.DEFAULT, ";
       }
 
-      // Create value meta data    
+      // Create value meta data
       generate_field_value_meta_data(out, field->get_type());
-      out  << ");" << endl;
+      out << ");" << endl;
     }
     scope_down(out);
   }
 }
 
-/** 
+/**
  * Returns a string with the haxe representation of the given thrift type
  * (e.g. for the type struct it returns "TType.STRUCT")
  */
 std::string t_haxe_generator::get_haxe_type_string(t_type* type) {
-  if (type->is_list()){
+  if (type->is_list()) {
     return "TType.LIST";
   } else if (type->is_map()) {
     return "TType.MAP";
@@ -1395,37 +1340,58 @@ std::string t_haxe_generator::get_haxe_type_string(t_type* type) {
     return get_haxe_type_string(((t_typedef*)type)->get_type());
   } else if (type->is_base_type()) {
     switch (((t_base_type*)type)->get_base()) {
-      case t_base_type::TYPE_VOID   : return      "TType.VOID"; break;
-      case t_base_type::TYPE_STRING : return    "TType.STRING"; break;
-      case t_base_type::TYPE_BOOL   : return      "TType.BOOL"; break;
-      case t_base_type::TYPE_BYTE   : return      "TType.BYTE"; break;
-      case t_base_type::TYPE_I16    : return       "TType.I16"; break;
-      case t_base_type::TYPE_I32    : return       "TType.I32"; break;
-      case t_base_type::TYPE_I64    : return       "TType.I64"; break;
-      case t_base_type::TYPE_DOUBLE : return    "TType.DOUBLE"; break;
-      default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_haxe_generator::get_haxe_type_string!"); break; // This should never happen!
+    case t_base_type::TYPE_VOID:
+      return "TType.VOID";
+      break;
+    case t_base_type::TYPE_STRING:
+      return "TType.STRING";
+      break;
+    case t_base_type::TYPE_BOOL:
+      return "TType.BOOL";
+      break;
+    case t_base_type::TYPE_BYTE:
+      return "TType.BYTE";
+      break;
+    case t_base_type::TYPE_I16:
+      return "TType.I16";
+      break;
+    case t_base_type::TYPE_I32:
+      return "TType.I32";
+      break;
+    case t_base_type::TYPE_I64:
+      return "TType.I64";
+      break;
+    case t_base_type::TYPE_DOUBLE:
+      return "TType.DOUBLE";
+      break;
+    default:
+      throw std::runtime_error("Unknown thrift type \"" + type->get_name()
+                               + "\" passed to t_haxe_generator::get_haxe_type_string!");
+      break; // This should never happen!
     }
   } else {
-    throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_haxe_generator::get_haxe_type_string!"); // This should never happen!
+    throw std::runtime_error(
+        "Unknown thrift type \"" + type->get_name()
+        + "\" passed to t_haxe_generator::get_haxe_type_string!"); // This should never happen!
   }
 }
 
-void t_haxe_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type){
+void t_haxe_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
   out << endl;
   indent_up();
   indent_up();
-  if (type->is_struct()){
+  if (type->is_struct()) {
     indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type);
-  } else if (type->is_container()){
-    if (type->is_list()){
+  } else if (type->is_container()) {
+    if (type->is_list()) {
       indent(out) << "new ListMetaData(TType.LIST, ";
-      t_type* elem_type = ((t_list*)type)->get_elem_type();    
-      generate_field_value_meta_data(out, elem_type);   
-    } else if (type->is_set()){
+      t_type* elem_type = ((t_list*)type)->get_elem_type();
+      generate_field_value_meta_data(out, elem_type);
+    } else if (type->is_set()) {
       indent(out) << "new SetMetaData(TType.SET, ";
-      t_type* elem_type = ((t_list*)type)->get_elem_type();    
-      generate_field_value_meta_data(out, elem_type); 
-    } else{ // map
+      t_type* elem_type = ((t_list*)type)->get_elem_type();
+      generate_field_value_meta_data(out, elem_type);
+    } else { // map
       indent(out) << "new MapMetaData(TType.MAP, ";
       t_type* key_type = ((t_map*)type)->get_key_type();
       t_type* val_type = ((t_map*)type)->get_val_type();
@@ -1441,7 +1407,6 @@ void t_haxe_generator::generate_field_value_meta_data(std::ofstream& out, t_type
   indent_down();
 }
 
-
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1455,18 +1420,15 @@ void t_haxe_generator::generate_service(t_service* tservice) {
   string f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + ".hx";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ <<
-    autogen_comment() << haxe_package() << ";" << endl;
-  
-  f_service_ << endl <<
-    haxe_type_imports() <<
-    haxe_thrift_imports() <<
-    haxe_thrift_gen_imports(tservice);
+  f_service_ << autogen_comment() << haxe_package() << ";" << endl;
 
-  if(tservice->get_extends() != NULL) {
+  f_service_ << endl << haxe_type_imports() << haxe_thrift_imports()
+             << haxe_thrift_gen_imports(tservice);
+
+  if (tservice->get_extends() != NULL) {
     t_type* parent = tservice->get_extends();
     string parent_namespace = parent->get_program()->get_namespace("haxe");
-    if(!parent_namespace.empty() && parent_namespace != package_name_) {
+    if (!parent_namespace.empty() && parent_namespace != package_name_) {
       f_service_ << "import " << type_name(parent) << ";" << endl;
     }
   }
@@ -1476,23 +1438,18 @@ void t_haxe_generator::generate_service(t_service* tservice) {
   generate_service_interface(tservice);
 
   f_service_.close();
-  
+
   // Now make the implementation/client file
-  f_service_name = package_dir_+"/"+get_cap_name(service_name_)+"Impl.hx";
+  f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Impl.hx";
   f_service_.open(f_service_name.c_str());
-  
-  f_service_ <<
-      autogen_comment() << haxe_package() << ";" << endl <<
-      endl <<
-      haxe_type_imports() <<
-      haxe_thrift_imports() <<
-      haxe_thrift_gen_imports(tservice) << endl;
 
+  f_service_ << autogen_comment() << haxe_package() << ";" << endl << endl << haxe_type_imports()
+             << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << endl;
 
-  if(tservice->get_extends() != NULL) {
+  if (tservice->get_extends() != NULL) {
     t_type* parent = tservice->get_extends();
     string parent_namespace = parent->get_program()->get_namespace("haxe");
-    if(!parent_namespace.empty() && parent_namespace != package_name_) {
+    if (!parent_namespace.empty() && parent_namespace != package_name_) {
       f_service_ << "import " << type_name(parent) << "Impl;" << endl;
     }
   }
@@ -1507,26 +1464,22 @@ void t_haxe_generator::generate_service(t_service* tservice) {
   generate_service_helpers(tservice);
 
   // Now make the processor/server file
-  f_service_name = package_dir_+"/"+get_cap_name(service_name_)+"Processor.hx";
+  f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Processor.hx";
   f_service_.open(f_service_name.c_str());
-  
-  f_service_ <<
-      autogen_comment() << haxe_package() << ";" << endl << 
-      endl <<
-      haxe_type_imports() <<
-      haxe_thrift_imports() <<
-      haxe_thrift_gen_imports(tservice) << endl;
-  
-  if(!package_name_.empty()) {
+
+  f_service_ << autogen_comment() << haxe_package() << ";" << endl << endl << haxe_type_imports()
+             << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << endl;
+
+  if (!package_name_.empty()) {
     f_service_ << "import " << package_name_ << ".*;" << endl;
-    f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str() << "Impl;" << endl;
+    f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str()
+               << "Impl;" << endl;
     f_service_ << endl;
   }
-  
+
   generate_service_server(tservice);
-  
+
   f_service_.close();
-    
 }
 
 /**
@@ -1534,31 +1487,33 @@ void t_haxe_generator::generate_service(t_service* tservice) {
  *
  * @param tfunction The service function to generate code for.
  */
-string t_haxe_generator::generate_service_method_onsuccess(t_function* tfunction, bool as_type, bool omit_name) {
-  if( tfunction->is_oneway()) {
+string t_haxe_generator::generate_service_method_onsuccess(t_function* tfunction,
+                                                           bool as_type,
+                                                           bool omit_name) {
+  if (tfunction->is_oneway()) {
     return "";
   }
-  
+
   string name = "";
-  if( ! omit_name) {
+  if (!omit_name) {
     name = "onSuccess";
-    if( as_type) {
+    if (as_type) {
       name += " : ";
     }
   }
-  
-  if( tfunction->get_returntype()->is_void()) {
-    if( as_type) {
-      return name + "Void->Void = null";    
+
+  if (tfunction->get_returntype()->is_void()) {
+    if (as_type) {
+      return name + "Void->Void = null";
     } else {
-      return name + "() : Void";    
+      return name + "() : Void";
     }
   }
-  
-  if( as_type) {
+
+  if (as_type) {
     return name + type_name(tfunction->get_returntype()) + "->Void = null";
   } else {
-    return name + "( retval : " + type_name(tfunction->get_returntype()) + ")";    
+    return name + "( retval : " + type_name(tfunction->get_returntype()) + ")";
   }
 }
 
@@ -1568,11 +1523,11 @@ string t_haxe_generator::generate_service_method_onsuccess(t_function* tfunction
  * @param tfunction The service function to generate code for.
  */
 void t_haxe_generator::generate_service_method_signature(t_function* tfunction, bool is_interface) {
-  if( callbacks_) {
-    generate_service_method_signature_callback( tfunction, is_interface);
+  if (callbacks_) {
+    generate_service_method_signature_callback(tfunction, is_interface);
   } else {
-    generate_service_method_signature_normal( tfunction, is_interface);
-  } 
+    generate_service_method_signature_normal(tfunction, is_interface);
+  }
 }
 
 /**
@@ -1580,12 +1535,12 @@ void t_haxe_generator::generate_service_method_signature(t_function* tfunction,
  *
  * @param tfunction The service function to generate code for.
  */
-void t_haxe_generator::generate_service_method_signature_normal(t_function* tfunction, bool is_interface) {
-  if( is_interface) {
+void t_haxe_generator::generate_service_method_signature_normal(t_function* tfunction,
+                                                                bool is_interface) {
+  if (is_interface) {
     indent(f_service_) << function_signature_normal(tfunction) << ";" << endl << endl;
   } else {
-    indent(f_service_) <<
-      "public " << function_signature_normal(tfunction) << " {" << endl;
+    indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << endl;
   }
 }
 
@@ -1594,19 +1549,18 @@ void t_haxe_generator::generate_service_method_signature_normal(t_function* tfun
  *
  * @param tfunction The service function to generate code for.
  */
-void t_haxe_generator::generate_service_method_signature_callback(t_function* tfunction, bool is_interface) {
+void t_haxe_generator::generate_service_method_signature_callback(t_function* tfunction,
+                                                                  bool is_interface) {
   if (!tfunction->is_oneway()) {
     std::string on_success_impl = generate_service_method_onsuccess(tfunction, false, false);
     indent(f_service_) << "// function onError(Dynamic) : Void;" << endl;
     indent(f_service_) << "// function " << on_success_impl.c_str() << ";" << endl;
   }
 
-  if( is_interface) {
-    indent(f_service_) << function_signature_callback(tfunction) << ";" <<
-      endl << endl;
+  if (is_interface) {
+    indent(f_service_) << function_signature_callback(tfunction) << ";" << endl << endl;
   } else {
-    indent(f_service_) <<
-      "public " << function_signature_callback(tfunction) << " {" << endl;
+    indent(f_service_) << "public " << function_signature_callback(tfunction) << " {" << endl;
   }
 }
 
@@ -1622,19 +1576,17 @@ void t_haxe_generator::generate_service_interface(t_service* tservice) {
   }
 
   generate_haxe_doc(f_service_, tservice);
-  f_service_ << indent() << "interface " << get_cap_name(service_name_) << extends_iface <<
-    " {" << endl << endl;
+  f_service_ << indent() << "interface " << get_cap_name(service_name_) << extends_iface << " {"
+             << endl << endl;
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     generate_haxe_doc(f_service_, *f_iter);
-    generate_service_method_signature(*f_iter,true);
+    generate_service_method_signature(*f_iter, true);
   }
   indent_down();
-  f_service_ <<
-    indent() << "}" << endl <<
-    endl;
+  f_service_ << indent() << "}" << endl << endl;
 }
 
 /**
@@ -1653,7 +1605,6 @@ void t_haxe_generator::generate_service_helpers(t_service* tservice) {
   }
 }
 
-
 /**
  * Generates a service client definition.
  *
@@ -1667,19 +1618,14 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
     extends_client = " extends " + extends + "Impl";
   }
 
-  indent(f_service_) <<
-    "class " << get_cap_name(service_name_) <<
-    "Impl" << extends_client <<
-    " implements " << get_cap_name(service_name_) <<
-    " {" << endl << endl;
+  indent(f_service_) << "class " << get_cap_name(service_name_) << "Impl" << extends_client
+                     << " implements " << get_cap_name(service_name_) << " {" << endl << endl;
   indent_up();
 
-  indent(f_service_) <<
-    "public function new( iprot : TProtocol, oprot : TProtocol = null)" << endl;
+  indent(f_service_) << "public function new( iprot : TProtocol, oprot : TProtocol = null)" << endl;
   scope_up(f_service_);
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "iprot_ = iprot;" << endl;
+    f_service_ << indent() << "iprot_ = iprot;" << endl;
     f_service_ << indent() << "if (oprot == null) {" << endl;
     indent_up();
     f_service_ << indent() << "oprot_ = iprot;" << endl;
@@ -1690,35 +1636,27 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
     indent_down();
     f_service_ << indent() << "}" << endl;
   } else {
-    f_service_ <<
-      indent() << "super(iprot, oprot);" << endl;
+    f_service_ << indent() << "super(iprot, oprot);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "private var iprot_ : TProtocol;"  << endl <<
-      indent() << "private var oprot_ : TProtocol;"  << endl <<
-      indent() << "private var seqid_ : Int;" << endl <<
-      endl;
-
-    indent(f_service_) <<
-      "public function getInputProtocol() : TProtocol" << endl;
+    f_service_ << indent() << "private var iprot_ : TProtocol;" << endl << indent()
+               << "private var oprot_ : TProtocol;" << endl << indent()
+               << "private var seqid_ : Int;" << endl << endl;
+
+    indent(f_service_) << "public function getInputProtocol() : TProtocol" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.iprot_;" << endl;
+    indent(f_service_) << "return this.iprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
 
-    indent(f_service_) <<
-      "public function getOutputProtocol() : TProtocol" << endl;
+    indent(f_service_) << "public function getOutputProtocol() : TProtocol" << endl;
     scope_up(f_service_);
-    indent(f_service_) <<
-      "return this.oprot_;" << endl;
+    indent(f_service_) << "return this.oprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
-
   }
 
   // Generate client method implementations
@@ -1728,51 +1666,49 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    generate_service_method_signature(*f_iter,false);
+    generate_service_method_signature(*f_iter, false);
 
     indent_up();
 
-
     // Get the struct of function call params
     t_struct* arg_struct = (*f_iter)->get_arglist();
-    
-    string argsname = get_cap_name( (*f_iter)->get_name() + "_args");
+
+    string argsname = get_cap_name((*f_iter)->get_name() + "_args");
     vector<t_field*>::const_iterator fld_iter;
     const vector<t_field*>& fields = arg_struct->get_members();
 
     // Serialize the request
     string calltype = (*f_iter)->is_oneway() ? "ONEWAY" : "CALL";
-    f_service_ <<
-      indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", TMessageType." << calltype << ", seqid_));" << endl <<
-      indent() << "var args : " << argsname << " = new " << argsname << "();" << endl;
+    f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname
+               << "\", TMessageType." << calltype << ", seqid_));" << endl << indent()
+               << "var args : " << argsname << " = new " << argsname << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ <<
-        indent() << "args." << (*fld_iter)->get_name() << " = " << (*fld_iter)->get_name() << ";" << endl;
+      f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
+                 << (*fld_iter)->get_name() << ";" << endl;
     }
 
-    f_service_ <<
-      indent() << "args.write(oprot_);" << endl <<
-    indent() << "oprot_.writeMessageEnd();" << endl;
-    
-    if( ! ((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
-      f_service_ << indent() << "var retval : " << type_name((*f_iter)->get_returntype()) <<";" << endl;
+    f_service_ << indent() << "args.write(oprot_);" << endl << indent()
+               << "oprot_.writeMessageEnd();" << endl;
+
+    if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
+      f_service_ << indent() << "var retval : " << type_name((*f_iter)->get_returntype()) << ";"
+                 << endl;
     }
-    
+
     if ((*f_iter)->is_oneway()) {
       f_service_ << indent() << "oprot_.getTransport().flush();" << endl;
-    }
-    else {
+    } else {
       indent(f_service_) << "oprot_.getTransport().flush(function(error:Dynamic) : Void {" << endl;
       indent_up();
-      if( callbacks_) {
+      if (callbacks_) {
         indent(f_service_) << "try {" << endl;
         indent_up();
       }
-      string resultname = get_cap_name( (*f_iter)->get_name() + "_result");
+      string resultname = get_cap_name((*f_iter)->get_name() + "_result");
       indent(f_service_) << "if (error != null) {" << endl;
       indent_up();
-      if( callbacks_) {
+      if (callbacks_) {
         indent(f_service_) << "if (onError != null) onError(error);" << endl;
         indent(f_service_) << "return;" << endl;
       } else {
@@ -1785,7 +1721,7 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
       indent_up();
       indent(f_service_) << "var x = TApplicationException.read(iprot_);" << endl;
       indent(f_service_) << "iprot_.readMessageEnd();" << endl;
-      if( callbacks_) {
+      if (callbacks_) {
         indent(f_service_) << "if (onError != null) onError(x);" << endl;
         indent(f_service_) << "return;" << endl;
       } else {
@@ -1793,7 +1729,8 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
       }
       indent_down();
       indent(f_service_) << "}" << endl;
-      indent(f_service_) << "var result : " << resultname << " = new " << resultname << "();" << endl;
+      indent(f_service_) << "var result : " << resultname << " = new " << resultname << "();"
+                         << endl;
       indent(f_service_) << "result.read(iprot_);" << endl;
       indent(f_service_) << "iprot_.readMessageEnd();" << endl;
 
@@ -1801,7 +1738,7 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void()) {
         indent(f_service_) << "if (result." << generate_isset_check("success") << ") {" << endl;
         indent_up();
-        if( callbacks_) {
+        if (callbacks_) {
           indent(f_service_) << "if (onSuccess != null) onSuccess(result.success);" << endl;
           indent(f_service_) << "return;" << endl;
         } else {
@@ -1818,8 +1755,9 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
         indent(f_service_) << "if (result." << (*x_iter)->get_name() << " != null) {" << endl;
         indent_up();
-        if( callbacks_) {
-          indent(f_service_) << "if (onError != null) onError(result." << (*x_iter)->get_name() << ");" << endl;
+        if (callbacks_) {
+          indent(f_service_) << "if (onError != null) onError(result." << (*x_iter)->get_name()
+                             << ");" << endl;
           indent(f_service_) << "return;" << endl;
         } else {
           indent(f_service_) << "throw result." << (*x_iter)->get_name() << ";" << endl;
@@ -1830,49 +1768,51 @@ void t_haxe_generator::generate_service_client(t_service* tservice) {
 
       // If you get here it's an exception, unless a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        if( callbacks_) {
+        if (callbacks_) {
           indent(f_service_) << "if (onSuccess != null) onSuccess();" << endl;
         }
         indent(f_service_) << "return;" << endl;
       } else {
-        if( callbacks_) {
+        if (callbacks_) {
           indent(f_service_) << "if (onError != null)" << endl;
           indent_up();
-          indent(f_service_) << "onError( new TApplicationException(TApplicationException.MISSING_RESULT," << endl;
-          indent(f_service_) << "                               \"" << (*f_iter)->get_name() << " failed: unknown result\"));" << endl;
+          indent(f_service_)
+              << "onError( new TApplicationException(TApplicationException.MISSING_RESULT," << endl;
+          indent(f_service_) << "                               \"" << (*f_iter)->get_name()
+                             << " failed: unknown result\"));" << endl;
           indent_down();
         } else {
-          indent(f_service_) << "throw new TApplicationException(TApplicationException.MISSING_RESULT," << endl;
-          indent(f_service_) << "                            \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+          indent(f_service_)
+              << "throw new TApplicationException(TApplicationException.MISSING_RESULT," << endl;
+          indent(f_service_) << "                            \"" << (*f_iter)->get_name()
+                             << " failed: unknown result\");" << endl;
         }
       }
 
-      if( callbacks_) {
+      if (callbacks_) {
         indent_down();
         indent(f_service_) << "} catch( e : TException) {" << endl;
         indent_up();
         indent(f_service_) << "if (onError != null) onError(e);" << endl;
         indent_down();
         indent(f_service_) << "}" << endl;
-      } 
-      
+      }
+
       indent_down();
-      indent(f_service_) <<
-      "});" << endl;
+      indent(f_service_) << "});" << endl;
     }
-    
-    if( ! ((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
+
+    if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
       f_service_ << indent() << "return retval;" << endl;
     }
-    
+
     // Close function
     scope_down(f_service_);
     f_service_ << endl;
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl;
+  indent(f_service_) << "}" << endl;
 }
 
 /**
@@ -1894,36 +1834,32 @@ void t_haxe_generator::generate_service_server(t_service* tservice) {
   }
 
   // Generate the header portion
-  indent(f_service_) <<
-    "class " << get_cap_name(service_name_) <<
-    "Processor" << extends_processor <<
-    " implements TProcessor {" << 
-    endl << endl;
+  indent(f_service_) << "class " << get_cap_name(service_name_) << "Processor" << extends_processor
+                     << " implements TProcessor {" << endl << endl;
   indent_up();
 
-  f_service_ <<
-    indent() << "private var " << get_cap_name(service_name_) << "_iface_ : " << get_cap_name(service_name_) << ";" << endl;
+  f_service_ << indent() << "private var " << get_cap_name(service_name_)
+             << "_iface_ : " << get_cap_name(service_name_) << ";" << endl;
 
   if (extends.empty()) {
-    f_service_ <<
-      indent() << "private var PROCESS_MAP = new StringMap< Int->TProtocol->TProtocol->Void >();" << endl;
+    f_service_ << indent()
+               << "private var PROCESS_MAP = new StringMap< Int->TProtocol->TProtocol->Void >();"
+               << endl;
   }
 
   f_service_ << endl;
 
-  indent(f_service_) <<
-    "public function new( iface : " << get_cap_name(service_name_) << ")" << endl;
+  indent(f_service_) << "public function new( iface : " << get_cap_name(service_name_) << ")"
+                     << endl;
   scope_up(f_service_);
   if (!extends.empty()) {
-    f_service_ <<
-      indent() << "super(iface);" << endl;
+    f_service_ << indent() << "super(iface);" << endl;
   }
-  f_service_ <<
-    indent() << get_cap_name(service_name_) << "_iface_ = iface;" << endl;
+  f_service_ << indent() << get_cap_name(service_name_) << "_iface_ = iface;" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ <<
-      indent() << "PROCESS_MAP.set(\"" << (*f_iter)->get_name() << "\", " << (*f_iter)->get_name() << "());" << endl;
+    f_service_ << indent() << "PROCESS_MAP.set(\"" << (*f_iter)->get_name() << "\", "
+               << (*f_iter)->get_name() << "());" << endl;
   }
 
   scope_down(f_service_);
@@ -1932,34 +1868,32 @@ void t_haxe_generator::generate_service_server(t_service* tservice) {
   // Generate the server implementation
   string override = "";
   if (tservice->get_extends() != NULL) {
-      override = "override ";
+    override = "override ";
   }
-  indent(f_service_) << override << "public function process( iprot : TProtocol, oprot : TProtocol) : Bool" << endl;
+  indent(f_service_) << override
+                     << "public function process( iprot : TProtocol, oprot : TProtocol) : Bool"
+                     << endl;
   scope_up(f_service_);
 
-  f_service_ <<
-  indent() << "var msg : TMessage = iprot.readMessageBegin();" << endl;
+  f_service_ << indent() << "var msg : TMessage = iprot.readMessageBegin();" << endl;
 
   // TODO(mcslee): validate message, was the seqid etc. legit?
   // AS- If all method is oneway:
   // do you have an oprot?
   // do you you need nullcheck?
-  f_service_ <<
-    indent() << "var fn  = PROCESS_MAP.get(msg.name);" << endl <<
-    indent() << "if (fn == null) {" << endl <<
-    indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl <<
-    indent() << "  iprot.readMessageEnd();" << endl <<
-    indent() << "  var x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl <<
-    indent() << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl <<
-    indent() << "  x.write(oprot);" << endl <<
-    indent() << "  oprot.writeMessageEnd();" << endl <<
-    indent() << "  oprot.getTransport().flush();" << endl <<
-    indent() << "  return true;" << endl <<
-    indent() << "}" << endl <<
-    indent() << "fn( msg.seqid, iprot, oprot);" << endl;
-
-  f_service_ <<
-    indent() << "return true;" << endl;
+  f_service_
+      << indent() << "var fn  = PROCESS_MAP.get(msg.name);" << endl << indent()
+      << "if (fn == null) {" << endl << indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);"
+      << endl << indent() << "  iprot.readMessageEnd();" << endl << indent()
+      << "  var x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid "
+         "method name: '\"+msg.name+\"'\");" << endl << indent()
+      << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
+      << endl << indent() << "  x.write(oprot);" << endl << indent() << "  oprot.writeMessageEnd();"
+      << endl << indent() << "  oprot.getTransport().flush();" << endl << indent()
+      << "  return true;" << endl << indent() << "}" << endl << indent()
+      << "fn( msg.seqid, iprot, oprot);" << endl;
+
+  f_service_ << indent() << "return true;" << endl;
 
   scope_down(f_service_);
   f_service_ << endl;
@@ -1970,9 +1904,7 @@ void t_haxe_generator::generate_service_server(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) <<
-    "}" << endl <<
-    endl;
+  indent(f_service_) << "}" << endl << endl;
 }
 
 /**
@@ -1985,7 +1917,7 @@ void t_haxe_generator::generate_function_helpers(t_function* tfunction) {
     return;
   }
 
-  string resultname = get_cap_name( tfunction->get_name() + "_result");
+  string resultname = get_cap_name(tfunction->get_name() + "_result");
   t_struct result(program_, resultname);
   t_field success(tfunction->get_returntype(), "success", 0);
   if (!tfunction->get_returntype()->is_void()) {
@@ -2007,27 +1939,24 @@ void t_haxe_generator::generate_function_helpers(t_function* tfunction) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_haxe_generator::generate_process_function(t_service* tservice,
-                                                 t_function* tfunction) {
-  (void) tservice;
+void t_haxe_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
+  (void)tservice;
   // Open class
-  indent(f_service_) <<
-  "private function " << tfunction->get_name() << "() : Int->TProtocol->TProtocol->Void {" << endl;
+  indent(f_service_) << "private function " << tfunction->get_name()
+                     << "() : Int->TProtocol->TProtocol->Void {" << endl;
   indent_up();
 
   // Open function
-  indent(f_service_) <<
-    "return function( seqid : Int, iprot : TProtocol, oprot : TProtocol) : Void"
-    << endl;
+  indent(f_service_) << "return function( seqid : Int, iprot : TProtocol, oprot : TProtocol) : Void"
+                     << endl;
   scope_up(f_service_);
 
-  string argsname = get_cap_name( tfunction->get_name() + "_args");
-  string resultname = get_cap_name( tfunction->get_name() + "_result");
+  string argsname = get_cap_name(tfunction->get_name() + "_args");
+  string resultname = get_cap_name(tfunction->get_name() + "_result");
 
-  f_service_ <<
-    indent() << "var args : "<< argsname << " = new " << argsname << "();" << endl <<
-    indent() << "args.read(iprot);" << endl <<
-    indent() << "iprot.readMessageEnd();" << endl;
+  f_service_ << indent() << "var args : " << argsname << " = new " << argsname << "();" << endl
+             << indent() << "args.read(iprot);" << endl << indent() << "iprot.readMessageEnd();"
+             << endl;
 
   t_struct* xs = tfunction->get_xceptions();
   const std::vector<t_field*>& xceptions = xs->get_members();
@@ -2035,53 +1964,51 @@ void t_haxe_generator::generate_process_function(t_service* tservice,
 
   // Declare result for non oneway function
   if (!tfunction->is_oneway()) {
-    f_service_ <<
-      indent() << "var result : " << resultname << " = new " << resultname << "();" << endl;
+    f_service_ << indent() << "var result : " << resultname << " = new " << resultname << "();"
+               << endl;
   }
 
   // Try block for any  function to catch (defined or undefined) exceptions
-  f_service_ <<
-    indent() << "try {" << endl;
+  f_service_ << indent() << "try {" << endl;
   indent_up();
 
-  if(callbacks_) {
+  if (callbacks_) {
     // callback function style onError/onSuccess
 
     // Generate the function call
     t_struct* arg_struct = tfunction->get_arglist();
     const std::vector<t_field*>& fields = arg_struct->get_members();
     vector<t_field*>::const_iterator f_iter;
-  
+
     f_service_ << indent();
-    f_service_ <<
-      get_cap_name(service_name_) << "_iface_." << tfunction->get_name() << "(";
+    f_service_ << get_cap_name(service_name_) << "_iface_." << tfunction->get_name() << "(";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
         first = false;
       } else {
         f_service_ << ", ";
-      } 
+      }
       f_service_ << "args." << (*f_iter)->get_name();
     }
-    
-    if( tfunction->is_oneway()) {
+
+    if (tfunction->is_oneway()) {
       f_service_ << ");" << endl;
     } else {
       if (first) {
         first = false;
       } else {
         f_service_ << ", ";
-      } 
+      }
       string on_success = generate_service_method_onsuccess(tfunction, false, true);
       indent_up();
       f_service_ << endl;
       indent(f_service_) << "null,  // errors are thrown by the handler" << endl;
-      if( tfunction->get_returntype()->is_void()) {
+      if (tfunction->get_returntype()->is_void()) {
         indent(f_service_) << "null); // no retval" << endl;
       } else {
         indent(f_service_) << "function" << on_success.c_str() << " {" << endl;
-        if(    ! tfunction->get_returntype()->is_void()) {
+        if (!tfunction->get_returntype()->is_void()) {
           indent_up();
           indent(f_service_) << "result.success = retval;" << endl;
           indent_down();
@@ -2093,41 +2020,40 @@ void t_haxe_generator::generate_process_function(t_service* tservice,
 
   } else {
     // normal function():result style
-  
+
     // Generate the function call
     t_struct* arg_struct = tfunction->get_arglist();
     const std::vector<t_field*>& fields = arg_struct->get_members();
     vector<t_field*>::const_iterator f_iter;
-  
+
     f_service_ << indent();
-    if( ! (tfunction->is_oneway() || tfunction->get_returntype()->is_void())) {
+    if (!(tfunction->is_oneway() || tfunction->get_returntype()->is_void())) {
       f_service_ << "result.success = ";
     }
-    f_service_ <<
-      get_cap_name(service_name_) << "_iface_." << tfunction->get_name() << "(";
+    f_service_ << get_cap_name(service_name_) << "_iface_." << tfunction->get_name() << "(";
     bool first = true;
     for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
       if (first) {
         first = false;
       } else {
         f_service_ << ", ";
-      } 
+      }
       f_service_ << "args." << (*f_iter)->get_name();
     }
     f_service_ << ");" << endl;
-
   }
 
   indent_down();
   f_service_ << indent() << "}";
-  if( ! tfunction->is_oneway()) {
+  if (!tfunction->

<TRUNCATED>