Got mixed coroutines working.

Got mixed coroutines working.

--- tests/core/test_experimental_threading2.cpp
+++ tests/core/test_experimental_threading2.cpp
@@ -925,40 +925,23 @@
     threadName += '\0';
     AllThreadData& p = m_threadData.at(i);
     {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-      HIGAN_CPU_BRACKET("thread - First steal!");
-#endif
       stealOrWait(p);
     }
-    while (!StopCondition)
-    {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-      HIGAN_CPU_BRACKET(threadName.c_str());
-#endif
-      // can we split work?
-      {
-        if (p.data.m_task.canSplit() && tasks_to_do < 128)
-        {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-          HIGAN_CPU_BRACKET("try split task");
-#endif
-          if (p.data.m_localQueueSize.load(std::memory_order::relaxed) == 0)
-          { // Queue didn't have anything, adding.
-            {
-              std::lock_guard<std::mutex> guard(*p.mutex);
-              p.data.m_localDeque.emplace_back(std::move(p.data.m_task.split())); // push back
-              p.data.m_localQueueSize.store(p.data.m_localDeque.size(), std::memory_order_relaxed);
-              tasks_to_do++;
-            }
-            notifyAll(p.data.m_ID);
-            continue;
+    while (!StopCondition) {
+      if (p.data.m_task.canSplit() && tasks_to_do < 128) {
+        if (p.data.m_localQueueSize.load(std::memory_order::relaxed) == 0) {
+          {
+            std::lock_guard<std::mutex> guard(*p.mutex);
+            p.data.m_localDeque.emplace_back(std::move(p.data.m_task.split())); // push back
+            p.data.m_localQueueSize.store(p.data.m_localDeque.size(), std::memory_order_relaxed);
           }
+          tasks_to_do++;
+          notifyAll(p.data.m_ID);
+          continue;
         }
       }
-      // we couldn't split or queue had something
       if (doWork(p))
       {
-        // out of work, steal work? sleep?
         stealOrWait(p);
       }
     }
@@ -986,8 +969,6 @@
       }
     }
     // other deques
-
-    //for (auto &it : m_threadData)
     const unsigned tdSize = static_cast<int>(m_threadData.size());
     for (unsigned i = 0; i < tdSize; ++i)
     {
@@ -1021,9 +1002,6 @@
       {
         return false;
       }
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-      HIGAN_CPU_BRACKET("try sleeping...");
-#endif
       std::unique_lock<std::mutex> lk(*data.mutex);
       idle_threads.fetch_add(1, std::memory_order::relaxed);
       data.cv->wait(lk, [&]{
@@ -1038,9 +1016,6 @@

   inline void stealOrWait(AllThreadData& data, bool allowedToSleep = true) noexcept
   {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-    HIGAN_CPU_FUNCTION_SCOPE();
-#endif
     ThreadData& p = data.data;
     p.m_task.m_id = 0;
     while (0 == p.m_task.m_id && !StopCondition)
@@ -1051,17 +1026,11 @@

   bool tryTakeTaskFromGlobalQueue(AllThreadData& data) noexcept
   {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-    HIGAN_CPU_FUNCTION_SCOPE();
-#endif
     std::vector<Task>& addable = data.addableTasks;
     if (tasks_in_queue.load(std::memory_order::relaxed) > 0)
     {
       if (!addable.empty())
         addable.clear();
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-      HIGAN_CPU_BRACKET("getting task from global queue");
-#endif
       std::unique_lock<std::mutex> guard(m_globalWorkMutex, std::defer_lock_t());
       if (guard.try_lock()) {
         m_taskQueue.erase(std::remove_if(m_taskQueue.begin(), m_taskQueue.end(), [&](const std::pair<std::vector<BarrierObserver>, Task>& it){
@@ -1076,9 +1045,6 @@
     }
     if (!addable.empty())
     {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-      HIGAN_CPU_BRACKET("adding tasks to own queue");
-#endif
       std::lock_guard<std::mutex> guard(*data.mutex);
       data.data.m_localDeque.insert(data.data.m_localDeque.end(), addable.begin(), addable.end());
       data.data.m_localQueueSize.store(data.data.m_localDeque.size(), std::memory_order_relaxed);
@@ -1099,7 +1065,7 @@
     BarrierObserver observs = data.data.m_task.m_blocks;
     data.data.m_task.m_blocks.kill();
     data.data.m_task.m_blocks = Barrier();
-    if (observs.done()) // possibly something done
+    if (observs.done())
     {
       tryTakeTaskFromGlobalQueue(data);
     }
@@ -1112,7 +1078,6 @@
 #endif
     if (amount <= 0)
     {
-      // did nothing, so nothing to report? wtf
       assert(false);
       return;
     }
@@ -1152,9 +1117,8 @@
     int queue_count =  my_queue_count();
     bool depsDone = allDepsDone(depends);
     bool spawnTask = !depends.empty() || !depsDone || queue_count <= 10;
-    //tasksReadyToProcess() < threads_awake.load(std::memory_order::relaxed)
     spawnTask = !((depends.empty() || depsDone) && queue_count > 2);
-    return spawnTask || true;
+    return spawnTask;
   }

   template<typename Func>
@@ -1168,11 +1132,9 @@
 #if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
     HIGAN_CPU_FUNCTION_SCOPE();
 #endif
-    // need a temporary storage for tasks that haven't had requirements filled
     int ThreadID = my_thread_index();
     size_t newId = m_nextTaskID.fetch_add(1);
     assert(newId < m_nextTaskID);
-    //printf("task added %zd\n", newId);
     BarrierObserver obs;
     Task newTask(newId, start_iter, iterations, std::move(obs.barrier()));
     auto& threadData = m_threadData.at(ThreadID);
@@ -1180,27 +1142,19 @@
     {
       if (depends.empty() || allDepsDone(depends))
       {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-        HIGAN_CPU_BRACKET("own queue");
-#endif
         std::unique_lock<std::mutex> u2(*threadData.mutex);
         threadData.data.m_localDeque.push_back(std::move(newTask));
         threadData.data.m_localQueueSize.store(threadData.data.m_localDeque.size());
         tasks_to_do++;
       }
-      else  // wtf add to WAITING FOR requi
+      else
       {
-#if defined(LBSPOOL_ENABLE_PROFILE_THREADS)
-        HIGAN_CPU_BRACKET("global queue");
-#endif
         std::unique_lock<std::mutex> u1(m_globalWorkMutex);
         m_taskQueue.push_back({ std::move(depends), std::move(newTask) });
         tasks_in_queue++;
       }
     }
     notifyAll(-1);
-    //while(!obs.done()){}
-    //std::this_thread::sleep_for(std::chrono::milliseconds(10));
     return obs;
   }

@@ -1264,7 +1218,7 @@

 static std::shared_ptr<LBSPool> my_pool = nullptr;
 thread_local void* thread_check_value = nullptr;
-thread_local int arpa = 1;
+//thread_local int arpa = 1;

 template<typename T>
 class lbs_awaitable {
@@ -1283,31 +1237,9 @@
         return false;
       }
       std::experimental::coroutine_handle<> await_suspend(coro_handle h) noexcept {
-        // The coroutine is now suspended at the final-suspend point.
-        // Lookup its continuation in the promise and resume it.
-        /*
-        auto handle = h.promise().continuation;
-        auto& barrier = handle.promise().dependency;
-        barrier = my_pool->task({h.promise().dependency}, [handlePtr = handle.address()](size_t) mutable {
-          auto handle = coro_handle::from_address(handlePtr);
-          if (!handle.done()) {
-            handle.resume();
-          }
-        });*/
-        auto finalDep = h.promise().finalDependency;
-        assert(!finalDep.done());
-        //finalDependency = h.promise().finalDependency;
-        void* ptr = h.address();
-
-        if (!h.promise().async && h.promise().m_continuation.address() != nullptr){
-          assert(thread_check_value != ptr);
-          finalDep.kill();
+        if (h.promise().m_continuation.address() != nullptr){
           return h.promise().m_continuation;
         }
-        //std::this_thread::sleep_for(std::chrono::milliseconds(100));
-        //assert(!h.promise().finalDependency.done());
-        //assert(h.promise().async && thread_check_value == ptr);
-        //assert(h.promise().finalDependency.done());
         return noop_coroutine(std::move(h.promise().finalDependency));
       }
       void await_resume() noexcept {}
@@ -1340,7 +1272,6 @@
         handle.resume();
         assert(thread_check_value == handlePtr);
         thread_check_value = nullptr;
-        //if (handle.done()) handle.promise().finalDependency.kill();
       });
     }
   }
@@ -1375,62 +1306,25 @@

   // enemy coroutine needs this coroutines result, therefore we compute it.
   std::experimental::coroutine_handle<> await_suspend(coro_handle handle) noexcept {
-    /*
-    auto& barrier = observer();
-    auto& enemyBarrier = handle.promise().dependency;
-    std::shared_ptr<coro_handle> otherHandle = handle.promise().weakref.lock();
-    enemyBarrier = my_pool->task({handle_->promise().wholeCoroReady,barrier, enemyBarrier}, [handlePtr = otherHandle](size_t) mutable {
-      if (!handlePtr->done()) {
-        handlePtr->resume();
-        if (handlePtr->done())
-        {
-          handlePtr->promise().wholeCoroReady.kill();
-        }
-      }
-    });
-    handle.promise().dependency = enemyBarrier;
-    */
     if(handle_.promise().async)
     {
-      //if (handle.address() != nullptr && !handle.done()) {
-        void* ptr = handle.address();
-        //assert(thread_check_value == ptr);
-        BarrierObserver obs;
-        auto finalDep = handle_.promise().finalDependency;
-        if (finalDep)
-          obs = BarrierObserver(finalDep);
-        if (obs.done() && handle_.promise().bar.done())
-        {
-          //assert(handle_.done());
-        }
-        else
-        {
-          //assert(!handle_.done());
-        }
-        bool wasIAsync = handle.promise().async;
-        Barrier temp;
-        BarrierObserver tobs(temp);
-        handle.promise().async = true;
-        /*
-        if (thread_check_value != handle.address())
-          assert(thread_check_value == handle_.address());*/
-        //assert(thread_check_value == handle.address());
-        handle.promise().bar = my_pool->task({std::move(obs), handle_.promise().bar, handle.promise().bar, tobs}, [handlePtr = handle.address()](size_t) mutable {
-          thread_check_value = handlePtr;
-          auto handle = coro_handle::from_address(handlePtr);
-          assert(!handle.done());
-          handle.resume();
-          assert(thread_check_value == handlePtr);
-          thread_check_value = nullptr;
-          //if (handle.done())
-          //  handle.promise().finalDependency.kill();
-        });
-        //if (wasIAsync)
-        //  std::this_thread::sleep_for(std::chrono::milliseconds(10));
-      //}
-      //else {
-      //  assert(false);
-      //}
+      void* ptr = handle.address();
+      BarrierObserver obs;
+      auto finalDep = handle_.promise().finalDependency;
+      if (finalDep)
+        obs = BarrierObserver(finalDep);
+      bool wasIAsync = handle.promise().async;
+      Barrier temp;
+      BarrierObserver tobs(temp);
+      handle.promise().async = true;
+      handle.promise().bar = my_pool->task({std::move(obs), handle_.promise().bar, handle.promise().bar, tobs}, [handlePtr = handle.address()](size_t) mutable {
+        thread_check_value = handlePtr;
+        auto handle = coro_handle::from_address(handlePtr);
+        assert(!handle.done());
+        handle.resume();
+        assert(thread_check_value == handlePtr);
+        thread_check_value = nullptr;
+      });
       return noop_coroutine(temp);
     }
     handle_.promise().m_continuation = handle;
@@ -1454,7 +1348,6 @@
       if (handle_.promise().async)
         my_pool->helpTasksUntilBarrierComplete(obs);
       else {
-        //assert(handle_.promise().async);
         handle_.resume();
         if (!wasIAsync && handle_.promise().async)
         {
@@ -1540,7 +1433,7 @@
   maxt = 0;
   auto omi = mint;
   auto oma = 0;
-  auto overlap = addInTreeLBS(treeSize, treeSize-computeTree);
+  //auto overlap = addInTreeLBS(treeSize, treeSize-computeTree);
   size_t aveg = 0;
   for (int i = 0; i < 4000; i++) {
     //my_pool->resetIDs();
@@ -1548,8 +1441,11 @@

     //}
     //funfun6().get();
+    //printf("start work\n");
     auto another = addInTreeLBS(treeSize, treeSize-computeTree);
+    //printf("doing work\n");//for (auto &it : m_threadData)
     int lbs = co_await another;//overlap;
+    //printf("got result %d\n", lbs);
     //overlap = std::move(another);
     auto t = time2.reset();
     aveg += t;
@@ -1566,15 +1462,15 @@
       fflush(stdout);
     }
   }
-  co_return co_await overlap;
+  co_return 0; //co_await overlap;
 }

 TEST_CASE("threaded awaitable - lbs")
 {
   {
     HIGAN_CPU_BRACKET("threaded awaitable - lbs");
-    int computeTree = 6;
-    int treeSize = 26;
+    int computeTree = 9;
+    int treeSize = 20;
     int a = addInTreeNormal(treeSize);
     a = addInTreeNormal(treeSize);
     a = addInTreeNormal(treeSize);


[assembler] moves tbb stuff to walker completely

--- dune/gdt/assembler/system.hh
+++ dune/gdt/assembler/system.hh
@@ -10,11 +10,6 @@
 #include <memory>

 #include <dune/common/version.hh>
-
-#if DUNE_VERSION_NEWER(DUNE_COMMON,3,9) //&& HAVE_TBB //EXADUNE
-# include <dune/grid/utility/partitioning/seedlist.hh>
-# include <dune/stuff/common/parallel/partitioner.hh>
-#endif

 #include <dune/stuff/grid/walker.hh>
 #include <dune/stuff/common/parallel/helper.hh>
@@ -227,17 +222,7 @@

   void assemble(const bool use_tbb = false)
   {
-#if DUNE_VERSION_NEWER(DUNE_COMMON,3,9) //EXADUNE
-    if (use_tbb) {
-      Stuff::IndexSetPartitioner< GridViewType > partitioner(this->grid_view_.indexSet());
-      SeedListPartitioning< typename GridViewType::Grid, 0 > partitioning(this->grid_view_, partitioner);
-      this->walk(partitioning);
-    } else
-#endif
-    {
-      const auto DUNE_UNUSED(no_warning_for_use_tbb) = use_tbb;
-      this->walk();
-    }
+    this->walk(use_tbb);
   }

 private:


[spaces.interface] add default_space_backend

--- dune/gdt/spaces/interface.hh
+++ dune/gdt/spaces/interface.hh
@@ -37,6 +37,16 @@
   , pdelab
   , fem
 }; // enum class ChooseSpaceBackend
+
+
+static constexpr ChooseSpaceBackend default_space_backend =
+#if HAVE_DUNE_FEM
+                                                            ChooseSpaceBackend::fem;
+#elif HAVE_DUNE_PDELAB
+                                                            ChooseSpaceBackend::pdelab;
+#else
+                                                            ChooseSpaceBackend::gdt;
+#endif

 template< ChooseSpaceBackend type >


[spaces.interface] drop include which lead to circular includes

--- dune/gdt/spaces/interface.hh
+++ dune/gdt/spaces/interface.hh
@@ -164,8 +164,4 @@
 } // namespace GDT
 } // namespace Dune

-
-#include <dune/gdt/discretefunction/default.hh>
-
-
 #endif // DUNE_GDT_SPACES_INTERFACE_HH


Reduced violations

Reduced violations


Histogram grid shows values and attributes correctly when hide empty columns is true.

Co-authored-by: Eloy Martinez <97f04252baff20a4458442a3d960a8c553348074@users.noreply.github.com>

--- src/histotablebase.cpp
+++ src/histotablebase.cpp
@@ -86,6 +86,10 @@
     --row;
   }

+  int tmpNumColumns = (int)myHisto->GetHistogram()->getNumColumns( myHisto->GetHistogram()->getCurrentStat() );
+  if (  myHisto->GetHistogram()->getHideColumns() )
+    tmpNumColumns = noVoidSemRanges->size();
+
   if( myHisto->GetHistogram()->getOnlyTotals() )
   {
     label = wxString::FromUTF8( LabelConstructor::histoTotalLabel( (THistoTotals)( row ) ).c_str() );
@@ -98,9 +102,9 @@
     else
       label = wxString::FromUTF8( LabelConstructor::histoTotalLabel( (THistoTotals)( iTotal - 1 ) ).c_str() );
   }
-  else if( !myHisto->GetHistogram()->getHorizontal() && row >= (int)myHisto->GetHistogram()->getNumColumns( myHisto->GetHistogram()->getCurrentStat() ) )
-  {
-    int iTotal = row - (int)myHisto->GetHistogram()->getNumColumns( myHisto->GetHistogram()->getCurrentStat() );
+  else if( !myHisto->GetHistogram()->getHorizontal() && row >= tmpNumColumns )
+  {
+    int iTotal = row - tmpNumColumns;
     if( iTotal == 0 )
       label = wxT( "" );
     else
@@ -111,7 +115,10 @@
   else if( myHisto->GetHistogram()->getHorizontal() )
     label = wxString::FromUTF8( myHisto->GetHistogram()->getRowLabel( (*selectedRows)[ row ] ).c_str() );
   else
+  {
+    row = myHisto->GetHistogram()->getSemanticRealColumn( row, *noVoidSemRanges );
     label = wxString::FromUTF8( myHisto->GetHistogram()->getColumnLabel( row ).c_str() );
+  }

   int w, h;
   wxFont tmpFont( GetView()->GetLabelFont() );
@@ -137,7 +144,11 @@
     return wxString::FromUTF8( myHisto->GetHistogram()->getRowLabel( col ).c_str() );

   if( myHisto->GetHistogram()->getHorizontal() )
+  {
+    col = myHisto->GetHistogram()->getSemanticRealColumn( col, *noVoidSemRanges );
+
     return wxString::FromUTF8( myHisto->GetHistogram()->getColumnLabel( col ).c_str() );
+  }
   else
     return wxString::FromUTF8( myHisto->GetHistogram()->getRowLabel( (*selectedRows)[ col ] ).c_str() );
 }
@@ -165,6 +176,8 @@
     row = col;
     col = tmp;
   }
+
+  col = myHisto->GetHistogram()->getSemanticRealColumn( col, *noVoidSemRanges );

   PRV_UINT16 idStat;
   label.Clear();
@@ -215,11 +228,6 @@
       }
       else
       {
-        // if( myHisto->GetHistogram()->getHideColumns() )
-        // {
-        //   if( myHisto->GetHistogram()->getHorizontal() )
-        //     GetView()->SetColSize( drawCol, 0 );
-        // }
         label = wxString::FromUTF8( "-" );
       }
     }
@@ -249,14 +257,6 @@
     }
     else
       label = wxString::FromUTF8( "-" );
-
-    // if( myHisto->GetHistogram()->getHideColumns() && !myHisto->GetHistogram()->getHorizontal() )
-    // {
-    //   vector<bool> noVoidSemRanges;
-    //   myHisto->GetColumnSelection().getSelected( noVoidSemRanges );
-    //   if( !noVoidSemRanges[ myHisto->GetHistogram()->getSemanticSortedColumn( col ) ] )
-    //     GetView()->SetRowSize( drawRow, 0 );
-    // }
   }
   else
     label = wxString::FromUTF8( "-" );
@@ -279,6 +279,10 @@
 {
   wxGridCellAttr *tmpAttr = new wxGridCellAttr();
   Timeline *controlWindow = myHisto->GetHistogram()->getControlWindow();
+  if ( myHisto->GetHistogram()->getHorizontal() )
+    col = myHisto->GetHistogram()->getSemanticRealColumn( col, *noVoidSemRanges );
+  else
+    row = myHisto->GetHistogram()->getSemanticRealColumn( row, *noVoidSemRanges );

   if( myHisto->GetHistogram()->getHorizontal() && myHisto->GetHistogram()->getFirstRowColored() )
   {


start 0.4.1

start 0.4.1

--- Siv3D/include/Siv3D/Version.hpp
+++ Siv3D/include/Siv3D/Version.hpp
@@ -16,7 +16,7 @@
 /// ライブラリのバージョン表示
 /// Version text
 /// </summary>
-# define SIV3D_VERSION	U"0.4.0"
+# define SIV3D_VERSION	U"0.4.1dev"

 namespace s3d
 {
@@ -24,5 +24,5 @@
 	/// バージョン ID
 	/// Version value
 	/// </summary>
-	inline constexpr uint32 Siv3DVersion = 200'004'003u;
+	inline constexpr uint32 Siv3DVersion = 200'004'010u;
 }


using random, and thread detach in example.

--- example.cpp
+++ example.cpp
@@ -1,9 +1,15 @@
 #include <iostream>
+#include <stdlib.h>
+#include <time.h>
 #include <thread>
+#include <unistd.h>
 #include "DoryProcessSpawn.hpp"

 using namespace std;
 using namespace spawn;
+
+std::thread *n;
+uv_loop_t* uv_loop = uv_default_loop();

 void loop(uv_loop_t* uv_loop) {
   uv_timer_t timer;
@@ -22,37 +28,51 @@
 }

 int main() {
-  uv_loop_t* uv_loop = uv_default_loop();
-  char* args[3];
-  args[0] = (char*)"./child";
-  args[1] = (char*)"200";
-  args[2] = NULL;
+  //init
+  n = new std::thread(loop, uv_loop);
+  n->detach();
+  srand(time(NULL));

-  DoryProcessSpawn process(uv_loop, args);
-  //process.timeout = 1000;
-  int r = process.on("timeout", []() {
-    cout << "timeout fired" << endl;
-  })
-  .on("stdout", [](char* buf, ssize_t nread) {
-    for(int i=0;i<nread;i++)
-      printf("%c", buf[i]);
-  })
-  .on("stderr", [](char* buf, ssize_t nread) {
-    for(int i=0;i<nread;i++)
-      printf("%c", buf[i]);
-  })
-  .on("exit", [](int64_t exitStatus, int termSignal) {
-    cout << "exit code : " << exitStatus << endl;
-    cout << "signal : " << termSignal << endl;
-  })
-  .spawn();
+  int i=0;
+  while(1) {
+    i++;

-  // check the result of spawn()
-  if (r != 0)
-    cout << uv_err_name(r) << " " << uv_strerror(r) << endl;
+    if (i > 10) {
+      usleep(10*1000);
+      continue;
+    }
+    char buf[10];
+    sprintf(buf,"%i",rand()%10000);

-  std::thread n(loop, uv_loop);
-  n.join();
+    char* args[3];
+    args[0] = (char*)"./child";
+    args[1] = buf;  // (char*)"2000";
+    args[2] = NULL;
+
+    // FIXME : leak
+    DoryProcessSpawn *process = new DoryProcessSpawn(uv_loop, args);
+    //process.timeout = 1000;
+    int r = process->on("timeout", []() {
+      cout << "timeout fired" << endl;
+    })
+    .on("stdout", [](char* buf, ssize_t nread) {
+      for(int i=0;i<nread;i++)
+        printf("%c", buf[i]);
+    })
+    .on("stderr", [](char* buf, ssize_t nread) {
+      for(int i=0;i<nread;i++)
+        printf("%c", buf[i]);
+    })
+    .on("exit", [](int64_t exitStatus, int termSignal) {
+      cout << "exit code : " << exitStatus << endl;
+      cout << "signal : " << termSignal << endl;
+    })
+    .spawn();
+
+    // check the result of spawn()
+    if (r != 0)
+      cout << uv_err_name(r) << " " << uv_strerror(r) << endl;
+  }

   return 0;
 }


Fix array out of bounds in unit test.

Fix array out of bounds in unit test.

I was passing a non-null-terminated string to a caller that expected null-terminated string.

Review URL: http://codereview.chromium.org/7934

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@3845 0039d316-1c4b-4281-b951-d872f2087c98

--- net/http/http_network_transaction_unittest.cc
+++ net/http/http_network_transaction_unittest.cc
@@ -268,9 +268,8 @@
   return out;
 }

-// Create a long header list that consumes >= |size| bytes. The caller is
-// responsible for freeing the memory.
-char* MakeLargeHeadersString(int size) {
+// Fill |str| with a long header list that consumes >= |size| bytes.
+void FillLargeHeadersString(std::string* str, int size) {
   const char* row =
       "SomeHeaderName: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n";
   const int sizeof_row = strlen(row);
@@ -278,11 +277,10 @@
       ceil(static_cast<float>(size) / sizeof_row));
   const int sizeof_data = num_rows * sizeof_row;
   DCHECK(sizeof_data >= size);
-
-  char* data = new char[sizeof_data];
+  str->reserve(sizeof_data);
+
   for (int i = 0; i < num_rows; ++i)
-    memcpy(data + i * sizeof_row, row, sizeof_row);
-  return data;
+    str->append(row, sizeof_row);
 }

 //-----------------------------------------------------------------------------
@@ -833,12 +831,12 @@
   request.load_flags = 0;

   // Respond with 50 kb of headers (we should fail after 32 kb).
-  scoped_array<char> large_headers_string(MakeLargeHeadersString(
-      50 * 1024));
+  std::string large_headers_string;
+  FillLargeHeadersString(&large_headers_string, 50 * 1024);

   MockRead data_reads[] = {
     MockRead("HTTP/1.0 200 OK\r\n"),
-    MockRead(large_headers_string.get()),
+    MockRead(true, large_headers_string.data(), large_headers_string.size()),
     MockRead("\r\nBODY"),
     MockRead(false, net::OK),
   };


ENH: If already empty, do not delete and set it to 0 after deleting so that you can create new one.

--- Common/vtkTimerLog.cxx
+++ Common/vtkTimerLog.cxx
@@ -38,7 +38,7 @@
 #endif
 #include "vtkObjectFactory.h"

-vtkCxxRevisionMacro(vtkTimerLog, "1.36");
+vtkCxxRevisionMacro(vtkTimerLog, "1.37");
 vtkStandardNewMacro(vtkTimerLog);

 // initialze the class variables
@@ -90,7 +90,12 @@
 // Remove timer log.
 void vtkTimerLog::CleanupLog()
 {
+  if ( vtkTimerLog::TimerLog )
+    {
+    return;
+    }
   delete [] vtkTimerLog::TimerLog;
+  vtkTimerLog::TimerLog = 0;
 }

 //----------------------------------------------------------------------------


Add Spdy ConnectFailure test back into spdy network tests.
BUG=none
TEST=net_unittests

Review URL: http://codereview.chromium.org/3040005

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@53049 0039d316-1c4b-4281-b951-d872f2087c98

--- net/spdy/spdy_network_transaction_unittest.cc
+++ net/spdy/spdy_network_transaction_unittest.cc
@@ -237,10 +237,19 @@
       RunDefaultTest();
       VerifyDataConsumed();
     }
-    // Only call AddData before calling RunPreTestSetup!!
+
+    // Only call AddData before calling RunPreTestSetup!! When RunPreTestSetup
+    // is run, it will add this Data Provider, and a corresponding SSL data
+    // provider.
     void AddData(StaticSocketDataProvider* data) {
       EXPECT_TRUE(add_data_allowed_);
       data_vector_.push_back(data);
+    }
+
+    // This can only be called after RunPreTestSetup. It adds a Data Provider,
+    // but not a corresponding SSL data provider
+    void AddDataNoSSL(StaticSocketDataProvider* data) {
+      session_deps_.socket_factory.AddSocketDataProvider(data);
     }

     void SetSession(scoped_refptr<HttpNetworkSession>& session) {
@@ -1893,6 +1902,74 @@
   EXPECT_EQ("goodbye world", out.response_data);
 }

+TEST_F(SpdyNetworkTransactionTest, ConnectFailureFallbackToHttp) {
+  MockConnect connects[]  = {
+    MockConnect(true, ERR_NAME_NOT_RESOLVED),
+    MockConnect(false, ERR_NAME_NOT_RESOLVED),
+    MockConnect(true, ERR_INTERNET_DISCONNECTED),
+    MockConnect(false, ERR_INTERNET_DISCONNECTED)
+  };
+
+  for (size_t index = 0; index < arraysize(connects); ++index) {
+    scoped_ptr<spdy::SpdyFrame> req(
+        ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
+    MockWrite writes[] = {
+      CreateMockWrite(*req),
+      MockWrite(true, 0, 0)  // EOF
+    };
+
+    scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
+    scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
+    MockRead reads[] = {
+      CreateMockRead(*resp),
+      CreateMockRead(*body),
+      MockRead(true, 0, 0)  // EOF
+    };
+
+    scoped_refptr<DelayedSocketData> data(
+        new DelayedSocketData(connects[index], 1, reads, arraysize(reads),
+                              writes, arraysize(writes)));
+    NormalSpdyTransactionHelper helper(CreateGetRequest(),
+                                       BoundNetLog());
+    helper.AddData(data.get());
+    helper.RunPreTestSetup();
+
+    // Set up http fallback data.
+    MockRead http_fallback_data[] = {
+      MockRead("HTTP/1.1 200 OK\r\n\r\n"),
+      MockRead("hello world!!!"),
+      MockRead(true, OK),
+    };
+
+    scoped_ptr<StaticSocketDataProvider> http_fallback(
+          new StaticSocketDataProvider(http_fallback_data,
+                                       arraysize(http_fallback_data),
+                                       NULL, 0));
+    helper.AddDataNoSSL(http_fallback.get());
+    HttpNetworkTransaction* trans = helper.trans();
+    TestCompletionCallback callback;
+
+    int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+    EXPECT_EQ(rv, ERR_IO_PENDING);
+    rv = callback.WaitForResult();
+    const HttpResponseInfo* response = trans->GetResponseInfo();
+    ASSERT_TRUE(response != NULL);
+    ASSERT_TRUE(response->headers != NULL);
+    EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
+    std::string response_data;
+    rv = ReadTransaction(trans, &response_data);
+    EXPECT_EQ(OK, rv);
+
+    EXPECT_TRUE(!response->was_fetched_via_spdy);
+    EXPECT_TRUE(!response->was_npn_negotiated);
+    EXPECT_TRUE(response->was_alternate_protocol_available);
+    EXPECT_TRUE(http_fallback->at_read_eof());
+    EXPECT_EQ(0u, data->read_index());
+    EXPECT_EQ(0u, data->write_index());
+    EXPECT_EQ("hello world!!!", response_data);
+  }
+}
+
 // Verify that basic buffering works; when multiple data frames arrive
 // at the same time, ensure that we don't notify a read completion for
 // each data frame individually.


BUG: Fix Bug #640 - vtkPolygon::IntersectPolygonWithPolygon()

--- Common/vtkTriangle.cxx
+++ Common/vtkTriangle.cxx
@@ -26,7 +26,7 @@
 #include "vtkPolygon.h"
 #include "vtkQuadric.h"

-vtkCxxRevisionMacro(vtkTriangle, "1.103");
+vtkCxxRevisionMacro(vtkTriangle, "1.104");
 vtkStandardNewMacro(vtkTriangle);

 // Construct the triangle with three points.
@@ -985,7 +985,7 @@

   //  Check whether normals go in same direction
   //
-  if ( (vtkMath::Dot(n1,n2) > 0.0) && (vtkMath::Dot(n2,n3) > 0.0) )
+  if ( (vtkMath::Dot(n1,n2) >= 0.0) && (vtkMath::Dot(n2,n3) >= 0.0) )
     {
     return 1;
     }


TODO-1029: trying to set up SIM900 test harness

--- portableUnitTests/OTRadioLink/OTSIM900Link.cpp
+++ portableUnitTests/OTRadioLink/OTSIM900Link.cpp
@@ -26,7 +26,7 @@

 // Test for general sanity of OTSIM900Link.
-// In particular, simulate some nominal REV7/DORM1/TRV1 numbers.
+// Make sure than an instance can be created and does not die horribly.
 TEST(OTSIM900Link,basics)
 {
     class NULLSerialStream final : public Stream


Finished implementing new vectorized graphics methods.

Signed-off-by: Adam Hintz <96c833980ca266d81f358ac8bd40898278f74af6@gmail.com>

--- Engine/Scripting/LuaBind.cpp
+++ Engine/Scripting/LuaBind.cpp
@@ -29,19 +29,19 @@
 {
 	if (!lua_istable(L, narg))
 	{
-		luaL_argerror(L, narg, "must pass a vector table");
+		luaL_argerror(L, narg, "must pass a vector table (not a table)");
 	}
 	float x, y;
 	lua_getfield(L, narg, "x");
 	if (!lua_isnumber(L, -1))
 	{
-		luaL_argerror(L, narg, "must pass a vector table");
+		luaL_argerror(L, narg, "must pass a vector table (bad x value)");
 	}
 	x = lua_tonumber(L, -1);
 	lua_getfield(L, narg, "y");
 	if (!lua_isnumber(L, -1))
 	{
-		luaL_argerror(L, narg, "must pass a vector table");
+		luaL_argerror(L, narg, "must pass a vector table (bad y value)");
 	}
 	y = lua_tonumber(L, -1);
 	lua_pop(L, 2);
@@ -893,7 +893,7 @@
 	return colour(r, g, b, a);
 }

-int GFX_DrawText_V ( lua_State* L )
+int GFX_DrawText ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	const char* text = luaL_checkstring(L, 1);
@@ -918,32 +918,6 @@
 	return 0;
 }

-int GFX_DrawText ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	const char* text = luaL_checkstring(L, 1);
-	const char* font = luaL_checkstring(L, 2);
-	const char* justify = luaL_checkstring(L, 3);
-	float loc_x = luaL_checknumber(L, 4);
-	float loc_y = luaL_checknumber(L, 5);
-	float height = luaL_checknumber(L, 6);
-	float rotation = 0.0f;
-	if (nargs >= 8)
-	{
-		rotation = luaL_checknumber(L, 8);
-	}
-	if (nargs >= 7)
-	{
-		luaL_argcheck(L, lua_istable(L, 7), 7, "bad colour");
-		Graphics::DrawTextSDL(text, font, justify, vec2(loc_x, loc_y), height, LoadColour(L, 7), rotation);
-	}
-	else
-	{
-		Graphics::DrawTextSDL(text, font, justify, vec2(loc_x, loc_y), height, colour(1.0f, 1.0f, 1.0f, 1.0f), rotation);
-	}
-	return 0;
-}
-
 int GFX_TextLength (lua_State* L )
 {
 	const char* text = luaL_checkstring(L, 1);
@@ -955,7 +929,7 @@
 	return 1;
 }

-int GFX_DrawLine_V ( lua_State* L )
+int GFX_DrawLine ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	float width;
@@ -973,27 +947,7 @@
 	return 0;
 }

-int GFX_DrawLine ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float x1, y1, x2, y2, width;
-	x1 = luaL_checknumber(L, 1);
-	y1 = luaL_checknumber(L, 2);
-	x2 = luaL_checknumber(L, 3);
-	y2 = luaL_checknumber(L, 4);
-	width = luaL_checknumber(L, 5);
-	if (nargs > 5)
-	{
-		Graphics::DrawLine(vec2(x1, y1), vec2(x2, y2), width, LoadColour(L, 6));
-	}
-	else
-	{
-		Graphics::DrawLine(vec2(x1, y1), vec2(x2, y2), width, colour(0.0f, 1.0f, 0.0f, 1.0f));
-	}
-	return 0;
-}
-
-int GFX_DrawLightning_V ( lua_State* L )
+int GFX_DrawLightning ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	float width, chaos;
@@ -1014,29 +968,6 @@
 	return 0;
 }

-int GFX_DrawLightning ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float x1, y1, x2, y2, width, chaos;
-	bool tailed;
-	x1 = luaL_checknumber(L, 1);
-	y1 = luaL_checknumber(L, 2);
-	x2 = luaL_checknumber(L, 3);
-	y2 = luaL_checknumber(L, 4);
-	width = luaL_checknumber(L, 5);
-	chaos = luaL_checknumber(L, 6);
-	tailed = lua_tonumber(L, 7);
-	if (nargs > 7)
-	{
-		Graphics::DrawLightning(vec2(x1, y1), vec2(x2, y2), width, chaos, LoadColour(L, 8), tailed);
-	}
-	else
-	{
-		Graphics::DrawLightning(vec2(x1, y1), vec2(x2, y2), width, chaos, colour(0.93f, 0.88f, 1.0f, 1.0f), tailed);
-	}
-	return 0;
-}
-
 int GFX_DrawBox ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
@@ -1057,7 +988,7 @@
 	return 0;
 }

-int GFX_DrawRadarTriangle_V ( lua_State* L )
+int GFX_DrawRadarTriangle ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	vec2 coordinates = luaL_checkvec2(L, 1);
@@ -1079,7 +1010,7 @@
 	return 0;
 }

-int GFX_DrawRadarPlus_V ( lua_State* L )
+int GFX_DrawRadarPlus ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	vec2 coordinates = luaL_checkvec2(L, 1);
@@ -1097,7 +1028,7 @@
 	return 0;
 }

-int GFX_DrawRadarBox_V ( lua_State* L )
+int GFX_DrawRadarBox ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	vec2 coordinates = luaL_checkvec2(L, 1);
@@ -1113,7 +1044,7 @@
 	return 0;
 }

-int GFX_DrawRadarDiamond_V ( lua_State* L )
+int GFX_DrawRadarDiamond ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	vec2 coordinates = luaL_checkvec2(L, 1);
@@ -1129,7 +1060,7 @@
 	return 0;
 }

-int GFX_DrawObject3DAmbient_V ( lua_State* L )
+int GFX_DrawObject3DAmbient ( lua_State* L )
 {
 	std::string object = luaL_checkstring(L, 1);
 	vec2 location = luaL_checkvec2(L, 2);
@@ -1141,93 +1072,6 @@
 	return 0;
 }

-int GFX_DrawRadarTriangle ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float coordinates[2] = { luaL_checknumber(L, 1), luaL_checknumber(L, 2) };
-	float varsize = luaL_checknumber(L, 3);
-	if (nargs > 3)
-	{
-		Graphics::DrawTriangle(vec2(coordinates[0], coordinates[1] + varsize),
-							   vec2(coordinates[0] - varsize, coordinates[1] - varsize),
-							   vec2(coordinates[0] + varsize, coordinates[1] - varsize),
-							   LoadColour(L, 4));
-	}
-	else
-	{
-		Graphics::DrawTriangle(vec2(coordinates[0], coordinates[1] + varsize),
-							   vec2(coordinates[0] - varsize, coordinates[1] - varsize),
-							   vec2(coordinates[0] + varsize, coordinates[1] - varsize),
-							   colour(0.0f, 1.0f, 0.0f, 1.0f));
-	}
-	return 0;
-}
-
-int GFX_DrawRadarPlus ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float coordinates[2] = { luaL_checknumber(L, 1), luaL_checknumber(L, 2) };
-	float varsize = luaL_checknumber(L, 3);
-	if (nargs > 3)
-	{
-		Graphics::DrawBox(coordinates[1] + varsize, coordinates[0] - 0.3 * varsize, coordinates[1] - varsize, coordinates[0] + 0.3 * varsize, 0, LoadColour(L, 4));
-		Graphics::DrawBox(coordinates[1] + 0.3 * varsize, coordinates[0] - varsize, coordinates[1] - 0.3 * varsize, coordinates[0] + varsize, 0, LoadColour(L, 4));
-	}
-	else
-	{
-		Graphics::DrawBox(coordinates[1] + varsize, coordinates[0] - 0.3 * varsize, coordinates[1] - varsize, coordinates[0] + 0.3 * varsize, 0, colour(0, 1, 0, 1));
-		Graphics::DrawBox(coordinates[1] + 0.3 * varsize, coordinates[0] - varsize, coordinates[1] - 0.3 * varsize, coordinates[0] + varsize, 0, colour(0, 1, 0, 1));
-	}
-	return 0;
-}
-
-int GFX_DrawRadarBox ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float coordinates[2] = { luaL_checknumber(L, 1), luaL_checknumber(L, 2) };
-	float varsize = luaL_checknumber(L, 3);
-	if (nargs > 3)
-	{
-		Graphics::DrawBox(coordinates[1] + varsize, coordinates[0] - varsize, coordinates[1] - varsize, coordinates[0] + varsize, 0, LoadColour(L, 4));
-	}
-	else
-	{
-		Graphics::DrawBox(coordinates[1] + varsize, coordinates[0] - varsize, coordinates[1] - varsize, coordinates[0] + varsize, 0, colour(0, 1, 0, 1));
-	}
-	return 0;
-}
-
-int GFX_DrawRadarDiamond ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float coordinates[2] = { luaL_checknumber(L, 1), luaL_checknumber(L, 2) };
-	float varsize = luaL_checknumber(L, 3);
-	if (nargs > 3)
-	{
-		Graphics::DrawDiamond(coordinates[1] + varsize, coordinates[0] - varsize, coordinates[1] - varsize, coordinates[0] + varsize, LoadColour(L, 4));
-	}
-	else
-	{
-		Graphics::DrawDiamond(coordinates[1] + varsize, coordinates[0] - varsize, coordinates[1] - varsize, coordinates[0] + varsize, colour(0, 1, 0, 1));
-	}
-	return 0;
-}
-
-int GFX_DrawObject3DAmbient ( lua_State* L )
-{
-	std::string object = luaL_checkstring(L, 1);
-	float x = luaL_checknumber(L, 2);
-	float y = luaL_checknumber(L, 3);
-	float r = luaL_checknumber(L, 4);
-	float g = luaL_checknumber(L, 5);
-	float b = luaL_checknumber(L, 6);
-	float scale = luaL_checknumber(L, 7);
-	float angle = luaL_checknumber(L, 8);
-	float bank = luaL_optnumber(L, 9, 0.0);
-	Graphics::DrawObject3DAmbient(object, vec2(x, y), colour(r, g, b), scale, angle, bank);
-	return 0;
-}
-
 int GFX_DrawParticles ( lua_State* L )
 {
 	Graphics::DrawParticles();
@@ -1239,7 +1083,7 @@
 	Graphics::ClearParticles();
 }

-int GFX_AddParticles_V ( lua_State* L )
+int GFX_AddParticles ( lua_State* L )
 {
 	const char* name = luaL_checkstring(L, 1);
 	unsigned long pcount = luaL_checkinteger(L, 2);
@@ -1253,7 +1097,7 @@
 	return 0;
 }

-int GFX_DrawCircle_V ( lua_State* L )
+int GFX_DrawCircle ( lua_State* L )
 {
 	int nargs = lua_gettop(L);
 	float radius, width;
@@ -1271,63 +1115,13 @@
 	return 0;
 }

-int GFX_DrawImage_V ( lua_State* L )
+int GFX_DrawImage ( lua_State* L )
 {
 	const char* imgName;
 	imgName = luaL_checkstring(L, 1);
 	vec2 location = luaL_checkvec2(L, 2);
 	vec2 size = luaL_checkvec2(L, 3);
 	Graphics::DrawImage(imgName, location, size);
-	return 0;
-}
-
-int GFX_AddParticles ( lua_State* L )
-{
-	const char* name = luaL_checkstring(L, 1);
-	unsigned long pcount = luaL_checkinteger(L, 2);
-	float x = luaL_checknumber(L, 3);
-	float y = luaL_checknumber(L, 4);
-	float velX = luaL_checknumber(L, 5);
-	float velY = luaL_checknumber(L, 6);
-	float velVarX = luaL_checknumber(L, 7);
-	float velVarY = luaL_checknumber(L, 8);
-	float accX = luaL_checknumber(L, 9);
-	float accY = luaL_checknumber(L, 10);
-	float size = luaL_checknumber(L, 11);
-	float lifetime = luaL_checknumber(L, 12);
-	Graphics::AddParticles(name, pcount, vec2(x, y), vec2(velX, velY), vec2(velVarX, velVarY), vec2(accX, accY), size, lifetime);
-	return 0;
-}
-
-int GFX_DrawCircle ( lua_State* L )
-{
-	int nargs = lua_gettop(L);
-	float x, y, radius, width;
-	x = luaL_checknumber(L, 1);
-	y = luaL_checknumber(L, 2);
-	radius = luaL_checknumber(L, 3);
-	width = luaL_checknumber(L, 4);
-	if (nargs > 4)
-	{
-		Graphics::DrawCircle(vec2(x, y), radius, width, LoadColour(L, 4));
-	}
-	else
-	{
-		Graphics::DrawCircle(vec2(x, y), radius, width, colour(0.0f, 1.0f, 0.0f, 1.0f));
-	}
-	return 0;
-}
-
-int GFX_DrawImage ( lua_State* L )
-{
-	const char* imgName;
-	float loc_x, loc_y, size_x, size_y;
-	imgName = luaL_checkstring(L, 1);
-	loc_x = luaL_checknumber(L, 2);
-	loc_y = luaL_checknumber(L, 3);
-	size_x = luaL_checknumber(L, 4);
-	size_y = luaL_checknumber(L, 5);
-	Graphics::DrawImage(imgName, vec2(loc_x, loc_y), vec2(size_x, size_y));
 	return 0;
 }

@@ -1341,7 +1135,7 @@
 	return 2;
 }

-int GFX_DrawSprite_V ( lua_State* L )
+int GFX_DrawSprite ( lua_State* L )
 {
 	const char* spritesheet;
 	int nargs = lua_gettop(L);
@@ -1365,32 +1159,6 @@
 	return 0;
 }

-int GFX_DrawSprite ( lua_State* L )
-{
-	const char* spritesheet;
-	int nargs = lua_gettop(L);
-	float loc_x, loc_y, size_x, size_y, rot = 0.0f;
-	colour col;
-	spritesheet = luaL_checkstring(L, 1);
-	loc_x = luaL_checknumber(L, 2);
-	loc_y = luaL_checknumber(L, 3);
-	size_x = luaL_checknumber(L, 4);
-	size_y = luaL_checknumber(L, 5);
-	if (nargs >= 6)
-	{
-		rot = luaL_checknumber(L, 6);
-	}
-	if (nargs > 6)
-	{
-		Graphics::DrawSprite(spritesheet, 0, 0, vec2(loc_x, loc_y), vec2(size_x, size_y), rot, LoadColour(L, 7));
-	}
-	else
-	{
-		Graphics::DrawSprite(spritesheet, 0, 0, vec2(loc_x, loc_y), vec2(size_x, size_y), rot, colour(1.0f, 1.0f, 1.0f, 1.0f));
-	}
-	return 0;
-}
-
 int GFX_DrawStarfield ( lua_State* L )
 {
 	if (lua_gettop(L) > 0)
@@ -1405,7 +1173,7 @@
 	return 0;
 }

-int GFX_IsCulled_V ( lua_State* L )
+int GFX_IsCulled ( lua_State* L )
 {
 	vec2 location = luaL_checkvec2(L, 1);
 	float radius = luaL_optnumber(L, 2, 0.0);
@@ -1414,17 +1182,7 @@
 	return 1;
 }

-int GFX_IsCulled ( lua_State* L )
-{
-	float x = luaL_checknumber(L, 1);
-	float y = luaL_checknumber(L, 2);
-	float radius = luaL_optnumber(L, 3, 0.0);
-	bool isCulled = Graphics::IsCulled(vec2(x, y), radius);
-	lua_pushboolean(L, isCulled ? 1 : 0);
-	return 1;
-}
-
-int GFX_DrawSpriteFromSheet_V ( lua_State* L )
+int GFX_DrawSpriteFromSheet ( lua_State* L )
 {
 	const char* spritesheet;
 	int nargs = lua_gettop(L);
@@ -1444,33 +1202,6 @@
 	else
 	{
 		Graphics::DrawSprite(spritesheet, sheet.X(), sheet.Y(), location, size, rot, colour(1.0f, 1.0f, 1.0f, 1.0f));
-	}
-	return 0;
-}
-
-int GFX_DrawSpriteFromSheet ( lua_State* L )
-{
-	const char* spritesheet;
-	int sheet_x, sheet_y, nargs = lua_gettop(L);
-	float loc_x, loc_y, size_x, size_y, rot = 0.0f;
-	spritesheet = luaL_checkstring(L, 1);
-	sheet_x = luaL_checkinteger(L, 2);
-	sheet_y = luaL_checkinteger(L, 3);
-	loc_x = luaL_checknumber(L, 4);
-	loc_y = luaL_checknumber(L, 5);
-	size_x = luaL_checknumber(L, 6);
-	size_y = luaL_checknumber(L, 7);
-	if (nargs == 8)
-	{
-		rot = luaL_checknumber(L, 8);
-	}
-	if (nargs > 8)
-	{
-		Graphics::DrawSprite(spritesheet, sheet_x, sheet_y, vec2(loc_x, loc_y), vec2(size_x, size_y), rot, LoadColour(L, 7));
-	}
-	else
-	{
-		Graphics::DrawSprite(spritesheet, sheet_x, sheet_y, vec2(loc_x, loc_y), vec2(size_x, size_y), rot, colour(1.0f, 1.0f, 1.0f, 1.0f));
 	}
 	return 0;
 }


DOC:  Images SVM Classifier Doc update.

DOC:  Images SVM Classifier Doc update.

--- Applications/Classification/otbImageSVMClassifier.cxx
+++ Applications/Classification/otbImageSVMClassifier.cxx
@@ -63,10 +63,14 @@

     // Documentation
     SetDocName("Image SVM Classifier Application");
-    SetDocLongDescription("This application performs an image classification based on the SVM classifier. The image to classify and the SVM model are given in input, the application will generate the classified output image. Optionnally, the user can give an image statistics file (that contains min, max) to normalize the input image before the classification. Furthemore, the user can give a mask to define area of work (only pixel with value greater to 0 will be porceed), this no classify pixels will appear in the output image with the value 0.");
+    SetDocLongDescription("This application performs an image classification based on the SVM classifier."
+        "The image to classify and the SVM model are given in input, the application will generate the classified output image. "
+        " Optionally, the user can give an image statistics file (that contains min, max) to normalize the input image before the classification."
+        " Furthemore, the user can give a mask to define area of work (only pixels with values greater to 0 will be proceed), "
+        "these no classify pixels will appear in the output image with the value 0.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("TrainSVMImagesClassifier application, ValidateSVMImagesClassifier");
+    SetDocSeeAlso("TrainSVMImagesClassifier, ValidateSVMImagesClassifier, EstimatesImagesStatistics");
     SetDocCLExample("otbApplicationLauncherCommandLine ImageSVMClassifier ${OTB-BIN}/bin --in ${OTB-DATA}/Classification/QB_1_ortho.tif  --imstat ${OTB-DATA}/Baseline/OTB-Applications/Files/clImageStatisticsQB1.xml --svn ${OTB-DATA}/Baseline/OTB-Applications/Files/clsvmModelQB1.svm --out otbConcatenateImages.png uchar");
     AddDocTag("Classification");
     AddDocTag("SVM");


Fixed typo.

Fixed typo.

--- Source/Core/OniFrameManager.cpp
+++ Source/Core/OniFrameManager.cpp
@@ -14,7 +14,7 @@
 OniFrameInternal* FrameManager::acquireFrame()
 {
 	OniFrameInternal* pFrame = m_frames.Acquire();
-    xnOSMemSet(pFrame, 0, sizeof(OniFrameInternal);
+    xnOSMemSet(pFrame, 0, sizeof(OniFrameInternal));
 	pFrame->refCount = 1;
 	return pFrame;
 }


Fixed two typos in 'LuaValue' documentation.

--- Sources/LuaValue.hpp
+++ Sources/LuaValue.hpp
@@ -45,15 +45,15 @@

-   /** An error in a \c LuaValueError that happens when a certain type is
-    *  expected but another one is found.
+   /** An error in a \c LuaValue that happens when a certain type is expected
+    *  but another one is found.
     */
    class TypeMismatchError: public LuaValueError
    {
       public:
          /** Constructs a \c TypeMismatchError object.
           *  @param expectedType The type that was expected.
-          *  @param expectedType The type that was actually found.
+          *  @param foundType The type that was actually found.
           */
          TypeMismatchError (const std::string& expectedType,
                             const std::string& foundType);


Fixed deprecation warning

Fixed deprecation warning

--- dune/multiscale/msfem/localproblems/subgrid-list.hh
+++ dune/multiscale/msfem/localproblems/subgrid-list.hh
@@ -79,7 +79,7 @@
   typedef boost::multi_array<bool, 3> EnrichmentMatrixType;
   //! @todo this should eventually be changed to the type of the coarse space
   typedef typename HostGridPartType::Codim<0>::EntityType::Geometry::LocalCoordinate LocalCoordinateType;
-  typedef GenericReferenceElements< typename  LocalCoordinateType::value_type,  LocalCoordinateType::dimension >
+  typedef ReferenceElements< typename  LocalCoordinateType::value_type,  LocalCoordinateType::dimension >
           CoarseRefElementType;
   typedef std::vector<std::vector<HostEntityPointerType>> EntityPointerCollectionType;


sort updated

sort updated

--- EstructurasLineales/List.hpp
+++ EstructurasLineales/List.hpp
@@ -42,7 +42,6 @@
         List<T> sublist(int, int);
         void reverse();
         void sort();
-        void bubblesort();
         bool sorted() const;

         void operator=(const List<T> &);
@@ -445,21 +444,12 @@
 }

 /**
- * Ordernar
- * */
-template<class T>
-void List<T>::sort()
-{
-    this->bubblesort();
-}
-
-/**
  * Ordena los elementos de la lista.
  * Ordena de menor a mayor los elementos de la lista, utilizando
  * el algoritmo de ordenamiento Bubble Sort.
  * */
 template<class T>
-void List<T>::bubblesort()
+void List<T>::sort()
 {
     if (!sorted())
     {


Another bugfix in PcapSearch

Another bugfix in PcapSearch

--- Examples/PcapSearch/main.cpp
+++ Examples/PcapSearch/main.cpp
@@ -199,8 +199,15 @@
     while (entry != NULL)
     {
     	std::string name(entry->d_name);
-    	std::string dirPath = directory + DIR_SEPARATOR + name;
-    	struct stat info;
+
+    	// construct directory full path
+    	std::string dirPath = directory;
+    	std::string dirSep = DIR_SEPARATOR;
+    	if (0 != directory.compare(directory.length() - dirSep.length(), dirSep.length(), dirSep)) // directory doesn't contain separator in the end
+    	    dirPath += DIR_SEPARATOR;
+    	dirPath += name;
+
+	struct stat info;

     	// get file attributes
     	if (stat(dirPath.c_str(), &info) != 0)
@@ -375,13 +382,6 @@
 	int totalFilesSearched = 0;
 	int totalPacketsFound = 0;

-	// if input dir contains a directory separator at the end, remove it
-	std::string dirSep = DIR_SEPARATOR;
-	if (0 == inputDirectory.compare(inputDirectory.length() - dirSep.length(), dirSep.length(), dirSep))
-	{
-		inputDirectory = inputDirectory.substr(0, inputDirectory.size()-1);
-	}
-
 	// the main call - start searching!
 	searchtDirectories(inputDirectory, includeSubDirectories, searchCriteria, detailedReportFile, extensionsToSearch, totalDirSearched, totalFilesSearched, totalPacketsFound);


change UART1

change UART1

--- DS3231_sample/main.cpp
+++ DS3231_sample/main.cpp
@@ -18,6 +18,10 @@
 #include "common/time.h"
 #include "chip/DS3231.hpp"

+// どれか一つだけ有効にする。
+// #define UART0
+#define UART1
+
 namespace {

 	typedef device::iica_io<device::IICA0> IICA;
@@ -27,7 +31,14 @@

 	typedef utils::fifo<128> buffer;

-	device::uart_io<device::SAU00, device::SAU01, buffer, buffer> uart0_;
+#ifdef UART0
+	// UART0 の定義（SAU0、SAU1）
+	device::uart_io<device::SAU00, device::SAU01, buffer, buffer> uart_;
+#endif
+#ifdef UART1
+	// UART1 の定義（SAU2、SAU3）
+	device::uart_io<device::SAU02, device::SAU03, buffer, buffer> uart_;
+#endif

 	device::itimer<uint8_t> itm_;

@@ -49,12 +60,12 @@
 	/* 10 */  nullptr,
 	/* 11 */  nullptr,
 	/* 12 */  nullptr,
-	/* 13 */  reinterpret_cast<void*>(uart0_.send_task),
-	/* 14 */  reinterpret_cast<void*>(uart0_.recv_task),
-	/* 15 */  reinterpret_cast<void*>(uart0_.error_task),
-	/* 16 */  nullptr,
-	/* 17 */  nullptr,
-	/* 18 */  nullptr,
+	/* 13 */  reinterpret_cast<void*>(uart_.send_task),  // UART0-TX
+	/* 14 */  reinterpret_cast<void*>(uart_.recv_task),  // UART0-RX
+	/* 15 */  reinterpret_cast<void*>(uart_.error_task), // UART0-ER
+	/* 16 */  reinterpret_cast<void*>(uart_.send_task),  // UART1-TX
+	/* 17 */  reinterpret_cast<void*>(uart_.recv_task),  // UART1-RX
+	/* 18 */  reinterpret_cast<void*>(uart_.error_task), // UART1-ER
 	/* 19 */  nullptr,
 	/* 20 */  nullptr,
 	/* 21 */  nullptr,
@@ -69,22 +80,22 @@
 extern "C" {
 	void sci_putch(char ch)
 	{
-		uart0_.putch(ch);
+		uart_.putch(ch);
 	}

 	void sci_puts(const char* str)
 	{
-		uart0_.puts(str);
+		uart_.puts(str);
 	}

 	char sci_getch(void)
 	{
-		return uart0_.getch();
+		return uart_.getch();
 	}

 	uint16_t sci_length()
 	{
-		return uart0_.recv_length();
+		return uart_.recv_length();
 	}
 };

@@ -230,10 +241,10 @@
 		itm_.start(60, intr_level);
 	}

-	// UART0 の開始
+	// UART の開始
 	{
 		uint8_t intr_level = 1;
-		uart0_.start(115200, intr_level);
+		uart_.start(115200, intr_level);
 	}

 	// IICA(I2C) の開始


Applied HARMONY-3252 [drlvm][winx64][build] Fixing importing JNI NIO function for Intel64 architecture

Now on windows x86_64 NIO natives are found correctly

svn path=/harmony/; revision=512240

--- enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
+++ enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
@@ -266,7 +266,7 @@
     }

     apr_dso_handle_sym_t gdba, gdbc, ndb;
-#ifdef WIN32
+#if defined WIN32 && !defined _EM64T_
 #define GET_DIRECT_BUFFER_ADDRESS "_GetDirectBufferAddress@8"
 #define GET_DIRECT_BUFFER_CAPACITY "_GetDirectBufferCapacity@8"
 #define NEW_DIRECT_BYTE_BUFFER "_NewDirectByteBuffer@16"


fixed ReceiveDlg bug

fixed ReceiveDlg bug

Former-commit-id: f9c8ab84ca172db836bdb8d55cac601672719484

--- DacrsUI/ReceiveDlg.cpp
+++ DacrsUI/ReceiveDlg.cpp
@@ -463,25 +463,24 @@

 	int count = m_listCtrl.GetItemCount();

-	int nSubIdx = 1,i =count;
+	int nSubIdx = 0,i =count;

 	CString strOrder(_T(""));
-	strOrder.Format(_T("%d"), count);
+	strOrder.Format(_T("%d"), ++count);
+
+	m_listCtrl.InsertItem( i , strOrder);  //
 	CString  strShowData;
-	m_listCtrl.InsertItem( i , strShowData) ;
 	strShowData.Format(_T("%s") ,addr.Lebel) ;
-
-
+	m_listCtrl.SetItemText( i , ++nSubIdx, strShowData ) ; //ǩ
+
 	CString addressd;
 	addressd.Format(_T("%s"),addr.address);

 	ASSERT(m_pListaddrInfo.count(addressd) == 0);
-
-    m_pListaddrInfo[addressd]=addr;
-	m_listCtrl.SetItemText( i , ++nSubIdx, strShowData ) ;
-
-	strShowData.Format(_T("%s") ,addr.address) ;
-	m_listCtrl.SetItemText(i , ++nSubIdx , strShowData ) ;
+	m_pListaddrInfo[addressd]=addr;
+
+	strShowData.Format(_T("%s"),addr.address);    //ַ
+	m_listCtrl.SetItemText( i , ++nSubIdx, strShowData );

 	if (addr.bSign == 1)
 	{


update

update

--- poj/3225_Help_with_Intervals_线段树.cpp
+++ poj/3225_Help_with_Intervals_线段树.cpp
@@ -17,7 +17,6 @@
     int rbd;
     int cover;
     int mask;
-    int flag;
 } tree[maxn*4+11];

 void build(int root, int left, int right) {
@@ -25,7 +24,6 @@
     tree[root].right = right;
     tree[root].cover = 0;
     tree[root].mask = 0;
-    tree[root].flag = 1;
     tree[root].lbd = left-1;
     tree[root].rbd = right+1;
     if (left >= right) {
@@ -58,47 +56,36 @@
       tree[rson].lbd = tree[rson].right;
       tree[rson].rbd = tree[rson].left;
     } else {
-      tree[lson].lbd = -1;
-      tree[lson].rbd = -1;
-      tree[rson].lbd = -1;
-      tree[rson].rbd = -1;
+      tree[lson].lbd = tree[lson].left - 1;
+      tree[lson].rbd = tree[lson].right + 1;
+      tree[rson].lbd = tree[rson].left - 1;
+      tree[rson].rbd = tree[rson].right + 1;
     }
-    tree[lson].flag = 1;
-    tree[rson].flag = 1;
     tree[root].mask = 0;
   }
 }

 void update(int root) {
-  if (tree[lson].cover == tree[rson].cover and tree[lson].flag and tree[rson].flag) {
-    tree[root].cover = tree[lson].cover;
-    tree[root].flag = 1;
-  } else {
-    tree[root].flag = 0;
-  }
-
   tree[root].lbd = tree[lson].lbd;
-  if (tree[rson].lbd != -1 and tree[lson].lbd == tree[lson].right) {
+  if (tree[lson].lbd == tree[lson].right) {
     tree[root].lbd = tree[rson].lbd;
   }
   tree[root].rbd = tree[rson].rbd;
-  if (tree[lson].rbd != -1 and tree[rson].rbd == tree[rson].left) {
+  if (tree[rson].rbd == tree[rson].left) {
     tree[root].rbd = tree[lson].rbd;
   }
 }

 void insert(int root, int left, int right, int c) {
-  tree[root].flag = 0;
   if (left <= tree[root].left and tree[root].right <= right) {
     line(tree[root].cover);
     tree[root].mask = c;
-    tree[root].flag = 1;
     if (tree[root].cover) {
       tree[root].lbd = tree[root].right;
       tree[root].rbd = tree[root].left;
     } else {
-      tree[root].lbd = -1;
-      tree[root].rbd = -1;
+      tree[root].lbd = tree[root].left - 1;
+      tree[root].rbd = tree[root].right + 1;
     }
     return;
   } else if (left > tree[root].right or right < tree[root].left) {
@@ -130,14 +117,15 @@
   insert(root, left, right, 2);
 }

-void query(int root) {
+void query(int root, int left, int right) {
   if (tree[root].left == tree[root].right) {
     return;
   }
+  if (tree[root].)
   query(lson);
-
-  l = tree[lson].rbd;
-
+  if (tree[lson].rbd <= tree[rson].lbd) {
+    printf("(%d, %d) ", tree[lson].rbd, tree[rson].lbd);
+  }
   query(rson);
 }

@@ -150,7 +138,7 @@
         //printf("%c %c%d,%d%c\n", order, l, a,b,r);
         f[(int)order](1, (a<<1)+(l=='('), (b<<1)-(r==')'));
     }
-    query(1);
+    query(1, -1, maxn+1);
 }

 int main() {


Relax shape validation checks. Log a warning instead of returning an error. (#1476)

* Mention OrtCreateSessionFromArray in C API doc

* Relax shape validation checks. Log a warning instead of returning an error.

--- onnxruntime/core/session/inference_session.cc
+++ onnxruntime/core/session/inference_session.cc
@@ -566,9 +566,12 @@
   auto input_shape_sz = input_shape.NumDimensions();
   auto expected_shape_sz = expected_shape.NumDimensions();
   if (input_shape_sz != expected_shape_sz) {
-    return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Invalid rank for input: ",
-                           input_name,
-                           " Got: ", input_shape_sz, " Expected: ", expected_shape_sz);
+    std::ostringstream ostr;
+    ostr << "Invalid rank for input: " << input_name
+         << " Got: " << input_shape_sz << " Expected: " << expected_shape_sz
+         << " Please fix either the inputs or the model.";
+    LOGS(*session_logger_, WARNING) << ostr.str();
+    return Status::OK();
   }

   std::vector<int> invalid_dim_indices;
@@ -588,7 +591,8 @@
       int idx = invalid_dim_indices[i];
       ostr << " index: " << idx << " Got: " << input_shape[idx] << " Expected: " << expected_shape[idx] << "\n";
     }
-    return Status(ONNXRUNTIME, INVALID_ARGUMENT, ostr.str());
+    ostr << " Please fix either the inputs or the model.";
+    LOGS(*session_logger_, WARNING) << ostr.str();
   }

   return Status::OK();


Fixed a bug for avoiding extending a existing link to a pattern .

--- opencog/learning/PatternMiner/PatternMiner.cc
+++ opencog/learning/PatternMiner/PatternMiner.cc
@@ -684,9 +684,6 @@

         foreach(Handle incomingHandle, incomings)
         {
-            if (isInHandleSeq(incomingHandle, instance))
-                continue;
-
             Handle extendedHandle;
             // if this atom is a igonred type, get its first parent that is not in the igonred types
             if (isIgnoredType (originalAtomSpace->getType(incomingHandle)) )
@@ -700,6 +697,9 @@

             // debug
             string extendedHandleStr = originalAtomSpace->atomAsString(extendedHandle);
+
+            if (isInHandleSeq(extendedHandle, instance))
+                continue;

             // Add this extendedHandle to the old pattern so as to make a new pattern
             HandleSeq originalLinks = instance;


thread pooled documentation clean up

thread pooled documentation clean up

--- inc/BSignals/Signal.hpp
+++ inc/BSignals/Signal.hpp
@@ -44,9 +44,10 @@
     // Emitted parameters are bound to the mapped function and enqueued on the
     // waiting thread. These messages are then processed synchronously in the
     // spawned thread.
-    // This method is recommended when quick emission is required, connected
-    // functions have longer execution time, and/or connected functions need to
-    // be processed in order of arrival (FIFO).
+    // This method is recommended when connected functions have longer execution
+    // time, the overhead of creating/destroying a thread for each slot would be
+    // unperformant, and/or connected functions need to be processed in order
+    // of arrival (FIFO).

     // THREAD POOLED:
     // Emission occurs asynchronously.
@@ -58,8 +59,11 @@
     // one of the waiting threads - acquisition of a thread is wait-free and
     // lock free. These messages are then processed when the relevant queue
     // is consumed by the mapped thread pool.
-    // This method is recommended when quick emission is required, connected
-    // functions have longer execution time, and order is irrelevant. This method
+    // This method is recommended when connected functions have longer execution
+    // time, the overhead of creating/destroying a thread for each slot would be
+    // unperformant, the overhead of a waiting thread for each slot is
+    // unnecessary, and/or connected functions do NOT need to be processed in
+    // order of arrival.
 //

 namespace BSignals{


Address PR comments

Address PR comments

--- tftrt/examples-cpp/benchmark_runner/main.cpp
+++ tftrt/examples-cpp/benchmark_runner/main.cpp
@@ -82,7 +82,7 @@

 // Returns info for nodes listed in the signature definition.
 std::vector<tensorflow::TensorInfo> getNodeInfo(
-    const google::protobuf::Map<std::string, tensorflow::TensorInfo>& signature) {
+    const google::protobuf::Map<string, tensorflow::TensorInfo>& signature) {
   std::vector<tensorflow::TensorInfo> info;
   for (const auto& item : signature) {
     info.push_back(item.second);
@@ -91,7 +91,8 @@
 }

 // Load the `SavedModel` located at `model_dir`.
-Status loadModel(const std::string& model_dir,
+Status loadModel(const string& model_dir,
+                 const string& signature_key,
                  tensorflow::SavedModelBundle* bundle,
                  std::vector<tensorflow::TensorInfo>* input_info,
                  std::vector<tensorflow::TensorInfo>* output_info) {
@@ -102,7 +103,7 @@

     // Get input and output names
     auto signature_map = bundle->GetSignatures();
-    const tensorflow::SignatureDef& signature = signature_map["serving_default"];
+    const tensorflow::SignatureDef& signature = signature_map[signature_key];
     *input_info = getNodeInfo(signature.inputs());
     *output_info = getNodeInfo(signature.outputs());

@@ -151,11 +152,13 @@
 int main(int argc, char* argv[]) {
     // Parse arguments
     string model_path = "/path/to/model/";
+    string signature_key = "serving_default";
     int32_t batch_size = 64;
     int32_t warmup_iters = 50;
     int32_t eval_iters = 1000;
     std::vector<Flag> flag_list = {
         Flag("model_path", &model_path, "graph to be executed"),
+        Flag("signature_key", &signature_key, "the serving signature to use"),
         Flag("batch_size", &batch_size, "batch size to use for inference"),
         Flag("warmup_iters", &warmup_iters, "number of warmup iterations to run"),
         Flag("eval_iters", &eval_iters, "number of timed iterations to run"),
@@ -178,7 +181,7 @@
     tensorflow::SavedModelBundle bundle;
     std::vector<tensorflow::TensorInfo> input_info;
     std::vector<tensorflow::TensorInfo> output_info;
-    TFTRT_ENSURE_OK(loadModel(model_path, &bundle, &input_info, &output_info));
+    TFTRT_ENSURE_OK(loadModel(model_path, signature_key, &bundle, &input_info, &output_info));

     // Create inputs and move to device
     const string device_name = getDeviceName(bundle.session);
@@ -215,13 +218,14 @@
     std::sort(infer_time.begin() + warmup_iters, infer_time.end());
     double total_compute_time = std::accumulate(infer_time.begin() + warmup_iters, infer_time.end(), 0.0);
     double total_wall_time = (end_time - eval_start_time).count() / 1e6;
-    int32_t m = eval_iters / 2;
+    int32_t m = warmup_iters + eval_iters / 2;
     LOG(INFO) << "Total wall time (s): " << total_wall_time / 1e3;
     LOG(INFO) << "Total GPU compute time (s): " << total_compute_time / 1e3;
     LOG(INFO) << "Mean GPU compute time (ms): " << total_compute_time / eval_iters;
     LOG(INFO) << "Median GPU compute time (ms): " << (eval_iters % 2 ? infer_time[m]
                                                                      : (infer_time[m - 1] + infer_time[m]) / 2);
-    LOG(INFO) << "Throughput (ims/s): " << 1e3 * eval_iters * batch_size / total_compute_time;
+    // Note: Throughput using GPU inference time, rather than wall time
+    LOG(INFO) << "Throughput (samples/s): " << 1e3 * eval_iters * batch_size / total_compute_time;
     LOG(INFO) << "First inference latency (ms): " << infer_time.front();

     return 0;


Fixing issue with catalog bundle API calls.  Code was passing back a new uninitialized payload rather than the object that was initialized in the code above as the non-bundle version of the APIs do.  Was causing an exception in the In Game Store sample as the has_next() API would return true when there was no get next call to be made. (#301)

--- Source/Services/Marketplace/catalog_service.cpp
+++ Source/Services/Marketplace/catalog_service.cpp
@@ -539,7 +539,7 @@
         }

         return utils::generate_xbox_live_result<browse_catalog_result>(
-            browse_catalog_result::_Deserialize(response->response_body_json()),
+            catalogResult,
             response
             );
     });


fixed: adjust to code update

fixed: adjust to code update

--- Source/System/FileIO/Collada/OSGColladaNode.cpp
+++ Source/System/FileIO/Collada/OSGColladaNode.cpp
@@ -794,30 +794,10 @@
 	m[1][2] = a2.y() * b.z() * alpha;
 	m[2][2] = a2.z() * b.z() * alpha + 1.0f;

-	domNodeRef        node   = getDOMElementAs<domNode>();
-
-    TransformUnrecPtr xform = Transform::create();
-	NodeUnrecPtr      xformN = makeNodeFor(xform);
-
-	xform->setMatrix(m);
-
-	 if(getGlobal()->getOptions()->getCreateNameAttachments() == true &&
-       node->getName()                                       != NULL   )
-    {
-        std::string nodeName = node->getName();
-
-        if(skew->getSid() != NULL &&
-			getGlobal()->getOptions()->getFlattenNodeXForms() == false)
-        {
-            nodeName.append("."                );
-            nodeName.append(skew->getSid());
-        }
-
-        setName(xformN, nodeName);
-    }
-
-    appendXForm(xformN);
-
+    if(skew->getSid() != NULL)
+        xformSID.assign(skew->getSid());
+
+    appendXForm(m, xformSID, instData);
 }

 void


fixes wrong avg computation in verbose mode.

--- inc/core/result_all.hpp
+++ inc/core/result_all.hpp
@@ -98,7 +98,7 @@
           }
           ss << std::setw(28)
             << static_cast<RecordType>(ival)
-             << ": " << std::setw(16) << sum/nruns
+             << ": " << std::setw(16) << sum/(T_NumberRuns-T_NumberWarmups)
              << " [avg]"
              << "\n";
         }


RouterAccess: please MSVC even more

RouterAccess: please MSVC even more

I find no words for this ...

Signed-off-by: Patrick Bruenn <27dd71a6a4a167461f53ec06010a2a08d399a527@beckhoff.com>

--- AdsLib/RouterAccess.cpp
+++ AdsLib/RouterAccess.cpp
@@ -15,10 +15,10 @@
 {
 struct SearchPciBusReq {
     SearchPciBusReq(const uint64_t quad)
-        : leVendorID(bhf::ads::htole<uint16_t>(quad >> 48))
-        , leDeviceID(bhf::ads::htole<uint16_t>(quad >> 32))
-        , leSubVendorID(bhf::ads::htole<uint16_t>(quad >> 16))
-        , leSubSystemID(bhf::ads::htole<uint16_t>(quad))
+        : leVendorID(bhf::ads::htole<uint16_t>(static_cast<uint16_t>(quad >> 48)))
+        , leDeviceID(bhf::ads::htole<uint16_t>(static_cast<uint16_t>(quad >> 32)))
+        , leSubVendorID(bhf::ads::htole<uint16_t>(static_cast<uint16_t>(quad >> 16)))
+        , leSubSystemID(bhf::ads::htole<uint16_t>(static_cast<uint16_t>(quad)))
     {}
 private:
     const uint16_t leVendorID;


When counting_iterator is given device_space_tag for its Space parameter, it needs to convert it to default_backend_space_tag

--- thrust/iterator/detail/counting_iterator.inl
+++ thrust/iterator/detail/counting_iterator.inl
@@ -20,6 +20,7 @@
 #include <thrust/iterator/iterator_traits.h>
 #include <thrust/detail/numeric_traits.h>
 #include <thrust/detail/device/dereference.h>
+#include <thrust/iterator/detail/backend_iterator_spaces.h>

 namespace thrust
 {
@@ -34,9 +35,16 @@
 template <typename Incrementable, typename Space, typename Traversal, typename Difference>
   struct counting_iterator_base
 {
-  typedef typename thrust::experimental::detail::ia_dflt_help<
-    Space,
-    thrust::detail::identity_<thrust::any_space_tag>
+  typedef typename thrust::detail::eval_if<
+    // use any_space_tag if we are given use_default
+    thrust::detail::is_same<Space,use_default>::value,
+    thrust::detail::identity_<thrust::any_space_tag>,
+    thrust::detail::eval_if<
+      // use the default backend space if we are given device_space_tag
+      thrust::detail::is_same<Space,thrust::device_space_tag>::value,
+      thrust::detail::identity_<thrust::detail::default_device_space_tag>,
+      thrust::detail::identity_<Space>
+    >
   >::type space;

   typedef typename thrust::experimental::detail::ia_dflt_help<


stateCreatorRobotPose tries to estimate the namespace for local planner params

--- tidyup_actions/src/stateCreatorRobotPose.cpp
+++ tidyup_actions/src/stateCreatorRobotPose.cpp
@@ -12,6 +12,7 @@
     StateCreatorRobotPose::StateCreatorRobotPose()
     {
         ros::NodeHandle nhPriv("~");
+        ros::NodeHandle nh;
         nhPriv.param("nav_target_tolerance_xy", _goalToleranceXY, 0.5);
         nhPriv.param("nav_target_tolerance_yaw", _goalToleranceYaw, 0.26);  //15deg

@@ -21,11 +22,23 @@
             // relative mode: 1. get the namespace for base_local_planner
             std::string base_local_planner_ns;
             if(!nhPriv.getParam("nav_base_local_planner_ns", base_local_planner_ns)) {
-                // TODO can we estimate this?
-                ROS_ERROR("nav_target_tolerance_relative_to_move_base was true, but nav_base_local_planner_ns is not set - falling back to absolute mode.");
-            } else { // success: 2. get the xy_goal_tolerance
+                ROS_WARN("nav_target_tolerance_relative_to_move_base set, but nav_base_local_planner_ns not set - trying to estimate");
+                std::string local_planner;
+                if(!nh.getParam("move_base_node/base_local_planner", local_planner)) {
+                    ROS_ERROR("move_base_node/base_local_planner not set - falling back to absolute mode.");
+                } else {
+                    // dwa_local_planner/DWAPlannerROS -> DWAPlannerROS
+                    std::string::size_type x = local_planner.find_last_of("/");
+                    if(x == std::string::npos)
+                        base_local_planner_ns = local_planner;
+                    else
+                        base_local_planner_ns = local_planner.substr(x + 1);
+                    ROS_INFO("Estimated base_local_planner_ns to %s.", base_local_planner_ns.c_str());
+                }
+            }
+
+            if(!base_local_planner_ns.empty()) { // success: 2. get the xy_goal_tolerance
                 double move_base_tol_xy;
-                ros::NodeHandle nh;
                 if(!nh.getParam(base_local_planner_ns + "/xy_goal_tolerance", move_base_tol_xy)) {
                     ROS_ERROR_STREAM("nav_target_tolerance_relative_to_move_base was true, but "
                             << (base_local_planner_ns + "/xy_goal_tolerance") << " was not set"


Fixes/enhancements in checkrings and getringdump
- checkrings -v output both input and output buffers of miscompare date to aid in debug
- fix ecmdDataBuffer size errors for very small rings using ignore masks in checkrings
- getringdump fix for SD_DEADBITS single latch that could show up multiple times in a ring

Signed-off-by: Kahn Evans <88417bcf564329fca88ff3071c3628a57ed3e5c7@us.ibm.com>

--- ecmd-core/cmd/ecmdRingUser.C
+++ ecmd-core/cmd/ecmdRingUser.C
@@ -424,7 +424,11 @@
                   }

                   /* If this is a fresh one we need to reset everything */
-                  if ((latchname == "") || (latchname != curLatchInfo->latchName.substr(0, curLatchInfo->latchName.rfind('(')))) {
+                  if ((latchname == "") || ((latchname != curLatchInfo->latchName.substr(0, curLatchInfo->latchName.rfind('('))) ||
+                                            /* Might have latch name without bit position, and it could show up multiple times.
+                                             Need that to go down this logic path as well.*/
+                                            ((latchname == curLatchInfo->latchName.substr(0, curLatchInfo->latchName.rfind('('))) &&
+                                             (isMultiBitLatch == ECMD_LATCHTYPE_SINGLEBIT)))) {
                     dataStartBit = dataEndBit = ECMD_UNSET;
                     curBitsToFetch = ECMD_UNSET;
                     curBufferBit = 0;
@@ -2807,32 +2811,52 @@
               sprintf(outstr, "checkrings - ecmdDataBuffer::setOr(ignore_mask) failed for ring %s", ringName.c_str());
               ecmdOutputWarning( outstr );
             } else {
-              std::string start_ignore = ignore_mask_data.genHexLeftStr(0, 96);
-              uint32_t end_ignore_start = (ignore_mask_data.getWordLength() - 2) * 32;
-              uint32_t end_ignore_length = ignore_mask_data.getBitLength() - end_ignore_start;
-              std::string end_ignore = ignore_mask_data.genHexLeftStr(end_ignore_start, end_ignore_length);
-              sprintf(outstr, "checkrings - using ignoremask %s...%s\n", start_ignore.c_str(), end_ignore.c_str());
+              // Small ring, print the whole thing
+              if (ignore_mask_data.getBitLength() <= 128)
+              {
+                sprintf(outstr, "checkrings - using ignoremask %s\n",
+                        ignore_mask_data.genHexLeftStr(0, ignore_mask_data.getBitLength() - 1).c_str());
+              }
+              // Just print the start and end of the ignore mask
+              else
+              {
+                std::string start_ignore = ignore_mask_data.genHexLeftStr(0, 96);
+                uint32_t end_ignore_start = (ignore_mask_data.getWordLength() - 2) * 32;
+                uint32_t end_ignore_length = ignore_mask_data.getBitLength() - end_ignore_start;
+                std::string end_ignore = ignore_mask_data.genHexLeftStr(end_ignore_start, end_ignore_length);
+                sprintf(outstr, "checkrings - using ignoremask %s...%s\n", start_ignore.c_str(), end_ignore.c_str());
+              }
               ecmdOutput( outstr );
             }
           }

           if (readRingBuffer != ringBuffer) {
             sprintf(outstr, "checkrings - Data fetched from ring %s did not match repeated pattern of %s's\n", ringName.c_str(),
-                    repPattern.c_str());
+                    (pattern) ? passedPattern.genHexLeftStr().c_str() : repPattern.c_str());
             ecmdOutputWarning( outstr );
             if (verbose) {
-              printed = "Offset  Data\n";
+              std::string read_printed;
+              std::string exp_printed;
+              printed = "Offset       Data Miscompares\n";
               printed += "------------------------------------------------------------------------\n";
               ecmdOutput( printed.c_str() );
-              for (uint32_t y=0; y < readRingBuffer.getBitLength();) {
-                printf("%6d ", y);
-                if ( (y+64) > readRingBuffer.getBitLength()) {
-                  printed = readRingBuffer.genBinStr(y,(readRingBuffer.getBitLength()-y)) + "\n";
+              for (uint32_t y=0; y < ringBuffer.getBitLength();) {
+                if ( (y+64) > ringBuffer.getBitLength()) {
+                  exp_printed = ringBuffer.genBinStr(y,(ringBuffer.getBitLength()-y)) + "\n";
+                  read_printed = readRingBuffer.genBinStr(y,(readRingBuffer.getBitLength()-y)) + "\n";
                 } else {
-                  printed = readRingBuffer.genBinStr(y,64) + "\n";
+                  exp_printed = ringBuffer.genBinStr(y,64) + "\n";
+                  read_printed = readRingBuffer.genBinStr(y,64) + "\n";
+                }
+                if (exp_printed != read_printed)
+                {
+                    printf("%8d IN  ", y);
+                    ecmdOutput( exp_printed.c_str() );
+                    printf("%8d OUT ", y);
+                    ecmdOutput( read_printed.c_str() );
+                    printf("\n");
                 }
                 y += 64;
-                ecmdOutput( printed.c_str() );
               }
             }
             foundProblem = true;


add aborting [not yet teseted

add aborting [not yet teseted

--- tms_ts/tms_ts_subtask/src/tms_ts_subtask.cpp
+++ tms_ts/tms_ts_subtask/src/tms_ts_subtask.cpp
@@ -3,8 +3,8 @@
 using namespace std;
 using namespace boost;

-volatile map<int, bool> MOVE_IS_WORKING;
-volatile map<int, bool> MOVE_IS_WAITING;
+map<int, bool> MOVE_IS_WORKING;
+map<int, bool> MOVE_IS_WAITING;

 double sp5arm_init_arg[26] =
 {
@@ -212,7 +212,7 @@
     case 9001: // move
     {
       ROS_INFO("[tms_rp]move command\n");
-      if(MOVE_IS_WORKING.find(sd.robot_id) = MOVE_IS_WORKING.end()){
+      if(0==MOVE_IS_WORKING.count(sd.robot_id)){
         MOVE_IS_WORKING[sd.robot_id] = false;  //初実行初期値設定
         MOVE_IS_WAITING[sd.robot_id] = false;
       }
@@ -675,6 +675,10 @@
       while(1)
       {
         ROS_INFO("result:%d, message:%s", rp_srv.response.success, rp_srv.response.message.c_str());
+        if(MOVE_IS_WAITING.at(sd.robot_id)){
+          MOVE_IS_WORKING.at(sd.robot_id) = false;
+          return 0;
+        }
         // call virtual_controller

         switch (sd.robot_id)
@@ -754,30 +758,30 @@
           }
           case 2005: //kobuki
           {
-			    		tms_msg_rc::rc_robot_control kobuki_srv;
-			    		kobuki_srv.request.arg.resize(3);
-			    		kobuki_srv.request.arg[0] = rp_srv.response.VoronoiPath[i].x;
-			    		kobuki_srv.request.arg[1] = rp_srv.response.VoronoiPath[i].y;
-			    		kobuki_srv.request.arg[2] = rp_srv.response.VoronoiPath[i].th;
-
-			    		if (sd.type == true) {
-				    		kobuki_srv.request.cmd = 0;
-				    		if (kobuki_actual_control_client.call(kobuki_srv)) ROS_INFO("result: %d", kobuki_srv.response.result);
-				    		else {
-				    			ROS_ERROR("Failed to call service kobuki_move");
-				    			return false;
-				    		}
-			    		} else {
-				    		kobuki_srv.request.unit = 1;
-				    		kobuki_srv.request.cmd = 15;
-				    		if (kobuki_virtual_control_client.call(kobuki_srv)) ROS_INFO("result: %d", kobuki_srv.response.result);
-				    		else {
-				    			ROS_ERROR("Failed to call service virtual_kobuki_move");
-				    			return false;
-				    		}
-				    		sleep(0.7);
-			    		}
-            break;
+			    	// 	tms_msg_rc::rc_robot_control kobuki_srv;
+			    	// 	kobuki_srv.request.arg.resize(3);
+			    	// 	kobuki_srv.request.arg[0] = rp_srv.response.VoronoiPath[i].x;
+			    	// 	kobuki_srv.request.arg[1] = rp_srv.response.VoronoiPath[i].y;
+			    	// 	kobuki_srv.request.arg[2] = rp_srv.response.VoronoiPath[i].th;
+            //
+			    	// 	if (sd.type == true) {
+				    // 		kobuki_srv.request.cmd = 0;
+				    // 		if (kobuki_actual_control_client.call(kobuki_srv)) ROS_INFO("result: %d", kobuki_srv.response.result);
+				    // 		else {
+				    // 			ROS_ERROR("Failed to call service kobuki_move");
+				    // 			return false;
+				    // 		}
+			    	// 	} else {
+				    // 		kobuki_srv.request.unit = 1;
+				    // 		kobuki_srv.request.cmd = 15;
+				    // 		if (kobuki_virtual_control_client.call(kobuki_srv)) ROS_INFO("result: %d", kobuki_srv.response.result);
+				    // 		else {
+				    // 			ROS_ERROR("Failed to call service virtual_kobuki_move");
+				    // 			return false;
+				    // 		}
+				    // 		sleep(0.7);
+			    	// 	}
+            // break;
           }
           case 2006: // kxp
           {


Fixed a bug causing vrml exports using values from invalid addresses. https://tracker.physiomeproject.org/show_bug.cgi?id=3260

--- core/source/graphics/render_vrml.cpp
+++ core/source/graphics/render_vrml.cpp
@@ -1127,6 +1127,11 @@
 			}
 		}
 		label = glyph_set->labels;
+		point = glyph_set->point_list;
+		axis1 = glyph_set->axis1_list;
+		axis2 = glyph_set->axis2_list;
+		axis3 = glyph_set->axis3_list;
+		scale = glyph_set->scale_list;
 		if (label || static_labels)
 		{
 			point=glyph_set->point_list;


Fix glyph count

Fix glyph count

--- VolumeVisualization/CGlyphNodeManager.cpp
+++ VolumeVisualization/CGlyphNodeManager.cpp
@@ -26,11 +26,11 @@

 void CGlyphNodeManager::LoadSceneElements()
 {
-	size_t const MaxParticles = Glyphs.size();
+	size_t const FloatsNeeded = Glyphs.size() * 3;
 	PositionBuffer = new ion::GL::VertexBuffer;
-	PositionBuffer->Data<f32>(MaxParticles * sizeof(f32), nullptr, 3);
+	PositionBuffer->Data<f32>(FloatsNeeded * sizeof(f32), nullptr, 3);
 	ColorBuffer = new ion::GL::VertexBuffer;
-	ColorBuffer->Data<f32>(MaxParticles * sizeof(f32), nullptr, 3);
+	ColorBuffer->Data<f32>(FloatsNeeded * sizeof(f32), nullptr, 3);

 	if (Node)
 	{
@@ -43,7 +43,6 @@
 	Positions.clear();
 	Colors.clear();

-	size_t const FloatsNeeded = Glyphs.size() * 3;
 	if (Positions.size() < FloatsNeeded)
 	{
 		Positions.resize(FloatsNeeded);
@@ -124,7 +123,6 @@
 		Glyphs.push_back(Glyph);
 	}

-	//Context->Scene.Glyphs->BuildLines();
 	LoadSceneElements();
 }


StorageTest: Add LoadPersistent and SavePersistent coverage.

--- test/unit/StorageTest.cpp
+++ test/unit/StorageTest.cpp
@@ -7,7 +7,10 @@

 #include "Storage.h"

+#include <sstream>
+
 #include "gtest/gtest.h"
+#include "gmock/gmock.h"

 namespace nt {

@@ -35,6 +38,55 @@
     storage.SetEntryTypeValue("bar2", Value::MakeBoolean(false));
     while (!updates().empty()) updates().pop();
   }
+};
+
+class StorageTestPersistent : public StorageTest {
+ public:
+  StorageTestPersistent() {
+    storage.SetEntryTypeValue("boolean/true", Value::MakeBoolean(true));
+    storage.SetEntryTypeValue("boolean/false", Value::MakeBoolean(false));
+    storage.SetEntryTypeValue("double/neg", Value::MakeDouble(-1.5));
+    storage.SetEntryTypeValue("double/zero", Value::MakeDouble(0.0));
+    storage.SetEntryTypeValue("double/big", Value::MakeDouble(1.3e8));
+    storage.SetEntryTypeValue("string/empty", Value::MakeString(StringRef("")));
+    storage.SetEntryTypeValue("string/normal",
+                              Value::MakeString(StringRef("hello")));
+    storage.SetEntryTypeValue("string/special",
+                              Value::MakeString(StringRef("\0\3\5\n", 4)));
+    storage.SetEntryTypeValue("raw/empty", Value::MakeRaw(StringRef("")));
+    storage.SetEntryTypeValue("raw/normal", Value::MakeRaw(StringRef("hello")));
+    storage.SetEntryTypeValue("raw/special",
+                              Value::MakeRaw(StringRef("\0\3\5\n", 4)));
+    storage.SetEntryTypeValue("booleanarr/empty",
+                              Value::MakeBooleanArray(std::vector<int>{}));
+    storage.SetEntryTypeValue("booleanarr/one",
+                              Value::MakeBooleanArray(std::vector<int>{1}));
+    storage.SetEntryTypeValue("booleanarr/two",
+                              Value::MakeBooleanArray(std::vector<int>{1, 0}));
+    storage.SetEntryTypeValue("doublearr/empty",
+                              Value::MakeDoubleArray(std::vector<double>{}));
+    storage.SetEntryTypeValue("doublearr/one",
+                              Value::MakeDoubleArray(std::vector<double>{0.5}));
+    storage.SetEntryTypeValue(
+        "doublearr/two",
+        Value::MakeDoubleArray(std::vector<double>{0.5, -0.25}));
+    storage.SetEntryTypeValue(
+        "stringarr/empty", Value::MakeStringArray(std::vector<std::string>{}));
+    storage.SetEntryTypeValue(
+        "stringarr/one",
+        Value::MakeStringArray(std::vector<std::string>{"hello"}));
+    storage.SetEntryTypeValue(
+        "stringarr/two",
+        Value::MakeStringArray(std::vector<std::string>{"hello", "world\n"}));
+    storage.SetEntryTypeValue(StringRef("\0\3\5\n", 4),
+                              Value::MakeBoolean(true));
+    while (!updates().empty()) updates().pop();
+  }
+};
+
+class MockLoadWarn {
+ public:
+  MOCK_METHOD2(Warn, void(std::size_t line, const char* msg));
 };

 TEST_F(StorageTest, Construct) {
@@ -309,4 +361,268 @@
   EXPECT_EQ(NT_BOOLEAN, info[0].type);
 }

+TEST_F(StorageTestPersistent, SavePersistentEmpty) {
+  std::ostringstream oss;
+  storage.SavePersistent(oss);
+  ASSERT_EQ("[NetworkTables Storage 3.0]\n", oss.str());
+}
+
+TEST_F(StorageTestPersistent, SavePersistent) {
+  for (auto& i : entries()) i.getValue()->set_flags(NT_PERSISTENT);
+  std::ostringstream oss;
+  storage.SavePersistent(oss);
+  std::string out = oss.str();
+  //fputs(out.c_str(), stderr);
+  llvm::StringRef line, rem = out;
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("[NetworkTables Storage 3.0]", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("boolean \"\\x00\\x03\\x05\\n\"=true", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("boolean \"boolean/false\"=false", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("boolean \"boolean/true\"=true", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array boolean \"booleanarr/empty\"=", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array boolean \"booleanarr/one\"=true", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array boolean \"booleanarr/two\"=true,false", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("double \"double/big\"=1.3e+08", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("double \"double/neg\"=-1.5", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("double \"double/zero\"=0", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array double \"doublearr/empty\"=", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array double \"doublearr/one\"=0.5", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array double \"doublearr/two\"=0.5,-0.25", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("raw \"raw/empty\"=", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("raw \"raw/normal\"=aGVsbG8=", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("raw \"raw/special\"=AAMFCg==", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("string \"string/empty\"=\"\"", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("string \"string/normal\"=\"hello\"", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("string \"string/special\"=\"\\x00\\x03\\x05\\n\"", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array string \"stringarr/empty\"=", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array string \"stringarr/one\"=\"hello\"", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("array string \"stringarr/two\"=\"hello\",\"world\\n\"", line);
+  std::tie(line, rem) = rem.split('\n');
+  ASSERT_EQ("", line);
+}
+
+TEST_F(StorageTest, LoadPersistentBadHeader) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss("");
+  EXPECT_CALL(warn, Warn(1, "header line mismatch, ignoring rest of file"));
+  EXPECT_FALSE(storage.LoadPersistent(iss, warn_func));
+
+  std::istringstream iss2("[NetworkTables");
+  EXPECT_CALL(warn, Warn(1, "header line mismatch, ignoring rest of file"));
+  EXPECT_FALSE(storage.LoadPersistent(iss2, warn_func));
+  ASSERT_TRUE(entries().empty());
+  ASSERT_TRUE(updates().empty());
+}
+
+TEST_F(StorageTest, LoadPersistentCommentHeader) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "\n; comment\n# comment\n[NetworkTables Storage 3.0]\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  ASSERT_TRUE(entries().empty());
+  ASSERT_TRUE(updates().empty());
+}
+
+TEST_F(StorageTest, LoadPersistentEmptyName) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"\"=true\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  ASSERT_TRUE(entries().empty());
+  ASSERT_TRUE(updates().empty());
+}
+
+TEST_F(StorageTest, LoadPersistentAssign) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"foo\"=true\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  auto entry = storage.GetEntry("foo");
+  EXPECT_EQ(*Value::MakeBoolean(true), *entry->value());
+  EXPECT_EQ(NT_PERSISTENT, entry->flags());
+  ASSERT_EQ(1u, updates().size());
+  auto update = updates().pop();
+  EXPECT_EQ(entry, update.entry);
+  EXPECT_EQ(Storage::Update::kAssign, update.kind);
+}
+
+TEST_F(StorageTestPopulateOne, LoadPersistentUpdateFlags) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"foo\"=true\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  auto entry = storage.GetEntry("foo");
+  EXPECT_EQ(*Value::MakeBoolean(true), *entry->value());
+  EXPECT_EQ(NT_PERSISTENT, entry->flags());
+  ASSERT_EQ(1u, updates().size());
+  auto update = updates().pop();
+  EXPECT_EQ(entry, update.entry);
+  EXPECT_EQ(Storage::Update::kFlagsUpdate, update.kind);
+}
+
+TEST_F(StorageTestPopulateOne, LoadPersistentUpdateValue) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  storage.GetEntry("foo")->set_flags(NT_PERSISTENT);
+  while (!updates().empty()) updates().pop();
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"foo\"=false\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  auto entry = storage.GetEntry("foo");
+  EXPECT_EQ(*Value::MakeBoolean(false), *entry->value());
+  EXPECT_EQ(NT_PERSISTENT, entry->flags());
+  ASSERT_EQ(1u, updates().size());
+  auto update = updates().pop();
+  EXPECT_EQ(entry, update.entry);
+  EXPECT_EQ(Storage::Update::kValueUpdate, update.kind);
+}
+
+TEST_F(StorageTestPopulateOne, LoadPersistentUpdateValueFlags) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"foo\"=false\n");
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  auto entry = storage.GetEntry("foo");
+  EXPECT_EQ(*Value::MakeBoolean(false), *entry->value());
+  EXPECT_EQ(NT_PERSISTENT, entry->flags());
+  ASSERT_EQ(2u, updates().size());
+  auto update = updates().pop();
+  EXPECT_EQ(entry, update.entry);
+  EXPECT_EQ(Storage::Update::kValueUpdate, update.kind);
+  update = updates().pop();
+  EXPECT_EQ(entry, update.entry);
+  EXPECT_EQ(Storage::Update::kFlagsUpdate, update.kind);
+}
+
+TEST_F(StorageTest, LoadPersistent) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::string in = "[NetworkTables Storage 3.0]\n";
+  in += "boolean \"\\x00\\x03\\x05\\n\"=true\n";
+  in += "boolean \"boolean/false\"=false\n";
+  in += "boolean \"boolean/true\"=true\n";
+  in += "array boolean \"booleanarr/empty\"=\n";
+  in += "array boolean \"booleanarr/one\"=true\n";
+  in += "array boolean \"booleanarr/two\"=true,false\n";
+  in += "double \"double/big\"=1.3e+08\n";
+  in += "double \"double/neg\"=-1.5\n";
+  in += "double \"double/zero\"=0\n";
+  in += "array double \"doublearr/empty\"=\n";
+  in += "array double \"doublearr/one\"=0.5\n";
+  in += "array double \"doublearr/two\"=0.5,-0.25\n";
+  in += "raw \"raw/empty\"=\n";
+  in += "raw \"raw/normal\"=aGVsbG8=\n";
+  in += "raw \"raw/special\"=AAMFCg==\n";
+  in += "string \"string/empty\"=\"\"\n";
+  in += "string \"string/normal\"=\"hello\"\n";
+  in += "string \"string/special\"=\"\\x00\\x03\\x05\\n\"\n";
+  in += "array string \"stringarr/empty\"=\n";
+  in += "array string \"stringarr/one\"=\"hello\"\n";
+  in += "array string \"stringarr/two\"=\"hello\",\"world\\n\"\n";
+
+  std::istringstream iss(in);
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+  ASSERT_EQ(21u, entries().size());
+  ASSERT_EQ(21u, updates().size());
+
+  EXPECT_EQ(*Value::MakeBoolean(true), *storage.GetEntryValue("boolean/true"));
+  EXPECT_EQ(*Value::MakeBoolean(false),
+            *storage.GetEntryValue("boolean/false"));
+  EXPECT_EQ(*Value::MakeDouble(-1.5), *storage.GetEntryValue("double/neg"));
+  EXPECT_EQ(*Value::MakeDouble(0.0), *storage.GetEntryValue("double/zero"));
+  EXPECT_EQ(*Value::MakeDouble(1.3e8), *storage.GetEntryValue("double/big"));
+  EXPECT_EQ(*Value::MakeString(StringRef("")),
+            *storage.GetEntryValue("string/empty"));
+  EXPECT_EQ(*Value::MakeString(StringRef("hello")),
+            *storage.GetEntryValue("string/normal"));
+  EXPECT_EQ(*Value::MakeString(StringRef("\0\3\5\n", 4)),
+            *storage.GetEntryValue("string/special"));
+  EXPECT_EQ(*Value::MakeRaw(StringRef("")),
+            *storage.GetEntryValue("raw/empty"));
+  EXPECT_EQ(*Value::MakeRaw(StringRef("hello")),
+            *storage.GetEntryValue("raw/normal"));
+  EXPECT_EQ(*Value::MakeRaw(StringRef("\0\3\5\n", 4)),
+            *storage.GetEntryValue("raw/special"));
+  EXPECT_EQ(*Value::MakeBooleanArray(std::vector<int>{}),
+            *storage.GetEntryValue("booleanarr/empty"));
+  EXPECT_EQ(*Value::MakeBooleanArray(std::vector<int>{1}),
+            *storage.GetEntryValue("booleanarr/one"));
+  EXPECT_EQ(*Value::MakeBooleanArray(std::vector<int>{1, 0}),
+            *storage.GetEntryValue("booleanarr/two"));
+  EXPECT_EQ(*Value::MakeDoubleArray(std::vector<double>{}),
+            *storage.GetEntryValue("doublearr/empty"));
+  EXPECT_EQ(*Value::MakeDoubleArray(std::vector<double>{0.5}),
+            *storage.GetEntryValue("doublearr/one"));
+  EXPECT_EQ(*Value::MakeDoubleArray(std::vector<double>{0.5, -0.25}),
+            *storage.GetEntryValue("doublearr/two"));
+  EXPECT_EQ(*Value::MakeStringArray(std::vector<std::string>{}),
+            *storage.GetEntryValue("stringarr/empty"));
+  EXPECT_EQ(*Value::MakeStringArray(std::vector<std::string>{"hello"}),
+            *storage.GetEntryValue("stringarr/one"));
+  EXPECT_EQ(
+      *Value::MakeStringArray(std::vector<std::string>{"hello", "world\n"}),
+      *storage.GetEntryValue("stringarr/two"));
+  EXPECT_EQ(*Value::MakeBoolean(true),
+            *storage.GetEntryValue(StringRef("\0\3\5\n", 4)));
+}
+
+TEST_F(StorageTest, LoadPersistentWarn) {
+  MockLoadWarn warn;
+  auto warn_func =
+      [&](std::size_t line, const char* msg) { warn.Warn(line, msg); };
+
+  std::istringstream iss(
+      "[NetworkTables Storage 3.0]\nboolean \"foo\"=foo\n");
+  EXPECT_CALL(warn,
+              Warn(2, "unrecognized boolean value, not 'true' or 'false'"));
+  EXPECT_TRUE(storage.LoadPersistent(iss, warn_func));
+
+  ASSERT_TRUE(entries().empty());
+  ASSERT_TRUE(updates().empty());
+}
+
 }  // namespace nt


Avoid a possible null pointer dereference with -alcdbg

--- AppleALC/kern_audio.cpp
+++ AppleALC/kern_audio.cpp
@@ -68,7 +68,7 @@
 			auto legacyId = OSDynamicCast(OSData, hdaService->getProperty("layout-id"));
 			if (legacyId && legacyId->getLength() == sizeof(uint32_t)) {
 				DBGLOG("audio", "found legacy alc-layout-id (from layout-id) %d",
-					   *static_cast<const uint32_t *>(alcId->getBytesNoCopy()));
+					   *static_cast<const uint32_t *>(legacyId->getBytesNoCopy()));
 				hdaService->setProperty("alc-layout-id", legacyId);
 			}
 		}


Fixed calculation of new CRPIX with spectral binning

--- cdetect.cpp
+++ cdetect.cpp
@@ -271,7 +271,12 @@
         }

         // Update wavelength array
-        crpix -= (spectral_bin-1)*cdelt/2.0;
+        crpix = (crpix - 1)/spectral_bin + 1;
+        if (spectral_bin % 2 == 0) {
+            crpix += 1/(2*spectral_bin) - 0.5;
+        } else {
+            crpix += -1/spectral_bin;
+        }
         cdelt *= spectral_bin;
         lam = crval + cdelt*(findgen(nlam) + (1 - crpix));
     } else {


-Fixed viewer launching issue on MacOS when passing in Chrome switches


Fix typo

Fix typo

--- include/SymbolTable.hpp
+++ include/SymbolTable.hpp
@@ -76,7 +76,7 @@
          * \param struct_ The structure to search for.
          * \return A pointer to the structure with the given name.
          */
-        std::shared_ptr<Struct> get_struct(const std::string& struct_
+        std::shared_ptr<Struct> get_struct(const std::string& struct_);

         /*!
          * Indicates if a structure with the given name exists.


Added insertion sort

Added insertion sort

--- include/aid/sorting.hpp
+++ include/aid/sorting.hpp
@@ -17,4 +17,15 @@
                     std::iter_swap(it2, std::next(it2));
     }

+    // worst case: n^2
+    // average case: n^2
+    // best case: n
+    // space complexity: 1
+    template<typename It>
+    void insertion_sort(It first, It last) {
+        for (auto it = std::next(first); it != last; ++it)
+            for (auto it2 = it; it2 != first && *std::prev(it2) > *it2; --it2)
+                std::iter_swap(std::prev(it2), it2);
+    }
+
 }


添加debug日志

添加debug日志

--- cetty-shuttle/src/cetty/shuttle/ShuttleBackend.cpp
+++ cetty-shuttle/src/cetty/shuttle/ShuttleBackend.cpp
@@ -61,13 +61,16 @@
     return true;
 }

-void ShuttleBackend::configure(const std::map<std::string, Backend*>& config, const EventLoopPoolPtr& pool) {
+void ShuttleBackend::configure(const std::map<std::string, Backend*>& config,
+                               const EventLoopPoolPtr& pool) {
     EventLoopPool::Iterator itr = pool->begin();

     for (; itr != pool->end(); ++itr) {
         ShuttleBackendPtr backend = ShuttleBackendPtr(new ShuttleBackend(*itr));
         backend->configure(config);
-        backends_.insert(std::make_pair((*itr)->threadId(), backend));
+        ThreadId id = (*itr)->threadId();
+        backends_.insert(std::make_pair(id, backend));
+        LOG_DEBUG << "config backend for " << id;
     }
 }

@@ -77,18 +80,21 @@
     for (itr = config.begin(); itr != config.end(); ++itr) {
         channels_.insert(std::make_pair(itr->first,
                                         builder_.build(itr->second->servers)));
+        LOG_DEBUG << "config the channel in backend for " << itr->first;
     }
 }

-
 const ChannelPtr& ShuttleBackend::getChannel(const std::string& method) {
+    ThreadId id = CurrentThread::id();
     std::map<ThreadId, ShuttleBackendPtr>::const_iterator itr =
-        backends_.find(CurrentThread::id());
+        backends_.find(id);

     if (itr != backends_.end()) {
         return itr->second->channel(method);
     }
     else {
+        LOG_WARN << "failed to found the channel for " << method
+                 << " in " << id;
         return emptyChannel_;
     }
 }
@@ -100,8 +106,10 @@
     if (itr != channels_.end()) {
         return itr->second;
     }
-
-    return emptyChannel_;
+    else {
+        LOG_WARN << "failed to found the channel for " << method;
+        return emptyChannel_;
+    }
 }

 ShuttleBackend::ShuttleBackend(const EventLoopPtr& loop)


gestures default threshold changed

gestures default threshold changed

--- src/input/gestures.cpp
+++ src/input/gestures.cpp
@@ -12,7 +12,7 @@
 using namespace et;

 const float GesturesRecognizer::defaultClickTemporalThreshold = 0.25f;
-const float GesturesRecognizer::defaultClickSpatialTreshold = 0.015f;
+const float GesturesRecognizer::defaultClickSpatialTreshold = std::sqrt(50.0f);
 const float GesturesRecognizer::defaultHoldTemporalThreshold = 1.0f;

 GesturesRecognizer::GesturesRecognizer(bool automaticMode) : InputHandler(automaticMode),
@@ -135,14 +135,14 @@
 	pointerPressed.invoke(pi);

 	_pointers[pi.id] = PointersInputDelta(pi, pi);
+
 	pressed.invoke(pi.normalizedPos, pi.type);

 	if (_pointers.size() == 1)
 	{
 		if (_shouldPerformClick)
 		{
-			float dp = (pi.normalizedPos - _singlePointer.normalizedPos).dotSelf();
-			if (dp <= sqr(_clickSpatialThreshold))
+			if ((pi.pos - _singlePointer.pos).dotSelf() <= sqr(_clickSpatialThreshold))
 			{
 				_shouldPerformClick = false;
 				_shouldPerformDoubleClick = true;
@@ -184,7 +184,7 @@

 		if (hasPressedPointer && (pi.id == _singlePointer.id))
 		{
-			float len = (pi.normalizedPos - _singlePointer.normalizedPos).dotSelf();
+			float len = (pi.pos - _singlePointer.pos).dotSelf();
 			shouldPerformMovement = (len >= sqr(_clickSpatialThreshold));
 		}


12956584 followup fix for mysqltest   run_query_stmt() might use disable_xxx vars after calling handle_no_error   But handle_no_error() hes reverted any ONCE settings   Fix is to take revert_properties() out of handle_no_error()

--- client/mysqltest.cc
+++ client/mysqltest.cc
@@ -5364,6 +5364,7 @@

   var_set_errno(0);
   handle_no_error(command);
+  revert_properties();
   return 1; /* Connected */
 }

@@ -7319,6 +7320,7 @@

   /* If we come here the query is both executed and read successfully */
   handle_no_error(command);
+  revert_properties();

 end:

@@ -7514,8 +7516,6 @@
     die("query '%s' succeeded - should have failed with sqlstate %s...",
         command->query, command->expected_errors.err[0].code.sqlstate);
   }
-
-  revert_properties();
   DBUG_VOID_RETURN;
 }

@@ -7546,9 +7546,6 @@
   DBUG_ENTER("run_query_stmt");
   DBUG_PRINT("query", ("'%-.60s'", query));

-  /* Remember disable_result_log since handle_no_error() may reset it */
-  my_bool dis_res= disable_result_log;
-
   /*
     Init a new stmt if it's not already one created for this connection
   */
@@ -7644,7 +7641,7 @@

   /* If we got here the statement was both executed and read successfully */
   handle_no_error(command);
-  if (!dis_res)
+  if (!disable_result_log)
   {
     /*
       Not all statements creates a result set. If there is one we can
@@ -7720,7 +7717,7 @@
     dynstr_free(&ds_prepare_warnings);
     dynstr_free(&ds_execute_warnings);
   }
-
+  revert_properties();

   /* Close the statement if - no reconnect, need new prepare */
   if (mysql->reconnect)