/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation.
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
 * copy of the license can be found in the License.html file at the root of this distribution. If
 * you cannot locate the Apache License, Version 2.0, please send an email to
 * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
 * by the terms of the Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * ***************************************************************************/

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdio.h>

// Used by debugger to detect when DLL is fully loaded and initialized and TraceFunc can be registered.
extern "C" {
    __declspec(dllexport)
    volatile char isInitialized;

    __declspec(dllexport)
    void OnInitialized() {
        volatile char dummy = 0;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
        isInitialized = 1;
        OnInitialized();
    }

    return TRUE;
}

/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation.
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
 * copy of the license can be found in the License.html file at the root of this distribution. If
 * you cannot locate the Apache License, Version 2.0, please send an email to
 * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
 * by the terms of the Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * ***************************************************************************/

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdio.h>

// Used by debugger to detect when DLL is fully loaded and initialized and TraceFunc can be registered.
extern "C" {
    __declspec(dllexport)
    volatile char isInitialized;

    __declspec(dllexport) __declspec(noinline)
    void OnInitialized() {
        volatile char dummy = 0;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
        isInitialized = 1;
        OnInitialized();
    }

    return TRUE;
}

Fix mixed-mode debugging on release PTVS builds.


//=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "il/GlobalArray.hpp"
#include "AssemblyFileWriter.hpp"

using namespace eddic;

GlobalArray::GlobalArray(std::string n, BaseType t, int s) : name(n), type(t), size(s) {}

void GlobalArray::write(AssemblyFileWriter& writer){
    writer.stream() << "VA" << name << ":" <<std::endl;
    writer.stream() << ".rept " << size << std::endl;

    if(type == BaseType::INT){
        writer.stream() << ".long 0" << std::endl;
    } else if(type == BaseType::STRING){
        writer.stream() << ".long S3" << std::endl;
        writer.stream() << ".long 0" << std::endl;
    }

    writer.stream() << ".endr" << std::endl;
}

//=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "il/GlobalArray.hpp"
#include "AssemblyFileWriter.hpp"

using namespace eddic;

GlobalArray::GlobalArray(std::string n, BaseType t, int s) : name(n), type(t), size(s) {}

void GlobalArray::write(AssemblyFileWriter& writer){
    writer.stream() << "VA" << name << ":" <<std::endl;
    writer.stream() << ".long " << size << std::endl;
    writer.stream() << ".rept " << size << std::endl;

    if(type == BaseType::INT){
        writer.stream() << ".long 0" << std::endl;
    } else if(type == BaseType::STRING){
        writer.stream() << ".long S3" << std::endl;
        writer.stream() << ".long 0" << std::endl;
    }

    writer.stream() << ".endr" << std::endl;
}

Include the size of the array in the array memory layout


/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file is part of the wikidata_cpp project:
 *     https://github.com/radupopescu/wikidata_cpp
 */

#include "data.h"

#include <rapidjson/Document.h>

#include <iostream>

namespace rj = rapidjson;

namespace data {

bool parseItem(const Languages& languages, const std::string& line, WikidataElement& elem)
{
  rj::Document j;
  j.Parse(line.substr(0, line.size() - 1).c_str());
  if (! j.HasParseError()) {
    if (j.HasMember("id")) {
      elem.id = j["id"].GetString();
      if (j.HasMember("sitelinks")) {
        const auto& s = j["sitelinks"].GetObject();
        for (const auto& l : languages) {
          const auto sitelink = l + "wiki";
          if (s.HasMember(sitelink.c_str())) {
            if (s[sitelink.c_str()].HasMember("title")) {
              elem.sites[l] = s[sitelink.c_str()]["title"].GetString();
            }
          }
        }
        return elem.sites.size() == languages.size();
      }
    }
  }

  return false;
}

}

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file is part of the wikidata_cpp project:
 *     https://github.com/radupopescu/wikidata_cpp
 */

#include "data.h"

#include <rapidjson/document.h>

#include <iostream>

namespace rj = rapidjson;

namespace data {

bool parseItem(const Languages& languages, const std::string& line, WikidataElement& elem)
{
  rj::Document j;
  j.Parse(line.substr(0, line.size() - 1).c_str());
  if (! j.HasParseError()) {
    if (j.HasMember("id")) {
      elem.id = j["id"].GetString();
      if (j.HasMember("sitelinks")) {
        const auto& s = j["sitelinks"].GetObject();
        for (const auto& l : languages) {
          const auto sitelink = l + "wiki";
          if (s.HasMember(sitelink.c_str())) {
            if (s[sitelink.c_str()].HasMember("title")) {
              elem.sites[l] = s[sitelink.c_str()]["title"].GetString();
            }
          }
        }
        return elem.sites.size() == languages.size();
      }
    }
  }

  return false;
}

}

Fix typo in include due to case insensitivity


#include <ros/ros.h>
#include <sensor_msgs/Imu.h>

int main(int argc, char **argv) {
  // Initialize ROS
  ros::init(argc, argv, "test_imu");
  ros::NodeHandle nh;

  // Create a publisher object
  ros::Publisher imuPub = nh.advertise<sensor_msgs::Imu>("imu/data",1);
  // Create an Imu message object
  sensor_msgs::Imu imuMsg;
  imuMsg.header.frame_id = "base_imu";
  // Create variables for yaw rate
  double yawRate = 0;
  imuMsg.header.stamp = ros::Time::now();
  imuMsg.angular_velocity.z = yawRate;
  imuPub.publish(imuMsg);

  ros::Rate loop_rate(30);
  while (ros::ok())
  {
    yawRate = 0;
    imuMsg.header.stamp = ros::Time::now();
    imuMsg.angular_velocity.z = yawRate;
    imuPub.publish(imuMsg);
    loop_rate.sleep();
  }
  return 0;
}

#include <ros/ros.h>
#include <sensor_msgs/Imu.h>

int main(int argc, char **argv) {
  // Initialize ROS
  ros::init(argc, argv, "test_imu");
  ros::NodeHandle nh;

  ros::NodeHandle private_nh("~");
  // Create variables for yaw rate
  double yawRate;
  if(!private_nh.getParam("rate", yawRate)) {
    yawRate = 0;
    ROS_WARN_STREAM("No rate was recieved. Using 0.0");
  }
  else {
    ROS_WARN_STREAM("Rate is " << yawRate);
  }

  // Create a publisher object
  ros::Publisher imuPub = nh.advertise<sensor_msgs::Imu>("imu/data",1);
  // Create an Imu message object
  sensor_msgs::Imu imuMsg;
  imuMsg.header.frame_id = "base_imu";
  imuMsg.header.stamp = ros::Time::now();
  imuMsg.angular_velocity.z = yawRate;
  imuPub.publish(imuMsg);

  ros::Rate loop_rate(30);
  while (ros::ok())
  {
    imuMsg.header.stamp = ros::Time::now();
    imuMsg.angular_velocity.z = yawRate;
    imuPub.publish(imuMsg);
    loop_rate.sleep();
  }
  return 0;
}

Use paramter to set yaw rate.

Use paramter to set yaw rate.


/// \file    main.cpp

#include "HelloTriangleApplication.hpp"
#include "VDeleter.hpp"

// waf-generated header
#include "config.hpp"

#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#include <iostream>
#include <string>

int main(int argc, char* argv[])
{
  int res{0};
#ifndef DOCTEST_CONFIG_DISABLE
  doctest::Context context;

  context.setOption("no-run", true);

  context.applyCommandLine(argc, argv);

  using namespace std::literals::string_literals;
  auto begin_argv = argv + 1;
  auto end_argv = argv + argc;
  if (end_argv != std::find(begin_argv, end_argv, "--test"s)) {
    context.setOption("no-run", false);
    context.setOption("exit", true);
  }

  res = context.run();
  if (context.shouldExit()) return res;
#endif
  HelloTriangleApplication app;

  try {
    app.run();
  }
  catch (const std::runtime_error& e) {
    std::cerr << e.what() << std::endl;
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS + res;
}

// vim:set et ts=2 sw=2 sts=2:

/// \file    main.cpp

#include "HelloTriangleApplication.hpp"
#include "VDeleter.hpp"

// waf-generated header
#include "config.hpp"

#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#include <iostream>
#include <string>

int main(int argc, char* argv[])
{
  int test_result{0};
#ifndef DOCTEST_CONFIG_DISABLE
  doctest::Context context;

  context.setOption("no-run", true);

  context.applyCommandLine(argc, argv);

  using namespace std::literals::string_literals;
  auto begin_argv = argv + 1;
  auto end_argv = argv + argc;
  if (end_argv != std::find(begin_argv, end_argv, "--test"s)) {
    context.setOption("no-run", false);
    context.setOption("exit", true);
  }

  test_result = context.run();
  if (context.shouldExit()) return test_result;
#endif
  HelloTriangleApplication app;

  try {
    app.run();
  }
  catch (const std::runtime_error& e) {
    std::cerr << e.what() << std::endl;
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS + test_result;
}

// vim:set et ts=2 sw=2 sts=2:

Rename 'res' variable to 'test_result'

Rename 'res' variable to 'test_result'


#include <QtQuick>

#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>

#include "factor.h"

int main(int argc, char *argv[])
{
    // For this example, wizard-generates single line code would be good enough,
    // but very soon it won't be enough for you anyway, so use this more detailed example from start
    QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
    QScopedPointer<QQuickView> view(SailfishApp::createView());

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

//    Here's how you will add QML components whenever you start using them
//    Check https://github.com/amarchen/Wikipedia for a more full example
//    view->engine()->addImportPath(SailfishApp::pathTo("qml/components").toString());
    view->engine()->rootContext()->setContextProperty("fact", &fact);
    view->setSource(SailfishApp::pathTo("qml/main.qml"));

    view->setTitle("Sailfactor");

    app->setApplicationName("harbour-sailfactor");
    app->setApplicationDisplayName("Sailfactor");

    view->show();

    return app->exec();
}

#include <QtQuick>

#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>

#include "factor.h"

int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
    QScopedPointer<QQuickView> view(SailfishApp::createView());

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

    view->engine()->rootContext()->setContextProperty("fact", &fact);
    view->setSource(SailfishApp::pathTo("qml/main.qml"));

    view->setTitle("Sailfactor");

    app->setApplicationName("harbour-sailfactor");
    app->setApplicationDisplayName("Sailfactor");

    view->show();

    return app->exec();
}

Remove comments originating from Helloworld Pro...


//===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/Utility/LLDBAssert.h"

#include "llvm/Support/Format.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace lldb_private;

void lldb_private::lldb_assert(bool expression, const char *expr_text,
                               const char *func, const char *file,
                               unsigned int line) {
  if (expression)
    ;
  else {
    errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
                     expr_text, func, file, line);
    errs() << "backtrace leading to the failure:\n";
    llvm::sys::PrintStackTrace(errs());
    errs() << "please file a bug report against lldb reporting this failure "
              "log, and as many details as possible\n";
  }
}

//===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/Utility/LLDBAssert.h"

#include "llvm/Support/Format.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace lldb_private;

void lldb_private::lldb_assert(bool expression, const char *expr_text,
                               const char *func, const char *file,
                               unsigned int line) {
  if (LLVM_LIKELY(expression))
    return;

  errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
                   expr_text, func, file, line);
  errs() << "backtrace leading to the failure:\n";
  llvm::sys::PrintStackTrace(errs());
  errs() << "please file a bug report against lldb reporting this failure "
            "log, and as many details as possible\n";
  abort();
}

Terminate debugger if an assert was hit

Terminate debugger if an assert was hit

Reviewers: JDevlieghere, teemperor, #lldb

Reviewed By: JDevlieghere

Subscribers: clayborg, lemo, lldb-commits

Differential Revision: https://reviews.llvm.org/D51604

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@341387 91177308-0d34-0410-b5e6-96231b3b80d8


#if defined(WIN32) && !defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:WINDOWS /entry:mainCRTStartup")
#endif

#include "Application.h"

#include <memory>

#include <gloperate-qtapplication/Viewer.h>

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

    std::unique_ptr<gloperate_qtapplication::Viewer> viewer(new gloperate_qtapplication::Viewer()); // make_unique is C++14
    viewer->show();

    return app.exec();
}

#if defined(WIN32) && !defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:WINDOWS /entry:mainCRTStartup")
#endif

#include "Application.h"

#include <memory>

#include <gloperate-qtapplication/Viewer.h>

#include <widgetzeug/dark_fusion_style.hpp>

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

    widgetzeug::enableDarkFusionStyle();

    std::unique_ptr<gloperate_qtapplication::Viewer> viewer(new gloperate_qtapplication::Viewer()); // make_unique is C++14
    viewer->show();

    return app.exec();
}

Use dark theme in cgwhite

Use dark theme in cgwhite


#include <cstdlib>
#include <string.h>
#include <iostream>

int main() {
#ifdef __APPLE__
  const char* name = "DYLD_LIBRARY_PATH";
#else
  const char* name = "LD_LIBRARY_PATH";
#endif

  const char* cetLDPathValue = getenv("CETD_LIBRARY_PATH");
  int res = setenv("DYLD_LIBRARY_PATH", cetLDPathValue, 1);

  const char* localLDPathValue = getenv(name);

  if(strcmp(localLDPathValue,cetLDPathValue) != 0) {
    return 1;
  }
  std::cout << localLDPathValue << std::endl;

  return 0;
}

#include <cstdlib>
#include <string.h>
#include <iostream>

int main() {
#ifdef __APPLE__
  const char* name = "DYLD_LIBRARY_PATH";
#else
  const char* name = "LD_LIBRARY_PATH";
#endif

  const char* cetLDPathValue = getenv("CETD_LIBRARY_PATH");
  int res = setenv(name, cetLDPathValue, 1);

  if (res != 0) {
    std::cerr << "could not set " << name << std::endl;
    return 1;
  }

  const char* localLDPathValue = getenv(name);

  if(strcmp(localLDPathValue,cetLDPathValue) != 0) {
    return 1;
  }
  std::cout << localLDPathValue << std::endl;

  return 0;
}

Fix errors reported by Travis on Linux

Fix errors reported by Travis on Linux

- Use return value from setenv
- Use name variable for platform dependent dynamic path


/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include <dali/public-api/dali-core.h>

#include <application.h>
#include <adaptor.h>
#include <render-surface.h>
#include <orientation.h>
#include <timer.h>

using namespace Dali;

/*****************************************************************************
 * Test to see if the dali-adaptor is linking correctly.
 */

class LinkerApp : public ConnectionTracker
{
public:
  LinkerApp(Application &app)
  {
    app.InitSignal().Connect(this, &LinkerApp::Create);
  }

public:

  void Create(Application& app)
  {
  }
};

/*****************************************************************************/

int
main(int argc, char **argv)
{
  Application app = Application::New(&argc, &argv);
  LinkerApp linkerApp (app);
  app.MainLoop();

  return 0;
}

/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include <dali/public-api/dali-core.h>

#include <application.h>
#include <adaptor.h>
#include <render-surface.h>
#include <orientation.h>
#include <timer.h>
#include <iostream>

using namespace Dali;

/*****************************************************************************
 * Test to see if the dali-adaptor is linking correctly.
 */

class LinkerApp : public ConnectionTracker
{
public:
  LinkerApp(Application &app)
  {
    app.InitSignal().Connect(this, &LinkerApp::Create);
  }

public:

  void Create(Application& app)
  {
  }
};

/*****************************************************************************/

int
main(int argc, char **argv)
{
  Application app = Application::New(&argc, &argv);

  try
  {
    LinkerApp linkerApp (app);
    app.MainLoop();
  }
  catch(...)
  {
    std::cout << "Exception caught";
  }

  return 0;
}

Fix prevent issue - uncaught exception

Fix prevent issue - uncaught exception

In function main(int, char **) an exception of type Dali::DaliException is thrown and never caught.
MainLoop() may throw an exception.

Change-Id: Iaa61013fd07a287e360fb37d0a3548c7ea33343c


// The main caffe test code. Your test cpp code should include this hpp
// to allow a main function to be compiled into the binary.

#include "caffe/caffe.hpp"
#include "caffe/test/test_caffe_main.hpp"

namespace caffe {
#ifndef CPU_ONLY
  cudaDeviceProp CAFFE_TEST_CUDA_PROP;
#endif
}

#ifndef CPU_ONLY
using caffe::CAFFE_TEST_CUDA_PROP;
#endif

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  caffe::GlobalInit(&argc, &argv);
#ifndef CPU_ONLY
  // Before starting testing, let's first print out a few cuda defice info.
  int device;
  cudaGetDeviceCount(&device);
  cout << "Cuda number of devices: " << device << endl;
  if (argc > 1) {
    // Use the given device
    device = atoi(argv[1]);
    cudaSetDevice(device);
    cout << "Setting to use device " << device << endl;
  } else if (CUDA_TEST_DEVICE >= 0) {
    // Use the device assigned in build configuration; but with a lower priority
    device = CUDA_TEST_DEVICE;
  }
  cudaGetDevice(&device);
  cout << "Current device id: " << device << endl;
  cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device);
  cout << "Current device name: " << CAFFE_TEST_CUDA_PROP.name << endl;
#endif
  // invoke the test.
  return RUN_ALL_TESTS();
}

Remove misleading comment from a test file


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "../client/gles2_lib.h"
#include "../common/thread_local.h"

namespace gles2 {
namespace {
gpu::ThreadLocalKey g_gl_context_key;
}  // namespace anonymous

void Initialize() {
  g_gl_context_key = gpu::ThreadLocalAlloc();
}

void Terminate() {
  gpu::ThreadLocalFree(g_gl_context_key);
  g_gl_context_key = 0;
}

gpu::gles2::GLES2Implementation* GetGLContext() {
  return static_cast<gpu::gles2::GLES2Implementation*>(
    gpu::ThreadLocalGetValue(g_gl_context_key));
}

void SetGLContext(gpu::gles2::GLES2Implementation* context) {
  gpu::ThreadLocalSetValue(g_gl_context_key, context);
}
}  // namespace gles2

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "../client/gles2_lib.h"
#include "../common/thread_local.h"

namespace gles2 {
// TODO(kbr): the use of this anonymous namespace core dumps the
// linker on Mac OS X 10.6 when the symbol ordering file is used
// namespace {
static gpu::ThreadLocalKey g_gl_context_key;
// }  // namespace anonymous

void Initialize() {
  g_gl_context_key = gpu::ThreadLocalAlloc();
}

void Terminate() {
  gpu::ThreadLocalFree(g_gl_context_key);
  g_gl_context_key = 0;
}

gpu::gles2::GLES2Implementation* GetGLContext() {
  return static_cast<gpu::gles2::GLES2Implementation*>(
    gpu::ThreadLocalGetValue(g_gl_context_key));
}

void SetGLContext(gpu::gles2::GLES2Implementation* context) {
  gpu::ThreadLocalSetValue(g_gl_context_key, context);
}
}  // namespace gles2

Work around bug in gcc's name mangling causing linker to crash on Mac
OS X.

BUG=40845
TEST=none
TBR=gman

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

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


#include "dafs/node.hpp"

namespace dafs
{
    Node::Node()
        : slot_minus(dafs::Root("p-minus")),
          slot_zero(dafs::Root("p-zero")),
          slot_plus(dafs::Root("p-plus"))
    {
    }

    dafs::Partition&
    Node::GetPartition(Slot slot)
    {
        switch (slot)
        {
            case Slot::Minus:
            {
                return slot_minus;
            }
            case Slot::Zero:
            {
                return slot_zero;
            }
            case Slot::Plus:
            {
                return slot_plus;
            }
        }
    }

    dafs::Partition&
    Node::GetPartition(Identity identity)
    {
        return slot_zero;
    }
}

#include "dafs/node.hpp"

namespace dafs
{
    Node::Node()
        : slot_minus(dafs::Root("p-minus")),
          slot_zero(dafs::Root("p-zero")),
          slot_plus(dafs::Root("p-plus"))
    {
    }

    dafs::Partition&
    Node::GetPartition(Slot slot)
    {
        switch (slot)
        {
            case Slot::Minus:
            {
                return slot_minus;
            }
            case Slot::Zero:
            {
                return slot_zero;
            }
            case Slot::Plus:
            {
                return slot_plus;
            }
        }
    }

    dafs::Partition&
    Node::GetPartition(Identity identity)
    {
        if (identity < slot_minus.GetIdentity())
        {
            return slot_minus;
        }
        else if (slot_plus.GetIdentity() < identity)
        {
            return slot_plus;
        }
        else
        {
            return slot_zero;
        }
    }
}

Implement identity to partition association


#include <iostream>

static constexpr unsigned getSequenceLength(unsigned number) noexcept
{
        unsigned length = 0;

        while (number != 1) {
                if ((number & 1) == 0) {
                        number >>= 1;
                } else {
                        number = 3 * number + 1;
                }

                ++length;
        }

        return length;
}

int main(int count, char *arguments[])
{
        unsigned number = 999999;
        unsigned maximum = 0;

        for (unsigned i = 999999; i > 0; --i) {
                unsigned length = getSequenceLength(i);

                if (length > maximum) {
                        maximum = length;
                        number = i;
                }
        }

        std::cout << number << '\n';
        return 0;
}

#include <iostream>

static constexpr unsigned getSequenceLength(unsigned number) noexcept
{
        unsigned length = 0;

        while (number != 1) {
                if ((number & 1) == 0) {
                        number >>= 1;
                } else {
                        number = 3 * number + 1;
                }

                ++length;
        }

        return length;
}

int main(int count, char *arguments[])
{
        unsigned number = 999999;
        unsigned sequenceLength = 0;

        for (unsigned i = 999999; i > 0; --i) {
                unsigned length = getSequenceLength(i);

                if (length > sequenceLength) {
                        number = i;
                        sequenceLength = length;
                }
        }

        std::cout << number << '\n';
        return 0;
}

Switch to better variable name

Switch to better variable name


// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Conditions/SelfCondition.hpp>
#include <Rosetta/Games/Game.hpp>
#include <utility>

namespace RosettaStone
{
SelfCondition::SelfCondition(std::function<bool(Entity*)> func)
    : m_func(std::move(func))
{
    // Do nothing
}

SelfCondition SelfCondition::IsControllingRace(Race race)
{
    return SelfCondition([&](Entity* entity) -> bool {
        for (auto& minion : entity->GetOwner().GetField().GetAllMinions())
        {
            if (minion->card.race == race)
            {
                return true;
            }
        }

        return false;
    });
}

bool SelfCondition::Evaluate(Entity* entity) const
{
    return m_func(entity);
}
}  // namespace RosettaStone

// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Conditions/SelfCondition.hpp>
#include <Rosetta/Games/Game.hpp>
#include <utility>

namespace RosettaStone
{
SelfCondition::SelfCondition(std::function<bool(Entity*)> func)
    : m_func(std::move(func))
{
    // Do nothing
}

SelfCondition SelfCondition::IsControllingRace(Race race)
{
    return SelfCondition([=](Entity* entity) -> bool {
        for (auto& minion : entity->GetOwner().GetField().GetAllMinions())
        {
            if (minion->card.race == race)
            {
                return true;
            }
        }

        return false;
    });
}

bool SelfCondition::Evaluate(Entity* entity) const
{
    return m_func(entity);
}
}  // namespace RosettaStone

fix: Correct invalid capture (reference -> value)


// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stdio.h>

#include "Arduino.h"

extern "C" {
    size_t _write(int handle, const unsigned char *buf, size_t bufSize)
    {
        /* Check for the command to flush all handles */
        if (handle == -1) {
            return 0;
        }

        /* Check for stdout and stderr (only necessary if FILE descriptors are enabled.) */
        if (handle != 1 && handle != 2) {
            return -1;
        }

        size_t nChars = 0;
        for (; bufSize > 0; --bufSize, ++buf, ++nChars) {
            Serial.write(*buf);
        }
        return nChars;
    }
}

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stdio.h>

#include "Arduino.h"

asm(".global _printf_float");
asm(".global _scanf_float");

extern "C" {
    size_t _write(int handle, const unsigned char *buf, size_t bufSize)
    {
        /* Check for the command to flush all handles */
        if (handle == -1) {
            return 0;
        }

        /* Check for stdout and stderr (only necessary if FILE descriptors are enabled.) */
        if (handle != 1 && handle != 2) {
            return -1;
        }

        size_t nChars = 0;
        for (; bufSize > 0; --bufSize, ++buf, ++nChars) {
            Serial.write(*buf);
        }
        return nChars;
    }
}

Add reference to _printf_float and _scanf_float so they are linked by linker


#include "gtest\gtest.h"
#include "TiledFixture.h"

TEST_F(TiledFixture, map_attributes_should_be_parsed)
{

    ASSERT_EQ("1.0", _parsedMap->get_version());
    ASSERT_EQ("1.0.3", _parsedMap->get_tiledVersion());
    ASSERT_EQ(Orientation::ORTOGNAL, _parsedMap->get_orientation());
    ASSERT_EQ(RenderOrder::RIGHT_DOWN, _parsedMap->get_renderOrder());
    ASSERT_EQ(10, _parsedMap->get_width());
    ASSERT_EQ(10, _parsedMap->get_height());
    ASSERT_EQ(32, _parsedMap->get_tileWidth());
    ASSERT_EQ(32, _parsedMap->get_tileHeight());
}

TEST_F(TiledFixture, map_should_have_TestObject_parsed)
{
    auto group = _parsedMap->getObjectGroup("TestObject");

    ASSERT_EQ(group.get_name(), "TestObject");
}

Test for map that check objectgroup

ADD: Test for map that check objectgroup


#include "About.h"

#include "../resource.h"
#include "../Updater/Updater.h"
#include "../Updater/Version.h"

void About::Initialize() {
    INIT_CONTROL(LBL_TITLE, Label, _title);

    std::wstring version = Updater::MainAppVersionString();
    _title.Text(L"3RVX " + version);
}

void About::LoadSettings() {

}

void About::SaveSettings() {

}

#include "About.h"

#include "../resource.h"
#include "../Updater/Updater.h"
#include "../Updater/Version.h"

void About::Initialize() {
    INIT_CONTROL(LBL_TITLE, Label, _title);

    std::wstring version = Updater::MainAppVersion().ToString();
    _title.Text(L"3RVX " + version);
}

void About::LoadSettings() {

}

void About::SaveSettings() {

}

Use new version ToString method

Use new version ToString method


// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.

#include "ApplicationLinux.h"

int main(int argc, char* argv[])
{
    ouzel::ApplicationLinux application(argc, argv);

    return application.run();
}

// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.

#include "EngineLinux.h"

int main(int argc, char* argv[])
{
    ouzel::EngineLinux engine(argc, argv);

    return engine.run();
}

Fix engine initialization on Linux

Fix engine initialization on Linux


// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "xwalk/dbus/dbus_manager.h"

#include <glib.h>
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
#include "dbus/bus.h"

namespace xwalk {

DBusManager::DBusManager() {}

DBusManager::~DBusManager() {
  if (session_bus_)
    session_bus_->ShutdownOnDBusThreadAndBlock();
}

scoped_refptr<dbus::Bus> DBusManager::session_bus() {
  if (!session_bus_) {
    base::Thread::Options thread_options;
    thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
    std::string thread_name = "Crosswalk D-Bus thread";
    dbus_thread_.reset(new base::Thread(thread_name.c_str()));
    dbus_thread_->StartWithOptions(thread_options);

    dbus::Bus::Options options;
    options.dbus_task_runner = dbus_thread_->message_loop_proxy();

    // On Tizen 2.x DBUS_SESSION_ADDRESS points to a wrong path, so we set
    // the correct one here.
    options.bus_type = dbus::Bus::CUSTOM_ADDRESS;
    options.address = base::StringPrintf(
        "unix:path=/run/user/%s/dbus/user_bus_socket", g_get_user_name());

    session_bus_ = new dbus::Bus(options);
  }

  return session_bus_;
}

}  // namespace xwalk

// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "xwalk/dbus/dbus_manager.h"

#include <glib.h>
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
#include "dbus/bus.h"

namespace xwalk {

DBusManager::DBusManager() {}

DBusManager::~DBusManager() {
  if (session_bus_)
    session_bus_->ShutdownOnDBusThreadAndBlock();
}

scoped_refptr<dbus::Bus> DBusManager::session_bus() {
  if (!session_bus_) {
    base::Thread::Options thread_options;
    thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
    std::string thread_name = "Crosswalk D-Bus thread";
    dbus_thread_.reset(new base::Thread(thread_name.c_str()));
    dbus_thread_->StartWithOptions(thread_options);

    dbus::Bus::Options options;
    options.dbus_task_runner = dbus_thread_->message_loop_proxy();

    session_bus_ = new dbus::Bus(options);
  }

  return session_bus_;
}

}  // namespace xwalk

[Tizen][Runtime] Fix session bus issue under service mode.

Tizen 3.x and Tizen 2.x have different DBUS_SESSION_ADDRESS values.
For Tizen 2.x, DBUS_SESSION_ADDRESS points to
'/run/user/$USERNAME/dbus/user_bus_socket',
while for Tizen 3.x, DBUS_SESSION_ADDRESS points to
'/run/user/$UID/dbus/user_bus_socket'.

Since Crosswalk switches to Tizen 3.x, we need to use the latter one.

BUG=XWALK-1112


#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>

#include <cppunit/TestRunner.h>

#include "Suite.h"

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{

    setUpSuite();

    // Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that colllects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
    runner.run( controller );

    // Print test in a compiler compatible format.
    CPPUNIT_NS::CompilerOutputter* outputter =
        CPPUNIT_NS::CompilerOutputter::defaultOutputter(&result, std::cout);
    outputter->write();
    delete outputter;

    tearDownSuite();

    return result.wasSuccessful() ? 0 : 1;

}

#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>

#include <cppunit/TestRunner.h>

#include "Suite.h"

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{

    setUpSuite();

    // Create the event manager and test controller
    CPPUNIT_NS::TestResult controller;

    // Add a listener that colllects test result
    CPPUNIT_NS::TestResultCollector result;
    controller.addListener( &result );

    // Add a listener that print dots as test run.
    CPPUNIT_NS::BriefTestProgressListener progress;
    controller.addListener( &progress );

    // Add the top suite to the test runner
    CPPUNIT_NS::TestRunner runner;
    runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
    runner.run( controller );

    // Print test results to a file
	std::ofstream ofile("OgreTestResults.log");

    CPPUNIT_NS::CompilerOutputter* outputter =
        CPPUNIT_NS::CompilerOutputter::defaultOutputter(&result, ofile);
    outputter->write();
    delete outputter;

    tearDownSuite();

    return result.wasSuccessful() ? 0 : 1;

}

Write test results to a file for easier examination

--HG--
extra : convert_revision : svn%3A8631bf8a-c64b-0410-883c-f3eb003322f7/trunk%40570


// Copyright (c) 2008 The Chromium Authors. All rights reserved.  Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.

#include "config.h"
#include "PluginData.h"

#include "PluginInfoStore.h"

#undef LOG
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webkit_glue.h"

namespace WebCore {

static bool refreshData = false;

void PluginData::initPlugins()
{
    std::vector<WebPluginInfo> plugins;
    if (!webkit_glue::GetPlugins(refreshData, &plugins))
        return;
    refreshData = false;

    PluginInfoStore c;
    for (size_t i = 0; i < plugins.size(); ++i) {
        PluginInfo* info = c.createPluginInfoForPluginAtIndex(i);
        m_plugins.append(info);
    }
}

void PluginData::refresh()
{
    // When next we initialize a PluginData, it'll be fresh.
    refreshData = true;
}

}

// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "config.h"
#include "PluginData.h"

#include "PluginInfoStore.h"

namespace WebCore {

void PluginData::initPlugins()
{
    PluginInfoStore c;
    for (size_t i = 0; i < c.pluginCount(); ++i)
        m_plugins.append(c.createPluginInfoForPluginAtIndex(i));
}

void PluginData::refresh()
{
    refreshPlugins(true);
}

}

Fix plugin data refreshing to work again.

R=ojan

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

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

Former-commit-id: 4c0c598fbab45f3990c86de4f79b5cd504acf1e8


// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

struct X1 {
  X1();
};

struct X2 {
  X2();
  ~X2();
};

void vararg(...);

void f(X1 x1, X2 x2) {
  vararg(x1); // okay
  vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
}

namespace PR11131 {
  struct S;

  S &getS();

  void f(...);

  void g() {
    (void)sizeof(f(getS()));
  }
}

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

struct X1 {
  X1();
};

struct X2 {
  X2();
  ~X2();
};

struct X3 {
  X3(const X3&) = default;
};

struct X4 {
  X4(const X4&) = default;
  X4(X4&);
};

void vararg(...);

void f(X1 x1, X2 x2, X3 x3, X4 x4) {
  vararg(x1); // OK
  vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
  vararg(x3); // OK
  vararg(x4); // expected-error{{cannot pass object of non-trivial type 'X4' through variadic function; call will abort at runtime}}
}

namespace PR11131 {
  struct S;

  S &getS();

  void f(...);

  void g() {
    (void)sizeof(f(getS()));
  }
}

Test that we correctly deal with multiple copy constructors when detecting
non-trivial special members for varargs calls.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@168476 91177308-0d34-0410-b5e6-96231b3b80d8


#include "ExecutableLauncherUnix.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>

using namespace clt::filesystem::operations;

void ExecutableLauncherUnix::execute(const entities::Path & path)
{
	pid_t cpid;

	cpid = fork();

	switch (cpid) {
		case -1: perror("fork");
			break;

		case 0:
			execl(path.getValue().c_str(), ""); /* this is the child */
			_exit(EXIT_FAILURE);
			break;

		default: waitpid(cpid, NULL, 0);
	}
}

#include "ExecutableLauncherUnix.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>

using namespace clt::filesystem::operations;

void ExecutableLauncherUnix::execute(const entities::Path & path)
{
	pid_t cpid;

	cpid = fork();

	switch (cpid) {
		case -1: perror("fork");
			break;

		case 0:
			execl(path.getValue().c_str(), path.getValue().c_str(), NULL, NULL); /* this is the child */
			_exit(EXIT_FAILURE);
			break;

		default: waitpid(cpid, NULL, 0);
	}
}

Add first parameter when launching executable for unix


#include "heapsort.hpp"
#include "heap.hpp"
#include "swap.hpp"

void heapsort(int *data, const int size_of_data)
{
    binary_max_heap(data, size_of_data - 1);

    do_heapsort(data, size_of_data - 1);
}

void do_heapsort(int *data, const int end)
{
    if(end <= 0) return;

    int k = 0;
    swap(data[k], data[end]); /* data[end] has been sorted and from now, should NOT touch */

    while(true)
    {
        if(2 * k + 2 < end) /* Have two child nodes */
        {
            if(data[k] < data[2 * k + 1] && data[2 * k + 1] >= data[2 * k + 2])
            {
                swap(data[k], data[2 * k + 1]);
                k = 2 * k + 1;
            }
            else if(data[k] < data[2 * k + 2])
            {
                swap(data[k], data[2 * k + 2]);
                k = 2 * k + 2;
            }
            else break;
        }
        else if(2 * k + 1 < end && data[k] < data[2 * k + 1]) /* Have one leaf node */
        {
            swap(data[k], data[2 * k + 1]);
            k = 2 * k + 1;
        }
        else break;
    }

    return do_heapsort(data, end - 1);
}

#include "heapsort.hpp"
#include "heap.hpp"
#include "swap.hpp"

void heapsort(int *data, const int size_of_data)
{
    convert_to_binary_max_heap(data, size_of_data);
    do_heapsort(data, size_of_data - 1);
}

void do_heapsort(int *data, const int end)
{
    if(end <= 0) return;

    int k = 0;
    swap(data[k], data[end]); /* data[end] has been sorted and from now, should NOT touch */

    while(true)
    {
        if(2 * k + 2 < end) /* Have two child nodes */
        {
            if(data[k] < data[2 * k + 1] && data[2 * k + 1] >= data[2 * k + 2])
            {
                swap(data[k], data[2 * k + 1]);
                k = 2 * k + 1;
            }
            else if(data[k] < data[2 * k + 2])
            {
                swap(data[k], data[2 * k + 2]);
                k = 2 * k + 2;
            }
            else break;
        }
        else if(2 * k + 1 < end && data[k] < data[2 * k + 1]) /* Have one leaf node */
        {
            swap(data[k], data[2 * k + 1]);
            k = 2 * k + 1;
        }
        else break;
    }

    return do_heapsort(data, end - 1);
}

Fix the not matching function declaration

* This commit due to commit a8da5935adc8054bf1f1eefc1e61395f336f40ff


#define BOOST_TEST_MODULE Bitcoin Test Suite
#include <boost/test/unit_test.hpp>

#include "db.h"
#include "txdb.h"
#include "main.h"
#include "wallet.h"

CWallet* pwalletMain;
CClientUIInterface uiInterface;

extern bool fPrintToConsole;
extern void noui_connect();

struct TestingSetup {
    CCoinsViewDB *pcoinsdbview;

    TestingSetup() {
        fPrintToDebugger = true; // don't want to write to debug.log file
        noui_connect();
        bitdb.MakeMock();
        pblocktree = new CBlockTreeDB(true);
        pcoinsdbview = new CCoinsViewDB(true);
        pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
        LoadBlockIndex();
        bool fFirstRun;
        pwalletMain = new CWallet("wallet.dat");
        pwalletMain->LoadWallet(fFirstRun);
        RegisterWallet(pwalletMain);
    }
    ~TestingSetup()
    {
        delete pwalletMain;
        pwalletMain = NULL;
        delete pcoinsTip;
        delete pcoinsdbview;
        delete pblocktree;
        bitdb.Flush(true);
    }
};

BOOST_GLOBAL_FIXTURE(TestingSetup);

void Shutdown(void* parg)
{
  exit(0);
}

void StartShutdown()
{
  exit(0);
}

#define BOOST_TEST_MODULE Bitcoin Test Suite
#include <boost/test/unit_test.hpp>

#include "db.h"
#include "txdb.h"
#include "main.h"
#include "wallet.h"

CWallet* pwalletMain;
CClientUIInterface uiInterface;

extern bool fPrintToConsole;
extern void noui_connect();

struct TestingSetup {
    CCoinsViewDB *pcoinsdbview;

    TestingSetup() {
        fPrintToDebugger = true; // don't want to write to debug.log file
        noui_connect();
        bitdb.MakeMock();
        pblocktree = new CBlockTreeDB(1 << 20, true);
        pcoinsdbview = new CCoinsViewDB(1 << 23, true);
        pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
        LoadBlockIndex();
        bool fFirstRun;
        pwalletMain = new CWallet("wallet.dat");
        pwalletMain->LoadWallet(fFirstRun);
        RegisterWallet(pwalletMain);
    }
    ~TestingSetup()
    {
        delete pwalletMain;
        pwalletMain = NULL;
        delete pcoinsTip;
        delete pcoinsdbview;
        delete pblocktree;
        bitdb.Flush(true);
    }
};

BOOST_GLOBAL_FIXTURE(TestingSetup);

void Shutdown(void* parg)
{
  exit(0);
}

void StartShutdown()
{
  exit(0);
}

Fix tests after cache tweaks

Fix tests after cache tweaks


#include "mock/unittest_utils.hpp"

#include <stdlib.h>

#include "errors.hpp"
#include <boost/bind.hpp>

#include "arch/timing.hpp"
#include "arch/runtime/starter.hpp"
#include "utils.hpp"            // randint

namespace mock {

temp_file_t::temp_file_t(const char *tmpl) {
    size_t len = strlen(tmpl);
    filename.init(len + 1);
    memcpy(filename.data(), tmpl, len+1);
    int fd = mkstemp(filename.data());
    guarantee_err(fd != -1, "Couldn't create a temporary file");
    close(fd);
}

temp_file_t::~temp_file_t() {
    unlink(filename.data());
}

void let_stuff_happen() {
    nap(100);
}

int randport() {
    return 10000 + randint(20000);
}

void run_in_thread_pool(const boost::function<void()>& fun, int num_workers) {
    ::run_in_thread_pool(fun, num_workers);
}

}  // namespace mock

#include "mock/unittest_utils.hpp"

#include <stdlib.h>

#include "errors.hpp"
#include <boost/bind.hpp>

#include "arch/timing.hpp"
#include "arch/runtime/starter.hpp"
#include "utils.hpp"            // randint

namespace mock {

temp_file_t::temp_file_t(const char *tmpl) {
    size_t len = strlen(tmpl);
    filename.init(len + 1);
    memcpy(filename.data(), tmpl, len+1);
    int fd = mkstemp(filename.data());
    guarantee_err(fd != -1, "Couldn't create a temporary file");
    close(fd);
}

temp_file_t::~temp_file_t() {
    unlink(filename.data());
}

void let_stuff_happen() {
#ifdef VALGRIND
    nap(2000);
#else
    nap(100);
#endif
}

int randport() {
    return 10000 + randint(20000);
}

void run_in_thread_pool(const boost::function<void()>& fun, int num_workers) {
    ::run_in_thread_pool(fun, num_workers);
}

}  // namespace mock

Make let_stuff_happen() wait longer under valgrind.


#include "lua.h"

extern "C"
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
__declspec(dllimport)
#endif
int luaopen_luapbintf(lua_State* L);

int main() {
    void * p = static_cast<void*>(luaopen_luapbintf);
    return 0;
}

#include "lua.h"

extern "C"
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
__declspec(dllimport)
#endif
int luaopen_luapbintf(lua_State* L);

int main() {
    int (*pFun)(lua_State*);
    pFun = luaopen_luapbintf;
    return 0;
}

Fix error: invalid static_cast from type ‘int(lua_State*)’ to type ‘void*’


/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/mlir/quantization/tensorflow/utils/quant_spec.h"

#include <memory>

#include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"

namespace mlir {
namespace quant {

std::unique_ptr<OpQuantScaleSpec> GetTfQuantScaleSpec(Operation* op) {
  auto scale_spec = std::make_unique<OpQuantScaleSpec>();
  if (llvm::isa<
          // clang-format off
          // go/keep-sorted start
          TF::IdentityOp,
          TF::MaxPoolOp,
          TF::ReshapeOp
          // go/keep-sorted end
          // clang-format on
          >(op)) {
    scale_spec->has_same_scale_requirement = true;
  }
  return scale_spec;
}

}  // namespace quant
}  // namespace mlir

/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/mlir/quantization/tensorflow/utils/quant_spec.h"

#include <memory>

#include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"

namespace mlir {
namespace quant {

std::unique_ptr<OpQuantScaleSpec> GetTfQuantScaleSpec(Operation* op) {
  auto scale_spec = std::make_unique<OpQuantScaleSpec>();
  if (llvm::isa<
          // clang-format off
          // go/keep-sorted start
          TF::ConcatV2Op,
          TF::IdentityOp,
          TF::MaxPoolOp,
          TF::ReshapeOp
          // go/keep-sorted end
          // clang-format on
          >(op)) {
    scale_spec->has_same_scale_requirement = true;
  }
  return scale_spec;
}

}  // namespace quant
}  // namespace mlir

Add ConcatV2 to the list of same scale ops

PiperOrigin-RevId: 436378646


#include <scriptzeug/ScriptContext.h>
#include <scriptzeug/Backend/AbstractScriptContext.h>
#include "BackendDuktape/DuktapeScriptContext.h"
#ifdef LIBZEUG_USE_V8
    #include "BackendJavaScript/JSScriptContext.h"
#endif

using namespace reflectionzeug;
namespace scriptzeug
{

ScriptContext::ScriptContext(const std::string & backend)
: m_backend(nullptr)
{
    // Create backend
    if (backend == "duktape")
        m_backend = new DuktapeScriptContext(this);

#ifdef LIBZEUG_USE_V8
    if (backend == "javascript")
        m_backend = new JSScriptContext(this);
#endif
}

ScriptContext::~ScriptContext()
{
    // Release backend
    if (m_backend)
        delete m_backend;
}

void ScriptContext::registerObject(reflectionzeug::PropertyGroup * obj)
{
    if (m_backend)
        m_backend->registerObject(obj);
}

Variant ScriptContext::evaluate(const std::string & code)
{
    if (m_backend)
        return m_backend->evaluate(code);
    else
        return Variant();
}

} // namespace scriptzeug

#include <scriptzeug/ScriptContext.h>
#include <scriptzeug/Backend/AbstractScriptContext.h>
#include "BackendDuktape/DuktapeScriptContext.h"
#ifdef LIBZEUG_USE_V8
    #include "BackendJavaScript/JSScriptContext.h"
#endif

using namespace reflectionzeug;
namespace scriptzeug
{

ScriptContext::ScriptContext(const std::string & backend)
: m_backend(nullptr)
{
    // Create backend

    // Javascript (default: duktape)

    // Duktape
    if (backend == "duktape" || backend == "javascript" || backend == "js") {
        m_backend = new DuktapeScriptContext(this);
    }

    // V8
#ifdef LIBZEUG_USE_V8
    else if (backend == "v8") {
        m_backend = new JSScriptContext(this);
    }
#endif
}

ScriptContext::~ScriptContext()
{
    // Release backend
    if (m_backend)
        delete m_backend;
}

void ScriptContext::registerObject(reflectionzeug::PropertyGroup * obj)
{
    if (m_backend)
        m_backend->registerObject(obj);
}

Variant ScriptContext::evaluate(const std::string & code)
{
    if (m_backend)
        return m_backend->evaluate(code);
    else
        return Variant();
}

} // namespace scriptzeug

Make "duktape" the default javascript backend


//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// debug.cpp: Debugging utilities.

#include "common/debug.h"

#include <stdio.h>
#include <stdarg.h>

namespace gl
{
void trace(const char *format, ...)
{
    if (true)
    {
        if (format)
        {
            FILE *file = fopen("debug.txt", "a");

            if (file)
            {
                va_list vararg;
                va_start(vararg, format);
                vfprintf(file, format, vararg);
                va_end(vararg);

                fclose(file);
            }
        }
    }
}
}

//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// debug.cpp: Debugging utilities.

#include "common/debug.h"

#include <stdio.h>
#include <stdarg.h>

static bool trace_on = true;

namespace gl
{
void trace(const char *format, ...)
{
    if (trace_on)
    {
        if (format)
        {
            FILE *file = fopen("debug.txt", "a");

            if (file)
            {
                va_list vararg;
                va_start(vararg, format);
                vfprintf(file, format, vararg);
                va_end(vararg);

                fclose(file);
            }
        }
    }
}
}

Make it easier to disable tracing

Make it easier to disable tracing

TRAC #11979

Signed-off-by: Shannon Woods
Signed-off-by: Daniel Koch

Author:    Andrew Lewycky

git-svn-id: a070b70d2b8c44c266a3870c0cddd9a0ee470458@178 736b8ea6-26fd-11df-bfd4-992fa37f6226


// RUN: %clang_cc1 -emit-llvm-only -verify %s
// PR6641

extern "C" int printf(const char *, ...);

struct Foo {
 Foo() : iFoo (2) {
  printf("%p\n", this);
 }
 int iFoo;
};

typedef Foo (*T)[3][4];

T bar() {
 return new Foo[2][3][4];
}

T bug(int i) {
  return new Foo[i][3][4];
}

void pr(T a) {
  for (int i = 0; i < 3; i++)
   for (int j = 0; j < 4; j++)
     printf("%p\n", a[i][j]);
}

Foo *test() {
  return new Foo[5];
}

int main() {
 T f =  bar();
 pr(f);
 f = bug(3);
 pr(f);

 Foo * g = test();
 for (int i = 0; i < 5; i++)
 printf("%d\n", g[i].iFoo);
 return 0;
}

// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
// PR6641

extern "C" int printf(const char *, ...);

struct Foo {
 Foo() : iFoo (2) {
  printf("%p\n", this);
 }
 int iFoo;
};

typedef Foo (*T)[3][4];

T bar() {
 return new Foo[2][3][4];
}

T bug(int i) {
  return new Foo[i][3][4];
}

void pr(T a) {
  for (int i = 0; i < 3; i++)
   for (int j = 0; j < 4; j++)
     printf("%p\n", a[i][j]);
}

Foo *test() {
  return new Foo[5];
}

int main() {
 T f =  bar();
 pr(f);
 f = bug(3);
 pr(f);

 Foo * g = test();
 for (int i = 0; i < 5; i++)
 printf("%d\n", g[i].iFoo);
 return 0;
}

// CHECK: call noalias i8* @_Znam
// CHECK: call noalias i8* @_Znam
// CHECK: call noalias i8* @_Znam

Check for some code gen. for PR6641 test.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@99526 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Björn Buchhold (buchhold@informatik.uni-freiburg.de)

#include <algorithm>
#include "DocsDB.h"
#include "../global/Constants.h"

// _____________________________________________________________________________
void DocsDB::init(const string& fileName) {
  _dbFile.open(fileName.c_str(), "r");
  if (_dbFile.empty()) {
    _size = 0;
  } else {
    off_t posLastOfft = _dbFile.getLastOffset(&_startOfOffsets);
    _size = (posLastOfft - _startOfOffsets) / sizeof(off_t);
  }
}

// _____________________________________________________________________________
string DocsDB::getTextExcerpt(Id cid) const {
  off_t ft[2];
  off_t& from = ft[0];
  off_t& to = ft[1];
  off_t at = _startOfOffsets + cid * sizeof(off_t);
  at += _dbFile.read(ft, sizeof(ft), at);
  while(to == from) {
    at += _dbFile.read(&to, sizeof(off_t), at);
  }
  assert(to > from);
  size_t nofBytes = static_cast<size_t>(to - from);
  string line(nofBytes, '\0');
  _dbFile.read(&line.front(), nofBytes, from);
  return line;
}

// Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Björn Buchhold (buchhold@informatik.uni-freiburg.de)

#include <algorithm>
#include "DocsDB.h"
#include "../global/Constants.h"

// _____________________________________________________________________________
void DocsDB::init(const string& fileName) {
  _dbFile.open(fileName.c_str(), "r");
  if (_dbFile.empty()) {
    _size = 0;
  } else {
    off_t posLastOfft = _dbFile.getLastOffset(&_startOfOffsets);
    _size = (posLastOfft - _startOfOffsets) / sizeof(off_t);
  }
}

// _____________________________________________________________________________
string DocsDB::getTextExcerpt(Id cid) const {
  off_t ft[2];
  off_t& from = ft[0];
  off_t& to = ft[1];
  off_t at = _startOfOffsets + cid * sizeof(off_t);
  at += _dbFile.read(ft, sizeof(ft), at);
  while(to == from) {
    at += _dbFile.read(&to, sizeof(off_t), at);
  }
  assert(to > from);
  size_t nofBytes = static_cast<size_t>(to - from);
  string line(nofBytes, '\0');
  // TODO in C++17 we'll get non-const pointer std::string::data() use it the
  _dbFile.read(&line.front(), nofBytes, from);
  return line;
}

Add TODO for C++17 non-const data()

Add TODO for C++17 non-const data()


// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "webkit/extensions/v8/playback_extension.h"

namespace extensions_v8 {

const char* kPlaybackExtensionName = "v8/PlaybackMode";

v8::Extension* PlaybackExtension::Get() {
  v8::Extension* extension = new v8::Extension(
      kPlaybackExtensionName,
      "(function () {"
      "  var orig_date = Date;"
      "  Math.random = function() {"
      "    return 0.5;"
      "  };"
      "  Date.__proto__.now = function() {"
      "    return new orig_date(1204251968254);"
      "  };"
      "  Date = function() {"
      "    return Date.now();"
      "  };"
      "})()");
    return extension;
}

}  // namespace extensions_v8

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "webkit/extensions/v8/playback_extension.h"

namespace extensions_v8 {

const char* kPlaybackExtensionName = "v8/PlaybackMode";

v8::Extension* PlaybackExtension::Get() {
  v8::Extension* extension = new v8::Extension(
      kPlaybackExtensionName,
      "(function () {"
      "  var orig_date = Date;"
      "  var x = 0;"
      "  var time_seed = 1204251968254;"
      "  Math.random = function() {"
      "    x += .1;"
      "    return (x % 1);"
      "  };"
      "  Date.__proto__.now = function() {"
      "    time_seed += 50;"
      "    return new orig_date(time_seed);"
      "  };"
      "  Date = function() {"
      "    return Date.now();"
      "  };"
      "})()");
    return extension;
}

}  // namespace extensions_v8

Update playback extension so that javascript functions return consistent (but not constant) values in an attempt to preserve the functionality but improve compatibility of the extension.

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

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


#include "gtest/gtest.h"

TEST(TestValues, Length)
{
    ASSERT_TRUE(false);
}

#include "gtest/gtest.h"

TEST(TestValues, Length)
{
    ASSERT_TRUE(false);

    Meters myFirstLength();
    Meters mySecondLength(1.53);

    Centimeters myThirdLength(153.0);

    // Test equality between mySecondLength and myThirdLength.
}

Test the ability to compare value types.


#include <platform_config.hpp>

#include <hal_config.hpp>

namespace platform {

MPU6000 imu(&SPID1, &mpu6000_spicfg);
DefaultMultirotorVehicleSystem system(&imu, &imu);

void init() {
  // Initialize platform HAL
  i2cPlatformInit();
  pwmPlatformInit();
  spiPlatformInit();
  usartPlatformInit();

  // Initialize platform devices
  imu.init();
  system.init();

  palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL);
}

msg_t HeartbeatThread::main(void) {
  while(true) {
    palSetPad(GPIOA, 6);
    sleep(MS2ST(50));
    palClearPad(GPIOA, 6);
    sleep(MS2ST(950));
  }

  return 0;
}

}

#include <platform_config.hpp>

#include <hal_config.hpp>

namespace platform {

MPU6000 imu(&SPID1, &mpu6000_spicfg);
DefaultMultirotorVehicleSystem system(&imu, &imu);

void init() {
  // Initialize platform HAL
  i2cPlatformInit();
  pwmPlatformInit();
  spiPlatformInit();
  usartPlatformInit();

  // Initialize platform devices
  imu.init();
  system.init();

  palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOA, 7, PAL_MODE_OUTPUT_PUSHPULL);
}

msg_t HeartbeatThread::main(void) {
  while(true) {
    palSetPad(GPIOA, 6);
    sleep(MS2ST(50));
    palClearPad(GPIOA, 6);
    palSetPad(GPIOA, 7);
    sleep(MS2ST(50));
    palClearPad(GPIOA, 7);
    sleep(MS2ST(900));
  }

  return 0;
}

}

Make heartbeat LED pattern for aerial_v3 fancier.


#include <omp.h>
#include "dispar.h"
#include "tournament.h"

template<typename T>
matrix createRandomTournamentPool(T container,
                                  const size_t nbGroup,
                                  const size_t poolSize) {

    std::bitset<1> bs(container.size());
    matrix pools(nbGroup);

    size_t cardinality = 0;

    for (auto&& pool: pools) {
        pool.reserve(poolSize);
    }

    while(cardinality < nbGroup * poolSize) {
        //int v = rand.nextInt(container.size());
        int v = 0;
        if(!bs[v]) {
            bs[v];
            cardinality++;
            pools[cardinality / poolSize][cardinality % poolSize] = v;
        }
    }

    return pools;
}

template<typename T, typename Alloc, template <typename, typename> class TT>
std::vector<int> selection(const size_t targetSize,
                           TT<T, Alloc> container,
                           std::function<void (const T&, const T&)> comparator) {

    const size_t nbGroup = 1;
    const size_t poolSize = 5;

    std::vector<int> selected_keys;
    selected_keys.reserve(targetSize);

    matrix pools = createRandomTournamentPool(container, nbGroup, poolSize);

    #pragma omp parallel for
    for (int i = 0; i < pools.size(); i++) {
        selected_keys.push_back(tournament<TT, T>(container, pools[i], comparator));
    }

    return selected_keys;
}

#include <omp.h>
#include "dispar.h"
#include "tournament.h"

template<typename T>
matrix createRandomTournamentPool(T container,
                                  const size_t nbGroup,
                                  const size_t poolSize) {

    std::vector<bool> bs(size);
    matrix pools(nbGroup);

    size_t cardinality = 0;

    for (auto&& pool: pools) {
        pool.reserve(poolSize);
    }

    while(cardinality < nbGroup * poolSize) {
        //int v = rand.random_int(offset, size - 1);
        int v = 0;
        if(!bs[v]) {
            bs[v];
            bs[v] = true;
            pools[cardinality / poolSize][cardinality % poolSize] = v;
            cardinality++;
        }
    }

    return pools;
}

template<typename T, typename Alloc, template <typename, typename> class TT>
std::vector<int> selection(const size_t targetSize,
                           TT<T, Alloc> container,
                           std::function<void (const T&, const T&)> comparator) {

    const size_t nbGroup = 1;
    const size_t poolSize = 5;

    std::vector<int> selected_keys;
    selected_keys.reserve(targetSize);

    matrix pools = createRandomTournamentPool(container, nbGroup, poolSize);

    #pragma omp parallel for
    for (int i = 0; i < pools.size(); i++) {
        selected_keys.push_back(tournament<TT, T>(container, pools[i], comparator));
    }

    return selected_keys;
}

Use vector of bool instead of bitset that need to know their size at compile time


#include "mediain.hpp"

MediaIn::MediaIn()
{
}

int MediaIn::frameCount(void) const
{
   return -1;
}

int MediaIn::frameCounter(void) const
{
   return -1;
}

void MediaIn::frameCounter(int frameCount)
{
	(void)frameCount;
}

bool MediaIn::getDepthMat(cv::Mat &depthMat)
{
	(void)depthMat;
	return false;
}

double MediaIn::getDepth(int x, int y)
{
	(void)x;
	(void)y;
   return -1000.;
}

#include "mediain.hpp"

MediaIn::MediaIn()
{
}

int MediaIn::frameCount(void) const
{
	return -1;
}

int MediaIn::frameCounter(void) const
{
	return -1;
}

void MediaIn::frameCounter(int frameCount)
{
	(void)frameCount;
}

bool MediaIn::getDepthMat(cv::Mat &depthMat)
{
	depthMat = Mat(); // return empty mat to indicate no depth info
	return false;     // in addition to returning false
}

double MediaIn::getDepth(int x, int y)
{
	(void)x;
	(void)y;
	return -1000.;
}

Set returned mat to empty in base getDepthMat


// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s

struct A {
  int x;
  A(int a) { x = a; }
  int getx() const { return x; }
};

void f1() {
  A x(3);
  if (x.getx() == 3) {
    int *p = 0;
    *p = 3;  // expected-warning{{Dereference of null pointer}}
  } else {
    int *p = 0;
    *p = 3;  // no-warning
  }
}

void f2() {
  const A &x = A(3);
  if (x.getx() == 3) {
    int *p = 0;
    *p = 3;  // expected-warning{{Dereference of null pointer}}
  } else {
    int *p = 0;
    *p = 3;  // no-warning
  }
}

// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
// XFAIL: *

struct A {
  int x;
  A(int a) { x = a; }
  int getx() const { return x; }
};

void f1() {
  A x(3);
  if (x.getx() == 3) {
    int *p = 0;
    *p = 3;  // expected-warning{{Dereference of null pointer}}
  } else {
    int *p = 0;
    *p = 3;  // no-warning
  }
}

void f2() {
  const A &x = A(3);
  if (x.getx() == 3) {
    int *p = 0;
    *p = 3;  // expected-warning{{Dereference of null pointer}}
  } else {
    int *p = 0;
    *p = 3;  // no-warning
  }
}

void f3() {
  const A &x = (A)3;
  if (x.getx() == 3) {
    int *p = 0;
    *p = 3;  // expected-warning{{Dereference of null pointer}}
  } else {
    int *p = 0;
    *p = 3;  // no-warning
  }
}

[analyzer] Disable a test until inlining CXXConstructExprs is fully investigated.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@126006 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkNullCanvas.h"

#include "SkCanvas.h"
#include "SKNWayCanvas.h"

SkCanvas* SkCreateNullCanvas() {
    // An N-Way canvas forwards calls to N canvas's. When N == 0 it's
    // effectively a null canvas.
    return SkNEW(SkNWayCanvas);
}

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkNullCanvas.h"

#include "SkCanvas.h"
#include "SKNWayCanvas.h"

SkCanvas* SkCreateNullCanvas() {
    // An N-Way canvas forwards calls to N canvas's. When N == 0 it's
    // effectively a null canvas.
    return SkNEW(SkNWayCanvas(0,0));
}

Fix SkNWayCanvas cons call when creating null canvas.

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@4223 2bbb7eff-a529-9590-31e7-b0007b416f81


/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
 *     Copyright 2016 Couchbase, Inc
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

#include <memory>

#include <gtest/gtest.h>

#include "utils/make_unique.h"

TEST(MakeUnique, succeed) {
    std::unique_ptr<int> unique_int = phosphor::utils::make_unique<int>(5);
    ASSERT_NE(unique_int.get(), nullptr);
    EXPECT_EQ(*unique_int, 5);
}

/* Used for full branch/line coverage of make_unique */
struct AlwaysThrow {
    AlwaysThrow() {
        throw std::runtime_error("AlwaysThrow::AlwaysThrow: Fake exception");
    }
};

TEST(MakeUnique, fail) {
    EXPECT_THROW(phosphor::utils::make_unique<AlwaysThrow>(), std::runtime_error);
}

Improve branch coverage of polyfill test


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Storage) {
  ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

#if defined(OS_WIN)
// Always fails on Windows after r110181: http://crbug.com/104419.
#define MAYBE_Storage FAILS_Storage
#else
#define MAYBE_Storage Storage
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Storage) {
  ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}

Mark ExtensionApiTest.Storage as failing, it always fails on Windows after r110181.

BUG=104419
TEST=none
Review URL: http://codereview.chromium.org/8573032

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


// friend class as template parameter

// originally found in package 'zipios'

// typechecking results:
//   errors:   0
//   warnings: 0
// error: k0069.cc:15:12: internal error: found dependent type `Friend' in non-template

// ERR-MATCH: internal error: found dependent type `[^(].*?' in non-template

template< class Type > struct T {
  friend struct Friend ;
};

struct Friend;

typedef T< Friend > T1 ;

// friend class as template parameter

// originally found in package 'zipios'

// typechecking results:
//   errors:   0
//   warnings: 0
// error: k0069.cc:15:12: internal error: found dependent type `Friend' in non-template

// ERR-MATCH: internal error: found dependent type `.*?' in non-template

template< class Type > struct T {
  friend struct Friend ;
};

struct Friend;

typedef T< Friend > T1 ;

Undo previous - hard to distinguish errors


#include "o2gft.h"
#include "o2google.h"

static const char *GftScope = "https://www.googleapis.com/auth/fusiontables";
static const char *GftEndpoint = "https://accounts.google.com/o/oauth2/auth";
static const char *GftTokenUrl = "https://accounts.google.com/o/oauth2/token";
static const char *GftRefreshUrl = "https://accounts.google.com/o/oauth2/token";

O2Gft::O2Gft(QObject *parent): O2Google(parent) {
    setScope(GftScope);
}

#include "o2gft.h"
#include "o2google.h"

static const char *GftScope = "https://www.googleapis.com/auth/fusiontables";

O2Gft::O2Gft(QObject *parent): O2Google(parent) {
    setScope(GftScope);
}

Remove unused constants causing warnings


/*************************************************
* Mutex Source File                              *
* (C) 1999-2006 The Botan Project                *
*************************************************/

#include <botan/mutex.h>

namespace Botan {

/*************************************************
* Mutex_Holder Constructor                       *
*************************************************/
Mutex_Holder::Mutex_Holder(Mutex* m) : mux(m)
   {
   if(!mux)
      throw Invalid_Argument("Mutex_Holder: Argument was NULL");
   mux->lock();
   }

/*************************************************
* Mutex_Holder Destructor                        *
*************************************************/
Mutex_Holder::~Mutex_Holder()
   {
   mux->unlock();
   }

/*************************************************
* Default Mutex Factory                          *
*************************************************/
Mutex* Mutex_Factory::make()
   {
   class Default_Mutex : public Mutex
      {
      public:
         class Mutex_State_Error : public Internal_Error
            {
            public:
               Mutex_State_Error(const std::string& where)
                  {
                  set_msg("Default_Mutex::" + where + ": Mutex is already " +
                          where + "ed");
                  }
            };

         void lock()
            {
            if(locked)
               throw Mutex_State_Error("lock");
            locked = true;
            }

         void unlock()
            {
            if(!locked)
               throw Mutex_State_Error("unlock");
            locked = false;
            }

         Default_Mutex() { locked = false; }
      private:
         bool locked;
      };

   return new Default_Mutex;
   }

}

/*************************************************
* Mutex Source File                              *
* (C) 1999-2006 The Botan Project                *
*************************************************/

#include <botan/mutex.h>

namespace Botan {

/*************************************************
* Mutex_Holder Constructor                       *
*************************************************/
Mutex_Holder::Mutex_Holder(Mutex* m) : mux(m)
   {
   if(!mux)
      throw Invalid_Argument("Mutex_Holder: Argument was NULL");
   mux->lock();
   }

/*************************************************
* Mutex_Holder Destructor                        *
*************************************************/
Mutex_Holder::~Mutex_Holder()
   {
   mux->unlock();
   }

/*************************************************
* Default Mutex Factory                          *
*************************************************/
Mutex* Mutex_Factory::make()
   {
   class Default_Mutex : public Mutex
      {
      public:
         class Mutex_State_Error : public Internal_Error
            {
            public:
               Mutex_State_Error(const std::string& where) :
                  Internal_Error("Default_Mutex::" + where + ": " +
                                 "Mutex is already " + where + "ed") {}
            };

         void lock()
            {
            if(locked)
               throw Mutex_State_Error("lock");
            locked = true;
            }

         void unlock()
            {
            if(!locked)
               throw Mutex_State_Error("unlock");
            locked = false;
            }

         Default_Mutex() { locked = false; }
      private:
         bool locked;
      };

   return new Default_Mutex;
   }

}

Fix the constructor of Mutex_State_Error


#include "Config.hpp"
#include <fstream>

#ifndef INSTALL_PREFIX
#error CMake has not defined INSTALL_PREFIX!
#endif

Json::Value Config::getQuorumNode()
{
  return loadFile(INSTALL_PREFIX + "/lib/tor-onions/quorum.json");
}

Json::Value Config::getMirror()
{
  return loadFile(INSTALL_PREFIX + "/lib/tor-onions/mirrors.json");
}

Json::Value Config::loadFile(const std::string& path)
{
  Json::Value value;
  std::ifstream file(path, std::ifstream::binary);
  file >> value;
  return value;
}

#include "Config.hpp"
#include "Log.hpp"
#include <fstream>

#ifndef INSTALL_PREFIX
#error CMake has not defined INSTALL_PREFIX!
#endif

Json::Value Config::getQuorumNode()
{
  return loadFile(INSTALL_PREFIX + "/lib/tor-onions/quorum.json");
}

Json::Value Config::getMirror()
{
  return loadFile(INSTALL_PREFIX + "/lib/tor-onions/mirrors.json");
}

Json::Value Config::loadFile(const std::string& path)
{
  Json::Value value;

  std::ifstream file;
  file.open(path, std::ifstream::binary);
  if (file.is_open())
    file >> value;
  else
    Log::get().error("Cannot open resource " + path);

  return value;
}

Handle inability to open a resource

Handle inability to open a resource


#include <iostream>
#include <gtest/gtest.h>
#include <GLFW/glfw3.h>

static void error_callback(int error, const char* description)
{
  FAIL() << "GLFW Failed (" << error << "): " << description;
}

TEST(GLFWTests, BuildInvisibleWindow)
{
  GLFWwindow* window;
  glfwSetErrorCallback(error_callback);

  if (!glfwInit())
    FAIL() << "GLFW failed to initialize";

  glfwWindowHint(GLFW_VISIBLE, 0);
  window = glfwCreateWindow(640, 480, "Invisible Example", NULL, NULL);
  if (!window)
  {
    glfwTerminate();
    FAIL() << "Failed to create glfw window";
  }

  glfwDestroyWindow(window);
  glfwTerminate();
}

int main(int argc, char** argv)
{
  ::testing::InitGoogleTest(&argc, argv);

  return RUN_ALL_TESTS();
}

#include <iostream>
#include <gtest/gtest.h>
#include <GLFW/glfw3.h>

static void error_callback(int error, const char* description)
{
  FAIL() << "GLFW Failed (" << error << "): " << description;
}

TEST(GLFWTests, BuildInvisibleWindow)
{
  GLFWwindow* window;
  glfwSetErrorCallback(error_callback);

  if (!glfwInit())
    FAIL() << "GLFW failed to initialize";

  //glfwWindowHint(GLFW_VISIBLE, 0);
  //window = glfwCreateWindow(640, 480, "Invisible Example", NULL, NULL);
  //if (!window)
  //{
  //  glfwTerminate();
  //  FAIL() << "Failed to create glfw window";
  //}

  //glfwDestroyWindow(window);
  glfwTerminate();
}

int main(int argc, char** argv)
{
  ::testing::InitGoogleTest(&argc, argv);

  return RUN_ALL_TESTS();
}

Remove window display. There is no X server on travis.


#include <sstream>

#include <boost/format.hpp>

#include "Colors.h"
#include "Trace.h"

Trace::Trace()
{
}

Trace::~Trace()
{
}

/* Add an instruction in the trace */
void Trace::addInstruction(Inst *instruction)
{
  this->instructions.push_back(instruction);
}

/* Returns the instructions list in the trace */
std::list<Inst *> &Trace::getInstructions()
{
  return this->instructions;
}

void Trace::display(std::ostream &os)
{
  boost::format outputInstruction("%1% %|15t| %2% %|55t|");

  for (auto inst : this->instructions){
    uint64_t count = 0;
    if (inst != nullptr) {
      std::stringstream expr(""), colr(ENDC);

      for (auto se : inst->getSymbolicElements()){

        if (count == 0) expr << se->getExpression()->str();
        else            expr << std::endl << boost::format(outputInstruction) % "" % "" << se->getExpression()->str();

        if (se->isTainted)
          colr.str(GREEN);

        count++;
      }

      os << colr.str()
         << boost::format(outputInstruction)
          % boost::io::group(std::hex, std::showbase, inst->getAddress())
          % inst->getDisassembly()
         << expr.str()
         << ENDC
         << std::endl;
    }
  }
}

#include <sstream>

#include <boost/format.hpp>

#include "Colors.h"
#include "Trace.h"

Trace::Trace()
{
}

Trace::~Trace()
{
}

/* Add an instruction in the trace */
void Trace::addInstruction(Inst *instruction)
{
  this->instructions.push_back(instruction);
}

/* Returns the instructions list in the trace */
std::list<Inst *> &Trace::getInstructions()
{
  return this->instructions;
}

void Trace::display(std::ostream &os)
{
  boost::format outputInstruction("[%1%] %|3t| %2% %|21t| %3% %|61t|");
  boost::format outputExpression("%|61t|");

  for (auto inst : this->instructions){
    uint64_t count = 0;
    if (inst != nullptr) {
      std::stringstream expr(""), colr(ENDC);

      for (auto se : inst->getSymbolicElements()){

        if (count == 0) expr << se->getExpression()->str();
        else            expr << std::endl << boost::format(outputExpression) << se->getExpression()->str();

        if (se->isTainted)
          colr.str(GREEN);

        count++;
      }

      os << colr.str()
         << boost::format(outputInstruction)
          % std::to_string(inst->getThreadId())
          % boost::io::group(std::hex, std::showbase, inst->getAddress())
          % inst->getDisassembly()
         << expr.str()
         << ENDC
         << std::endl;
    }
  }
}

Add the threadID viewing in the output

Add the threadID viewing in the output


#include <exception>
//#if (__GLIBCXX__ / 10000) == 2014
namespace std {
inline bool uncaught_exception() noexcept(true)
{ return current_exception() != nullptr; }
} // namespace std
//#endif

#define CATCH_CONFIG_MAIN
#include <catch.hpp>

Remove GCC fix that is not needed

Remove GCC fix that is not needed


// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/profile_management_switches.h"

#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/chrome_switches.h"

namespace {

const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";

bool CheckProfileManagementFlag(std::string command_switch, bool active_state) {
  std::string trial_type =
      base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
  if (!trial_type.empty()) {
    if (trial_type == "Enabled")
      return active_state;
    if (trial_type == "Disabled")
      return !active_state;
  }
  return CommandLine::ForCurrentProcess()->HasSwitch(command_switch);
}

}  // namespace

namespace switches {

bool IsEnableWebBasedSignin() {
  return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false);
}

bool IsGoogleProfileInfo() {
  return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true);
}

bool IsNewProfileManagement() {
  return CheckProfileManagementFlag(switches::kNewProfileManagement, true);
}

}  // namespace switches

// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/profile_management_switches.h"

#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/chrome_switches.h"

namespace {

const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";

bool CheckProfileManagementFlag(std::string command_switch, bool active_state) {
  // Individiual flag settings take precedence.
  if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) {
    return true;
  }

  // --new-profile-management flag always affects all switches.
  if (CommandLine::ForCurrentProcess()->HasSwitch(
        switches::kNewProfileManagement)) {
    return active_state;
  }

  // NewProfileManagement experiment acts like above flag.
  std::string trial_type =
      base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
  if (!trial_type.empty()) {
    if (trial_type == "Enabled")
      return active_state;
    if (trial_type == "Disabled")
      return !active_state;
  }

  return false;
}

}  // namespace

namespace switches {

bool IsEnableWebBasedSignin() {
  return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false);
}

bool IsGoogleProfileInfo() {
  return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true);
}

bool IsNewProfileManagement() {
  return CheckProfileManagementFlag(switches::kNewProfileManagement, true);
}

}  // namespace switches

Use --new-profile-management to set all related flags.

BUG=324046

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

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


// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Generic.hpp>
#include <Rosetta/Tasks/SimpleTasks/DamageTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/DestroyTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>

namespace RosettaStone::SimpleTasks
{
DamageTask::DamageTask(EntityType entityType, std::size_t damage,
                       bool isSpellDamage)
    : ITask(entityType), m_damage(damage), m_isSpellDamage(isSpellDamage)
{
    // Do nothing
}

TaskID DamageTask::GetTaskID() const
{
    return TaskID::DAMAGE;
}

TaskStatus DamageTask::Impl(Player& player)
{
    auto entities =
        IncludeTask::GetEntities(m_entityType, player, m_source, m_target);

    for (auto& entity : entities)
    {
        auto character = dynamic_cast<Character*>(entity);
        Generic::TakeDamageToCharacter(
            m_source, character, static_cast<int>(m_damage), m_isSpellDamage);
    }

    for (auto& entity : entities)
    {
        if (entity->isDestroyed)
        {
            entity->Destroy();
        }
    }

    return TaskStatus::COMPLETE;
}
}  // namespace RosettaStone::SimpleTasks

// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Generic.hpp>
#include <Rosetta/Tasks/SimpleTasks/DamageTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/DestroyTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>

namespace RosettaStone::SimpleTasks
{
DamageTask::DamageTask(EntityType entityType, std::size_t damage,
                       bool isSpellDamage)
    : ITask(entityType), m_damage(damage), m_isSpellDamage(isSpellDamage)
{
    // Do nothing
}

TaskID DamageTask::GetTaskID() const
{
    return TaskID::DAMAGE;
}

TaskStatus DamageTask::Impl(Player& player)
{
    auto entities =
        IncludeTask::GetEntities(m_entityType, player, m_source, m_target);

    for (auto& entity : entities)
    {
        auto character = dynamic_cast<Character*>(entity);
        Generic::TakeDamageToCharacter(
            m_source, character, static_cast<int>(m_damage), m_isSpellDamage);
    }

    return TaskStatus::COMPLETE;
}
}  // namespace RosettaStone::SimpleTasks

Delete code to call Destroy() method

feat(card-impl): Delete code to call Destroy() method


// RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: stable-runtime

// XFAIL: ubsan
// FIXME(dliew): Make this test work on Darwin with LSan
// XFAIL: darwin && lsan

#include <sanitizer/common_interface_defs.h>
#include <stdio.h>

volatile char *zero = 0;

void Death() {
  fprintf(stderr, "DEATH CALLBACK EXECUTED\n");
}
// CHECK: DEATH CALLBACK EXECUTED

char global;
volatile char *sink;

__attribute__((noinline))
void MaybeInit(int *uninitialized) {
  if (zero)
    *uninitialized = 1;
}

__attribute__((noinline))
void Leak() {
  // Trigger lsan report. Two attempts in case the address of the first
  // allocation remained on the stack.
  sink = new char[100];
  sink = new char[100];
}

int main(int argc, char **argv) {
  int uninitialized;
  __sanitizer_set_death_callback(Death);
  MaybeInit(&uninitialized);
  if (uninitialized)  // trigger msan report.
    global = 77;
  sink = new char[100];
  delete[] sink;
  global = sink[0];  // use-after-free: trigger asan/tsan report.
  Leak();
  sink = 0;
}

// RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: stable-runtime

// XFAIL: ubsan
// FIXME: On Darwin, LSAn detects the leak, but does not invoke the death_callback.
// XFAIL: darwin && lsan

#include <sanitizer/common_interface_defs.h>
#include <stdio.h>

volatile char *zero = 0;

void Death() {
  fprintf(stderr, "DEATH CALLBACK EXECUTED\n");
}
// CHECK: DEATH CALLBACK EXECUTED

char global;
volatile char *sink;

__attribute__((noinline))
void MaybeInit(int *uninitialized) {
  if (zero)
    *uninitialized = 1;
}

__attribute__((noinline))
void Leak() {
  // Trigger lsan report. Two attempts in case the address of the first
  // allocation remained on the stack.
  sink = new char[100];
  sink = new char[100];
}

int main(int argc, char **argv) {
  int uninitialized;
  __sanitizer_set_death_callback(Death);
  MaybeInit(&uninitialized);
  if (uninitialized)  // trigger msan report.
    global = 77;
  sink = new char[100];
  delete[] sink;
  global = sink[0];  // use-after-free: trigger asan/tsan report.
  Leak();
  sink = 0;
}

Add comment explaining test failure

[LSan][Darwin][NFC] Add comment explaining test failure

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@354290 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * vkmark is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "cube",
        "clear"
    };
}

/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * vkmark is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "texture:anisotropy=0",
        "texture:anisotropy=16",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "cube",
        "clear"
    };
}

main: Add texture scene variants to default benchmarks


//
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "string_utils.h"

namespace gtx {

std::string TrimWhitespace(std::string str) {
  auto first_nonwhitespace_iter =
      std::find_if_not(str.begin(), str.end(), std::isspace);
  auto trimmed_leading = str.substr(first_nonwhitespace_iter - str.begin(),
                                    str.end() - first_nonwhitespace_iter);
  auto last_nonwhitespace_iter = std::find_if_not(
      trimmed_leading.rbegin(), trimmed_leading.rend(), std::isspace);
  return trimmed_leading.substr(
      0, trimmed_leading.rend() - last_nonwhitespace_iter);
}

}  // namespace gtx

//
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "string_utils.h"

namespace gtx {

std::string TrimWhitespace(std::string str) {
  auto first_nonwhitespace_iter = std::find_if_not(
      str.begin(), str.end(), [](char c) { return std::isspace(c); });
  auto trimmed_leading = str.substr(first_nonwhitespace_iter - str.begin(),
                                    str.end() - first_nonwhitespace_iter);
  auto last_nonwhitespace_iter =
      std::find_if_not(trimmed_leading.rbegin(), trimmed_leading.rend(),
                       [](char c) { return std::isspace(c); });
  return trimmed_leading.substr(
      0, trimmed_leading.rend() - last_nonwhitespace_iter);
}

}  // namespace gtx

Correct find_if_not predicate compile error.


#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include "../../src/systemcmds/tests/tests.h"

int main(int argc, char *argv[]) {
	warnx("Host execution started");

	char* args[] = {argv[0], "../../ROMFS/px4fmu_common/mixers/IO_pass.mix",
				 "../../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};

	test_mixer(3, args);

	test_conv(1, args);
}

#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include "../../src/systemcmds/tests/tests.h"

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

	int ret;

	warnx("Host execution started");

	char* args[] = {argv[0], "../ROMFS/px4fmu_common/mixers/IO_pass.mix",
				 "../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};

	if (ret = test_mixer(3, args));

	test_conv(1, args);

	return 0;
}

Improve mixer test, no firm checks yet

Improve mixer test, no firm checks yet


// local
#include "Object.hpp"

#include "core/utils/exceptions.h"

using namespace corryvreckan;

Object::Object() : m_detectorID(), m_timestamp(0) {}
Object::Object(std::string detectorID) : m_detectorID(detectorID), m_timestamp(0) {}
Object::Object(double timestamp) : m_detectorID(), m_timestamp(timestamp) {}
Object::Object(std::string detectorID, double timestamp) : m_detectorID(detectorID), m_timestamp(timestamp) {}
Object::~Object() {}

ClassImp(Object)

Remove ClassImp as done for other classes in !139


#include "window_configuration.h"

const char *kFlutterWindowTitle = "taqo_client";
const unsigned int kFlutterWindowWidth = 1280;
const unsigned int kFlutterWindowHeight = 720;

#include "window_configuration.h"

const char *kFlutterWindowTitle = "Taqo";
const unsigned int kFlutterWindowWidth = 1024;
const unsigned int kFlutterWindowHeight = 768;

Fix window title and initial size

Fix window title and initial size