Throw exception for duplicate android classes between dex/jar

Summary:
We should catch the duplication errror earlier.
Only throw for "android*" duplications because we will get errors if we report all. We could add a list of classes that can be duplicate then report all other errors.

Reviewed By: thezhangwei

Differential Revision: D24177650

fbshipit-source-id: 6f465f3af62fbc5b7fe4b0236c77d7be3034e54f

--- libredex/JarLoader.cpp
+++ libredex/JarLoader.cpp
@@ -396,14 +396,17 @@
             "  Previous: '%s'\n",
             SHOW(self), jar_location.c_str(), cls->get_location().c_str());

-      // There are still blocking issues in instrumentation test that are
-      // blocking. We can make this throw again once they are fixed.
-
-      // throw RedexException(RedexError::DUPLICATE_CLASSES,
-      //                      "Found duplicate class in two different files.",
-      //                      {{"class", SHOW(self)},
-      //                       {"dex1", jar_location},
-      //                       {"dex2", cls->get_location()}});
+      // TODO: There are still blocking issues in instrumentation test that are
+      // blocking. We currently only fail for duplicate `android*` classes,
+      // we can make this throw for all the classes once they are fixed.
+
+      if (boost::starts_with(cls->str(), "Landroid")) {
+        throw RedexException(RedexError::DUPLICATE_CLASSES,
+                             "Found duplicate class in two different files.",
+                             {{"class", SHOW(self)},
+                              {"jar", jar_location},
+                              {"dex", cls->get_location()}});
+      }
     }
     return true;
   }


Oilpan: have ScriptStreamingTest correctly trace its PendingScript.

As testing::Test is not on the heap, accommodate Oilpan by wrapping up
ScriptStreamingTest's PendingScript (a part object containing a Member)
inside an object that is on the heap & use a Persistent to refer to it
from ScriptStreamingTest.

R=ager
BUG=

Review URL: https://codereview.chromium.org/576853003

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@182136 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/bindings/core/v8/ScriptStreamerTest.cpp
+++ Source/bindings/core/v8/ScriptStreamerTest.cpp
@@ -12,6 +12,7 @@
 #include "core/dom/PendingScript.h"
 #include "core/frame/Settings.h"
 #include "platform/Task.h"
+#include "platform/heap/Handle.h"
 #include "public/platform/Platform.h"

 #include <gtest/gtest.h>
@@ -20,6 +21,41 @@
 namespace blink {

 namespace {
+
+// For the benefit of Oilpan, put the part object PendingScript inside
+// a wrapper that's on the Oilpan heap and hold a reference to that wrapper
+// from ScriptStreamingTest.
+class PendingScriptWrapper : public NoBaseWillBeGarbageCollectedFinalized<PendingScriptWrapper> {
+public:
+    static PassOwnPtrWillBeRawPtr<PendingScriptWrapper> create()
+    {
+        return adoptPtrWillBeNoop(new PendingScriptWrapper());
+    }
+
+    static PassOwnPtrWillBeRawPtr<PendingScriptWrapper> create(Element* element, ScriptResource* resource)
+    {
+        return adoptPtrWillBeNoop(new PendingScriptWrapper(element, resource));
+    }
+
+    PendingScript& get() { return m_pendingScript; }
+
+    void trace(Visitor* visitor)
+    {
+        visitor->trace(m_pendingScript);
+    }
+
+private:
+    PendingScriptWrapper()
+    {
+    }
+
+    PendingScriptWrapper(Element* element, ScriptResource* resource)
+        : m_pendingScript(PendingScript(element, resource))
+    {
+    }
+
+    PendingScript m_pendingScript;
+};

 class ScriptStreamingTest : public testing::Test {
 public:
@@ -28,7 +64,7 @@
         , m_settings(Settings::create())
         , m_resourceRequest("http://www.streaming-test.com/")
         , m_resource(new ScriptResource(m_resourceRequest, "text/utf-8"))
-        , m_pendingScript(0, m_resource) // Takes ownership of m_resource.
+        , m_pendingScript(PendingScriptWrapper::create(0, m_resource)) // Takes ownership of m_resource.
     {
         m_settings->setV8ScriptStreamingEnabled(true);
         m_resource->setLoading(true);
@@ -37,10 +73,7 @@
     ScriptState* scriptState() const { return m_scope.scriptState(); }
     v8::Isolate* isolate() const { return m_scope.isolate(); }

-    void trace(Visitor* visitor)
-    {
-        visitor->trace(m_pendingScript);
-    }
+    PendingScript& pendingScript() const { return m_pendingScript->get(); }

 protected:
     void appendData(const char* data)
@@ -85,7 +118,7 @@
     // ScriptResource::appendData.
     ResourceRequest m_resourceRequest;
     ScriptResource* m_resource;
-    PendingScript m_pendingScript;
+    OwnPtrWillBePersistent<PendingScriptWrapper> m_pendingScript;
 };

 class TestScriptResourceClient : public ScriptResourceClient {
@@ -104,9 +137,9 @@
 TEST_F(ScriptStreamingTest, CompilingStreamedScript)
 {
     // Test that we can successfully compile a streamed script.
-    bool started = ScriptStreamer::startStreaming(m_pendingScript, m_settings.get(), m_scope.scriptState());
-    TestScriptResourceClient client;
-    m_pendingScript.watchForLoad(&client);
+    bool started = ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState());
+    TestScriptResourceClient client;
+    pendingScript().watchForLoad(&client);
     EXPECT_TRUE(started);

     appendData("function foo() {");
@@ -122,7 +155,7 @@
     processTasksUntilStreamingComplete();
     EXPECT_TRUE(client.finished());
     bool errorOccurred = false;
-    ScriptSourceCode sourceCode = m_pendingScript.getSource(KURL(), errorOccurred);
+    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
     EXPECT_FALSE(errorOccurred);
     EXPECT_TRUE(sourceCode.streamer());
     v8::TryCatch tryCatch;
@@ -136,9 +169,9 @@
     // Test that scripts with parse errors are handled properly. In those cases,
     // the V8 side typically finished before loading finishes: make sure we
     // handle it gracefully.
-    bool started = ScriptStreamer::startStreaming(m_pendingScript, m_settings.get(), m_scope.scriptState());
-    TestScriptResourceClient client;
-    m_pendingScript.watchForLoad(&client);
+    bool started = ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState());
+    TestScriptResourceClient client;
+    pendingScript().watchForLoad(&client);
     EXPECT_TRUE(started);
     appendData("function foo() {");
     appendData("this is the part which will be a parse error");
@@ -156,7 +189,7 @@
     EXPECT_TRUE(client.finished());

     bool errorOccurred = false;
-    ScriptSourceCode sourceCode = m_pendingScript.getSource(KURL(), errorOccurred);
+    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
     EXPECT_FALSE(errorOccurred);
     EXPECT_TRUE(sourceCode.streamer());
     v8::TryCatch tryCatch;
@@ -169,9 +202,9 @@
 {
     // Test that the upper layers (PendingScript and up) can be ramped down
     // while streaming is ongoing, and ScriptStreamer handles it gracefully.
-    bool started = ScriptStreamer::startStreaming(m_pendingScript, m_settings.get(), m_scope.scriptState());
-    TestScriptResourceClient client;
-    m_pendingScript.watchForLoad(&client);
+    bool started = ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState());
+    TestScriptResourceClient client;
+    pendingScript().watchForLoad(&client);
     EXPECT_TRUE(started);
     appendData("function foo() {");

@@ -182,8 +215,8 @@
     // Simulate cancelling the network load (e.g., because the user navigated
     // away).
     EXPECT_FALSE(client.finished());
-    m_pendingScript.stopWatchingForLoad(&client);
-    m_pendingScript = PendingScript(); // This will destroy m_resource.
+    pendingScript().stopWatchingForLoad(&client);
+    m_pendingScript = PendingScriptWrapper::create(); // This will destroy m_resource.
     m_resource = 0;

     // The V8 side will complete too. This should not crash. We don't receive
@@ -198,9 +231,9 @@
     // is suppressed (V8 doesn't parse while the script is loading), and the
     // upper layer (ScriptResourceClient) should get a notification when the
     // script is loaded.
-    bool started = ScriptStreamer::startStreaming(m_pendingScript, m_settings.get(), m_scope.scriptState());
-    TestScriptResourceClient client;
-    m_pendingScript.watchForLoad(&client);
+    bool started = ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState());
+    TestScriptResourceClient client;
+    pendingScript().watchForLoad(&client);
     EXPECT_TRUE(started);
     appendData("function foo() {");
     appendPadding();
@@ -213,7 +246,7 @@
     EXPECT_TRUE(client.finished());

     bool errorOccurred = false;
-    ScriptSourceCode sourceCode = m_pendingScript.getSource(KURL(), errorOccurred);
+    ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
     EXPECT_FALSE(errorOccurred);
     // ScriptSourceCode doesn't refer to the streamer, since we have suppressed
     // the streaming and resumed the non-streaming code path for script


chore(compiler/erase_irrelevant): compilation warnings

--- src/compiler/erase_irrelevant.cpp
+++ src/compiler/erase_irrelevant.cpp
@@ -29,9 +29,9 @@
         name const & rec_name       = const_name(fn);
         name const & I_name         = rec_name.get_prefix();
         unsigned nparams            = *inductive::get_num_params(env(), I_name);
-        unsigned nminors            = *inductive::get_num_minor_premises(env(), I_name);
+        DEBUG_CODE(unsigned nminors = *inductive::get_num_minor_premises(env(), I_name););
         unsigned nindices           = *inductive::get_num_indices(env(), I_name);
-        unsigned arity              = nparams + 1 /* typeformer/motive */ + nindices + 1 /* major premise */ + nminors;
+        DEBUG_CODE(unsigned arity   = nparams + 1 /* typeformer/motive */ + nindices + 1 /* major premise */ + nminors;);
         lean_assert(args.size() >= arity);
         for (unsigned i = nparams + 1 + nindices; i < args.size(); i++) {
             args[i] = visit(args[i]);
@@ -89,16 +89,16 @@
     /* We can eliminate no_confusion applications, they do not add any relevant information to the environment */
     expr visit_no_confusion(expr const & fn, buffer<expr> const & args) {
         lean_assert(is_constant(fn));
-        name const & no_confusion_name = const_name(fn);
-        name const & I_name            = no_confusion_name.get_prefix();
-        unsigned nparams               = *inductive::get_num_params(env(), I_name);
-        unsigned nindices              = *inductive::get_num_indices(env(), I_name);
-        unsigned basic_arity           = nparams + nindices + 1 /* motive */ + 2 /* lhs/rhs */ + 1 /* equality */;
+        name const & no_confusion_name  = const_name(fn);
+        name const & I_name             = no_confusion_name.get_prefix();
+        unsigned nparams                = *inductive::get_num_params(env(), I_name);
+        unsigned nindices               = *inductive::get_num_indices(env(), I_name);
+        DEBUG_CODE(unsigned basic_arity = nparams + nindices + 1 /* motive */ + 2 /* lhs/rhs */ + 1 /* equality */;);
         lean_assert(args.size() >= basic_arity);
-        expr lhs                       = ctx().whnf(args[nparams + nindices + 1]);
-        expr rhs                       = ctx().whnf(args[nparams + nindices + 2]);
-        optional<name> lhs_constructor = is_constructor_app(env(), lhs);
-        optional<name> rhs_constructor = is_constructor_app(env(), rhs);
+        expr lhs                        = ctx().whnf(args[nparams + nindices + 1]);
+        expr rhs                        = ctx().whnf(args[nparams + nindices + 2]);
+        optional<name> lhs_constructor  = is_constructor_app(env(), lhs);
+        optional<name> rhs_constructor  = is_constructor_app(env(), rhs);
         if (!lhs_constructor || !rhs_constructor)
             throw exception(sstream() << "code generation failed, unsupported occurrence of '" << no_confusion_name << "', constructors expected");
         if (lhs_constructor != rhs_constructor)


realm: add memories should use new allocator

--- runtime/realm/mem_impl.cc
+++ runtime/realm/mem_impl.cc
@@ -79,6 +79,7 @@
       , peak_usage(stringbuilder() << "realm/mem " << _me << "/peak_usage")
       , peak_footprint(stringbuilder() << "realm/mem " << _me << "/peak_footprint")
     {
+      allocator.add_range(0, _size);
     }

     MemoryImpl::~MemoryImpl(void)
@@ -619,7 +620,6 @@
     log_malloc.debug("CPU memory at %p, size = %zd%s%s", base, _size,
 		     prealloced ? " (prealloced)" : "", registered ? " (registered)" : "");
     free_blocks[0] = _size;
-    allocator.add_range(0, _size);
   }

   LocalCPUMemory::~LocalCPUMemory(void)


Older Mesa drivers cause linux display artifacts upon graphics restore, remove this context and let it fall back to GL2

--- Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp
+++ Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp
@@ -2472,6 +2472,35 @@
     {
         impl_->context_ = SDL_GL_CreateContext(window_);

+#if defined(__linux__)
+        String driverx( (const char*)glGetString(GL_VERSION) );
+        Vector<String>tokens = driverx.Split (' ');
+        if (tokens.Size() > 2) // must have enough tokens to work with
+        {
+            // Size() - 2 is the manufacturer, "Mesa" is the target
+            if ( tokens[ tokens.Size()-2].Compare ( "Mesa", false ) == 0 )
+            {
+                // Size() - 1  is the version number, convert to long, can be n | n.n | n.n.n
+                Vector<String>versionx = tokens[tokens.Size()-1].Split ('.');
+                int majver = 0;
+                int minver = 0;
+                int pointver = 0;
+                if ( tokens.Size() > 1 ) majver = atoi(versionx[0].CString());
+                if ( tokens.Size() > 2 ) minver = atoi(versionx[1].CString());
+                if ( tokens.Size() > 3 ) pointver = atoi(versionx[2].CString());
+
+                int allver = (majver * 10000) + (minver * 1000) + pointver;
+
+                if ( allver < 101004 ) // Mesa drivers less than this version cause linux display artifacts
+                {                      // so remove this context and let it fall back to GL2
+                    SDL_GL_DeleteContext(impl_->context_);
+                    impl_->context_ = NULL;
+                    URHO3D_LOGINFOF ( "Mesa GL Driver: %s detected, forcing GL2 context creation.  Please use gl2 command line option to avoid this warning.", driverx.CString() );
+                }
+            }
+        }
+#endif
+
 #ifndef GL_ES_VERSION_2_0
         // If we're trying to use OpenGL 3, but context creation fails, retry with 2
         if (!forceGL2_ && !impl_->context_)


Use non-templated evaluator also in matrix-free MG transfer

--- source/multigrid/mg_transfer_matrix_free.cc
+++ source/multigrid/mg_transfer_matrix_free.cc
@@ -203,7 +203,8 @@
     do_prolongate_add<10>(to_level, this->ghosted_level_vector[to_level],
                           this->ghosted_level_vector[to_level-1]);
   else
-    AssertThrow(false, ExcNotImplemented("Only degrees 0 up to 10 implemented."));
+    do_prolongate_add<-1>(to_level, this->ghosted_level_vector[to_level],
+                          this->ghosted_level_vector[to_level-1]);

   this->ghosted_level_vector[to_level].compress(VectorOperation::add);
   dst = this->ghosted_level_vector[to_level];
@@ -263,7 +264,9 @@
     do_restrict_add<10>(from_level, this->ghosted_level_vector[from_level-1],
                         this->ghosted_level_vector[from_level]);
   else
-    AssertThrow(false, ExcNotImplemented("Only degrees 0 up to 10 implemented."));
+    // go to the non-templated version of the evaluator
+    do_restrict_add<-1>(from_level, this->ghosted_level_vector[from_level-1],
+                        this->ghosted_level_vector[from_level]);

   this->ghosted_level_vector[from_level-1].compress(VectorOperation::add);
   dst += this->ghosted_level_vector[from_level-1];
@@ -280,7 +283,8 @@
                         const unsigned int n_components,
                         AlignedVector<VectorizedArray<Number> > &evaluation_data)
   {
-    AssertDimension(n_components * Eval::n_q_points, n_child_cell_dofs);
+    if (Eval::n_q_points != numbers::invalid_unsigned_int)
+      AssertDimension(n_components * Eval::n_q_points, n_child_cell_dofs);
     VectorizedArray<Number> *t0 = &evaluation_data[0];
     VectorizedArray<Number> *t1 = &evaluation_data[n_child_cell_dofs];
     VectorizedArray<Number> *t2 = &evaluation_data[2*n_child_cell_dofs];
@@ -320,11 +324,13 @@
   template <int dim, int degree, typename Number>
   void weight_dofs_on_child (const VectorizedArray<Number> *weights,
                              const unsigned int n_components,
+                             const unsigned int fe_degree,
                              VectorizedArray<Number> *data)
   {
-    Assert(degree > 0, ExcNotImplemented());
-    const int loop_length = 2*degree+1;
-    unsigned int degree_to_3 [loop_length];
+    Assert(fe_degree > 0, ExcNotImplemented());
+    Assert(fe_degree < 100, ExcNotImplemented());
+    const int loop_length = degree != -1 ? 2*degree+1 : 2*fe_degree+1;
+    unsigned int degree_to_3 [100];
     degree_to_3[0] = 0;
     for (int i=1; i<loop_length-1; ++i)
       degree_to_3[i] = 1;
@@ -355,7 +361,8 @@
                      const LinearAlgebra::distributed::Vector<Number> &src) const
 {
   const unsigned int vec_size = VectorizedArray<Number>::n_array_elements;
-  const unsigned int n_child_dofs_1d = 2*(fe_degree+1) - element_is_continuous;
+  const unsigned int degree_size = (degree > -1 ? degree : fe_degree) + 1;
+  const unsigned int n_child_dofs_1d = 2*degree_size - element_is_continuous;
   const unsigned int n_scalar_cell_dofs = Utilities::fixed_power<dim>(n_child_dofs_1d);
   const unsigned int three_to_dim = Utilities::fixed_int_power<3,dim>::value;

@@ -370,13 +377,13 @@
         {
           const unsigned int shift = internal::MGTransfer::compute_shift_within_children<dim>
                                      (parent_child_connect[to_level-1][cell+v].second,
-                                      degree+1-element_is_continuous, degree);
+                                      fe_degree+1-element_is_continuous, fe_degree);
           const unsigned int *indices = &level_dof_indices[to_level-1][parent_child_connect[to_level-1][cell+v].first*n_child_cell_dofs+shift];
           for (unsigned int c=0, m=0; c<n_components; ++c)
             {
-              for (unsigned int k=0; k<(dim>2 ? (degree+1) : 1); ++k)
-                for (unsigned int j=0; j<(dim>1 ? (degree+1) : 1); ++j)
-                  for (unsigned int i=0; i<(degree+1); ++i, ++m)
+              for (unsigned int k=0; k<(dim>2 ? degree_size : 1); ++k)
+                for (unsigned int j=0; j<(dim>1 ? degree_size : 1); ++j)
+                  for (unsigned int i=0; i<degree_size; ++i, ++m)
                     evaluation_data[m][v] =
                       src.local_element(indices[c*n_scalar_cell_dofs +
                                                 k*n_child_dofs_1d*n_child_dofs_1d+
@@ -388,31 +395,33 @@
             }
         }

+      AssertDimension(prolongation_matrix_1d.size(),
+                      degree_size * n_child_dofs_1d);
       // perform tensorized operation
       if (element_is_continuous)
         {
-          AssertDimension(prolongation_matrix_1d.size(),
-                          (2*degree+1)*(degree+1));
-          typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,2*degree+1,VectorizedArray<Number> > Evaluator;
+          typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,degree!=-1 ? 2*degree+1 : 0,VectorizedArray<Number> > Evaluator;
           Evaluator evaluator(prolongation_matrix_1d,
                               prolongation_matrix_1d,
-                              prolongation_matrix_1d);
+                              prolongation_matrix_1d,
+                              fe_degree,
+                              2*fe_degree+1);
           perform_tensorized_op<dim,Evaluator,Number,true>(evaluator,
                                                            n_child_cell_dofs,
                                                            n_components,
                                                            evaluation_data);
           weight_dofs_on_child<dim,degree,Number>(&weights_on_refined[to_level-1][(cell/vec_size)*three_to_dim],
-                                                  n_components,
+                                                  n_components, fe_degree,
                                                   &evaluation_data[2*n_child_cell_dofs]);
         }
       else
         {
-          AssertDimension(prolongation_matrix_1d.size(),
-                          2*(degree+1)*(degree+1));
           typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,2*(degree+1),VectorizedArray<Number> > Evaluator;
           Evaluator evaluator(prolongation_matrix_1d,
                               prolongation_matrix_1d,
-                              prolongation_matrix_1d);
+                              prolongation_matrix_1d,
+                              fe_degree,
+                              2*(fe_degree+1));
           perform_tensorized_op<dim,Evaluator,Number,true>(evaluator,
                                                            n_child_cell_dofs,
                                                            n_components,
@@ -441,7 +450,8 @@
                    const LinearAlgebra::distributed::Vector<Number> &src) const
 {
   const unsigned int vec_size = VectorizedArray<Number>::n_array_elements;
-  const unsigned int n_child_dofs_1d = 2*(fe_degree+1) - element_is_continuous;
+  const unsigned int degree_size = (degree > -1 ? degree : fe_degree) + 1;
+  const unsigned int n_child_dofs_1d = 2*degree_size - element_is_continuous;
   const unsigned int n_scalar_cell_dofs = Utilities::fixed_power<dim>(n_child_dofs_1d);
   const unsigned int three_to_dim = Utilities::fixed_int_power<3,dim>::value;

@@ -463,17 +473,19 @@
           }
       }

+      AssertDimension(prolongation_matrix_1d.size(),
+                      degree_size * n_child_dofs_1d);
       // perform tensorized operation
       if (element_is_continuous)
         {
-          AssertDimension(prolongation_matrix_1d.size(),
-                          (2*degree+1)*(degree+1));
-          typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,2*degree+1,VectorizedArray<Number> > Evaluator;
+          typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,degree!=-1 ? 2*degree+1 : 0,VectorizedArray<Number> > Evaluator;
           Evaluator evaluator(prolongation_matrix_1d,
                               prolongation_matrix_1d,
-                              prolongation_matrix_1d);
+                              prolongation_matrix_1d,
+                              fe_degree,
+                              2*fe_degree+1);
           weight_dofs_on_child<dim,degree,Number>(&weights_on_refined[from_level-1][(cell/vec_size)*three_to_dim],
-                                                  n_components,
+                                                  n_components, fe_degree,
                                                   &evaluation_data[0]);
           perform_tensorized_op<dim,Evaluator,Number,false>(evaluator,
                                                             n_child_cell_dofs,
@@ -482,12 +494,12 @@
         }
       else
         {
-          AssertDimension(prolongation_matrix_1d.size(),
-                          2*(degree+1)*(degree+1));
           typedef internal::EvaluatorTensorProduct<internal::evaluate_general,dim,degree,2*(degree+1),VectorizedArray<Number> > Evaluator;
           Evaluator evaluator(prolongation_matrix_1d,
                               prolongation_matrix_1d,
-                              prolongation_matrix_1d);
+                              prolongation_matrix_1d,
+                              fe_degree,
+                              2*(fe_degree+1));
           perform_tensorized_op<dim,Evaluator,Number,false>(evaluator,
                                                             n_child_cell_dofs,
                                                             n_components,
@@ -499,7 +511,7 @@
         {
           const unsigned int shift = internal::MGTransfer::compute_shift_within_children<dim>
                                      (parent_child_connect[from_level-1][cell+v].second,
-                                      degree+1-element_is_continuous, degree);
+                                      fe_degree+1-element_is_continuous, fe_degree);
           AssertIndexRange(parent_child_connect[from_level-1][cell+v].first*
                            n_child_cell_dofs+n_child_cell_dofs-1,
                            level_dof_indices[from_level-1].size());
@@ -510,9 +522,9 @@
               for (std::vector<unsigned short>::const_iterator i=dirichlet_indices[from_level-1][cell+v].begin(); i!=dirichlet_indices[from_level-1][cell+v].end(); ++i)
                 evaluation_data[2*n_child_cell_dofs+(*i)][v] = 0.;

-              for (unsigned int k=0; k<(dim>2 ? (degree+1) : 1); ++k)
-                for (unsigned int j=0; j<(dim>1 ? (degree+1) : 1); ++j)
-                  for (unsigned int i=0; i<(degree+1); ++i, ++m)
+              for (unsigned int k=0; k<(dim>2 ? degree_size : 1); ++k)
+                for (unsigned int j=0; j<(dim>1 ? degree_size : 1); ++j)
+                  for (unsigned int i=0; i<degree_size; ++i, ++m)
                     dst.local_element(indices[c*n_scalar_cell_dofs +
                                               k*n_child_dofs_1d*n_child_dofs_1d+
                                               j*n_child_dofs_1d+i])


[Fix] Translation path

[Fix] Translation path

--- Core/Application.cpp
+++ Core/Application.cpp
@@ -603,8 +603,8 @@
 	settings.beginGroup("Language");

 	if (settings.value("version", 0).toInt() < 15) {
-		QDir(DataPaths::currentProfilePath() + "locale").removeRecursively();
-		copyPath(QDir(":data/locale").absolutePath(), DataPaths::currentProfilePath() + "locale");
+		QDir(DataPaths::currentProfilePath() + "/locale").removeRecursively();
+		copyPath(QDir(":data/locale").absolutePath(), DataPaths::currentProfilePath() + "/locale");
 		settings.setValue("version", 15);
 	}
 }


Fix signed-unsigned-warning in test

Fix signed-unsigned-warning in test

--- source/tests/fiblib-test/fibonacci_test.cpp
+++ source/tests/fiblib-test/fibonacci_test.cpp
@@ -13,9 +13,9 @@
 {
     fiblib::Fibonacci fib;

-    EXPECT_EQ( 0, fib( 0));
-    EXPECT_EQ( 1, fib( 1));
-    EXPECT_EQ( 1, fib( 2));
-    EXPECT_EQ(21, fib( 8));
+    EXPECT_EQ((unsigned int) 0, fib(0));
+    EXPECT_EQ((unsigned int) 1, fib(1));
+    EXPECT_EQ((unsigned int) 1, fib(2));
+    EXPECT_EQ((unsigned int)21, fib(8));
     // ...
 }


[1.4.00b] Sielo Open Beta 1

[1.4.00b] Sielo Open Beta 1

--- Core/Application.cpp
+++ Core/Application.cpp
@@ -74,7 +74,7 @@

 namespace Sn {

-QString Application::currentVersion = QString("1.3.00e");
+QString Application::currentVersion = QString("1.4.00b");

 // Static member
 QList<QString> Application::paths()


Fix Cygwin build

Fix Cygwin build

--- source/threads/named_condition_variable.cpp
+++ source/threads/named_condition_variable.cpp
@@ -13,10 +13,10 @@

 #include <algorithm>

-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
 #include "system/shared_type.h"
 #include <pthread.h>
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
 #include "system/shared_type.h"
 #include <windows.h>
 #undef max
@@ -31,13 +31,13 @@
 {
 public:
     Impl(const std::string& name) : _name(name)
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         , _shared(name)
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         , _shared(name)
 #endif
     {
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         // Only the owner should initializate a named condition variable
         if (_shared.owner())
         {
@@ -69,7 +69,7 @@
             if (result != 0)
                 throwex SystemException("Failed to destroy a conditional variable attribute for the named condition variable!", result);
         }
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         // Owner of the condition variable should initialize its value
         if (_shared.owner())
             *_shared = 0;
@@ -84,7 +84,7 @@

     ~Impl()
     {
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         // Only the owner should destroy a named condition variable
         if (_shared.owner())
         {
@@ -95,7 +95,7 @@
             if (result != 0)
                 fatality(SystemException("Failed to destroy a conditional variable for the named condition variable!", result));
         }
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         if (!CloseHandle(_mutex))
             fatality(SystemException("Failed to close a named mutex for the named condition variable!"));
         if (!CloseHandle(_semaphore))
@@ -110,11 +110,11 @@

     void NotifyOne()
     {
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         int result = pthread_cond_signal(&_shared->cond);
         if (result != 0)
             throwex SystemException("Failed to signal a named condition variable!", result);
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         // Lock the named mutex
         DWORD result = WaitForSingleObject(_mutex, INFINITE);
         if (result != WAIT_OBJECT_0)
@@ -132,11 +132,11 @@

     void NotifyAll()
     {
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         int result = pthread_cond_broadcast(&_shared->cond);
         if (result != 0)
             throwex SystemException("Failed to broadcast a named condition variable!", result);
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         // Lock the named mutex
         DWORD result = WaitForSingleObject(_mutex, INFINITE);
         if (result != WAIT_OBJECT_0)
@@ -154,11 +154,11 @@

     void Wait()
     {
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         int result = pthread_cond_wait(&_shared->cond, &_shared->mutex);
         if (result != 0)
             throwex SystemException("Failed to waiting a named condition variable!", result);
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         // Lock the named mutex
         DWORD result = WaitForSingleObject(_mutex, INFINITE);
         if (result != WAIT_OBJECT_0)
@@ -180,7 +180,7 @@
     {
         if (timespan < 0)
             return false;
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
         struct timespec timeout;
         timeout.tv_sec = timespan.seconds();
         timeout.tv_nsec = timespan.nanoseconds() % 1000000000;
@@ -188,7 +188,7 @@
         if ((result != 0) && (result != ETIMEDOUT))
             throwex SystemException("Failed to waiting a named condition variable for the given timeout!", result);
         return (result == 0);
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
         // Lock the named mutex
         DWORD result = WaitForSingleObject(_mutex, INFINITE);
         if (result != WAIT_OBJECT_0)
@@ -209,7 +209,7 @@

 private:
     std::string _name;
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)) && !defined(__CYGWIN__)
     // Shared condition variable structure
     struct CondVar
     {
@@ -219,7 +219,7 @@

     // Shared condition variable structure wrapper
     SharedType<CondVar> _shared;
-#elif defined(_WIN32) || defined(_WIN64)
+#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
     HANDLE _mutex;
     HANDLE _semaphore;
     SharedType<LONG> _shared;


fdo#43095: allow the use of real access() calls

--- sal/osl/unx/file_stat.cxx
+++ sal/osl/unx/file_stat.cxx
@@ -163,6 +163,22 @@
         }
     }

+    /* contrary to what is stated above the use of access calls
+       is required on network file systems not using unix semantics
+      (AFS)
+    */
+    inline void set_file_access_real_rights(const rtl::OUString& file_path, oslFileStatus* pStat)
+    {
+        pStat->uValidFields |= osl_FileStatus_Mask_Attributes;
+
+        if (access_u(file_path.pData, W_OK) < 0)
+            pStat->uAttributes |= osl_File_Attribute_ReadOnly;
+
+        if (access_u(file_path.pData, X_OK) == 0)
+            pStat->uAttributes |= osl_File_Attribute_Executable;
+    }
+
+
     inline void set_file_hidden_status(const rtl::OUString& file_path, oslFileStatus* pStat)
     {
         pStat->uAttributes   = osl::systemPathIsHiddenFileOrDirectoryEntry(file_path) ? osl_File_Attribute_Hidden : 0;
@@ -177,10 +193,15 @@
         set_file_hidden_status(file_path, pStat);
         set_file_access_mask(file_stat, pStat);

+#ifdef FAKE_ACCESS_RIGHTS
         // we set the file access rights only on demand
         // because it's potentially expensive
         if (uFieldMask & osl_FileStatus_Mask_Attributes)
                set_file_access_rights(file_stat, pStat);
+#else
+        if (uFieldMask & osl_FileStatus_Mask_Attributes)
+            set_file_access_real_rights(file_path, pStat);
+#endif
     }

     inline void set_file_access_time(const struct stat& file_stat, oslFileStatus* pStat)


RE-adding a source_weigth matrix to balance each speaker during the dbap_calculate2D of a source.
there is also a method (src_weight) to set this matrix by passing the source number and the list of weights
for each speaker.

git-svn-id: c70bd4441ad5e0563430019b01ef925cf1c0ee30@4498 464221e2-0a0f-0410-983b-f8d57d210c17

--- SourceCode/MaxObjects/jcom.dbap/jcom.dbap.cpp
+++ SourceCode/MaxObjects/jcom.dbap/jcom.dbap.cpp
@@ -13,6 +13,10 @@
 const long MAX_NUM_SOURCES = 250;
 const long MAX_NUM_DESTINATIONS = 500;

+// This is to
+const long MAX_NUM_WEIGHTED_SOURCES = 64;
+const long MAX_NUM_WEIGHTED_DESTINATIONS = 32;
+
 t_symbol		*ps_dst_position,
 				*ps_src_position,
 				*ps_src_gain,
@@ -34,7 +38,7 @@
 	t_xyz		src_position[MAX_NUM_SOURCES];			///< Positions of the virtual source
 	float		blur[MAX_NUM_SOURCES];					///< Spatial bluriness ratio in percents for each source
 	float		src_gain[MAX_NUM_SOURCES];				///< Linear gain for each source, not yet used
-	//float		src_weight[MAX_NUM_SOURCES][MAX_NUM_DESTINATIONS];	///< Weight for each source for each destination
+	float		src_weight[MAX_NUM_WEIGHTED_SOURCES][MAX_NUM_WEIGHTED_DESTINATIONS];///< Weight for each source for each destination
 	float		src_not_muted[MAX_NUM_SOURCES];				///< Mute and unmute sources
 	float		master_gain;							///< Mater gain for all ofr the algorithm
 	t_xyz		dst_position[MAX_NUM_DESTINATIONS];		///< Array of speaker positions
@@ -74,7 +78,7 @@
 void dbap_mastergain(t_dbap *x, double f);

 /** Set weight for nth source by passing a list to balance each destination. */
-//void dbap_sourceweight(t_dbap *x, t_symbol *msg, long argc, t_atom *argv);
+void dbap_sourceweight(t_dbap *x, t_symbol *msg, long argc, t_atom *argv);

 /** Mute and unmute sources */
 void dbap_sourcemute(t_dbap *x, void *msg, long argc, t_atom *argv);
@@ -163,7 +167,7 @@
 	class_addmethod(c, (method)dbap_source,				"src_position",	A_GIMME,	0);
 	class_addmethod(c, (method)dbap_destination,		"dst_position",	A_GIMME,	0);
 	class_addmethod(c, (method)dbap_sourcegain,			"src_gain",		A_GIMME,	0);
-	//class_addmethod(c, (method)dbap_sourceweight,		"src_weight",	A_GIMME,	0);
+	class_addmethod(c, (method)dbap_sourceweight,		"src_weight",	A_GIMME,	0);
 	class_addmethod(c, (method)dbap_mastergain,			"master_gain",	A_FLOAT,	0);
 	class_addmethod(c, (method)dbap_sourcemute,			"src_mute",		A_GIMME,	0);
 	class_addmethod(c, (method)dbap_assist,				"assist",		A_CANT,		0);
@@ -230,11 +234,11 @@
 			x->dst_position[i].z = 0.;
 		}

-		/*for(i=0;i<MAX_NUM_SOURCES;i++){
-			for(j=0;j<MAX_NUM_SOURCES;j++){
+		for(i=0;i<MAX_NUM_WEIGHTED_SOURCES;i++){
+			for(j=0;j<MAX_NUM_WEIGHTED_DESTINATIONS;j++){
 				x->src_weight[i][j] = 1.;
 			}
-		}*/
+		}

 		x->hull1.min = 0.0;
 		x->hull1.max = 0.0;
@@ -397,16 +401,16 @@
 		dbap_calculate(x, i);
 }

-/*void dbap_sourceweight(t_dbap *x, t_symbol *msg, long argc, t_atom *argv)
+void dbap_sourceweight(t_dbap *x, t_symbol *msg, long argc, t_atom *argv)
 {
 	long n;
 	long i;
 	float f;

-	if((argc == MAX_NUM_DESTINATIONS+1) && argv) {			// the first argument is the source number
+	if((argc == x->attr_num_destinations+1) && argv) {			// the first argument is the source number
 		n = atom_getlong(argv)-1;							// we start counting from 1 for sources
-		if ( (n<0) || (n>=MAX_NUM_SOURCES) ) {
-			error("Invalid argument(s) for source_weight");
+		if((n < 0)||(n >= x->attr_num_sources)) {
+			error("Invalid argument(s) for src_weight");
 			return;
 		}
 		for(i=1;i<argc;i++){								// the rest is the list of weights for each destination
@@ -417,8 +421,8 @@
 		}
 	}
 	else
-		error("Invalid argument(s) for source_weight");
-}*/
+		error("Invalid argument(s) for src_weight");
+}

 void dbap_sourcemute(t_dbap *x, void *msg, long argc, t_atom *argv)
 {
@@ -437,7 +441,6 @@
 	else
 		error("Invalid argument(s) for source_gain");
 }
-

 void dbap_info(t_dbap *x)
 {
@@ -661,8 +664,7 @@
 		dx = x->src_position[n].x - x->dst_position[i].x;
 		dy = x->src_position[n].y - x->dst_position[i].y;
 		dia[i] = pow(double(dx*dx + dy*dy + r2), double(0.5*x->a));
-		//k2inv = k2inv + (x->src_weight[n][i]*x->src_weight[n][i])/(dia[i]*dia[i]);
-		k2inv = k2inv + 1./(dia[i]*dia[i]);
+		k2inv = k2inv + (x->src_weight[n][i]*x->src_weight[n][i])/(dia[i]*dia[i]);
 	}
 	k = sqrt(1./k2inv);
 	k = k*x->master_gain*x->src_gain[n]*x->src_not_muted[n];
@@ -671,7 +673,7 @@

 	for (i=0; i<x->attr_num_destinations; i++) {
 		atom_setlong(&a[1], i);
-		atom_setfloat(&a[2], k/dia[i]);
+		atom_setfloat(&a[2], x->src_weight[n][i]*k/dia[i]);
 		outlet_anything(x->outlet[0], _sym_list, 3, a);
 	}
 }


gridsize removal

gridsize removal

--- src/Textures.cpp
+++ src/Textures.cpp
@@ -883,7 +883,7 @@
 	aShader->uniform("iTempoTime", mParameterBag->iTempoTime);
 	aShader->uniform("iGlitch", (int)mParameterBag->controlValues[45]);
 	aShader->uniform("iTrixels", mParameterBag->controlValues[16]);
-	aShader->uniform("iGridSize", mParameterBag->controlValues[17]);
+	aShader->uniform("iGridSize", 0.0f);// mParameterBag->controlValues[17]);
 	aShader->uniform("iFlipH", mParameterBag->iFlipHorizontally);
 	aShader->uniform("iBeat", mParameterBag->iBeat);
 	aShader->uniform("iSeed", mParameterBag->iSeed);


[Fix] Missing break

[Fix] Missing break

--- Core/Web/WebView.cpp
+++ Core/Web/WebView.cpp
@@ -157,6 +157,7 @@
 		switch (event->type()) {
 		case QEvent::Wheel:
 			newWheelEvent(static_cast<QWheelEvent*>(event));
+			break;
 		case QEvent::MouseButtonPress:
 			newMousePressEvent(static_cast<QMouseEvent*>(event));
 			break;
@@ -189,7 +190,42 @@
 		}
 	}

-	return QWebEngineView::eventFilter(watched, event);
+	if (watched == this) {
+		switch (event->type()) {
+		case QEvent::KeyPress:
+		case QEvent::KeyRelease:
+		case QEvent::MouseButtonPress:
+		case QEvent::MouseButtonRelease:
+		case QEvent::MouseMove:
+		case QEvent::Wheel:
+			return true;
+
+		case QEvent::Hide:
+			if (isFullScreen()) {
+				triggerPageAction(QWebEnginePage::ExitFullScreen);
+			}
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	const bool res = QWebEngineView::eventFilter(watched, event);
+
+	if (watched == m_child) {
+		switch (event->type()) {
+		case QEvent::FocusIn:
+		case QEvent::FocusOut:
+			emit focusChanged(hasFocus());
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	return res;
 }

 QString WebView::title() const


add database query logs

add database query logs

--- CoreLib/Database.cpp
+++ CoreLib/Database.cpp
@@ -50,6 +50,7 @@
 #include "SharedObjectPool.hpp"

 #define     MAX_DATABASE_CONNECTIONS    16
+#define     QUERY_SUCCEED               "CoreLib::Database ==>  Query Succeed!"
 #define     UNKNOWN_ERROR               "Unknow database error!"

 using namespace std;
@@ -217,6 +218,8 @@
         pqxx::result r = txn.exec((format("SELECT EXISTS ( SELECT 1 FROM pg_type WHERE typname = %1% );")
                                    % txn.quote(m_pimpl->EnumNames[id])).str());

+        LOG_INFO(QUERY_SUCCEED, r.query());
+
         if (!r.empty()) {
             std::string exists(r[0][0].as<string>());

@@ -228,9 +231,11 @@
                     ph += txn.quote(m_pimpl->Enumerators[id][i]);
                 }

-                txn.exec((format("CREATE TYPE \"%1%\" AS ENUM ( %2% );")
+                r = txn.exec((format("CREATE TYPE \"%1%\" AS ENUM ( %2% );")
                           % txn.esc(m_pimpl->EnumNames[id])
                           % txn.esc(ph)).str());
+
+                LOG_INFO(QUERY_SUCCEED, r.query());

                 txn.commit();
             }
@@ -255,9 +260,11 @@
         c->activate();
         pqxx::work txn(*c.get());

-        txn.exec((format("CREATE TABLE IF NOT EXISTS \"%1%\" ( %2% );")
+        pqxx::result r = txn.exec((format("CREATE TABLE IF NOT EXISTS \"%1%\" ( %2% );")
                   % txn.esc(m_pimpl->TableNames[id])
                   % txn.esc(m_pimpl->TableFields[id])).str());
+
+        LOG_INFO(QUERY_SUCCEED, r.query());

         txn.commit();

@@ -280,8 +287,10 @@
         c->activate();
         pqxx::work txn(*c.get());

-        txn.exec((format("DROP TABLE IF EXISTS \"%1%\";")
+        pqxx::result r = txn.exec((format("DROP TABLE IF EXISTS \"%1%\";")
                   % txn.esc(m_pimpl->TableNames[id])).str());
+
+        LOG_INFO(QUERY_SUCCEED, r.query());

         txn.commit();

@@ -306,9 +315,11 @@
             c->activate();
             pqxx::work txn(*c.get());

-            txn.exec((format("ALTER TABLE \"%1%\" RENAME TO \"%2%\";")
+            pqxx::result r = txn.exec((format("ALTER TABLE \"%1%\" RENAME TO \"%2%\";")
                       % txn.esc(m_pimpl->TableNames[id])
                       % txn.esc(newName)).str());
+
+            LOG_INFO(QUERY_SUCCEED, r.query());

             txn.commit();

@@ -352,7 +363,9 @@

         ss << ");";

-        txn.exec(ss.str());
+        pqxx::result r = txn.exec(ss.str());
+
+        LOG_INFO(QUERY_SUCCEED, r.query());

         txn.commit();

@@ -384,12 +397,14 @@
             processedSet = boost::replace_nth_copy(set, "?", 0, txn.quote(arg));
         }

-        txn.exec((format("UPDATE ONLY \"%1%\" SET %2% WHERE \"%3%\" = %4%;")
+        pqxx::result r = txn.exec((format("UPDATE ONLY \"%1%\" SET %2% WHERE \"%3%\" = %4%;")
                   % txn.esc(m_pimpl->TableNames[id])
                   % processedSet
                   % txn.esc(where)
                   % txn.quote(value)).str());

+        LOG_INFO(QUERY_SUCCEED, r.query());
+
         txn.commit();

         return true;
@@ -413,11 +428,13 @@
         c->activate();
         pqxx::work txn(*c.get());

-        txn.exec((format("DELETE FROM ONLY \"%1%\" WHERE \"%2%\"=%3%;")
+        pqxx::result r = txn.exec((format("DELETE FROM ONLY \"%1%\" WHERE \"%2%\"=%3%;")
                   % txn.esc(m_pimpl->TableNames[id])
                   % txn.esc(where)
                   % txn.quote(value)).str());

+        LOG_INFO(QUERY_SUCCEED, r.query());
+
         txn.commit();

         return true;


Run2TuneMC tuned

Run2TuneMC tuned

--- TENDER/TenderSupplies/AliPHOSTenderSupply.cxx
+++ TENDER/TenderSupplies/AliPHOSTenderSupply.cxx
@@ -843,15 +843,16 @@
   }
   if(fNonlinearityVersion=="Run2TuneMC"){ //Improved Run2 tune for MC
     if(en<=0.) return 0.;
-    const Double_t p0 = 1.04397e+00;
-    const Double_t p1 = 5.19307e-01;
-    const Double_t p2 = 0.144512;
-    const Double_t p3 = -1.55093e-01;
-    const Double_t p4 = -0.470662;
-
-    const Double_t Nonlin = 1.001/(p0+p1/en+p2/en/en+p3/TMath::Sqrt(en)+p4/en/TMath::Sqrt(en));
-
-    return en / Nonlin;
+
+    const Double_t p0 = 1.04397;
+    const Double_t p1 = 0.512307;
+    const Double_t p2 = 0.133812;
+    const Double_t p3 = -0.150093;
+    const Double_t p4 = -0.455062;
+
+    const Double_t Nonlin = p0+p1/en+p2/en/en+p3/TMath::Sqrt(en)+p4/en/TMath::Sqrt(en);
+
+    return en * Nonlin;
   }

   return en ;


MemoryPool: Add timeout and wake tests

MemoryPool: Add timeout and wake tests

--- TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp
+++ TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp
@@ -20,6 +20,9 @@

 using namespace utest::v1;

+#define THREAD_STACK_SIZE 512
+#define TEST_TIMEOUT 50
+
 /* Enum used to select block allocation method. */
 typedef enum {
     ALLOC, CALLOC
@@ -448,6 +451,80 @@
     if (atype == CALLOC) {
         TEST_ASSERT_EQUAL(true, comp_is_cleared(p_blocks[0]));
     }
+}
+
+/* Test alloc timeout
+ *
+ * Given a pool with one slot for int data
+ * When a thread tries to allocate two blocks with @ TEST_TIMEOUT timeout
+ * Then first operation succeeds immediately and second fails at the correct time.
+ */
+void test_mem_pool_timeout()
+{
+    MemoryPool<int, 1> mem_pool;
+
+    Timer timer;
+    timer.start();
+
+    int *item = mem_pool.alloc_for(TEST_TIMEOUT);
+    TEST_ASSERT_NOT_NULL(item);
+    TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, 0, timer.read_us());
+
+    item = mem_pool.alloc_for(TEST_TIMEOUT);
+    TEST_ASSERT_NULL(item);
+    TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, TEST_TIMEOUT * 1000, timer.read_us());
+
+    uint64_t end_time = Kernel::get_ms_count() + TEST_TIMEOUT;
+    item = mem_pool.alloc_until(end_time);
+    TEST_ASSERT_NULL(item);
+    TEST_ASSERT_UINT64_WITHIN(TEST_TIMEOUT * 100, end_time, Kernel::get_ms_count());
+}
+
+namespace {
+struct free_capture {
+    MemoryPool<int, 1> *pool;
+    int *item;
+};
+}
+
+static void free_int_item(free_capture *to_free)
+{
+    ThisThread::sleep_for(TEST_TIMEOUT);
+
+    osStatus status = to_free->pool->free(to_free->item);
+    TEST_ASSERT_EQUAL(osOK, status);
+}
+
+/** Test alloc wait forever
+ *
+ * Given two threads A & B and a pool with one slot for int data
+ * When thread A allocs a block from the pool and tries to alloc a second one with @a osWaitForever timeout
+ * Then thread waits for a block to become free in the pool
+ * When thread B frees the first block from the pool
+ * Then thread A successfully allocs a block from the pool
+ */
+void test_mem_pool_waitforever()
+{
+    Thread t(osPriorityNormal, THREAD_STACK_SIZE);
+    MemoryPool<int, 1> pool;
+
+    Timer timer;
+    timer.start();
+
+    int *item = pool.alloc_for(osWaitForever);
+    TEST_ASSERT_NOT_NULL(item);
+    TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, 0, timer.read_us());
+
+    struct free_capture to_free;
+    to_free.pool = &pool;
+    to_free.item = item;
+    t.start(callback(free_int_item, &to_free));
+
+    item = pool.alloc_for(osWaitForever);
+    TEST_ASSERT_EQUAL(item, to_free.item);
+    TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, TEST_TIMEOUT * 1000, timer.read_us());
+
+    t.join();
 }

 /* Robustness checks for free() function.
@@ -569,6 +646,9 @@

     Case("Test: fail (out of free blocks).", test_mem_pool_alloc_fail_wrapper<int, 3>),

+    Case("Test: timeout", test_mem_pool_timeout),
+    Case("Test: wait forever", test_mem_pool_waitforever),
+
     Case("Test: free() - robust (free called with invalid param - NULL).", free_block_invalid_parameter_null),
     Case("Test: free() - robust (free called with invalid param).", free_block_invalid_parameter)
 };


- Removed unused csVector3 tmp.

- Removed unused csVector3 tmp.

git-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@31378 8cc4aa7f-3514-0410-904f-f2cc9021211c

--- libs/csgeom/tritri.cpp
+++ libs/csgeom/tritri.cpp
@@ -633,8 +633,6 @@
                                            csSegment3& isectSeg,
                                            float& t0, float &t1)
 {
-  csVector3 tmp;
-
   // t_edge = dv1_0 / (dv1_0 - dv1_1), see (4) in Möller
   float t_edge = d[0] / (d[0] - d[1]);

@@ -643,7 +641,6 @@

   // Compute real point of intersection
   isectSeg.SetStart (tri[0] + (tri[1] - tri[0]) * t_edge);
-

   // REDO FOR OTHER EDGE


COMP: SpatialOrientationAdapter is not a templated class anymore.

--- Testing/Code/IO/itkBrains2MaskImageIOTest.cxx
+++ Testing/Code/IO/itkBrains2MaskImageIOTest.cxx
@@ -52,7 +52,7 @@
   img->SetBufferedRegion(region);
   img->SetRequestedRegion(region);
   img->Allocate();
-  itk::SpatialOrientationAdapter<3>::DirectionType CORdir=itk::SpatialOrientationAdapter<3>().ToDirectionCosines(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);
+  itk::SpatialOrientationAdapter::DirectionType CORdir=itk::SpatialOrientationAdapter().ToDirectionCosines(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);
   img->SetDirection(CORdir);

   vnl_sample_reseed(8775070);


debug

debug

--- libsrc/csg/algprim.cpp
+++ libsrc/csg/algprim.cpp
@@ -193,6 +193,10 @@
     pplane(0) = p1p * ex;
     pplane(1) = p1p * ey;
     zone = 0;
+
+    *testout << "Plane::toplane" << endl;
+    *testout << "p3d = " << p3d << endl;
+    *testout << "pplane = " << pplane << endl;
   }

   void Plane :: FromPlane (const Point<2> & pplane, Point<3> & p3d, double h) const


Automagically load RevokeResult and RevokeRequest messages

git-svn-id: c5bb8e2b15dc16fd1aec0e5653c08870c9ddec7d@379067 13f79535-47bb-0310-9956-ffa450edef68

--- c/src/xkms/impl/XKMSMessageFactoryImpl.cpp
+++ c/src/xkms/impl/XKMSMessageFactoryImpl.cpp
@@ -317,6 +317,33 @@
 		return (XKMSRegisterResult *) ret;

 	}
+	else if (strEquals(name, XKMSConstants::s_tagRevokeRequest)) {
+
+		// This is a <RevokeRequest> message
+		XKMSRevokeRequestImpl * ret;
+		XSECnew(ret, XKMSRevokeRequestImpl(env, elt));
+		Janitor<XKMSRevokeRequestImpl> j_ret(ret);
+
+		ret->load();
+
+		j_ret.release();
+		return (XKMSRevokeRequest *) ret;
+
+	}
+
+	else if (strEquals(name, XKMSConstants::s_tagRevokeResult)) {
+
+		// This is a <RevokeResult> message
+		XKMSRevokeResultImpl * ret;
+		XSECnew(ret, XKMSRevokeResultImpl(env, elt));
+		Janitor<XKMSRevokeResultImpl> j_ret(ret);
+
+		ret->load();
+
+		j_ret.release();
+		return (XKMSRevokeResult *) ret;
+
+	}

 	delete env;
 	return NULL;
@@ -932,6 +959,7 @@
 	case XKMSMessageAbstractType::CompoundRequest :
 	case XKMSMessageAbstractType::PendingRequest :
 	case XKMSMessageAbstractType::RegisterRequest :
+	case XKMSMessageAbstractType::RevokeRequest :
 	case XKMSMessageAbstractType::StatusRequest :

 		return (XKMSRequestAbstractType *) msg;
@@ -953,6 +981,7 @@
 	case XKMSMessageAbstractType::ValidateResult :
 	case XKMSMessageAbstractType::CompoundResult :
 	case XKMSMessageAbstractType::RegisterResult :
+	case XKMSMessageAbstractType::RevokeResult :
 	case XKMSMessageAbstractType::StatusResult :
 	case XKMSMessageAbstractType::Result :


Rename the remaining getData methods to getSamples

--- ouzel/audio/Audio.cpp
+++ ouzel/audio/Audio.cpp
@@ -148,7 +148,7 @@

         Audio::Audio(Driver driver, bool debugAudio, Window* window):
             device(createAudioDevice(driver,
-                                     std::bind(&Audio::getData, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4),
+                                     std::bind(&Audio::getSamples, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4),
                                      debugAudio, window)),
             mixer(device->getBufferSize(), device->getChannels(),
                   std::bind(&Audio::eventCallback, this, std::placeholders::_1)),
@@ -211,7 +211,7 @@
                                                                                updateFunction)));
         }

-        void Audio::getData(uint32_t frames, uint16_t channels, uint32_t sampleRate, std::vector<float>& samples)
+        void Audio::getSamples(uint32_t frames, uint16_t channels, uint32_t sampleRate, std::vector<float>& samples)
         {
             mixer.getSamples(frames, channels, sampleRate, samples);
         }


:construction: chore(lox): updated the lox starting

--- cplusplus/loxpp/main.cc
+++ cplusplus/loxpp/main.cc
@@ -27,29 +27,39 @@
 #include <cstdlib>
 #include <fstream>
 #include <iostream>
+#include <memory>
 #include <sstream>
 #include <string>
+#include "error_reporter.h"
 #include "scanner.h"
+#include "parser.h"
+#include "ast_printer.h"
+#include "interpreter.h"

-static bool had_error{};
+static ErrorReporter err_reporter;
+static std::shared_ptr<Interpreter> interp = std::make_shared<Interpreter>(err_reporter);

-static void report(
-    int line, const std::string& where, const std::string& message) {
-  std::cerr
-    << "[line " << line << "] ERROR " << where << ": "
-    << message << std::endl;
-  had_error = true;
-}
-
-static void error(int line, const std::string& message) {
-  report(line, "", message);
-}
-
-static void print_tokens(const std::string& source) {
+static void run(const std::string& source) {
   Scanner s(source);
   auto tokens = s.scan_tokens();
-  for (auto& t : tokens)
-    std::cout << t.repr() << std::endl;
+  // for (auto& t : tokens)
+  //   std::cout << t.repr() << std::endl;
+
+  // Parser p(tokens);
+  // auto expr = p.parse();
+  // std::cout << std::make_shared<AstPrinter>()->as_string(expr) << std::endl;
+
+  // auto interp = std::make_shared<Interpreter>(err_reporter);
+  // interp->interpret(expr);
+
+  Parser p(tokens);
+  auto stmts = p.parse_stmt();
+
+  // auto interp = std::make_shared<Interpreter>(err_reporter);
+  interp->interpret(stmts);
+
+  if (err_reporter.had_error())
+    std::abort();
 }

 static void repl(void) {
@@ -62,9 +72,7 @@
       break;
     }

-    // interpret(line);
-    print_tokens(line);
-    had_error = false;
+    run(line);
   }
 }

@@ -79,17 +87,9 @@
   return "";
 }

-static void run(const std::string& source) {
-}
-
 static void run_file(const std::string& path) {
   auto bytes = read_file(path);
-  // run(bytes);
-
-  print_tokens(bytes);
-
-  if (had_error)
-    std::exit(1);
+  run(bytes);
 }

 int main(int argc, char* argv[]) {


fix cppcheck errors.

fix cppcheck errors.

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@42504 27541ba8-7e3a-0410-8455-c3a389f83636

--- graf2d/qt/src/GQtGUI.cxx
+++ graf2d/qt/src/GQtGUI.cxx
@@ -1892,17 +1892,25 @@
    if (id == kNone || id == kDefault ) return;
    QPainter paint(iwid(id));
    paint.setBackgroundMode( Qt::OpaqueMode); // Qt::TransparentMode
-   TQtClientWidget *wd =  dynamic_cast<TQtClientWidget*>(wid(id));
+   TQtClientWidget *wd = dynamic_cast<TQtClientWidget*>(wid(id));
+   if (!wd) {
+      qDebug() << "TGQt::ClearArea: ***   wd = 0";
+      return;
+   }
    const QColor  *c = 0;
    const QPixmap *p = 0;
 #if QT_VERSION < 0x50000
-   c = wd ? wd->fEraseColor  : 0;
-   p = wd ? wd->fErasePixmap : 0;
+   c = wd->fEraseColor;
+   p = wd->fErasePixmap;
    const QColor  &cr = *c;
    const QPixmap &pr = *p;
 #else
-   const QColor  &cr = wd ? wd->palette().color(QPalette::Window) : *c;
-   c = wd ? &cr : 0;
+   const QColor  &cr = wd->palette().color(QPalette::Window);
+   c = &cr;
+   if (!p) {
+      qDebug() << "TGQt::ClearArea: ***   p = 0, code needs fixing";
+      return;
+   }
    const QPixmap &pr = *p;
 #endif
    if (int(w) <=0) {


Update Homework-7.cpp

Update Homework-7.cpp

--- M10B/Homework/Homework-7.cpp
+++ M10B/Homework/Homework-7.cpp
@@ -85,7 +85,7 @@
 	* Print this Complex Number as (a, b). Where a is the real number and b is the imaginary part.
 	*/
 	void print() {
-		cout << "(" << this->real << ", " << this->imaginary << ")" << endl;
+		cout << endl << "The new imaginary number is: (" << this->real << ", " << this->imaginary << ")" << endl << endl;
 	}

 	/**


INTEGRATION: CWS pchfix02 (1.3.14); FILE MERGED 2006/09/01 17:23:17 kaib 1.3.14.1: #i68856# Added header markers and pch files

--- cppuhelper/source/implementationentry.cxx
+++ cppuhelper/source/implementationentry.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: implementationentry.cxx,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.4 $
  *
- *  last change: $Author: hr $ $Date: 2006-06-19 10:33:53 $
+ *  last change: $Author: obo $ $Date: 2006-09-16 12:41:06 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -32,6 +32,9 @@
  *    MA  02111-1307  USA
  *
  ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cppuhelper.hxx"
 #ifndef _CPPUHELPER_IMPLEMENATIONENTRY_HXX_
 #include <cppuhelper/implementationentry.hxx>
 #endif


[vtest] Remove no longer needed static casts

--HG--
branch : v1-10

--- Tests/VisualTests/Context/src/TestContext.cpp
+++ Tests/VisualTests/Context/src/TestContext.cpp
@@ -119,8 +119,9 @@

     // Grab input, since moving the window seemed to change the results (in Linux anyways).
     setupInput(mNoGrabMouse);
-
+
     locateResources();
+
     createDummyScene();
 #ifdef INCLUDE_RTSHADER_SYSTEM
     if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION) == false)
@@ -637,7 +638,7 @@
         //newViewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);

         // creates shaders for base material BaseWhite using the RTSS
-        Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME).staticCast<Material>();
+        Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
         baseWhite->setLightingEnabled(false);
         mShaderGenerator->createShaderBasedTechnique(
             "BaseWhite",
@@ -660,7 +661,7 @@
             Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
         mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
                                            "BaseWhiteNoLighting");
-        Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME).staticCast<Material>();
+        Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
         if(baseWhite->getNumTechniques() > 1)
         {
             baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(


More of the same.

More of the same.

--- cpp/lib/src/Resolver.cc
+++ cpp/lib/src/Resolver.cc
@@ -662,7 +662,9 @@
     case 1:
         if (verbosity >= 2)
             logger->info("in Resolver::DecodeReply: the server indicated that we sent an invalid request!");
+        #if __GNUC__ >= 7
         [[fallthrough]];
+        #endif
     default:
         /* Some kind of error condition that we ignore. */
         return false;


cql3: Fix create_table_statement::raw_statement definition lookup

The column_identifiers are wrapped in shared_ptr<> so use the
appropriate hash and comparison functions for the container.

Signed-off-by: Pekka Enberg <add4fcd06328a394f0ad91feda7ee057316dc5ed@cloudius-systems.com>

--- cql3/statements/create_table_statement.hh
+++ cql3/statements/create_table_statement.hh
@@ -99,7 +99,11 @@

 class create_table_statement::raw_statement : public cf_statement {
 private:
-    std::unordered_map<::shared_ptr<column_identifier>, ::shared_ptr<cql3_type::raw>> _definitions;
+    using defs_type = std::unordered_map<::shared_ptr<column_identifier>,
+                                         ::shared_ptr<cql3_type::raw>,
+                                         shared_ptr_value_hash<column_identifier>,
+                                         shared_ptr_equal_by_value<column_identifier>>;
+    defs_type _definitions;
 public:
     const ::shared_ptr<cf_prop_defs> properties = ::make_shared<cf_prop_defs>();
 private:


Fixed a couple of problems.

Fixed a couple of problems.

--- cpp/lib/src/TextUtil.cc
+++ cpp/lib/src/TextUtil.cc
@@ -719,13 +719,13 @@
                     ++line_no;
                 current_value += *ch;
             } else {
-                if ((ch + 1) != file_contents.cend() and *(ch + 1) == quote) { // We have an embedded double quote.
+                if ((ch + 1) != file_contents.cend() and *(ch + 1) == quote) { // We have an embedded quote.
                     current_value += quote;
                     ++ch;
                 } else {
                     if ((ch + 1) != file_contents.cend()
                         and not (*(ch + 1) == separator or *(ch + 1) == '\r' or *(ch + 1) == '\n'))
-                        ERROR("garbage after double-quoted value in \"" + path + "\" on line " + std::to_string(line_no) + "!");
+                        ERROR("garbage after quoted value in \"" + path + "\" on line " + std::to_string(line_no) + "!");
                     logical_line.emplace_back(current_value);
                     current_value.clear();
                     in_string_constant = false;
@@ -733,11 +733,16 @@
             }
         } else if (*ch == quote)
             in_string_constant = true;
-        else if (*ch == separator)
+        else if (*ch == separator) {
+            if ((ch + 1) != file_contents.cend() and not (*(ch + 1) != '\r' or *(ch + 1) != '\n'))
+                ERROR("garbage after separator in \"" + path + "\" on line " + std::to_string(line_no) + "!");
             logical_line.emplace_back(current_value);
-        else if (*ch == '\r' and (ch + 1 == file_contents.cend() or *(ch + 1) != '\n'))
-            ERROR("unexpected carriage return in \"" + path + "\" on line " + std::to_string(line_no) + "!");
-        else if (*ch == '\n') {
+        } else if (*ch == '\r') {
+            if (ch + 1 == file_contents.cend() or *(ch + 1) != '\n')
+                ERROR("unexpected carriage return in \"" + path + "\" on line " + std::to_string(line_no) + "!");
+            ++ch; // Skip over the linefeed.
+            ++line_no;
+        } else if (*ch == '\n') {
             ++line_no;
             logical_line.emplace_back(current_value);
             current_value.clear();


Update TextUtil.cc

Update TextUtil.cc

--- cpp/lib/src/TextUtil.cc
+++ cpp/lib/src/TextUtil.cc
@@ -866,8 +866,7 @@
                 } else {
                     std::string utf8;
                     if (unlikely(not WCharToUTF8String(utf32_char, &utf8))) {
-                        WARNING("WCharToUTF8String failed! (Character was "
-                                      + std::to_string(utf32_char) + ")");
+                        WARNING("WCharToUTF8String failed! (Character was " + std::to_string(utf32_char) + ")");
                         return *utf8_string;
                     }
                     collapsed_string += utf8;


Fixed an obvious bug.

Fixed an obvious bug.

--- cpp/lib/src/TextUtil.cc
+++ cpp/lib/src/TextUtil.cc
@@ -759,8 +759,8 @@
                 err_msg_ = "quoted value starting on line #" + std::to_string(start_line_no) + " was never terminated!";
                 return SYNTAX_ERROR;
             }
-        }
-        value_ += static_cast<char>(ch);
+            value_ += static_cast<char>(ch);
+        }
     } else { // Unquoted value.
         value_ += static_cast<char>(ch);
         for (;;) {


Added a missing error message.

Added a missing error message.

--- cpp/marc_char_filter.cc
+++ cpp/marc_char_filter.cc
@@ -139,7 +139,7 @@

     const std::string filter_chars(argv[4]);
     if (filter_chars.empty())
-        Error("");
+        Error("missing characters to be filtered!");

     try {
         Filter(input.get(), output.get(), subfield_specs, filter_chars);


Print best lap as last line

Print best lap as last line

--- cpp/throttle_tester.cpp
+++ cpp/throttle_tester.cpp
@@ -37,10 +37,13 @@
   }
   boost::filesystem::create_directories("bin/" + FLAGS_race_id);

-  std::unique_ptr<bots::RawBot> bot(new bots::RawBot(new bots::wojtek::Bot()));
-  std::unique_ptr<game::Simulator> simulator(new game::Simulator());
+  game::Simulator::Result result;
+  {
+    std::unique_ptr<bots::RawBot> bot(new bots::RawBot(new bots::wojtek::Bot()));
+    std::unique_ptr<game::Simulator> simulator(new game::Simulator());

-  auto result = simulator->Run(bot.get());
+    result = simulator->Run(bot.get());
+  }

   std::cout << "BEST LAP: " << result.best_lap_time_in_ticks << std::endl;
   if (result.crashed) {


zotero_harvester: fix potential endless loop while waiting on conversion tasks

--- cpp/zotero_harvester.cc
+++ cpp/zotero_harvester.cc
@@ -474,7 +474,7 @@
         bool wait_for_next_item(false);
         if (ignore_wait_condition)
             ;// Fall-through without checking.
-        if (not current_conversion->isComplete())
+        else if (not current_conversion->isComplete())
             wait_for_next_item = true;
         else if (previous_converted_item_id != current_converted_item_id and
                  current_converted_item_id != previous_converted_item_id + 1)


whocc-scan-titers

whocc-scan-titers

--- cc/whocc-scan-titers.cc
+++ cc/whocc-scan-titers.cc
@@ -12,7 +12,8 @@

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

-void scan(const fs::path& source_dir, std::vector<fs::path>& ace_files);
+void find_ace_files(const fs::path& source_dir, std::vector<fs::path>& ace_files);
+void scan_titers(const fs::path& filename, std::set<Titer>& titers);

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

@@ -31,10 +32,12 @@
     if (exit_code == 0) {
         try {
             std::vector<fs::path> ace_files;
-            scan(fs::path(options.source_dir), ace_files);
-            std::cout << ace_files.size() << std::endl;
-            for (const auto& p: ace_files)
-                std::cout << p << std::endl;
+            find_ace_files(fs::path(options.source_dir), ace_files);
+            std::cout << "Total .ace files found: " << ace_files.size() << std::endl;
+            std::set<Titer> titers;
+            for (const auto& filename: ace_files)
+                scan_titers(filename, titers);
+            std::cout << titers << std::endl;
         }
         catch (std::exception& err) {
             std::cerr << err.what() << std::endl;
@@ -81,21 +84,31 @@

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

-void scan(const fs::path& source_dir, std::vector<fs::path>& ace_files)
+void find_ace_files(const fs::path& source_dir, std::vector<fs::path>& ace_files)
 {
     if (!fs::is_directory(source_dir))
         throw std::runtime_error(source_dir.string() + " is not a directory");
     for (fs::directory_entry& dirent: fs::directory_iterator(source_dir)) {
         if (fs::is_directory(dirent.status()))
-            scan(dirent.path(), ace_files);
+            find_ace_files(dirent.path(), ace_files);
         else if (is_regular_file(dirent.status()) && dirent.path().extension().string() == ".ace")
             ace_files.push_back(dirent.path());
     }

-} // scan
+} // find_ace_files

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

+void scan_titers(const fs::path& filename, std::set<Titer>& titers)
+{
+    std::unique_ptr<Chart> chart{import_chart(filename.string())};
+    for (size_t antigen_no = 0; antigen_no < chart->antigens().size(); ++antigen_no) {
+        for (size_t serum_no = 0; serum_no < chart->sera().size(); ++serum_no) {
+            titers.insert(chart->titers().get(antigen_no, serum_no));
+        }
+    }
+
+} // scan_titers

 // ----------------------------------------------------------------------
 /// Local Variables:


use new and delete rather than malloc and free

--- src/algo.cc
+++ src/algo.cc
@@ -237,10 +237,8 @@

   if (uclustfile != nullptr)
     {
-      dir = static_cast<unsigned char *>
-        (xmalloc(longestamplicon * longestamplicon));
-      hearray = static_cast<uint64_t *>
-        (xmalloc(2 * longestamplicon * sizeof(uint64_t)));
+      dir = new unsigned char[longestamplicon * longestamplicon];
+      hearray = new uint64_t[2 * longestamplicon];
     }

   /* set ampliconid for all */
@@ -634,9 +632,8 @@
               fprintf(uclustfile, "\n");
               fflush(uclustfile);

-              if (nwalignment != nullptr) {
-                xfree(nwalignment);
-              }
+              delete [] nwalignment;
+              nwalignment = nullptr;
             }

         }
@@ -659,8 +656,10 @@

   if (uclustfile != nullptr)
     {
-      xfree(dir);
-      xfree(hearray);
+      delete [] dir;
+      dir = nullptr;
+      delete [] hearray;
+      hearray = nullptr;
     }


Clarify usage message

Clarify usage message

--- src/app.cpp
+++ src/app.cpp
@@ -167,7 +167,7 @@

 void App::_printUsage(char *progname) {
 	std::stringstream ss;
-	ss << "Usage: " << progname << " [OPTION]..." << std::endl;
+	ss << "Usage: " << progname << " -r|-u|-l [OPTION]..." << std::endl;
 	ss << "Register a script file type (.sh) to Windows File Explorer."
 	   << std::endl << std::endl;
 	ss << help;


Formatting.

Formatting.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@63199 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -374,12 +374,9 @@
 /// larger then ValueVT then AssertOp can be used to specify whether the extra
 /// bits are known to be zero (ISD::AssertZext) or sign extended from ValueVT
 /// (ISD::AssertSext).
-static SDValue getCopyFromParts(SelectionDAG &DAG,
-                                  const SDValue *Parts,
-                                  unsigned NumParts,
-                                  MVT PartVT,
-                                  MVT ValueVT,
-                                  ISD::NodeType AssertOp = ISD::DELETED_NODE) {
+static SDValue getCopyFromParts(SelectionDAG &DAG, const SDValue *Parts,
+                                unsigned NumParts, MVT PartVT, MVT ValueVT,
+                                ISD::NodeType AssertOp = ISD::DELETED_NODE) {
   assert(NumParts > 0 && "No parts to assemble!");
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   SDValue Val = Parts[0];
@@ -587,8 +584,8 @@
       unsigned RoundBits = RoundParts * PartBits;
       unsigned OddParts = NumParts - RoundParts;
       SDValue OddVal = DAG.getNode(ISD::SRL, ValueVT, Val,
-                                     DAG.getConstant(RoundBits,
-                                                     TLI.getShiftAmountTy()));
+                                   DAG.getConstant(RoundBits,
+                                                   TLI.getShiftAmountTy()));
       getCopyToParts(DAG, OddVal, Parts + RoundParts, OddParts, PartVT);
       if (TLI.isBigEndian())
         // The odd parts were reversed by getCopyToParts - unreverse them.


Fix trim()

Fix trim()

--- src/common/inifile.cpp
+++ src/common/inifile.cpp
@@ -21,10 +21,10 @@
     // Remove leading whitespace
     auto first = str.find_first_not_of(ws);

-    // No whitespace found
+    // Only whitespace found
     if (first == std::string::npos)
     {
-        first = 0;
+        return "";
     }

     // Remove trailing whitespace


added copy_vertex_map

added copy_vertex_map

--- viennagrid/mesh/mesh_operations.hpp
+++ viennagrid/mesh/mesh_operations.hpp
@@ -16,7 +16,7 @@
 #include "viennagrid/forwards.hpp"
 #include "viennagrid/mesh/mesh.hpp"
 #include "viennagrid/mesh/segmentation.hpp"
-//#include "viennagrid/mesh/element_creation.hpp"
+#include "viennagrid/mesh/element_creation.hpp"
 #include "viennagrid/mesh/coboundary_iteration.hpp"

@@ -26,6 +26,40 @@

 namespace viennagrid
 {
+
+  template<typename SrcMeshT, typename DstMeshT>
+  class vertex_copy_map
+  {
+  public:
+    vertex_copy_map( DstMeshT & dst_mesh_ ) : dst_mesh(dst_mesh_) {}
+
+    typedef typename viennagrid::result_of::vertex<SrcMeshT>::type SrcVertexType;
+    typedef typename viennagrid::result_of::vertex_id<SrcMeshT>::type SrcVertexIDType;
+
+    typedef typename viennagrid::result_of::vertex<DstMeshT>::type DstVertexType;
+    typedef typename viennagrid::result_of::vertex_handle<DstMeshT>::type DstVertexHandleType;
+
+    DstVertexHandleType operator()( SrcVertexType const & src_vertex )
+    {
+      typename std::map<SrcVertexIDType, DstVertexHandleType>::iterator vit = vertex_map.find( src_vertex.id() );
+      if (vit != vertex_map.end())
+        return vit->second;
+      else
+      {
+        DstVertexHandleType vh = viennagrid::make_vertex( dst_mesh, viennagrid::point(src_vertex) );
+        vertex_map[src_vertex.id()] = vh;
+        return vh;
+      }
+    }
+
+  private:
+
+    DstMeshT & dst_mesh;
+    std::map<SrcVertexIDType, DstVertexHandleType> vertex_map;
+  };
+
+
+

   /** @brief Copies a mesh and an associated segmentation over to another mesh and an associated segmentation */
   template<typename SrcMeshT, typename SrcSegmentationT, typename DstMeshT, typename DstSegmentationT>


Remove unnecessary bit-wise AND from the limited precision work.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@56049 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -2755,18 +2755,16 @@

 // GetExponent - Get the exponent:
 //
-//   (float)(((Op1 & 0x7f800000) >> 23) - 127);
+//   (float)((Op1 >> 23) - 127);
 //
 // where Op is the hexidecimal representation of floating point value.
 static SDValue
 GetExponent(SelectionDAG &DAG, SDValue Op) {
-    SDValue t1 = DAG.getNode(ISD::AND, MVT::i32, Op,
-                             DAG.getConstant(0x7f800000, MVT::i32));
-    SDValue t2 = DAG.getNode(ISD::SRL, MVT::i32, t1,
+    SDValue t1 = DAG.getNode(ISD::SRL, MVT::i32, Op,
                              DAG.getConstant(23, MVT::i32));
-    SDValue t3 = DAG.getNode(ISD::SUB, MVT::i32, t2,
+    SDValue t2 = DAG.getNode(ISD::SUB, MVT::i32, t1,
                              DAG.getConstant(127, MVT::i32));
-    return DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t3);
+    return DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t2);
 }

 /// Inlined utility function to implement binary input atomic intrinsics for


Add missing constructor to CPPLanguage class to make it compile with CLang.
P=rafael.espindola R=jimb at https://bugzilla.mozilla.org/show_bug.cgi?id=623121

git-svn-id: 7939527bf0a06ad24ad020f729d5600cb42ed5d7@764 4c0a9323-5329-0410-9bdc-e9ce6186880e

--- src/common/language.cc
+++ src/common/language.cc
@@ -39,6 +39,7 @@
 // C++ language-specific operations.
 class CPPLanguage: public Language {
  public:
+  CPPLanguage() {}
   string MakeQualifiedName(const string &parent_name,
                            const string &name) const {
     if (parent_name.empty())


Fixes possible crash in tool tip manager.

BUG=none
TEST=none

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

git-svn-id: http://src.chromium.org/svn/trunk/src@27527 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: db59f7d494ef2943515df4b2c2f5a93e2f12d6f5

--- views/widget/tooltip_manager_gtk.cc
+++ views/widget/tooltip_manager_gtk.cc
@@ -103,8 +103,15 @@
     GtkLabel* real_label = NULL;
     gtk_container_foreach(GTK_CONTAINER(parent), LabelLocatorCallback,
                           static_cast<gpointer>(&real_label));
-    if (real_label)
+    if (real_label) {
+      // For some reason I'm occasionally seeing a crash in trying to get font
+      // metrics. Explicitly setting the font avoids this.
+      PangoFontDescription* pfd =
+          gfx::Font::PangoFontFromGfxFont(gfx::Font());
+      gtk_widget_modify_font(GTK_WIDGET(real_label), pfd);
+      pango_font_description_free(pfd);
       gtk_label_set_max_width_chars(GTK_LABEL(real_label), 3000);
+    }
   }
 }


copyright updated

copyright updated

--- src/WinClient.cc
+++ src/WinClient.cc
@@ -1,5 +1,5 @@
 // WinClient.cc for Fluxbox - an X11 Window manager
-// Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
+// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
 //
 // Permission is hereby granted, free of charge, to any person obtaining a
 // copy of this software and associated documentation files (the "Software"),


Update: DRW2D

Update: DRW2D

--- DSOS_sample/main.cpp
+++ DSOS_sample/main.cpp
@@ -115,7 +115,8 @@
 	typedef graphics::font<AFONT, KFONT> FONT;
 	FONT		font_(afont_, kfont_);

-	typedef graphics::render<GLCDC_MGR, FONT> RENDER;
+//	typedef graphics::render<GLCDC_MGR, FONT> RENDER;
+	typedef device::drw2d_mgr<GLCDC_MGR, FONT> RENDER;
 	RENDER		render_(glcdc_mgr_, font_);

 	// 標準カラーインスタンス
@@ -304,23 +305,21 @@
 			if(!glcdc_mgr_.control(GLCDC_MGR::CONTROL_CMD::START_DISPLAY)) {
 				utils::format("GLCDC ctrl fail...\n");
 			}
+			glcdc_mgr_.enable_double_buffer();
 		} else {
 			utils::format("GLCDC Fail\n");
 		}
 	}

-#if 0
 	{  // DRW2D 初期化
-		auto ver = render_.get_version();
-		utils::format("DRW2D Version: %04X\n") % ver;
-
 		if(render_.start()) {
 			utils:: format("Start DRW2D\n");
+			auto ver = render_.get_version();
+			utils::format("    Version: %04X\n") % ver;
 		} else {
 			utils:: format("DRW2D Fail\n");
 		}
 	}
-#endif

 	{  // FT5206 touch screen controller
 		TOUCH::reset<FT5206_RESET>();
@@ -341,8 +340,6 @@

 	cmd_.set_prompt("# ");

-	glcdc_mgr_.enable_double();
-
 	while(1) {
 		render_.sync_frame();


AddressLowering: Handle opaque use in ValueMetatypeInst

--- lib/SILOptimizer/Mandatory/AddressLowering.cpp
+++ lib/SILOptimizer/Mandatory/AddressLowering.cpp
@@ -2598,6 +2598,12 @@
     yield->setOperand(0, addr);
   }

+  void visitValueMetatypeInst(ValueMetatypeInst *vmi) {
+    auto opAddr =
+        pass.valueStorageMap.getStorage(vmi->getOperand()).storageAddress;
+    vmi->setOperand(opAddr);
+  }
+
   void visitAssignInst(AssignInst *assignInst);

   void visitBeginBorrowInst(BeginBorrowInst *borrow);


[AArch64][RegisterBankInfo] Fix mapping cost for GPR.

In r292478, we changed the order of the enum that is referenced by
PMI_FirstXXX. This had the side effect of changing the cost of the
mapping of all the loads, instead of just the FPRs ones.

Reinstate the higher cost for all but GPR loads.
Note: This did not have any external visible effects:
- For Fast mode, the cost would have been higher, but we don't care
  because we don't try to use alternative mappings.
- For Greedy mode, the higher cost of the GPR loads, would have
  triggered the use of the supposedly alternative mapping, that
  would be in fact the same GPR mapping but with a lower cost.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@302452 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/AArch64/AArch64RegisterBankInfo.cpp
+++ lib/Target/AArch64/AArch64RegisterBankInfo.cpp
@@ -529,7 +529,7 @@
     // for the greedy mode the cost of the cross bank copy will
     // offset this number.
     // FIXME: Should be derived from the scheduling model.
-    if (OpRegBankIdx[0] >= PMI_FirstFPR)
+    if (OpRegBankIdx[0] != PMI_FirstGPR)
       Cost = 2;
     break;
   }


Fix build.

Fix build.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@305967 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Target/SystemZ/SystemZMachineScheduler.cpp
+++ lib/Target/SystemZ/SystemZMachineScheduler.cpp
@@ -23,7 +23,7 @@
 #ifndef NDEBUG
 // Print the set of SUs
 void SystemZPostRASchedStrategy::SUSet::
-dump(SystemZHazardRecognizer &HazardRec) {
+dump(SystemZHazardRecognizer &HazardRec) const {
   dbgs() << "{";
   for (auto &SU : *this) {
     HazardRec.dumpSU(SU, dbgs());


Minesweeper: Added: right click flags a bomb, Bombs are red, win/lose screen is transparent

--- Samples/Minesweeper/src/Sample_Minesweeper.cpp
+++ Samples/Minesweeper/src/Sample_Minesweeper.cpp
@@ -52,6 +52,8 @@
     bool handleGameStartClicked(const CEGUI::EventArgs& event);
     // Handle click on a button of the board
     bool handleMineButtonClicked(const CEGUI::EventArgs& event);
+    // Handle mouse button down on a button of the board
+    bool handleMineButtonDown(const CEGUI::EventArgs& event);
     // Update the timer if needed
     bool handleUpdateTimer(const CEGUI::EventArgs& event);
     // reset the board
@@ -205,19 +207,27 @@
     const float d_inc = 1.0 / MinesweeperSize;
     for(size_t i = 0 ; i < MinesweeperSize ; ++i)
     {
+        // create a container for each row
+        Window* row = winMgr.createWindow("DefaultWindow");
+        row->setArea(URect(UDim(0,0), UDim(d_inc * i, 0),
+            UDim(1,0), UDim(d_inc * (i + 1), 0)));
+        grid->addChildWindow(row);
         for(size_t j = 0 ; j < MinesweeperSize ; ++j)
         {
             // Initialize buttons coordinate
             d_buttonsMapping[i][j].d_col = j;
             d_buttonsMapping[i][j].d_row = i;
             d_buttons[i][j] = (PushButton*)winMgr.createWindow("Vanilla/Button");
-            grid->addChildWindow(d_buttons[i][j]);
-            d_buttons[i][j]->setArea(URect(UDim(d_inc * j, 0.0), UDim(d_inc * i, 0.0),
-                                 UDim(d_inc * (j + 1), 0.0), UDim(d_inc * (i + 1), 0.0)));
+            row->addChildWindow(d_buttons[i][j]);
+            d_buttons[i][j]->setArea(URect(UDim(d_inc * j, 0), UDim(0,0),
+                                 UDim(d_inc * (j + 1), 0), UDim(1,0)));
             d_buttons[i][j]->setEnabled(false);
-            // Associate user data and connect event handler
+            // Associate user data
             d_buttons[i][j]->setUserData(&(d_buttonsMapping[i][j]));
+            d_buttons[i][j]->setID(0);
+            // Connect event handlers
             d_buttons[i][j]->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&MinesweeperSample::handleMineButtonClicked, this));
+            d_buttons[i][j]->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&MinesweeperSample::handleMineButtonDown, this));
         }
     }
     d_result = winMgr.createWindow("Vanilla/StaticText");
@@ -229,6 +239,7 @@
     d_result->setAlwaysOnTop(true);
     d_result->setProperty("HorzFormatting", "HorzCentred");
     d_result->setVisible(false);
+    d_result->setAlpha(0.67f);
     // activate the background window
     background->activate();
     // success!
@@ -276,7 +287,11 @@
     const CEGUI::WindowEventArgs* evt = static_cast<const CEGUI::WindowEventArgs*>(&event);
     CEGUI::PushButton* button = static_cast<CEGUI::PushButton*>(evt->window);
     Location* buttonLoc = static_cast<Location*>(button->getUserData());
-
+    if (button->getID() > 0)
+    {
+        // dont touch flagged buttons
+        return true;
+    }
     if (boardDiscover(*buttonLoc))
     {
         // We did not find a mine
@@ -295,6 +310,7 @@
                     if (d_board[i][j] > 8)
                     {
                         d_buttons[i][j]->setText("B");
+                        d_buttons[i][j]->setProperty("DisabledTextColour", "FFFF1010");
                     }
                     else
                     {
@@ -308,6 +324,35 @@
     }
     return true;
 }
+/************************************************************************
+    Handle click on a mine button (any mouse button)
+************************************************************************/
+bool MinesweeperSample::handleMineButtonDown(const CEGUI::EventArgs& event)
+{
+    const CEGUI::MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(event);
+    if (me.button == CEGUI::RightButton)
+    {
+        CEGUI::Window* button = me.window;
+        if (!button->isDisabled())
+        {
+            Location* buttonLoc = static_cast<Location*>(button->getUserData());
+            size_t x = buttonLoc->d_col;
+            size_t y = buttonLoc->d_row;
+            if (button->getID() == 0)
+            {
+                button->setID(1);
+                button->setText("F");
+            }
+            else
+            {
+                button->setID(0);
+                button->setText("");
+            }
+            return true;
+        }
+    }
+    return false;
+}
 /***********************************************************************
     Handle timer refresh
 ***********************************************************************/
@@ -415,7 +460,8 @@

 bool MinesweeperSample::boardDiscover(const Location& loc)
 {
-    if (d_buttons[loc.d_row][loc.d_col]->isDisabled())
+    CEGUI::PushButton* btn = d_buttons[loc.d_row][loc.d_col];
+    if (btn->isDisabled() || btn->getID() > 0)
         return true;

     if (d_board[loc.d_row][loc.d_col] > 8)


fix default template when compiled with USE_FLOAT

Former-commit-id: e09ded8a299200c69eb151d77d3c12c941b250e6

--- modules/SofaMiscEngine/ProjectiveTransformEngine.cpp
+++ modules/SofaMiscEngine/ProjectiveTransformEngine.cpp
@@ -42,10 +42,11 @@
         .add< ProjectiveTransformEngine<defaulttype::Vec3fTypes> >(true) // default template
 #else
         .add< ProjectiveTransformEngine<defaulttype::Vec3dTypes> >(true) // default template
-#endif
 #ifndef SOFA_DOUBLE
         .add< ProjectiveTransformEngine<defaulttype::Vec3fTypes> >()
 #endif
+#endif
+
         .add< ProjectiveTransformEngine<defaulttype::ExtVec3fTypes> >()
         ;


Switch to using AudioEncoderPcm16B instead of ACMPCM16B

This change switches from the old codec wrapper ACMPCM16B to the new
AudioEncoderPcm16B wrapped in an ACMGenericCodecWrapper.

BUG=4228
COAUTHOR=kwiberg@webrtc.org
R=tina.legrand@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/33249004

Cr-Original-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#8324}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: c2d0473320456cd783a1e7612ea7008723593257

--- modules/audio_coding/main/acm2/acm_codec_database.cc
+++ modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -746,46 +746,9 @@
     return new ACMCNG(codec_id, enable_red);
   } else if (!STR_CASE_CMP(codec_inst.plname, "L16")) {
 #ifdef WEBRTC_CODEC_PCM16
-    // For L16 we need to check sampling frequency to know what codec to create.
-    int codec_id;
-    if (codec_inst.channels == 1) {
-      switch (codec_inst.plfreq) {
-        case 8000: {
-          codec_id = kPCM16B;
-          break;
-        }
-        case 16000: {
-          codec_id = kPCM16Bwb;
-          break;
-        }
-        case 32000: {
-          codec_id = kPCM16Bswb32kHz;
-          break;
-        }
-        default: {
-          return NULL;
-        }
-      }
-    } else {
-      switch (codec_inst.plfreq) {
-        case 8000: {
-          codec_id = kPCM16B_2ch;
-          break;
-        }
-        case 16000: {
-          codec_id = kPCM16Bwb_2ch;
-          break;
-        }
-        case 32000: {
-          codec_id = kPCM16Bswb32kHz_2ch;
-          break;
-        }
-        default: {
-          return NULL;
-        }
-      }
-    }
-    return new ACMPCM16B(codec_id, enable_red);
+    return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb,
+                                      cng_pt_swb, cng_pt_fb, enable_red,
+                                      red_payload_type);
 #endif
   } else if (!STR_CASE_CMP(codec_inst.plname, "telephone-event")) {
 #ifdef WEBRTC_CODEC_AVT


Guardian : fix update frequency

Guardian : fix update frequency

--- modules/canbus/vehicle/lincoln/lincoln_controller.cc
+++ modules/canbus/vehicle/lincoln/lincoln_controller.cc
@@ -869,7 +869,7 @@
       (chassis_detail.safety().is_passenger_detected() &&
        (!chassis_detail.safety().is_passenger_airbag_enabled() ||
         !chassis_detail.safety().is_passenger_buckled()));
-  AINFO << "Vehicle safety error status is : " << safety_error << endl;
+  ADEBUG << "Vehicle safety error status is : " << safety_error;
   return safety_error;
 }


core(simd): fix compilation with MSVC-Clang

--- modules/core/include/opencv2/core/hal/intrin_sse.hpp
+++ modules/core/include/opencv2/core/hal/intrin_sse.hpp
@@ -244,7 +244,7 @@
     explicit v_uint64x2(__m128i v) : val(v) {}
     v_uint64x2(uint64 v0, uint64 v1)
     {
-#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64)
+#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__)
         val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
 #elif defined(__GNUC__)
         val = _mm_setr_epi64((__m64)v0, (__m64)v1);
@@ -278,7 +278,7 @@
     explicit v_int64x2(__m128i v) : val(v) {}
     v_int64x2(int64 v0, int64 v1)
     {
-#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64)
+#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__)
         val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
 #elif defined(__GNUC__)
         val = _mm_setr_epi64((__m64)v0, (__m64)v1);


Fold:
   (X + (X << C2)) --> X * ((1 << C2) + 1)
   ((X << C2) + X) --> X * ((1 << C2) + 1)

This means that we now canonicalize "Y+Y+Y" into:

        %tmp.2 = mul long %Y, 3         ; <long> [#uses=1]

instead of:

        %tmp.10 = shl long %Y, ubyte 1          ; <long> [#uses=1]
        %tmp.6 = add long %Y, %tmp.10               ; <long> [#uses=1]

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@17701 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -617,6 +617,19 @@
   ConstantInt *C2;
   if (match(RHS, m_And(m_Value(), m_ConstantInt(C2))))
     if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2))) return R;
+
+  // (X + (X << C2)) --> X * ((1 << C2) + 1)
+  // ((X << C2) + X) --> X * ((1 << C2) + 1)
+  Value *Tmp;
+  if ((RHS->hasOneUse() && match(RHS, m_Shl(m_Value(Tmp),
+                                            m_ConstantInt(C2))) && LHS == Tmp)||
+      (LHS->hasOneUse() && match(LHS, m_Shl(m_Value(Tmp),
+                                            m_ConstantInt(C2))) && RHS == Tmp)){
+    ConstantInt *One = ConstantInt::get(LHS->getType(), 1);
+    Constant *NewRHS =
+      ConstantExpr::getAdd(ConstantExpr::getShl(One, C2), One);
+    return BinaryOperator::createMul(Tmp, NewRHS);
+  }

   if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
     Value *X;


Use interned strings as dictionary keys.

--- src/appleseed/foundation/containers/dictionary.cpp
+++ src/appleseed/foundation/containers/dictionary.cpp
@@ -41,8 +41,8 @@
 namespace foundation
 {

-typedef std::map<std::string, std::string> StringMap;
-typedef std::map<std::string, Dictionary> DictionaryMap;
+typedef std::map<InternedString, std::string> StringMap;
+typedef std::map<InternedString, Dictionary> DictionaryMap;

 //
@@ -185,7 +185,7 @@
     assert(key);
     assert(value);

-    impl->m_strings[key] = value;
+    impl->m_strings[InternedString(key)] = value;

     return *this;
 }
@@ -195,7 +195,7 @@
     assert(key);
     assert(value);

-    const StringMap::iterator i = impl->m_strings.find(key);
+    const StringMap::iterator i = impl->m_strings.find(InternedString(key));

     if (i == impl->m_strings.end())
         throw ExceptionDictionaryKeyNotFound(key);
@@ -209,7 +209,7 @@
 {
     assert(key);

-    const StringMap::const_iterator i = impl->m_strings.find(key);
+    const StringMap::const_iterator i = impl->m_strings.find(InternedString(key));

     if (i == impl->m_strings.end())
         throw ExceptionDictionaryKeyNotFound(key);
@@ -221,14 +221,14 @@
 {
     assert(key);

-    return impl->m_strings.find(key) != impl->m_strings.end();
+    return impl->m_strings.find(InternedString(key)) != impl->m_strings.end();
 }

 StringDictionary& StringDictionary::remove(const char* key)
 {
     assert(key);

-    const StringMap::iterator i = impl->m_strings.find(key);
+    const StringMap::iterator i = impl->m_strings.find(InternedString(key));

     if (i != impl->m_strings.end())
         impl->m_strings.erase(i);
@@ -465,7 +465,7 @@
 {
     assert(key);

-    impl->m_dictionaries[key] = value;
+    impl->m_dictionaries[InternedString(key)] = value;

     return *this;
 }
@@ -474,7 +474,7 @@
 {
     assert(key);

-    const DictionaryMap::iterator i = impl->m_dictionaries.find(key);
+    const DictionaryMap::iterator i = impl->m_dictionaries.find(InternedString(key));

     if (i == impl->m_dictionaries.end())
         throw ExceptionDictionaryKeyNotFound(key);
@@ -488,7 +488,7 @@
 {
     assert(key);

-    const DictionaryMap::iterator i = impl->m_dictionaries.find(key);
+    const DictionaryMap::iterator i = impl->m_dictionaries.find(InternedString(key));

     if (i == impl->m_dictionaries.end())
         throw ExceptionDictionaryKeyNotFound(key);
@@ -500,7 +500,7 @@
 {
     assert(key);

-    const DictionaryMap::const_iterator i = impl->m_dictionaries.find(key);
+    const DictionaryMap::const_iterator i = impl->m_dictionaries.find(InternedString(key));

     if (i == impl->m_dictionaries.end())
         throw ExceptionDictionaryKeyNotFound(key);
@@ -512,14 +512,14 @@
 {
     assert(key);

-    return impl->m_dictionaries.find(key) != impl->m_dictionaries.end();
+    return impl->m_dictionaries.find(InternedString(key)) != impl->m_dictionaries.end();
 }

 DictionaryDictionary& DictionaryDictionary::remove(const char* key)
 {
     assert(key);

-    const DictionaryMap::iterator i = impl->m_dictionaries.find(key);
+    const DictionaryMap::iterator i = impl->m_dictionaries.find(InternedString(key));

     if (i != impl->m_dictionaries.end())
         impl->m_dictionaries.erase(i);


This change fixed a bug in the function visitMul.  The prior version
assumed that a constant on the RHS of a multiplication was either an
IntConstant or an FPConstant.  It checked for an IntConstant and then,
if it did not find one, did a hard cast to an FPConstant.  That code
would crash if the RHS were a ConstantExpr that was neither an
IntConstant nor an FPConstant.  This version replaces the hard cast
with a dyn_cast.  It performs the same way for IntConstants and
FPConstants but does nothing, instead of crashing, for constant
expressions.

The regression test for this change is 2004-07-27-ConstantExprMul.ll.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@15291 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -509,8 +509,9 @@
   }

   // X + X --> X << 1
-  if (I.getType()->isInteger())
+  if (I.getType()->isInteger()) {
     if (Instruction *Result = AssociativeOpt(I, AddRHS(RHS))) return Result;
+  }

   // -A + B  -->  B - A
   if (Value *V = dyn_castNegVal(LHS))
@@ -745,8 +746,7 @@
       if (uint64_t C = Log2(Val))            // Replace X*(2^C) with X << C
         return new ShiftInst(Instruction::Shl, Op0,
                              ConstantUInt::get(Type::UByteTy, C));
-    } else {
-      ConstantFP *Op1F = cast<ConstantFP>(Op1);
+    } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
       if (Op1F->isNullValue())
         return ReplaceInstUsesWith(I, Op1);


Remove unused variables

Remove unused variables

--- src/appleseed/renderer/kernel/shading/closures.cpp
+++ src/appleseed/renderer/kernel/shading/closures.cpp
@@ -827,18 +827,19 @@
         {
             const Params* p = reinterpret_cast<const Params*>(osl_params);

+            // todo: reimplement.
             // Assume one of the media is air.
-            double from_ior, to_ior;
-            if (p->eta > 1.0f)
-            {
-                from_ior = 1.0;
-                to_ior = 1.0f / p->eta;
-            }
-            else
-            {
-                from_ior = p->eta;
-                to_ior = 1.0;
-            }
+            // double from_ior, to_ior;
+            // if (p->eta > 1.0f)
+            // {
+            //     from_ior = 1.0;
+            //     to_ior = 1.0f / p->eta;
+            // }
+            // else
+            // {
+            //     from_ior = p->eta;
+            //     to_ior = 1.0;
+            // }

             InputValues* values =
                 composite_closure.add_closure<InputValues>(
@@ -853,7 +854,7 @@
             values->m_transmittance_multiplier = 1.0;
             values->m_fresnel_multiplier = 0.0;

-            // todo
+            // todo: reimplement.
             // values->m_from_ior = from_ior;
             // values->m_to_ior = to_ior;
         }


fix a regression on vector or instructions.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@35314 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3636,9 +3636,8 @@
   bool Changed = SimplifyCommutative(I);
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);

-  if (isa<UndefValue>(Op1))
-    return ReplaceInstUsesWith(I,                         // X | undef -> -1
-                               ConstantInt::getAllOnesValue(I.getType()));
+  if (isa<UndefValue>(Op1))                       // X | undef -> -1
+    return ReplaceInstUsesWith(I, ConstantInt::getAllOnesValue(I.getType()));

   // or X, X = X
   if (Op0 == Op1)
@@ -3646,12 +3645,13 @@

   // See if we can simplify any instructions used by the instruction whose sole
   // purpose is to compute bits we don't care about.
-  uint32_t BitWidth = cast<IntegerType>(I.getType())->getBitWidth();
-  APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
-  if (!isa<VectorType>(I.getType()) &&
-      SimplifyDemandedBits(&I, APInt::getAllOnesValue(BitWidth),
-                           KnownZero, KnownOne))
-    return &I;
+  if (!isa<VectorType>(I.getType())) {
+    uint32_t BitWidth = cast<IntegerType>(I.getType())->getBitWidth();
+    APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
+    if (SimplifyDemandedBits(&I, APInt::getAllOnesValue(BitWidth),
+                             KnownZero, KnownOne))
+      return &I;
+  }

   // or X, -1 == -1
   if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {