Thrift: Cleaned up whitespace.
authorDavid Reiss <dreiss@apache.org>
Thu, 26 Jul 2007 21:10:32 +0000 (21:10 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 26 Jul 2007 21:10:32 +0000 (21:10 +0000)
Summary:
Replaced a lot of tabs with spaces in the thrift codebase.
Removed a lot of trailing whitespace from thrift-generated c++.
Added a few things to cleanup.sh.

Trac Bug: #

Blame Rev:

Reviewed By: mcslee

Test Plan:
Recompiled thrift.
Re-thrifted some test .thrifts.
Compiled the genrated c++.
Ran cleanup.sh.

Revert Plan: ok

Notes:

EImportant:

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665176 13f79535-47bb-0310-9956-ffa450edef68

13 files changed:
compiler/cpp/src/generate/t_cpp_generator.cc
lib/cpp/cleanup.sh
lib/cpp/src/concurrency/Mutex.h
lib/cpp/src/concurrency/ThreadManager.cpp
lib/cpp/src/concurrency/TimerManager.cpp
lib/cpp/src/concurrency/test/Tests.cpp
lib/cpp/src/concurrency/test/ThreadFactoryTests.h
lib/cpp/src/concurrency/test/ThreadManagerTests.h
lib/cpp/src/concurrency/test/TimerManagerTests.h
lib/cpp/src/protocol/TBinaryProtocol.cpp
lib/cpp/src/protocol/TBinaryProtocol.h
lib/cpp/src/protocol/TOneWayProtocol.h
lib/cpp/src/protocol/TProtocol.h

index d3d4ccb..354926d 100644 (file)
@@ -424,8 +424,7 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
         }
       }
     }
-    indent_down();
-    indent(out) << "} " << endl;
+    scope_down(out);
   }
   
   out <<
@@ -527,7 +526,7 @@ void t_cpp_generator::generate_struct_reader(ofstream& out,
     
     // Check for field STOP marker
     out <<
-      indent() << "if (ftype == facebook::thrift::protocol::T_STOP) { " << endl <<
+      indent() << "if (ftype == facebook::thrift::protocol::T_STOP) {" << endl <<
       indent() << "  break;" << endl <<
       indent() << "}" << endl;
     
@@ -820,7 +819,7 @@ void t_cpp_generator::generate_service_interface(t_service* tservice) {
   }
   f_header_ <<
     "class " << service_name_ << "If" << extends << " {" << endl <<
-    " public: " << endl;
+    " public:" << endl;
   indent_up(); 
   f_header_ <<
     indent() << "virtual ~" << service_name_ << "If() {}" << endl;
@@ -832,7 +831,7 @@ void t_cpp_generator::generate_service_interface(t_service* tservice) {
   }
   indent_down();
   f_header_ <<
-    "}; " << endl << endl;
+    "};" << endl << endl;
 }
 
 /**
@@ -847,7 +846,7 @@ void t_cpp_generator::generate_service_null(t_service* tservice) {
   }
   f_header_ <<
     "class " << service_name_ << "Null : virtual public " << service_name_ << "If" << extends << " {" << endl <<
-    " public: " << endl;
+    " public:" << endl;
   indent_up(); 
   f_header_ <<
     indent() << "virtual ~" << service_name_ << "Null() {}" << endl;
@@ -878,7 +877,7 @@ void t_cpp_generator::generate_service_null(t_service* tservice) {
   }
   indent_down();
   f_header_ <<
-    "}; " << endl << endl;
+    "};" << endl << endl;
 }
 
 
@@ -908,7 +907,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) {
     "class " << service_name_ << "Multiface : " <<
     "virtual public " << service_name_ << "If" <<
     extends_multiface << " {" << endl <<
-    " public: " << endl;
+    " public:" << endl;
   indent_up();
   f_header_ << 
     indent() << service_name_ << "Multiface(" << list_type << "& ifaces) : ifaces_(ifaces) {" << endl;
@@ -931,7 +930,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) {
   f_header_ <<
     indent() << list_type << " ifaces_;" << endl <<
     indent() << service_name_ << "Multiface() {}" << endl <<
-    indent() << "void add(boost::shared_ptr<" << service_name_ << "If> iface) { " << endl;
+    indent() << "void add(boost::shared_ptr<" << service_name_ << "If> iface) {" << endl;
   if (!extends.empty()) {
     f_header_ <<
       indent() << "  " << extends << "Multiface::add(iface);" << endl;
@@ -1029,7 +1028,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice) {
 
   indent_up();
   f_header_ <<
-    indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> prot) : " << endl;
+    indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> prot) :" << endl;
   if (extends.empty()) {
     f_header_ <<
       indent() << "  piprot_(prot)," << endl <<
@@ -1043,7 +1042,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice) {
   }
 
   f_header_ <<
-    indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> oprot) : " << endl;
+    indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> oprot) :" << endl;
   if (extends.empty()) {
     f_header_ <<
       indent() << "  piprot_(iprot)," << endl <<
@@ -1334,7 +1333,7 @@ void t_cpp_generator::generate_service_processor(t_service* tservice) {
   indent_down();
 
   f_header_ << 
-    " public: " << endl <<
+    " public:" << endl <<
     indent() << service_name_ << "Processor(boost::shared_ptr<" << service_name_ << "If> iface) :" << endl;
   if (extends.empty()) {
     f_header_ <<
@@ -2080,15 +2079,18 @@ string t_cpp_generator::namespace_open(string ns) {
     return "";
   }
   string result = "";
+  string separator = "";
   string::size_type loc;
   while ((loc = ns.find(".")) != string::npos) {
+    result += separator;
     result += "namespace ";
     result += ns.substr(0, loc);
-    result += " { ";
+    result += " {";
+    separator = " ";
     ns = ns.substr(loc+1);
   }
   if (ns.size() > 0) {
-    result += "namespace " + ns + " { ";
+    result += separator + "namespace " + ns + " {";
   }
   return result;
 }
index 71151e9..687b376 100755 (executable)
@@ -27,4 +27,6 @@ install-sh \
 libtool \
 ltmain.sh \
 Makefile.in \
-missing
+missing \
+config.hin~ \
+stamp-h1
index bb2a606..02accf9 100644 (file)
@@ -66,9 +66,9 @@ class RWGuard {
     RWGuard(const ReadWriteMutex& value, bool write = 0) : rw_mutex_(value) {
       if (write) {
         rw_mutex_.acquireWrite();
-      }        else {
+      } else {
         rw_mutex_.acquireRead();
-      }        
+      }
     }  
     ~RWGuard() {
       rw_mutex_.release();
index 3d87724..d8b1e8c 100644 (file)
@@ -202,8 +202,8 @@ class ThreadManager::Worker: public Runnable {
       Synchronized s(manager_->monitor_);
       active = manager_->workerCount_ < manager_->workerMaxCount_;
       if (active) {
-       manager_->workerCount_++;
-       notifyManager = manager_->workerCount_ == manager_->workerMaxCount_;
+        manager_->workerCount_++;
+        notifyManager = manager_->workerCount_ == manager_->workerMaxCount_;
       }
     }
 
@@ -227,24 +227,24 @@ class ThreadManager::Worker: public Runnable {
        */
       {
         Synchronized s(manager_->monitor_);
-       active = isActive();
+        active = isActive();
 
-       while (active && manager_->tasks_.empty()) {
+        while (active && manager_->tasks_.empty()) {
           manager_->idleCount_++;
           idle_ = true;
           manager_->monitor_.wait();
           active = isActive();
           idle_ = false;
           manager_->idleCount_--;
-       }
+        }
 
-       if (active) {
+        if (active) {
           if (!manager_->tasks_.empty()) {
             task = manager_->tasks_.front();
             manager_->tasks_.pop();
             if (task->state_ == ThreadManager::Task::WAITING) {
               task->state_ = ThreadManager::Task::EXECUTING;
-           }
+            }
 
             /* If we have a pending task max and we just dropped below it, wakeup any
                thread that might be blocked on add. */
@@ -252,22 +252,22 @@ class ThreadManager::Worker: public Runnable {
                 manager_->tasks_.size() == manager_->pendingTaskCountMax_ - 1) {
               manager_->workerMonitor_.notify();
             }
-         }
-       } else {
-         idle_ = true;
-         manager_->workerCount_--;
+          }
+        } else {
+          idle_ = true;
+          manager_->workerCount_--;
           notifyManager = (manager_->workerCount_ == manager_->workerMaxCount_);
-       }
+        }
       }
 
       if (task != NULL) {
-       if (task->state_ == ThreadManager::Task::EXECUTING) {
-         try {
+        if (task->state_ == ThreadManager::Task::EXECUTING) {
+          try {
             task->run();
           } catch(...) {
             // XXX need to log this
-         }
-       }
+          }
+        }
       }
     }
 
@@ -384,7 +384,7 @@ void ThreadManager::Impl::removeWorker(size_t value) {
 
     if (idleCount_ < value) {
       for (size_t ix = 0; ix < idleCount_; ix++) {
-       monitor_.notify();
+        monitor_.notify();
       }
     } else {
       monitor_.notifyAll();
index b9e604c..4f77b2f 100644 (file)
@@ -74,8 +74,8 @@ class TimerManager::Dispatcher: public Runnable {
     {
       Synchronized s(manager_->monitor_);
       if (manager_->state_ == TimerManager::STARTING) {
-       manager_->state_ = TimerManager::STARTED;
-       manager_->monitor_.notifyAll();
+        manager_->state_ = TimerManager::STARTED;
+        manager_->monitor_.notifyAll();
       }
     }
 
@@ -83,32 +83,32 @@ class TimerManager::Dispatcher: public Runnable {
       std::set<shared_ptr<TimerManager::Task> > expiredTasks;
       {
         Synchronized s(manager_->monitor_);
-       task_iterator expiredTaskEnd;
-       int64_t now = Util::currentTime();
-       while (manager_->state_ == TimerManager::STARTED && 
+        task_iterator expiredTaskEnd;
+        int64_t now = Util::currentTime();
+        while (manager_->state_ == TimerManager::STARTED && 
                (expiredTaskEnd = manager_->taskMap_.upper_bound(now)) == manager_->taskMap_.begin()) {
-         int64_t timeout = 0LL;
-         if (!manager_->taskMap_.empty()) {
+          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));
           try {
             manager_->monitor_.wait(timeout);
           } catch (TimedOutException &e) {}
-         now = Util::currentTime();
-       }
-       
-       if (manager_->state_ == TimerManager::STARTED) {
+          now = Util::currentTime();
+        }
+        
+        if (manager_->state_ == TimerManager::STARTED) {
           for (task_iterator ix = manager_->taskMap_.begin(); ix != expiredTaskEnd; ix++) {
-           shared_ptr<TimerManager::Task> task = ix->second;
+            shared_ptr<TimerManager::Task> task = ix->second;
             expiredTasks.insert(task);
-           if (task->state_ == TimerManager::Task::WAITING) {
-             task->state_ = TimerManager::Task::EXECUTING;
-           }
+            if (task->state_ == TimerManager::Task::WAITING) {
+              task->state_ = TimerManager::Task::EXECUTING;
+            }
             manager_->taskCount_--;
-         }
+          }
           manager_->taskMap_.erase(manager_->taskMap_.begin(), expiredTaskEnd);
-       }
+        }
       }
       
       for (std::set<shared_ptr<Task> >::iterator ix =  expiredTasks.begin(); ix != expiredTasks.end(); ix++) {
@@ -120,8 +120,8 @@ class TimerManager::Dispatcher: public Runnable {
     {
       Synchronized s(manager_->monitor_);
       if (manager_->state_ == TimerManager::STOPPING) {
-       manager_->state_ = TimerManager::STOPPED; 
-       manager_->monitor_.notify();
+        manager_->state_ = TimerManager::STOPPED; 
+        manager_->monitor_.notify();
       }
     }
     return;
index a160472..2b7b7f3 100644 (file)
@@ -129,13 +129,13 @@ int main(int argc, char** argv) {
 
       for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
 
-       size_t taskCount = workerCount * tasksPerWorker;
+        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;
+        ThreadManagerTests threadManagerTests;
 
-       threadManagerTests.loadTest(taskCount, delay, workerCount);
+        threadManagerTests.loadTest(taskCount, delay, workerCount);
       }
     }
   }
index 99bc94e..0dcf0bb 100644 (file)
@@ -162,22 +162,22 @@ public:
     void run() {
       {
         Synchronized s(_monitor);
-       if (_state == SynchStartTask::STARTING) {
-         _state = SynchStartTask::STARTED;
-         _monitor.notify();
-       }
+        if (_state == SynchStartTask::STARTING) {
+          _state = SynchStartTask::STARTED;
+          _monitor.notify();
+        }
       }
 
       {
         Synchronized s(_monitor);
         while (_state == SynchStartTask::STARTED) {
-         _monitor.wait();
-       }
+          _monitor.wait();
+        }
 
-       if (_state == SynchStartTask::STOPPING) {
+        if (_state == SynchStartTask::STOPPING) {
           _state = SynchStartTask::STOPPED;
           _monitor.notifyAll();
-       }
+        }
       }
     }
 
@@ -208,7 +208,7 @@ public:
     {
       Synchronized s(monitor);
       while (state == SynchStartTask::STARTING) {
-       monitor.wait();
+        monitor.wait();
       }
     }
 
@@ -224,13 +224,13 @@ public:
 
       if (state == SynchStartTask::STARTED) {
 
-       state = SynchStartTask::STOPPING;
+        state = SynchStartTask::STOPPING;
 
-       monitor.notify();
+        monitor.notify();
       }
 
       while (state == SynchStartTask::STOPPING) {
-       monitor.wait();
+        monitor.wait();
       }
     }
 
index a8fdcda..261ad5e 100644 (file)
@@ -65,14 +65,14 @@ public:
       {
         Synchronized s(_monitor);
 
-       // std::cout << "Thread " << _count << " completed " << std::endl;
+        // std::cout << "Thread " << _count << " completed " << std::endl;
 
-       _count--;
+        _count--;
 
-       if (_count == 0) {
+        if (_count == 0) {
 
-         _monitor.notify();
-       }
+          _monitor.notify();
+        }
       }
     }
 
@@ -117,7 +117,7 @@ public:
 
     for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
 
-       threadManager->add(*ix);
+        threadManager->add(*ix);
     }
 
     {
@@ -125,7 +125,7 @@ public:
 
       while(activeCount > 0) {
 
-       monitor.wait();
+        monitor.wait();
       }
     }
 
@@ -147,19 +147,19 @@ public:
       assert(delta > 0);
 
       if (task->_startTime < firstTime) {
-       firstTime = task->_startTime;
+        firstTime = task->_startTime;
       }
 
       if (task->_endTime > lastTime) {
-       lastTime = task->_endTime;
+        lastTime = task->_endTime;
       }
 
       if (delta < minTime) {
-       minTime = delta;
+        minTime = delta;
       }
 
       if (delta > maxTime) {
-       maxTime = delta;
+        maxTime = delta;
       }
 
       averageTime+= delta;
@@ -258,7 +258,7 @@ public:
       }
 
       for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
-       threadManager->add(*ix);
+        threadManager->add(*ix);
       }
 
       if(!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
index e7948e4..bd959cd 100644 (file)
@@ -54,7 +54,7 @@ class TimerManagerTests {
       float error = delta / _timeout;
 
       if(error < ERROR) {
-       _success = true;
+        _success = true;
       }
       
       _done = true;
@@ -62,7 +62,7 @@ class TimerManagerTests {
       std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; //debug      
 
       {Synchronized s(_monitor);
-       _monitor.notifyAll();
+        _monitor.notifyAll();
       }
     }  
 
@@ -99,11 +99,11 @@ class TimerManagerTests {
       {
         Synchronized s(_monitor);
 
-       timerManager.add(orphanTask, 10 * timeout);
+        timerManager.add(orphanTask, 10 * timeout);
 
-       timerManager.add(task, timeout);
+        timerManager.add(task, timeout);
 
-       _monitor.wait();
+        _monitor.wait();
       }
 
       assert(task->_done);
index 6945851..30bbde6 100644 (file)
@@ -193,8 +193,8 @@ uint32_t TBinaryProtocol::writeString(const string& str) {
  */
 
 uint32_t TBinaryProtocol::readMessageBegin(std::string& name,
-                                          TMessageType& messageType,
-                                          int32_t& seqid) {
+                                           TMessageType& messageType,
+                                           int32_t& seqid) {
   uint32_t result = 0;
   int32_t sz;
   result += readI32(sz);
index 5047e02..01f7c3b 100644 (file)
@@ -127,8 +127,8 @@ class TBinaryProtocol : public TProtocol {
 
 
   uint32_t readMessageBegin(std::string& name,
-                           TMessageType& messageType,
-                           int32_t& seqid);
+                            TMessageType& messageType,
+                            int32_t& seqid);
 
   uint32_t readMessageEnd();
 
@@ -137,14 +137,14 @@ class TBinaryProtocol : public TProtocol {
   uint32_t readStructEnd();
 
   uint32_t readFieldBegin(std::string& name,
-                         TType& fieldType,
-                         int16_t& fieldId);
+                          TType& fieldType,
+                          int16_t& fieldId);
   
   uint32_t readFieldEnd();
  
   uint32_t readMapBegin(TType& keyType,
-                       TType& valType,
-                       uint32_t& size);
+                        TType& valType,
+                        uint32_t& size);
 
   uint32_t readMapEnd();
 
@@ -154,7 +154,7 @@ class TBinaryProtocol : public TProtocol {
   uint32_t readListEnd();
 
   uint32_t readSetBegin(TType& elemType,
-                       uint32_t& size);
+                        uint32_t& size);
 
   uint32_t readSetEnd();
 
index c928058..635744c 100644 (file)
@@ -35,8 +35,8 @@ class TWriteOnlyProtocol : public TProtocol {
    */
 
   uint32_t readMessageBegin(std::string& name,
-                           TMessageType& messageType,
-                           int32_t& seqid) {
+                            TMessageType& messageType,
+                            int32_t& seqid) {
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
         subclass_ + " does not support reading (yet).");
   }
@@ -57,8 +57,8 @@ class TWriteOnlyProtocol : public TProtocol {
   }
 
   uint32_t readFieldBegin(std::string& name,
-                         TType& fieldType,
-                         int16_t& fieldId) {
+                          TType& fieldType,
+                          int16_t& fieldId) {
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
         subclass_ + " does not support reading (yet).");
   }
@@ -69,8 +69,8 @@ class TWriteOnlyProtocol : public TProtocol {
   }
  
   uint32_t readMapBegin(TType& keyType,
-                       TType& valType,
-                       uint32_t& size) {
+                        TType& valType,
+                        uint32_t& size) {
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
         subclass_ + " does not support reading (yet).");
   }
@@ -92,7 +92,7 @@ class TWriteOnlyProtocol : public TProtocol {
   }
 
   uint32_t readSetBegin(TType& elemType,
-                       uint32_t& size) {
+                        uint32_t& size) {
     throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
         subclass_ + " does not support reading (yet).");
   }
index a7560ca..7fa3de8 100644 (file)
@@ -122,26 +122,26 @@ class TProtocol {
   virtual uint32_t writeStructEnd() = 0;
   
   virtual uint32_t writeFieldBegin(const std::string& name,
-                                  const TType fieldType,
-                                  const int16_t fieldId) = 0;
+                                   const TType fieldType,
+                                   const int16_t fieldId) = 0;
 
   virtual uint32_t writeFieldEnd() = 0;
 
   virtual uint32_t writeFieldStop() = 0;
                                       
   virtual uint32_t writeMapBegin(const TType keyType,
-                                const TType valType,
-                                const uint32_t size) = 0;
+                                 const TType valType,
+                                 const uint32_t size) = 0;
 
   virtual uint32_t writeMapEnd() = 0;
   
   virtual uint32_t writeListBegin(const TType elemType,
-                                 const uint32_t size) = 0;
+                                  const uint32_t size) = 0;
 
   virtual uint32_t writeListEnd() = 0;
 
   virtual uint32_t writeSetBegin(const TType elemType,
-                                const uint32_t size) = 0;
+                                 const uint32_t size) = 0;
 
   virtual uint32_t writeSetEnd() = 0;
 
@@ -164,8 +164,8 @@ class TProtocol {
    */
 
   virtual uint32_t readMessageBegin(std::string& name,
-                                   TMessageType& messageType,
-                                   int32_t& seqid) = 0;
+                                    TMessageType& messageType,
+                                    int32_t& seqid) = 0;
   
   virtual uint32_t readMessageEnd() = 0;
 
@@ -174,24 +174,24 @@ class TProtocol {
   virtual uint32_t readStructEnd() = 0;
 
   virtual uint32_t readFieldBegin(std::string& name,
-                                 TType& fieldType,
-                                 int16_t& fieldId) = 0;
+                                  TType& fieldType,
+                                  int16_t& fieldId) = 0;
   
   virtual uint32_t readFieldEnd() = 0;
  
   virtual uint32_t readMapBegin(TType& keyType,
-                               TType& valType,
-                               uint32_t& size) = 0;
+                                TType& valType,
+                                uint32_t& size) = 0;
 
   virtual uint32_t readMapEnd() = 0;
 
   virtual uint32_t readListBegin(TType& elemType,
-                                uint32_t& size) = 0;
+                                 uint32_t& size) = 0;
 
   virtual uint32_t readListEnd() = 0;
 
   virtual uint32_t readSetBegin(TType& elemType,
-                               uint32_t& size) = 0;
+                                uint32_t& size) = 0;
 
   virtual uint32_t readSetEnd() = 0;