static void (*real_one) ();
static void stub(){}

/* in CheatSheetTest.cpp */
#include "CppUTest/TestHarness.h"

/* Declare TestGroup with name CheatSheet */
TEST_GROUP(CheatSheet)
{
/* declare a setup method for the test group. Optional. */
    void setup ()
    {
/* Set method real_one to stub. Automatically restore in teardown */
        UT_PTR_SET(real_one, stub);
    }

/* Declare a teardown method for the test group. Optional */
    void teardown()
    {
    }
}; /* Do not forget semicolumn */

/* Declare one test within the test group */
TEST(CheatSheet, TestName)
{
    /* Check two longs are equal */
    LONGS_EQUAL(1, 2);

    /* Check a condition */
    CHECK(true == true);

    /* Check a string */
    STRCMP_EQUAL("HelloWorld", "HelloWorld");
}

static void (*real_one) ();
static void stub(){}

/* in CheatSheetTest.cpp */
#include "CppUTest/TestHarness.h"

/* Declare TestGroup with name CheatSheet */
TEST_GROUP(CheatSheet)
{
/* declare a setup method for the test group. Optional. */
    void setup ()
    {
/* Set method real_one to stub. Automatically restore in teardown */
        UT_PTR_SET(real_one, stub);
    }

/* Declare a teardown method for the test group. Optional */
    void teardown()
    {
    }
}; /* Do not forget semicolumn */

/* Declare one test within the test group */
TEST(CheatSheet, TestName)
{
    /* Check two longs are equal */
    LONGS_EQUAL(1, 1);

    /* Check a condition */
    CHECK(true == true);

    /* Check a string */
    STRCMP_EQUAL("HelloWorld", "HelloWorld");
}

Remove intentional failure again, so build can pass


#include "Image.h"

namespace hm
{
	Image::Image()
	{

	}

	Image::Image(std::string filename, SDL_Renderer* renderer)
	{
		loadImage(filename, renderer);
	}

	void Image::loadImage(std::string filename, SDL_Renderer* renderer)
	{
		// Unload a previous image.
		if(texture != nullptr)
		{
			SDL_DestroyTexture(texture);
			texture = nullptr;
		}

		SDL_Surface* surface = IMG_Load(filename.c_str());

		// Check if it was loaded.
		if(surface == NULL)
		{
			std::cout << "Could not open " << filename << std::endl;
			return;
		}

		// Color key surface
		Uint32 key = SDL_MapRGB(surface->format, 0xFF, 0x00, 0xFF);
		SDL_SetColorKey(surface, SDL_TRUE, key);

		// Convert to texture.
		texture = SDL_CreateTextureFromSurface(renderer, surface);
		SDL_FreeSurface(surface);
		surface = nullptr;

		// Get dimensions.
		SDL_QueryTexture(texture, nullptr, nullptr, &info.w, &info.h);

		return;
	}

	void Image::setColorKey(Uint8 r, Uint8 g, Uint8 b)
	{
		color_key = { r, g, b, 0 };
		return;
	}
}

#include "Image.h"

namespace hm
{
	Image::Image()
	{

	}

	Image::Image(std::string filename, SDL_Renderer* renderer)
	{
		loadImage(filename, renderer);
	}

	void Image::loadImage(std::string filename, SDL_Renderer* renderer)
	{
		// Unload a previous image.
		if(texture != nullptr)
		{
			SDL_DestroyTexture(texture);
			texture = nullptr;
		}

		SDL_Surface* surface = IMG_Load(filename.c_str());

		// Check if it was loaded.
		if(surface == NULL)
		{
			std::cout << "Could not open image: " << filename << std::endl;
			return;
		}

		// Color key surface
		Uint32 key = SDL_MapRGB(surface->format, 0xFF, 0x00, 0xFF);
		SDL_SetColorKey(surface, SDL_TRUE, key);

		// Convert to texture.
		texture = SDL_CreateTextureFromSurface(renderer, surface);
		SDL_FreeSurface(surface);
		surface = nullptr;

		// Get dimensions.
		SDL_QueryTexture(texture, nullptr, nullptr, &info.w, &info.h);

		return;
	}

	void Image::setColorKey(Uint8 r, Uint8 g, Uint8 b)
	{
		color_key = { r, g, b, 0 };
		return;
	}
}

Make it more obvious that a file name should follow.


// Copyright (c) 2010 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 "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

// Copyright (c) 2010 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 "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

// Disabled, flakily exceeds timeout, http://crbug.com/72165.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

Disable ExtensionApiTest.WebNavigationEvents1, flakily exceeds test timeout

TBR=jochen

BUG=72165
TEST=browser_tests
Review URL: http://codereview.chromium.org/6286142

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


#include <iostream>
#include <StringObserverImpl.h>

void StringObserverImpl::update()
{
   char* cur_value = mSubject->getValue();

   std::cout << "Current string value is now '" << cur_value << "'\n";
   delete cur_value;
}

#include <vpr/Util/Debug.h>
#include <StringObserverImpl.h>

void StringObserverImpl::update()
{
   char* cur_value = mSubject->getValue();

   vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
      << "Current string value is now '" << cur_value << "'\n"
      << vprDEBUG_FLUSH;
   delete cur_value;
}

Use vprDEBUG instead of std::cout to print the current string value.

git-svn-id: 769d22dfa2d22aad706b9a451492fb87c0735f19@11032 08b38cba-cd3b-11de-854e-f91c5b6e4272


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

namespace PR10622 {
  struct foo {
    const int first;
    foo(const foo&) = default;
  };
  void find_or_insert(const foo& __obj) {
    foo x(__obj);
  }
}

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

namespace PR10622 {
  struct foo {
    const int first;
    foo(const foo&) = default;
  };
  void find_or_insert(const foo& __obj) {
    foo x(__obj);
  }

  struct bar : foo {
    bar(const bar&) = default;
  };
  void test_bar(const bar &obj) {
    bar obj2(obj);
  }
}

Expand test of C++0x [class.copymove]p15 to make sure we're actually calling the copy constructor of a base/member from an explicitly-defaulted copy constructor, rather than the default constructor

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


#include "extensions.h"
#include "extensions/accelerometer.h"
#include "extensions/debugconsole.h"
#include "extensions/deviceinfo.h"
#include "extensions/hash.h"
#include "extensions/notification.h"

#ifdef Q_WS_S60
#include "extensions/camera.h"
#include "extensions/memorywatcher.h"
#endif

#include <QWebFrame>

Extensions::Extensions(QWebView *webView) :
    QObject(webView) {

    m_frame = webView->page()->mainFrame();
    connect(m_frame, SIGNAL(javaScriptWindowObjectCleared()), SLOT(attachExtensions()));

    m_extensions["GapAccelerometer"] = new Accelerometer(this);
    m_extensions["GapDebugConsole"] = new DebugConsole(this);
    m_extensions["GapDeviceInfo"] = new DeviceInfo(this);
    m_extensions["GapHash"] = new Hash(this);
    m_extensions["GapNotification"] = new Notification(this);

#ifdef Q_WS_S60
    m_extensions["GapCamera"] = new Camera(this);
    m_extensions["GapMemoryWatcher"] = new MemoryWatcher(this);
#endif

    attachExtensions();
}

void Extensions::attachExtensions() {

    foreach (QString name, m_extensions.keys()) {
        m_frame->addToJavaScriptWindowObject(name, m_extensions[name]);
    }
}

#include "extensions.h"
#include "extensions/accelerometer.h"
#include "extensions/debugconsole.h"
#include "extensions/deviceinfo.h"
#include "extensions/geolocation.h"
#include "extensions/hash.h"
#include "extensions/notification.h"

#ifdef Q_WS_S60
#include "extensions/camera.h"
#include "extensions/memorywatcher.h"
#endif

#include <QWebFrame>

Extensions::Extensions(QWebView *webView) :
    QObject(webView) {

    m_frame = webView->page()->mainFrame();
    connect(m_frame, SIGNAL(javaScriptWindowObjectCleared()), SLOT(attachExtensions()));

    m_extensions["GapAccelerometer"] = new Accelerometer(this);
    m_extensions["GapDebugConsole"] = new DebugConsole(this);
    m_extensions["GapDeviceInfo"] = new DeviceInfo(this);
    m_extensions["GapGeolocation"] = new Geolocation(this);
    m_extensions["GapHash"] = new Hash(this);
    m_extensions["GapNotification"] = new Notification(this);

#ifdef Q_WS_S60
    m_extensions["GapCamera"] = new Camera(this);
    m_extensions["GapMemoryWatcher"] = new MemoryWatcher(this);
#endif

    attachExtensions();
}

void Extensions::attachExtensions() {

    foreach (QString name, m_extensions.keys()) {
        m_frame->addToJavaScriptWindowObject(name, m_extensions[name]);
    }
}

Add Geolocation to exported APIs.

Add Geolocation to exported APIs.


#include "tgbot/Bot.h"

#include "tgbot/EventBroadcaster.h"

#if __cplusplus < 201402L
namespace std {
    template<class T> struct _Unique_if {
        typedef unique_ptr<T> _Single_object;
    };

    template<class T> struct _Unique_if<T[]> {
        typedef unique_ptr<T[]> _Unknown_bound;
    };

    template<class T, size_t N> struct _Unique_if<T[N]> {
        typedef void _Known_bound;
    };

    template<class T, class... Args>
        typename _Unique_if<T>::_Single_object
        make_unique(Args&&... args) {
            return unique_ptr<T>(new T(std::forward<Args>(args)...));
        }

    template<class T>
        typename _Unique_if<T>::_Unknown_bound
        make_unique(size_t n) {
            typedef typename remove_extent<T>::type U;
            return unique_ptr<T>(new U[n]());
        }

    template<class T, class... Args>
        typename _Unique_if<T>::_Known_bound
        make_unique(Args&&...) = delete;
}
#endif

namespace TgBot {

Bot::Bot(std::string token, const HttpClient& httpClient)
    : _token(std::move(token))
    , _api(_token, httpClient)
    , _eventBroadcaster(std::make_unique<EventBroadcaster>())
    , _eventHandler(getEvents()) {
}

}

#include "tgbot/Bot.h"

#include "tgbot/EventBroadcaster.h"

#if __cplusplus == 201103L
namespace std {
    template<typename T>
    inline std::unique_ptr<T> make_unique() {
        return std::unique_ptr<T>(new T());
    }
}
#endif

namespace TgBot {

Bot::Bot(std::string token, const HttpClient& httpClient)
    : _token(std::move(token))
    , _api(_token, httpClient)
    , _eventBroadcaster(std::make_unique<EventBroadcaster>())
    , _eventHandler(getEvents()) {
}

}

Fix build error in versions below MSVC 12.0


//===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===//
//
// This program is an automated compiler debugger tool.  It is used to narrow
// down miscompilations and crash problems to a specific pass in the compiler,
// and the specific Module or Function input that is causing the problem.
//
//===----------------------------------------------------------------------===//

#include "BugDriver.h"
#include "Support/CommandLine.h"
#include "llvm/Support/PassNameParser.h"

static cl::list<std::string>
InputFilenames(cl::Positional, cl::OneOrMore,
               cl::desc("<input llvm ll/bc files>"));

// The AnalysesList is automatically populated with registered Passes by the
// PassNameParser.
//
static cl::list<const PassInfo*, bool, PassNameParser>
PassList(cl::desc("Passes available:"), cl::ZeroOrMore);

//cl::list<std::string>
//InputArgv(cl::ConsumeAfter, cl::desc("<program arguments>..."));

int main(int argc, char **argv) {
  cl::ParseCommandLineOptions(argc, argv);

  BugDriver D(argv[0]);
  if (D.addSources(InputFilenames)) return 1;
  D.addPasses(PassList.begin(), PassList.end());

  return D.run();
}

//===- bugpoint.cpp - The LLVM BugPoint utility ---------------------------===//
//
// This program is an automated compiler debugger tool.  It is used to narrow
// down miscompilations and crash problems to a specific pass in the compiler,
// and the specific Module or Function input that is causing the problem.
//
//===----------------------------------------------------------------------===//

#include "BugDriver.h"
#include "Support/CommandLine.h"
#include "llvm/Support/PassNameParser.h"

static cl::list<std::string>
InputFilenames(cl::Positional, cl::OneOrMore,
               cl::desc("<input llvm ll/bc files>"));

// The AnalysesList is automatically populated with registered Passes by the
// PassNameParser.
//
static cl::list<const PassInfo*, bool, PassNameParser>
PassList(cl::desc("Passes available:"), cl::ZeroOrMore);

// Anything specified after the --args option are taken as arguments to the
// program being debugged.
cl::list<std::string>
InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
          cl::ZeroOrMore);

int main(int argc, char **argv) {
  cl::ParseCommandLineOptions(argc, argv);

  BugDriver D(argv[0]);
  if (D.addSources(InputFilenames)) return 1;
  D.addPasses(PassList.begin(), PassList.end());

  return D.run();
}

Add variable to capture arguments that should be passed to the user program
This is unused so far.

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


// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s

#include <string.h>

extern "C" __declspec(dllexport)
int test_function() {
  char buff[6] = "Hello";

  memchr(buff, 'z', 7);
// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: READ of size 7 at [[ADDR]] thread T0
// CHECK-NEXT:  __asan_wrap_memchr
// CHECK-NEXT:  memchr
// CHECK-NEXT:  test_function {{.*}}dll_intercept_memchr.cc:[[@LINE-5]]
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
// CHECK-NEXT:  test_function {{.*}}dll_intercept_memchr.cc
// CHECK: 'buff' <== Memory access at offset {{.*}} overflows this variable
  return 0;
}

// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s

// On windows 64-bit, the memchr function is written in assembly and is not
// hookable with the interception library. There is not enough padding before
// the function and there is a short jump on the second instruction which
// doesn't not allow enough space to encode a 64-bit indirect jump.
// UNSUPPORTED: x86_64-windows

#include <string.h>

extern "C" __declspec(dllexport)
int test_function() {
  char buff[6] = "Hello";

  memchr(buff, 'z', 7);
// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
// CHECK: READ of size 7 at [[ADDR]] thread T0
// CHECK-NEXT:  __asan_wrap_memchr
// CHECK-NEXT:  memchr
// CHECK-NEXT:  test_function {{.*}}dll_intercept_memchr.cc:[[@LINE-5]]
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
// CHECK-NEXT:  test_function {{.*}}dll_intercept_memchr.cc
// CHECK: 'buff' <== Memory access at offset {{.*}} overflows this variable
  return 0;
}

[compiler-rt][asan] Disable a broken test on windows 64-bits

Summary:
This test is broken on wndows 64-bit.

The interception library is not able to hook on the memchr functions.

Snippet of the function that is not hookable:
```
--- No source file -------------------------------------------------------------
000007FEFA1A18CD CC                   int         3
000007FEFA1A18CE CC                   int         3
000007FEFA1A18CF CC                   int         3
--- f:\dd\vctools\crt\vcruntime\src\string\amd64_arm_arm64\memchr.c ------------
        while ( cnt && (*(unsigned char *)buf != (unsigned char)chr) ) {
000007FEFA1A18D0 4D 85 C0             test        r8,r8
000007FEFA1A18D3 74 0D                je          memchr+12h (07FEFA1A18E2h)
000007FEFA1A18D5 38 11                cmp         byte ptr [rcx],dl
000007FEFA1A18D7 74 09                je          memchr+12h (07FEFA1A18E2h)
                buf = (unsigned char *)buf + 1;
000007FEFA1A18D9 48 FF C1             inc         rcx
                cnt--;
000007FEFA1A18DC 49 83 E8 01          sub         r8,1
000007FEFA1A18E0 75 F3                jne         memchr+5h (07FEFA1A18D5h)
        }
```

Reviewers: rnk

Subscribers: kubabrecka, dberris, llvm-commits, chrisha

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

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


#include <stdio.h>
#include <stdlib.h>

int *list;
int size;
int sum;

int main(void)
{
    size = 9;
    sum = 15;
    list = (int *)malloc(sizeof(int) * size);

    list[0] = 1;
    list[1] = 5;
    list[2] = 8;
    list[3] = 3;
    list[4] = 7;
    list[5] = 12;
    list[6] = 11;
    list[7] = 2;
    list[8] = 6;

    func(size - 1);

    free(list);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

void trim_out_of_range(void);
int shift_right(const int idx, const int sum = 0);
int shift_down(const int idx, const int sum = 0);

int *list;
int size;
int sum;

int main(void)
{
    printf("Enter n= "); scanf("%d", &size);

    list = (int *)malloc(sizeof(int) * size);
    for(int i = 0; i < size; i++)
    {
        printf("Enter list[%d]= ", i); scanf("%d", &list[i]);
    }

    printf("Enter k= "); scanf("%d", &sum);

    trim_out_of_range();
    printf("Result: %d\n", shift_right(size - 1));

    free(list);

    return 0;
}

void trim_out_of_range(void)
{
    for(int i = size - 1; i >= 0; i--)
        if(list[i] > sum)
        {
            for(int j = i; j < size; j++) list[j] = list[j + 1];
            size--;
        }
}

int shift_right(const int idx, const int sum)
{
    if(idx < 0 && sum == ::sum) return 1;
    if(idx < 0) return 0;

    return shift_right(idx - 1, sum + list[idx]) + shift_down(idx, sum);
}

int shift_down(const int idx, const int sum)
{
    if(idx - 1 < 0) return 0;
    return shift_right(idx - 1, sum);
}

Add solution of prob 2

Add solution of prob 2


#include "Genes/Stacked_Pawns_Gene.h"

#include <memory>
#include <string>

#include "Game/Board.h"
#include "Game/Piece.h"
#include "Game/Color.h"

#include "Genes/Gene.h"

double Stacked_Pawns_Gene::score_board(const Board& board, Color perspective, size_t) const
{
    double score = 0.0;

    auto own_pawn = board.piece_instance(PAWN, perspective);
    for(char file = 'a'; file <= 'h'; ++file)
    {
        int pawn_count = 0;

        for(int rank = 1; rank <= 8; ++rank)
        {
            if(board.piece_on_square(file, rank) == own_pawn)
            {
                ++pawn_count;
            }
        }

        if(pawn_count > 1)
        {
            score += pawn_count - 1;
        }
    }

    return -score/6; // negative since, presumably, stacked pawns are bad;
                     // priority can still evolve to be negative.
                     // Divide by six since six is the maximum number of pawns
                     // that can be blocked by other pawns.
}

std::unique_ptr<Gene> Stacked_Pawns_Gene::duplicate() const
{
    return std::make_unique<Stacked_Pawns_Gene>(*this);
}

std::string Stacked_Pawns_Gene::name() const
{
    return "Stacked Pawns Gene";
}

#include "Genes/Stacked_Pawns_Gene.h"

#include <memory>
#include <string>

#include "Game/Board.h"
#include "Game/Piece.h"
#include "Game/Color.h"

#include "Genes/Gene.h"

double Stacked_Pawns_Gene::score_board(const Board& board, Color perspective, size_t) const
{
    double score = 0.0;

    auto own_pawn = board.piece_instance(PAWN, perspective);
    for(char file = 'a'; file <= 'h'; ++file)
    {
        int pawn_count = 0;

        for(int rank = 2; rank <= 7; ++rank)
        {
            if(board.piece_on_square(file, rank) == own_pawn)
            {
                ++pawn_count;
            }
        }

        if(pawn_count > 1)
        {
            score += pawn_count - 1;
        }
    }

    return -score/6; // negative since, presumably, stacked pawns are bad;
                     // priority can still evolve to be negative.
                     // Divide by six since six is the maximum number of pawns
                     // that can be blocked by other pawns.
}

std::unique_ptr<Gene> Stacked_Pawns_Gene::duplicate() const
{
    return std::make_unique<Stacked_Pawns_Gene>(*this);
}

std::string Stacked_Pawns_Gene::name() const
{
    return "Stacked Pawns Gene";
}

Reduce search space when looking for pawns


#include "common.h"
#include "Integrator.h"
#include "IntegrableProperty.h"
#include "EventManager.h"

void Integrator::Update(DeltaTicks &dt) {
	accumulator += dt;
	if(accumulator.Seconds() > 1.0f) { accumulator.SetSeconds(1.0f); }
	alphaMicroseconds = static_cast<uint32_t>(accumulator.Seconds() * 1000000.0f);

	while(accumulator >= timestep) {
		Tick(timestep.Seconds());
		accumulator -= timestep;
	}
}

void Integrator::Tick(DeltaTicks::seconds_type seconds) {
	for(auto it = engine->objects.left.begin(); it != engine->objects.left.end(); ++it) {
		auto property = it->info->Get<IntegrableProperty>().lock();
		if(property) {
			for(auto integrable : *property->GetIntegrables()) {
				integrable->Integrate(seconds);
			}
		}
	}
	engine->GetSystem<EventManager>().lock()->FireIn("integrator", "ticked", seconds);
}

#include "common.h"
#include "Integrator.h"
#include "IntegrableProperty.h"
#include "EventManager.h"

void Integrator::Update(DeltaTicks &dt) {
	accumulator += dt;
	if(accumulator.Seconds() > 1.0f) { accumulator.SetSeconds(1.0f); }

	while(accumulator >= timestep) {
		Tick(timestep.Seconds());
		accumulator -= timestep;
	}

	alphaMicroseconds = static_cast<uint32_t>(accumulator.Seconds() * 1000000.0f);
}

void Integrator::Tick(DeltaTicks::seconds_type seconds) {
	for(auto it = engine->objects.left.begin(); it != engine->objects.left.end(); ++it) {
		auto property = it->info->Get<IntegrableProperty>().lock();
		if(property) {
			for(auto integrable : *property->GetIntegrables()) {
				integrable->Integrate(seconds);
			}
		}
	}
	engine->GetSystem<EventManager>().lock()->FireIn("integrator", "ticked", seconds);
}

Set integrator microseconds value at end of tick


//
// Copyright © 2015 Slack Technologies, Inc. All rights reserved.
//

#include "slack/http.h"

namespace slack
{
namespace http
{

std::function<response(std::string url, params)> get;
std::function<response(std::string url, params)> post;

} //namespace http
} //namespace slack

//
// Copyright © 2015 Slack Technologies, Inc. All rights reserved.
//

#include "slack/http.h"
#include <cpr.h>

namespace slack
{
namespace http
{

std::function<response(std::string url, params)> get = [](std::string url, slack::http::params params) -> slack::http::response {
    cpr::Parameters p;
    for (auto &kv : params)
    {
        p.AddParameter({kv.first, kv.second});
    }

    auto response = cpr::Get(cpr::Url{url}, p);

    return {static_cast<uint32_t>(response.status_code), response.text};
};

std::function<response(std::string url, params)> post = [](std::string url, slack::http::params params) -> slack::http::response {
    cpr::Parameters p;
    for (auto &kv : params)
    {
        p.AddParameter({kv.first, kv.second});
    }

    auto response = cpr::Post(cpr::Url{url}, p);

    return {static_cast<uint32_t>(response.status_code), response.text};
};

} //namespace http
} //namespace slack

Use CPR by default now.

Use CPR by default now.


#include <QTest>
#include <QObject>

#include "uritests.h"

// This is all you need to run all the tests
int main(int argc, char *argv[])
{
    URITests test1;
    QTest::qExec(&test1);
}

#include <QTest>
#include <QObject>

#include "uritests.h"

// This is all you need to run all the tests
int main(int argc, char *argv[])
{
    bool fInvalid = false;

    URITests test1;
    if (QTest::qExec(&test1) != 0)
        fInvalid = true;

    return fInvalid;
}

Return !0 when qt tests fail.

Return !0 when qt tests fail.


// RUN: %clang  -g -S -emit-llvm %s -o - | FileCheck %s

namespace A {
#line 1 "foo.cpp"
namespace B {
int i;
}
}

// CHECK: [[FILE:![0-9]*]]} ; [ DW_TAG_file_type ] [{{.*}}/test/CodeGenCXX/debug-info-namespace.cpp]
// CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i]
// CHECK: [[NS]] = {{.*}}, metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1]
// CHECK: [[CTXT]] = {{.*}}, metadata [[FILE:![0-9]*]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 3]
// CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]

// RUN: %clang  -g -S -emit-llvm %s -o - | FileCheck %s

namespace A {
#line 1 "foo.cpp"
namespace B {
int i;
}
}

// CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-namespace.cpp"
// CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i]
// CHECK: [[NS]] = {{.*}}, metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1]
// CHECK: [[CTXT]] = {{.*}}, metadata [[FILE]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 3]
// CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]

Debug info - generalize namespace test to not depend on a DW_TAG_file_type entry

This isn't necessary & with the next change to LLVM the DW_TAG_file_type entry
won't be emitted at all - only the raw filename/directory pair, so match on
that directly instead.

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


/*
 *  modules.cpp
 *  StatusSpec project
 *
 *  Copyright (c) 2014 thesupremecommander
 *  BSD 2-Clause License
 *  http://opensource.org/licenses/BSD-2-Clause
 *
 */

#pragma once

#include "stdafx.h"

#include "modules.h"

void ModuleManager::UnloadAllModules() {
	for (auto iterator = modules.begin(); iterator != modules.end(); ++iterator) {
		delete iterator->second;
	}

	modules.clear();
}

/*
 *  modules.cpp
 *  StatusSpec project
 *
 *  Copyright (c) 2014 thesupremecommander
 *  BSD 2-Clause License
 *  http://opensource.org/licenses/BSD-2-Clause
 *
 */

#pragma once

#include "stdafx.h"

#include "modules.h"

void ModuleManager::UnloadAllModules() {
	for (auto iterator = modules.begin(); iterator != modules.end(); ++iterator) {
		PRINT_TAG();
		ConColorMsg(Color(0, 255, 0, 255), "Module %s unloaded!\n", iterator->first.c_str());

		delete iterator->second;
	}

	modules.clear();
}

Add a message when unloading a module.

Add a message when unloading a module.


// RUN: clang -fsyntax-only -verify %s
class A { };

class B1 : A { };

class B2 : virtual A { };

class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}

class C : public B1, private B2 { };

class D;

class E : public D { }; // expected-error{{base class has incomplete type}}

typedef int I;

class F : public I { }; // expected-error{{base specifier must name a class}}

union U1 : public A { }; // expected-error{{unions cannot have base classes}}

union U2 {};

class G : public U2 { }; // expected-error{{unions cannot be base classes}}

typedef G G_copy;
typedef G G_copy_2;
typedef G_copy G_copy_3;

class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' specified more than once as a direct base class}}
          public G_copy_3 { }; // expected-error{{base class 'G_copy' specified more than once as a direct base class}}

// RUN: clang -fsyntax-only -verify %s
class A { };

class B1 : A { };

class B2 : virtual A { };

class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}

class C : public B1, private B2 { };

class D;		// expected-note {{forward declaration of 'class D'}}

class E : public D { }; // expected-error{{base class has incomplete type}}

typedef int I;

class F : public I { }; // expected-error{{base specifier must name a class}}

union U1 : public A { }; // expected-error{{unions cannot have base classes}}

union U2 {};

class G : public U2 { }; // expected-error{{unions cannot be base classes}}

typedef G G_copy;
typedef G G_copy_2;
typedef G_copy G_copy_3;

class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' specified more than once as a direct base class}}
          public G_copy_3 { }; // expected-error{{base class 'G_copy' specified more than once as a direct base class}}

Add expected note.  Surely people test before the check in stuff.

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


void build(Solution &s)
{
    auto &tgbot = s.addTarget<StaticLibraryTarget>("reo7sp.tgbot", "1.2.0");
    {
        tgbot += Git("https://github.com/reo7sp/tgbot-cpp", "v{M}.{m}");

        tgbot += cpp11;

        tgbot.Public += "org.sw.demo.boost.property_tree"_dep;
        tgbot.Public += "org.sw.demo.openssl.ssl"_dep;
        tgbot.Public += "org.sw.demo.boost.system"_dep;
        tgbot.Public += "org.sw.demo.boost.date_time"_dep;
        tgbot.Public += "org.sw.demo.badger.curl.libcurl"_dep, "HAVE_CURL"_def;
        tgbot.Public += "org.sw.demo.boost.asio"_dep;
    }

    auto &t = tgbot.addExecutable("test");
    {
        t.Scope = TargetScope::Test;
        t += "test/.*"_rr;
        t += "test"_idir;
        t += "SW_BUILD"_def;
        t += tgbot;
        t += "org.sw.demo.boost.test"_dep;
    }

    tgbot.addTest(t);
}

void build(Solution &s)
{
    auto &tgbot = s.addTarget<StaticLibraryTarget>("reo7sp.tgbot", "1.2.0");
    {
        tgbot += Git("https://github.com/reo7sp/tgbot-cpp", "v{M}.{m}");

        tgbot += cpp11;

        tgbot.Public += "org.sw.demo.boost.property_tree"_dep;
        tgbot.Public += "org.sw.demo.openssl.ssl"_dep;
        tgbot.Public += "org.sw.demo.boost.system"_dep;
        tgbot.Public += "org.sw.demo.boost.date_time"_dep;
        tgbot.Public += "org.sw.demo.badger.curl.libcurl"_dep, "HAVE_CURL"_def;
        tgbot.Public += "org.sw.demo.boost.asio"_dep;
    }

    auto &t = tgbot.addExecutable("test");
    {
        t.Scope = TargetScope::Test;
        t += cpp11;
        t += "test/.*"_rr;
        t += "test"_idir;
        t += "SW_BUILD"_def;
        t += tgbot;
        t += "org.sw.demo.boost.test"_dep;
    }

    tgbot.addTest(t);
}

Add cpp11 for test also.

Add cpp11 for test also.


#include "Log.h"
#include <boost/date_time/posix_time/posix_time.hpp>

Log * g_Log = nullptr;

static const char * g_LogLevelStr[eNumLogLevels] =
{
	"error", // eLogError
	"warn",  // eLogWarning
	"info",  // eLogInfo
	"debug"	 // eLogDebug
};

void LogMsg::Process()
{
	output << boost::posix_time::second_clock::local_time().time_of_day () <<
		"/" << g_LogLevelStr[level] << " - ";
	output << s.str();
}

void Log::Flush ()
{
#ifndef _WIN32
	if (m_LogFile)
		m_LogFile->flush();
#endif
// TODO: find out what's wrong with flush for Windows
}

void Log::SetLogFile (const std::string& fullFilePath)
{
	if (m_LogFile) delete m_LogFile;
	m_LogFile = new std::ofstream (fullFilePath, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);
	if (m_LogFile->is_open ())
		LogPrint("Logging to file ",  fullFilePath, " enabled.");
	else
	{
		delete m_LogFile;
		m_LogFile = nullptr;
	}
}

#include "Log.h"
#include <boost/date_time/posix_time/posix_time.hpp>

Log * g_Log = nullptr;

static const char * g_LogLevelStr[eNumLogLevels] =
{
	"error", // eLogError
	"warn",  // eLogWarning
	"info",  // eLogInfo
	"debug"	 // eLogDebug
};

void LogMsg::Process()
{
	output << boost::posix_time::second_clock::local_time().time_of_day () <<
		"/" << g_LogLevelStr[level] << " - ";
	output << s.str();
}

void Log::Flush ()
{
	if (m_LogFile)
		m_LogFile->flush();
}

void Log::SetLogFile (const std::string& fullFilePath)
{
	if (m_LogFile) delete m_LogFile;
	m_LogFile = new std::ofstream (fullFilePath, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);
	if (m_LogFile->is_open ())
		LogPrint("Logging to file ",  fullFilePath, " enabled.");
	else
	{
		delete m_LogFile;
		m_LogFile = nullptr;
	}
}

Revert "fixed typo" and "fixed crash for Windows"

This reverts commits c8a80a497d6b7f0f98841b72febb0dba9fabec28 and f7791e5289ef61860e0fca024f86c31e448982f1

This didn't actually fix Windows crash problem. In fact, it still
crashed without --log=0 being set. Changes to the i2pd.vcxproj file
fixed the crashes with VS 2013 > update 1.  i2pd now works with VS 2013
Update 3 and Update 4 RC.

Since these changes didn't have the intended effect, let's remove them.


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * 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 <folly/python/executor.h>

#include <stdexcept>

#include <folly/CppAttributes.h>
#include <folly/python/executor_api.h> // @manual

namespace folly {
namespace python {

namespace {

void ensure_imported() {
  static bool imported = false;
  if (!imported) {
    if (0 != import_folly__executor()) {
      throw std::runtime_error("import_folly__executor failed");
    }
    imported = true;
  }
}

} // namespace

folly::Executor* getExecutor() {
  ensure_imported();
  return get_running_executor(false); // TODO: fried set this to true
}

int setExecutorForLoop(PyObject* loop, AsyncioExecutor* executor) {
  ensure_imported();
  return set_executor_for_loop(loop, executor);
}

} // namespace python
} // namespace folly

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * 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 <folly/python/executor.h>

#include <stdexcept>

#include <folly/python/executor_api.h> // @manual

namespace folly {
namespace python {

namespace {

void ensure_imported() {
  static bool imported = false;
  if (!imported) {
    if (0 != import_folly__executor()) {
      throw std::runtime_error("import_folly__executor failed");
    }
    imported = true;
  }
}

} // namespace

folly::Executor* getExecutor() {
  ensure_imported();
  return get_running_executor(false); // TODO: fried set this to true
}

int setExecutorForLoop(PyObject* loop, AsyncioExecutor* executor) {
  ensure_imported();
  return set_executor_for_loop(loop, executor);
}

} // namespace python
} // namespace folly

Remove dead includes in folly/python

Remove dead includes in folly/python

Reviewed By: pranavtbhat

Differential Revision: D34103812

fbshipit-source-id: e02b728d468bf091e8b4521f8f8746a986a2130d


#include "../src/pugixml.hpp"

#if PUGIXML_VERSION != 1120
#error Unexpected pugixml version
#endif

#include "../src/pugixml.hpp"

#if PUGIXML_VERSION != 1130
#error Unexpected pugixml version
#endif

Fix version check in test

Fix version check in test


//=======================================================================
// 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 "tac/Utils.hpp"

using namespace eddic;

void eddic::tac::computeBlockUsage(std::shared_ptr<tac::Function> function, std::unordered_set<std::shared_ptr<tac::BasicBlock>>& usage){
    for(auto& block : function->getBasicBlocks()){
        for(auto& statement : block->statements){
            if(auto* ptr = boost::get<std::shared_ptr<tac::Goto>>(&statement)){
                usage.insert((*ptr)->block);
            } else if(auto* ptr = boost::get<std::shared_ptr<tac::IfFalse>>(&statement)){
                usage.insert((*ptr)->block);
            } else if(auto* ptr = boost::get<std::shared_ptr<tac::If>>(&statement)){
                usage.insert((*ptr)->block);
            }
        }
    }
}

bool eddic::tac::safe(std::shared_ptr<tac::Call> call){
    auto function = call->function;

    //These three functions are considered as safe because they save/restore all the registers and does not return anything
    return function == "print_integer" || function == "print_string" || function == "print_line";
}

//=======================================================================
// 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 "tac/Utils.hpp"

using namespace eddic;

void eddic::tac::computeBlockUsage(std::shared_ptr<tac::Function> function, std::unordered_set<std::shared_ptr<tac::BasicBlock>>& usage){
    for(auto& block : function->getBasicBlocks()){
        for(auto& statement : block->statements){
            if(auto* ptr = boost::get<std::shared_ptr<tac::Goto>>(&statement)){
                usage.insert((*ptr)->block);
            } else if(auto* ptr = boost::get<std::shared_ptr<tac::IfFalse>>(&statement)){
                usage.insert((*ptr)->block);
            } else if(auto* ptr = boost::get<std::shared_ptr<tac::If>>(&statement)){
                usage.insert((*ptr)->block);
            }
        }
    }
}

bool eddic::tac::safe(std::shared_ptr<tac::Call> call){
    auto function = call->function;

    //These functions are considered as safe because they save/restore all the registers and does not return anything
    return
        function == "_F5printB" || function == "_F5printI" || function == "_F5printS" ||
        function == "_F7printlnB" || function == "_F7printlnI" || function == "_F7printlnS" ||
        function == "_F7println";
}

Fix the safe functions calculations function to handle the new function names


// 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 "base/system_monitor.h"

namespace base {

void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
  PowerEvent power_event;
  switch (event_id) {
    case PBT_APMPOWERSTATUSCHANGE:
      power_event = POWER_STATE_EVENT;
      break;
    case PBT_APMRESUMEAUTOMATIC:
      power_event = RESUME_EVENT;
      break;
    case PBT_APMSUSPEND:
      power_event = SUSPEND_EVENT;
      break;
    default:
      DCHECK(false);
  }
  ProcessPowerMessage(power_event);
}

// Function to query the system to see if it is currently running on
// battery power.  Returns true if running on battery.
bool SystemMonitor::IsBatteryPower() {
  SYSTEM_POWER_STATUS status;
  if (!GetSystemPowerStatus(&status)) {
    LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
    return false;
  }
  return (status.ACLineStatus == 0);
}

} // namespace base

// 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 "base/system_monitor.h"

namespace base {

void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
  PowerEvent power_event;
  switch (event_id) {
    case PBT_APMPOWERSTATUSCHANGE:  // The power status changed.
      power_event = POWER_STATE_EVENT;
      break;
    case PBT_APMRESUMEAUTOMATIC:  // Non-user initiated resume from suspend.
    case PBT_APMRESUMESUSPEND:    // User initiated resume from suspend.
      power_event = RESUME_EVENT;
      break;
    case PBT_APMSUSPEND:  // System has been suspended.
      power_event = SUSPEND_EVENT;
      break;
    default:
      return;

    // Other Power Events:
    // PBT_APMBATTERYLOW - removed in Vista.
    // PBT_APMOEMEVENT - removed in Vista.
    // PBT_APMQUERYSUSPEND - removed in Vista.
    // PBT_APMQUERYSUSPENDFAILED - removed in Vista.
    // PBT_APMRESUMECRITICAL - removed in Vista.
    // PBT_POWERSETTINGCHANGE - user changed the power settings.
  }
  ProcessPowerMessage(power_event);
}

// Function to query the system to see if it is currently running on
// battery power.  Returns true if running on battery.
bool SystemMonitor::IsBatteryPower() {
  SYSTEM_POWER_STATUS status;
  if (!GetSystemPowerStatus(&status)) {
    LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
    return false;
  }
  return (status.ACLineStatus == 0);
}

} // namespace base

Update comments and remove bogus DCHECK in windows-specific broadcasted power message status.

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

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

Former-commit-id: 426ce67687a6f4396181ab45ffe6223098d4fd4e


#include <ShObjIdl.h>
#include <atlbase.h>
#include <wchar.h>

int wmain(int argc, wchar_t* argv[])
{
    HRESULT hr = S_OK;

    if (argc < 2)
    {
        hr = E_INVALIDARG;
        wprintf(L"Supply an app ID (AppUserModelId) for the application to launch.");
        return hr;
    }

    const wchar_t* appId = argv[1];

    hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
    if (FAILED(hr))
    {
        wprintf(L"Error initializing COM");
        return hr;
    }

    CComPtr<IApplicationActivationManager> aam = nullptr;
    hr = CoCreateInstance(CLSID_ApplicationActivationManager, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&aam));
    if (FAILED(hr))
    {
        wprintf(L"Error creating ApplicationActivationManager");
        CoUninitialize();
        return hr;
    }

    hr = CoAllowSetForegroundWindow(aam, nullptr);
    if (FAILED(hr))
    {
        wprintf(L"Error calling CoAllowSetForegroundWindow");
        CoUninitialize();
        return hr;
    }

    unsigned long pid = 0;
    hr = aam->ActivateApplication(appId, nullptr, AO_NONE, &pid);
    if (FAILED(hr))
    {
        wprintf(L"Error calling ActivateApplication");
        CoUninitialize();
        return hr;
    }

    CoUninitialize();
    return hr;
}

#include <ShObjIdl.h>
#include <wchar.h>

HRESULT CreateAAM(IApplicationActivationManager*& aam)
{
    return CoCreateInstance(CLSID_ApplicationActivationManager, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&aam));
}

HRESULT ActivateApp(IApplicationActivationManager* aam, const wchar_t* appId)
{
    unsigned long unused = 0;
    return aam->ActivateApplication(appId, nullptr, AO_NONE, &unused);
}

int wmain(int argc, wchar_t* argv[])
{
    HRESULT hr = S_OK;

    if (argc < 2)
    {
        hr = E_INVALIDARG;
        wprintf(L"Supply an app ID (AppUserModelId) for the application to launch.");
    }
    else
    {
        hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
        if (FAILED(hr))
        {
            wprintf(L"Error initializing COM");
        }
        else
        {
            IApplicationActivationManager* aam = nullptr;
            hr = CreateAAM(aam);
            if (FAILED(hr))
            {
                wprintf(L"Error creating ApplicationActivationManager");
            }
            else
            {
                hr = CoAllowSetForegroundWindow(aam, nullptr);
                if (FAILED(hr))
                {
                    wprintf(L"Error calling CoAllowSetForegroundWindow");
                }
                else
                {
                    hr = ActivateApp(aam, argv[1]);
                    if (FAILED(hr))
                    {
                        wprintf(L"Error calling ActivateApplication");
                    }
                }

                aam->Release();
            }

            CoUninitialize();
        }
    }

    return hr;
}

Switch to nesting for less repetitive error handling.

Also extract some methods.


//
// Copyright 2012 Francisco Jerez
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

#include "core/platform.hpp"

using namespace clover;

platform::platform() : adaptor_range(derefs(), devs) {
   int n = pipe_loader_probe(NULL, 0);
   std::vector<pipe_loader_device *> ldevs(n);

   pipe_loader_probe(&ldevs.front(), n);

   for (pipe_loader_device *ldev : ldevs) {
      try {
         devs.push_back(transfer(new device(*this, ldev)));
      } catch (error &) {}
   }
}

//
// Copyright 2012 Francisco Jerez
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

#include "core/platform.hpp"

using namespace clover;

platform::platform() : adaptor_range(derefs(), devs) {
   int n = pipe_loader_probe(NULL, 0);
   std::vector<pipe_loader_device *> ldevs(n);

   pipe_loader_probe(&ldevs.front(), n);

   for (pipe_loader_device *ldev : ldevs) {
      try {
         devs.push_back(transfer(new device(*this, ldev)));
      } catch (error &) {
         pipe_loader_release(&ldev, 1);
      }
   }
}

clover: Fix memory leak when initializing a device object fails.

Tested-by: Tom Stellard <85590917cb30a670bf23f5b4273617f8815d1e87@amd.com>


/*
* Darwin SecRandomCopyBytes EntropySource
* (C) 2015 Daniel Seither (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/internal/darwin_secrandom.h>
#include <Security/Security.h>
#include <Security/SecRandom.h>

namespace Botan {

/**
* Gather entropy from SecRandomCopyBytes
*/
size_t Darwin_SecRandom::poll(RandomNumberGenerator& rng)
   {
   secure_vector<uint8_t> buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);

   if(0 == SecRandomCopyBytes(kSecRandomDefault, buf.size(), buf.data()))
      {
      rng.add_entropy(buf.data(), buf.size());
      return buf.size() * 8;
      }
   }

}

/*
* Darwin SecRandomCopyBytes EntropySource
* (C) 2015 Daniel Seither (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/internal/darwin_secrandom.h>
#include <Security/Security.h>
#include <Security/SecRandom.h>

namespace Botan {

/**
* Gather entropy from SecRandomCopyBytes
*/
size_t Darwin_SecRandom::poll(RandomNumberGenerator& rng)
   {
   secure_vector<uint8_t> buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);

   if(0 == SecRandomCopyBytes(kSecRandomDefault, buf.size(), buf.data()))
      {
      rng.add_entropy(buf.data(), buf.size());
      return buf.size() * 8;
      }

   return 0;
   }

}

Return 0 bits in Darwin_SecRandom::poll on SecRandomCopyBytes failure


// Copyright (c) 2015 Klaralvdalens Datakonsult AB (KDAB).
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "debug.h"

#include <QString>
#include <QDebug>

#include <iostream>

std::ostream& operator<<(std::ostream& stream, const wchar_t *input)
{
    return stream << qPrintable(QString::fromWCharArray(input));
}

QDebug operator<<(QDebug stream, const CefString& string)
{
  return stream << QString::fromStdString(string.ToString());
}

Q_LOGGING_CATEGORY(handler, "phantomjs.handler", QtWarningMsg)
Q_LOGGING_CATEGORY(print, "phantomjs.print", QtWarningMsg)
Q_LOGGING_CATEGORY(app, "phantomjs.app", QtWarningMsg)

// Copyright (c) 2015 Klaralvdalens Datakonsult AB (KDAB).
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "debug.h"

#include <QString>
#include <QDebug>

#include <iostream>

std::ostream& operator<<(std::ostream& stream, const wchar_t *input)
{
    return stream << qPrintable(QString::fromWCharArray(input));
}

QDebug operator<<(QDebug stream, const CefString& string)
{
  return stream << QString::fromStdString(string.ToString());
}

#if QT_VERSION >= 0x050400
#define WARNING_BY_DEFAULT , QtWarningMsg
#else
#define WARNING_BY_DEFAULT
#endif

Q_LOGGING_CATEGORY(handler, "phantomjs.handler" WARNING_BY_DEFAULT)
Q_LOGGING_CATEGORY(print, "phantomjs.print" WARNING_BY_DEFAULT)
Q_LOGGING_CATEGORY(app, "phantomjs.app" WARNING_BY_DEFAULT)

Make code compile with Qt 5.2

Make code compile with Qt 5.2


// 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 "cameo/runtime/app/cameo_main_delegate.h"
#include "content/public/app/content_main.h"

#if defined(OS_WIN)
#include "content/public/app/startup_helper_win.h"
#include "sandbox/win/sandbox_types.h"
#endif

#if defined(OS_WIN)
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
  sandbox::SandboxInterfaceInfo sandbox_info = {0};
  content::InitializeSandboxInfo(&sandbox_info);
  cameo::CameoMainDelegate delegate;
  return content::ContentMain(instance, &sandbox_info, &delegate);
}
#elif defined(OS_LINUX)
int main(int argc, const char** argv) {
  cameo::CameoMainDelegate delegate;
  return content::ContentMain(argc, argv, &delegate);
}
#else
#error "Unsupport platform."
#endif

// 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 "cameo/runtime/app/cameo_main_delegate.h"
#include "content/public/app/content_main.h"

#if defined(OS_WIN)
#include "content/public/app/startup_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif

#if defined(OS_WIN)
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
  sandbox::SandboxInterfaceInfo sandbox_info = {0};
  content::InitializeSandboxInfo(&sandbox_info);
  cameo::CameoMainDelegate delegate;
  return content::ContentMain(instance, &sandbox_info, &delegate);
}
#elif defined(OS_LINUX)
int main(int argc, const char** argv) {
  cameo::CameoMainDelegate delegate;
  return content::ContentMain(argc, argv, &delegate);
}
#else
#error "Unsupport platform."
#endif

Fix wrongly changed include path when removing cameo/src dir


// Copyright 2016 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 "ozone/ui/desktop_aura/desktop_factory_ozone_wayland.h"

#include "ozone/ui/desktop_aura/desktop_screen_wayland.h"
#include "ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc"

namespace views {

DesktopWindowTreeHost* DesktopFactoryOzoneWayland::CreateWindowTreeHost(
    internal::NativeWidgetDelegate* native_widget_delegate,
    DesktopNativeWidgetAura* desktop_native_widget_aura) {
  return new DesktopWindowTreeHostOzone(native_widget_delegate,
                                        desktop_native_widget_aura);
}

gfx::Screen* DesktopFactoryOzoneWayland::CreateDesktopScreen() {
  return new DesktopScreenWayland;
}

DesktopFactoryOzone* CreateDesktopFactoryOzoneWayland() {
  return new DesktopFactoryOzoneWayland;
}

}  // namespace views

// Copyright 2016 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 "ozone/ui/desktop_aura/desktop_factory_ozone_wayland.h"

#include "ozone/ui/desktop_aura/desktop_screen_wayland.h"
#include "ozone/ui/desktop_aura/desktop_window_tree_host_ozone.h"

namespace views {

DesktopWindowTreeHost* DesktopFactoryOzoneWayland::CreateWindowTreeHost(
    internal::NativeWidgetDelegate* native_widget_delegate,
    DesktopNativeWidgetAura* desktop_native_widget_aura) {
  return new DesktopWindowTreeHostOzone(native_widget_delegate,
                                        desktop_native_widget_aura);
}

gfx::Screen* DesktopFactoryOzoneWayland::CreateDesktopScreen() {
  return new DesktopScreenWayland;
}

DesktopFactoryOzone* CreateDesktopFactoryOzoneWayland() {
  return new DesktopFactoryOzoneWayland;
}

}  // namespace views

Fix multiple definition link error

Fix multiple definition link error

Include desktop_window_tree_host_ozone header instead of its implementation
in desktop_factory_ozone_wayland.cc to solve the following link issue:

  obj/ozone/ui/desktop_aura/views.desktop_window_tree_host_ozone.o: In function `views::DesktopWindowTreeHostOzone::AsWindowTreeHost()':
  src/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc:239: multiple definition of `views::DesktopWindowTreeHostOzone::AsWindowTreeHost()'
  src/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc:239: first defined here
  obj/ozone/ui/desktop_aura/views.desktop_window_tree_host_ozone.o: In function `views::DesktopWindowTreeHostOzone::ShowMaximizedWithBounds(gfx::Rect const&)':
  src/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc:268: multiple definition of `views::DesktopWindowTreeHostOzone::ShowMaximizedWithBounds(gfx::Rect const&)'
  src/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc:268: first defined here
  [...]


#include <QString>
#include <QDir>
#include <QtCore>
#include <iostream>

int main(int argc, char** argv)
{
    //QCoreApplication app(argc, argv);
    QDir dir;

    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Size | QDir::Reversed);

    QString path = argv[1];

    dir.cd(path);

    QFileInfoList list = dir.entryInfoList();

    std::cout << "     Bytes Filename" << std::endl;

    for (int i = 0; i < list.size(); ++i)
    {
        QFileInfo fileInfo = list.at(i);

        std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10).arg(fileInfo.fileName()));
        std::cout << std::endl;
    }

    return 0; //app.exec();
}

#include <QString>
#include <QDir>
#include <QtCore>
#include <iostream>

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    QDir dir;

    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Size | QDir::Reversed);

    QString path = argv[1];

    dir.cd(path);

    QFileInfoList list = dir.entryInfoList();

    std::cout << "     Bytes Filename" << std::endl;

    for (int i = 0; i < list.size(); ++i)
    {
        QFileInfo fileInfo = list.at(i);

        std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10).arg(fileInfo.fileName()));
        std::cout << std::endl;
    }

    return app.exec();
}

Add QCoreApplication app. Replace return 0 on return app.exec().


#include <Ab/Config.hpp>
#include <Ab/LinearMemory.hpp>
#include <gtest/gtest.h>

namespace Ab::Test {

TEST(LinearMemoryTest, InitAndKill) { LinearMemory m; }

TEST(LinearMemoryTest, GrowThreeTimes) {
	LinearMemory m;
	for (std::size_t i = 0; i < 3; i++) {
		m.grow();
	}
}

TEST(LinearMemoryTest, AssignToMemory) {
	LinearMemoryConfig cfg;
	cfg.page_count_min = 1;
	cfg.page_count_max = 1;

	LinearMemory m(cfg);

	auto ptr = to_ptr<int>(m.address());
	EXPECT_NE(ptr, nullptr);
	EXPECT_EQ(*ptr, 0);
	*ptr = 123;
	EXPECT_EQ(*ptr, 123);
}

}  // namespace Ab::Test

#include <Ab/Config.hpp>
#include <Ab/LinearMemory.hpp>
#include <gtest/gtest.h>

namespace Ab::Test {

TEST(LinearMemoryTest, InitAndKill) { LinearMemory m; }

TEST(LinearMemoryTest, GrowThreeTimes) {
	LinearMemoryConfig cfg;
	cfg.page_count_min = 0;
	cfg.page_count_max = 3;

	LinearMemory m(cfg);
	for (std::size_t i = 0; i < 3; i++) {
		m.grow();
	}
}

TEST(LinearMemoryTest, AssignToMemory) {
	LinearMemoryConfig cfg;
	cfg.page_count_min = 1;
	cfg.page_count_max = 1;

	LinearMemory m(cfg);

	auto ptr = to_ptr<int>(m.address());
	EXPECT_NE(ptr, nullptr);
	EXPECT_EQ(*ptr, 0);
	*ptr = 123;
	EXPECT_EQ(*ptr, 123);
}

}  // namespace Ab::Test

Use LinearMemoryConfig when creating LinearMemory in test

Signed-off-by: Andrew Young <9b1c84997b9b503084a7ab9e0b7da3894895a5c3@gmail.com>


#include "stdafx.h"

#include "TimeUtilities.h"

#include <time.h>

namespace SDK
	{

	namespace Utilities
		{

		void SleepSeconds(ulong i_seconds)
			{
			clock_t now = clock();
			clock_t limit = now + i_seconds * CLOCKS_PER_SEC;
			while ( limit > now )
				now = clock();
			}

		void SleepMiliseconds(ulong i_miliseconds)
			{
			long timeout = clock() + i_miliseconds;
			while( clock() < timeout ) continue;
			}

		} // Utilities

	} // SDK

#include "stdafx.h"

#include "TimeUtilities.h"

#include <time.h>

#ifdef _WIN32
    #include <windows.h>
#else
    #include <unistd.h>
#endif

namespace SDK
	{

	namespace Utilities
		{

		void SleepSeconds(ulong i_seconds)
			{
			SleepMiliseconds(i_seconds*1000);
			}

		void SleepMiliseconds(ulong i_miliseconds)
			{
			#ifdef _WIN32
				Sleep(i_miliseconds);
			#else
			 usleep(i_miliseconds * 1000); // takes microseconds
			#endif
			}

		} // Utilities

	} // SDK

[Utilities] Use standard functions for Linux and Windows


//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp -----------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "AMDGPURelocationHandler.h"

using namespace lld::elf;

std::error_code AMDGPUTargetRelocationHandler::applyRelocation(
    ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
    const Reference &ref) const {
  return std::error_code();
}

//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp -----------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "AMDGPURelocationHandler.h"

using namespace lld;
using namespace lld::elf;

std::error_code AMDGPUTargetRelocationHandler::applyRelocation(
    ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
    const Reference &ref) const {
  return std::error_code();
}

ELF/AMDGPU: Add missing: using namespace lld; to try to fix windows bot

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@246179 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2010 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 "remoting/host/capturer.h"

namespace remoting {

Capturer::Capturer()
    : width_(0),
      height_(0),
      pixel_format_(PixelFormatInvalid),
      bytes_per_pixel_(0),
      bytes_per_row_(0),
      current_buffer_(0) {
}

Capturer::~Capturer() {
}

void Capturer::GetDirtyRects(DirtyRects* rects) const {
  *rects = dirty_rects_;
}

int Capturer::GetWidth() const {
  return width_;
}

int Capturer::GetHeight() const {
  return height_;
}

PixelFormat Capturer::GetPixelFormat() const {
  return pixel_format_;
}

void Capturer::InvalidateRect(gfx::Rect dirty_rect) {
  inval_rects_.push_back(dirty_rect);
}

void Capturer::FinishCapture(Task* done_task) {
  done_task->Run();
  delete done_task;

  // Select the next buffer to be the current buffer.
  current_buffer_ = ++current_buffer_ % kNumBuffers;
}

}  // namespace remoting

// Copyright (c) 2010 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 "remoting/host/capturer.h"

namespace remoting {

Capturer::Capturer()
    : width_(0),
      height_(0),
      pixel_format_(PixelFormatInvalid),
      bytes_per_pixel_(0),
      bytes_per_row_(0),
      current_buffer_(0) {
}

Capturer::~Capturer() {
}

void Capturer::GetDirtyRects(DirtyRects* rects) const {
  *rects = dirty_rects_;
}

int Capturer::GetWidth() const {
  return width_;
}

int Capturer::GetHeight() const {
  return height_;
}

PixelFormat Capturer::GetPixelFormat() const {
  return pixel_format_;
}

void Capturer::InvalidateRect(gfx::Rect dirty_rect) {
  inval_rects_.push_back(dirty_rect);
}

void Capturer::FinishCapture(Task* done_task) {
  done_task->Run();
  delete done_task;

  // Select the next buffer to be the current buffer.
  current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
}

}  // namespace remoting

Coverity: Fix undefined assignment evaluation order in remoting::Capturer::FinishCapture.

CID=10878
BUG=none
TEST=builds

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

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

Former-commit-id: 0261c625161fafb471c018e572b46d59fed09119


#include "AbstractUniformImplementation.h"

#include <globjects/globjects.h>

#include "BindlessUniformImplementation.h"
#include "LegacyUniformImplementation.h"

namespace glo {

AbstractUniformImplementation::AbstractUniformImplementation()
{
}

AbstractUniformImplementation::~AbstractUniformImplementation()
{
}

AbstractUniformImplementation * AbstractUniformImplementation::create()
{
    if (hasExtension(gl::GLextension::GL_EXT_direct_state_access))
    {
        return new BindlessUniformImplementation();
    }
    else
    {
        return new LegacyUniformImplementation();
    }
}

} // namespace glo

#include "AbstractUniformImplementation.h"

#include <globjects/globjects.h>

#include "BindlessUniformImplementation.h"
#include "LegacyUniformImplementation.h"

namespace glo {

AbstractUniformImplementation::AbstractUniformImplementation()
{
}

AbstractUniformImplementation::~AbstractUniformImplementation()
{
}

AbstractUniformImplementation * AbstractUniformImplementation::create()
{
    if (hasExtension(gl::GLextension::GL_ARB_separate_shader_objects))
    {
        return new BindlessUniformImplementation();
    }
    else
    {
        return new LegacyUniformImplementation();
    }
}

} // namespace glo

Fix required extension for bindless uniform setters


#include "hackypassabilityagent.h"

#include <QQuickItem>
#include <QQuickWindow>

#include "quickentity.h"
#include "utils.h"

HackyPassabilityAgent::HackyPassabilityAgent() :
    mGridItem(nullptr)
{
}

bool HackyPassabilityAgent::isPassable(const QPointF &pos, AbstractEntity *entity)
{
    if (!mGridItem)
        return false;

    QuickEntity *quickEntity = dynamic_cast<QuickEntity*>(entity);
    Q_ASSERT(quickEntity);

    // very basic, hacky check that doesn't take into account a radius.
    QQuickItem *child = mGridItem->childAt(pos.x(), pos.y());
    if (child->property("blocksMovement").toBool()) {
        return false;
    }

    return true;
}

QQuickItem *HackyPassabilityAgent::gridItem() const
{
    return mGridItem;
}

void HackyPassabilityAgent::setGridItem(QQuickItem *gridItem)
{
    if (gridItem == mGridItem)
        return;

    mGridItem = gridItem;
    emit gridItemChanged();
}

#include "hackypassabilityagent.h"

#include <QQuickItem>
#include <QQuickWindow>

#include "quickentity.h"
#include "utils.h"

HackyPassabilityAgent::HackyPassabilityAgent() :
    mGridItem(nullptr)
{
}

bool HackyPassabilityAgent::isPassable(const QPointF &pos, AbstractEntity *entity)
{
    if (!mGridItem)
        return false;

    QuickEntity *quickEntity = dynamic_cast<QuickEntity*>(entity);
    Q_ASSERT(quickEntity);

    // very basic, hacky check that doesn't take into account a radius.
    QQuickItem *child = mGridItem->childAt(pos.x(), pos.y());
    if (child && child->property("blocksMovement").toBool()) {
        return false;
    }

    return true;
}

QQuickItem *HackyPassabilityAgent::gridItem() const
{
    return mGridItem;
}

void HackyPassabilityAgent::setGridItem(QQuickItem *gridItem)
{
    if (gridItem == mGridItem)
        return;

    mGridItem = gridItem;
    emit gridItemChanged();
}

Fix null pointer access in HackyPassabilityAgent


#include "Client.hh"

#include <string>
#include "Socket.hh"
#include "http/Response.hh"
#include "http/Request.hh"
#include "methods/Get.hh"
#include "Config.hh"

ss::Client::Client(Socket* socket) : socket(socket)
{
	auto request = get_request();
	http::Response response;
	response.headers["protocol"] = "HTTP/1.1";

	if (request.headers["method"] == "GET")
	{
		methods::Get(request, &response);
	}

	send_response(response);
}

ss::http::Request ss::Client::get_request()
{
	std::string response;

	// An endless wait may happen if the last response is the same size as buffer.
	while (true)
	{
		char buffer[1024];
		int received;
		socket->receive(&buffer, sizeof(buffer), &received);
		response.append(buffer, received);

		if (received < sizeof(buffer))
		{
			break;
		}
	}

	return http::Request(response);
}

void ss::Client::send_response(const http::Response& response)
{
	const auto response_string = response.as_string();
	socket->send(response_string.data(), response_string.size());
	socket->disconnect();
}

#include "Client.hh"

#include <string>
#include "Socket.hh"
#include "http/Response.hh"
#include "http/Request.hh"
#include "methods/Get.hh"
#include "Config.hh"

ss::Client::Client(Socket* socket) : socket(socket)
{
	auto request = get_request();
	http::Response response;
	response.headers["protocol"] = "HTTP/1.1";

	if (request.headers["method"] == "GET")
	{
		methods::Get(request, &response);
	}

	send_response(response);
}

ss::http::Request ss::Client::get_request()
{
	std::string response;

  char buffer[1024];
	int received = sizeof(buffer);
	// An endless wait may happen if the last response is the same size as buffer.
  while (received == sizeof(buffer)) {
		socket->receive(&buffer, sizeof(buffer), &received);
		response.append(buffer, received);
	}

	return http::Request(response);
}

void ss::Client::send_response(const http::Response& response)
{
	const auto response_string = response.as_string();
	socket->send(response_string.data(), response_string.size());
	socket->disconnect();
}

Make while loop more compact

Make while loop more compact


/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "QmitkToolGUI.h"

#include <iostream>

QmitkToolGUI::~QmitkToolGUI()
{
  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0; // otherwise ITK will complain in LightObject's destructor
  m_ReferenceCountLock.Unlock();
}

void QmitkToolGUI::Register() const
{
  // empty on purpose, just don't let ITK handle calls to Register()
}

void QmitkToolGUI::UnRegister() const
{
  // empty on purpose, just don't let ITK handle calls to UnRegister()
}

void QmitkToolGUI::SetReferenceCount(int)
{
  // empty on purpose, just don't let ITK handle calls to SetReferenceCount()
}

void QmitkToolGUI::SetTool( mitk::Tool* tool )
{
  m_Tool = tool;

  emit( NewToolAssociated(tool) );
}

/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "QmitkToolGUI.h"

#include <iostream>

QmitkToolGUI::~QmitkToolGUI()
{
  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0; // otherwise ITK will complain in LightObject's destructor
  m_ReferenceCountLock.Unlock();
}

void QmitkToolGUI::Register() const
{
  // empty on purpose, just don't let ITK handle calls to Register()
}

void QmitkToolGUI::UnRegister() const ITK_NOEXCEPT
{
  // empty on purpose, just don't let ITK handle calls to UnRegister()
}

void QmitkToolGUI::SetReferenceCount(int)
{
  // empty on purpose, just don't let ITK handle calls to SetReferenceCount()
}

void QmitkToolGUI::SetTool( mitk::Tool* tool )
{
  m_Tool = tool;

  emit( NewToolAssociated(tool) );
}

Add missing keyword to UnRegister definition

(gcc was complaining)


#include <iostream>

//Thomas' Prototypes

//Hannah's Prototypes

int atomic_distance (int distance); //Kate's Prototype: defines atomic distance as integer

int (main)
{
using nedit file...
create new input "hannah's test changes"
}

#include <iostream>

//Thomas' Prototypes

//Hannah's Prototypes

int atomic_distance (int x, int y, int z); //Kate's Prototype: defines atomic distance as combination of x, y, z coordinates

int (main)
{
using nedit file...
create new input "hannah's test changes"
}

Update to Kate's First Function Prototype


// 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 "base/native_library.h"

#include <dlfcn.h>

#include "base/file_path.h"
#include "base/logging.h"

namespace base {

// static
NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
  void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY);
  if (!dl)
    NOTREACHED() << "dlopen failed: " << dlerror();

  return dl;
}

// static
void UnloadNativeLibrary(NativeLibrary library) {
  int ret = dlclose(library);
  if (ret < 0)
    NOTREACHED() << "dlclose failed: " << dlerror();
}

// static
void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
                                          NativeLibraryFunctionNameType name) {
  return dlsym(library, name);
}

}  // namespace base

// 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 "base/native_library.h"

#include <dlfcn.h>

#include "base/file_path.h"
#include "base/logging.h"

namespace base {

// static
NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
  void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY|RTLD_DEEPBIND);
  if (!dl)
    NOTREACHED() << "dlopen failed: " << dlerror();

  return dl;
}

// static
void UnloadNativeLibrary(NativeLibrary library) {
  int ret = dlclose(library);
  if (ret < 0)
    NOTREACHED() << "dlclose failed: " << dlerror();
}

// static
void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
                                          NativeLibraryFunctionNameType name) {
  return dlsym(library, name);
}

}  // namespace base

Use RTLD_DEEPBIND to make sure plugins don't use Chrome's symbols instead of their own

Review URL: http://codereview.chromium.org/112030
Patch from Antoine Labour <piman@google.com>.

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


#include "KAI/Console/Console.h"

#include <iostream>

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif

using namespace std;

USING_NAMESPACE_KAI

//static Color _color;

int main(int argc, char **argv)
{
	KAI_UNUSED_2(argc, argv);

	cout << "pyro v0.1" << endl;

	Console console;
	console.SetLanguage(Language::Pi);

	Process::trace = 0;
	console.GetExecutor()->SetTraceLevel(0);

	return console.Run();
}

#include <KAI/Console/Console.h>
#include <iostream>

using namespace std;

USING_NAMESPACE_KAI

int main(int argc, char **argv)
{
	KAI_UNUSED_2(argc, argv);

	cout << "KAI v0.1" << endl;

	Console console;
	console.SetLanguage(Language::Pi);

	// the higher the number, the greater the verbosity of debug output
	Process::trace = 0;
	console.GetExecutor()->SetTraceLevel(0);

	// start the REPL
	return console.Run();
}

Remove explicit WIN32 references from Console app.


// 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/Models/Enchantment.hpp>
#include <Rosetta/Tasks/SimpleTasks/RemoveEnchantmentTask.hpp>

namespace RosettaStone::SimpleTasks
{
TaskID RemoveEnchantmentTask::GetTaskID() const
{
    return TaskID::REMOVE_ENCHANTMENT;
}

TaskStatus RemoveEnchantmentTask::Impl(Player&)
{
    auto enchantment = dynamic_cast<Enchantment*>(m_source);
    if (enchantment == nullptr)
    {
        return TaskStatus::STOP;
    }

    enchantment->Remove();

    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/Models/Enchantment.hpp>
#include <Rosetta/Tasks/SimpleTasks/RemoveEnchantmentTask.hpp>

namespace RosettaStone::SimpleTasks
{
TaskID RemoveEnchantmentTask::GetTaskID() const
{
    return TaskID::REMOVE_ENCHANTMENT;
}

TaskStatus RemoveEnchantmentTask::Impl(Player&)
{
    auto enchantment = dynamic_cast<Enchantment*>(m_source);
    if (enchantment == nullptr)
    {
        return TaskStatus::STOP;
    }

    if (enchantment->card.power.GetEnchant() != nullptr)
    {
        for (auto& effect : enchantment->card.power.GetEnchant()->effects)
        {
            effect->Remove(m_target);
        }
    }

    enchantment->Remove();

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

Add code to remove effects

feat(card-impl): Add code to remove effects


#include <boost/log/trivial.hpp>
#include <boost/program_options.hpp>

#include <dsnutil/log/init.h>

namespace po = boost::program_options;

int main(int argc, char** argv)
{
    dsn::log::init();

    try {
        po::options_description descr;
        descr.add_options()("help,?", "Display list of valid arguments");

        po::variables_map vm;
        po::store(po::parse_command_line(argc, argv, descr), vm);
        po::notify(vm);
    }

    catch (po::error& ex) {
        BOOST_LOG_TRIVIAL(error) << "Failed to parse command line arguments: " << ex.what();
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

#include <iostream>

#include <boost/log/trivial.hpp>
#include <boost/program_options.hpp>

#include <dsnutil/log/init.h>
#include <build-bot/bot.h>

namespace po = boost::program_options;

int main(int argc, char** argv)
{
    dsn::log::init();

    std::string configFile;
    try {
        po::options_description descr;
        descr.add_options()("help,?", "Display list of valid arguments");
        descr.add_options()("config,c", po::value<std::string>()->required()->default_value(dsn::build_bot::Bot::DEFAULT_CONFIG_FILE), "Path to configuration file");

        po::variables_map vm;
        po::store(po::parse_command_line(argc, argv, descr), vm);
        po::notify(vm);

        if (vm.count("help")) {
            std::cerr << descr << std::endl;
            return EXIT_SUCCESS;
        }

        configFile = vm["config"].as<std::string>();
    }

    catch (po::error& ex) {
        BOOST_LOG_TRIVIAL(error) << "Failed to parse command line arguments: " << ex.what();
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

Add parameter for config file

Add parameter for config file


/***************************************************************************
 *  @file       The code is for the exercises in C++ Primmer 5th Edition
 *  @author     @Yue Wang @gupenghu
 *  @date       29.11.2014
 *  @remark
 ***************************************************************************/

//!
//! Exercise 12.26:
//! Rewrite the program on page 481 using an allocator.
//!

#include <iostream>
#include <memory>
int main()
{
    //! create a allocator object and use it to handle string.
    //! create a movable pointer to the address p points
    std::allocator<std::string> alloc;
    std::string* const p = alloc.allocate(5);
    std::string* p_movable = p;

    //! constuct each object using copy constructor
    std::cout << "enter 4 times\n";
    for(std::string word ;std::cin >> word && p_movable != p + 3; ++p_movable)
        alloc.construct(p_movable,word);

    //! move the movable pointer back home
    p_movable = p;

    //! print the strings constructed.
    for( ;  p_movable != p + 3; ++p_movable){
        std::cout << *p_movable <<"\n";
        alloc.destroy(p_movable);
    }

    //! free the allocated memory.
    alloc.deallocate(p, 5);
    std::cout << "exit normally\n";
    return 0;
}
//! output
//!
//enter 4 times
//ss
//ss
//ss
//ss
//ss
//ss
//ss
//exit normally

/***************************************************************************
 *  @file       The code is for the exercises in C++ Primmer 5th Edition
 *  @author     @Yue Wang @gupenghu
 *  @date       29.11.2014
 *  @remark
 ***************************************************************************/

//!
//! Exercise 12.26:
//! Rewrite the program on page 481 using an allocator.
//!

#include <iostream>
#include <memory>
int main()
{
    //! create a allocator object and use it to handle string.
    //! create a movable pointer to the address p points
    std::allocator<std::string> alloc;
    std::string* const p = alloc.allocate(5);
    std::string* p_movable = p;

    //! constuct each object using copy constructor
    std::cout << "enter 4 times\n";
    for(std::string word ;std::cin >> word and p_movable != p + 3; ++p_movable)
        alloc.construct(p_movable,word);

    //! move the movable pointer back home
    p_movable = p;

    //! print the strings constructed.
    for( ;  p_movable != p + 3; ++p_movable){
        std::cout << *p_movable <<"\n";
        alloc.destroy(p_movable);
    }

    //! free the allocated memory.
    alloc.deallocate(p, 5);
    std::cout << "exit normally\n";
    return 0;
}
//! output
//!
//enter 4 times
//ss
//ss
//ss
//ss
//ss
//ss
//ss
//exit normally

Replace && with and for readability.

Replace && with and for readability.


/*
 * Copyright 2016 - 2021 gary@drinkingtea.net
 *
 * 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/.
 */

#include <nostalgia/core/core.hpp>

#include "app.hpp"

static ox::Error run(int argc, const char **argv) noexcept {
	ox::trace::init();
	if (argc < 2) {
		oxErr("Please provide path to project directory or OxFS file.");
		return OxError(1);
	}
	const auto path = argv[1];
	oxRequire(fs, nostalgia::core::loadRomFs(path));
	return run(fs.get());
}

int main(int argc, const char **argv) {
	const auto err = run(argc, argv);
	oxAssert(err, "Something went wrong...");
	return static_cast<int>(err);
}

/*
 * Copyright 2016 - 2021 gary@drinkingtea.net
 *
 * 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/.
 */

#include <nostalgia/core/core.hpp>

#include "app.hpp"

static ox::Error run(int argc, const char **argv) noexcept {
	ox::trace::init();
	if (argc < 2) {
		oxErr("Please provide path to project directory or OxFS file.\n");
		return OxError(1);
	}
	const auto path = argv[1];
	oxRequire(fs, nostalgia::core::loadRomFs(path));
	return run(fs.get());
}

int main(int argc, const char **argv) {
	const auto err = run(argc, argv);
	oxAssert(err, "Something went wrong...");
	return static_cast<int>(err);
}

Add new line to oxErr output

[nostalgia/player] Add new line to oxErr output


#include <miopen/hipoc_kernel.hpp>
#include <miopen/errors.hpp>
#include <hip/hip_hcc.h>

namespace miopen {

void HIPOCKernelInvoke::run(void* args, std::size_t size) const
{
    HipEventPtr start = nullptr;
    HipEventPtr stop = nullptr;
    void *config[] = {
        HIP_LAUNCH_PARAM_BUFFER_POINTER, args,
        HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
        HIP_LAUNCH_PARAM_END
    };
    if (callback)
    {
        start = make_hip_event();
        stop = make_hip_event();

        hipEventRecord(start.get(), stream);
    }

    // std::cerr << "Launch kernel: " << name << std::endl;
    auto status = hipHccModuleLaunchKernel(fun, gdims[0], gdims[1], gdims[2], ldims[0], ldims[1], ldims[2], 0, stream, nullptr, (void**)&config);
    if(status != hipSuccess) MIOPEN_THROW_HIP_STATUS(status, "Failed to launch kernel");

    if (callback)
    {
        hipEventRecord(stop.get(), stream);
        hipEventSynchronize(stop.get());
        callback(start.get(), stop.get());
    }
}

HIPOCKernelInvoke HIPOCKernel::Invoke(hipStream_t stream, std::function<void(hipEvent_t, hipEvent_t)> callback)
{
    return HIPOCKernelInvoke{stream, fun, ldims, gdims, name, callback};
}
}

#include <miopen/hipoc_kernel.hpp>
#include <miopen/errors.hpp>
#include <hip/hip_hcc.h>

namespace miopen {

void HIPOCKernelInvoke::run(void* args, std::size_t size) const
{
    HipEventPtr start = nullptr;
    HipEventPtr stop = nullptr;
    void *config[] = {
        HIP_LAUNCH_PARAM_BUFFER_POINTER, args,
        HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
        HIP_LAUNCH_PARAM_END
    };
    if (callback)
    {
        start = make_hip_event();
        stop = make_hip_event();
    }

    // std::cerr << "Launch kernel: " << name << std::endl;
    auto status = hipHccModuleLaunchKernel(fun, gdims[0], gdims[1], gdims[2], ldims[0], ldims[1], ldims[2], 0, stream, nullptr, (void**)&config, start.get(), stop.get());
    if(status != hipSuccess) MIOPEN_THROW_HIP_STATUS(status, "Failed to launch kernel");

    if (callback)
    {
        hipEventSynchronize(stop.get());
        callback(start.get(), stop.get());
    }
}

HIPOCKernelInvoke HIPOCKernel::Invoke(hipStream_t stream, std::function<void(hipEvent_t, hipEvent_t)> callback)
{
    return HIPOCKernelInvoke{stream, fun, ldims, gdims, name, callback};
}
}

Use more precise kernel timers for HIP.

Use more precise kernel timers for HIP.

Use new hipHccModuleLaunchKernel API which optionally accepts start /
stop events.  This allows host code to precisely time the kernel start
and stop times.  The traditional CUDA/HIP approach involves enqueueing
additional events and the time for the GPU to process those events is
included in the measurement.  The diff in this patch shows a succinct
comparison of the two approaches since we replaced the traditional
HIP/CUDA code with the new more surgical one.

This requires the following HIP checkin that supports the new API:

    commit 6656d33f75bbc13c48e6e24b02ec43dc43af1fac
    Author: Ben Sander <ben.sander@amd.com>
    Date:   Thu Apr 6 21:00:00 2017 -0500

-ben


// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++17-compat-pedantic -verify %s

struct A {};
int (A::*pa)() const&;
int use_pa = (A().*pa)();
#if __cplusplus <= 201703L
  // expected-warning@-2 {{invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension}}
#else
  // expected-warning@-4 {{invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++2a}}
#endif

struct B {
  void b() {
    (void) [=, this] {};
#if __cplusplus <= 201703L
    // expected-warning@-2 {{explicit capture of 'this' with a capture default of '=' is a C++2a extension}}
#else
    // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++2a}}
#endif
  }
};

// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++17-compat-pedantic -verify %s

struct A {};
int (A::*pa)() const&;
int use_pa = (A().*pa)();
#if __cplusplus <= 201703L
  // expected-warning@-2 {{invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension}}
#else
  // expected-warning@-4 {{invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++2a}}
#endif

struct B {
  void b() {
    (void) [=, this] {};
#if __cplusplus <= 201703L
    // expected-warning@-2 {{explicit capture of 'this' with a capture default of '=' is a C++2a extension}}
#else
    // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++2a}}
#endif
  }

  int n : 5 = 0;
#if __cplusplus <= 201703L
    // expected-warning@-2 {{default member initializer for bit-field is a C++2a extension}}
#else
    // expected-warning@-4 {{default member initializer for bit-field is incompatible with C++ standards before C++2a}}
#endif
};

Add test for -Wc++17-compat warning for P0683R1.

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


#include "../../valhalla/mjolnir/signbuilder.h"

using namespace valhalla::baldr;

namespace valhalla {
namespace mjolnir {

// Constructor with arguments
SignBuilder::SignBuilder(const uint32_t idx,
                                 const Sign::Type& type,
                                 const uint32_t text_offset)
    : Sign(idx, type, text_offset) {
}

// Set the directed edge index.
void SignBuilder::set_edgeindex(const uint32_t idx) {
  edgeindex_ = idx;
}

}
}

#include "../../valhalla/mjolnir/signbuilder.h"

using namespace valhalla::baldr;

namespace valhalla {
namespace mjolnir {

// Constructor with arguments
SignBuilder::SignBuilder(const uint32_t idx,
                                 const Sign::Type& type,
                                 const uint32_t text_offset)
    : Sign(idx, type, text_offset) {
}

// Set the directed edge index.
void SignBuilder::set_edgeindex(const uint32_t idx) {
  data_.edgeindex = idx;
}

}
}

Update to reflect changes to signs.

Update to reflect changes to signs.


// Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#include "Bitstrip.h"

Bitstrip::Bitstrip(std::wstring bitmapName, int x, int y, int units) :
Meter(bitmapName, x, y, units) {
    _rect.Height = _bitmap->GetHeight() / _units;
}

void Bitstrip::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) {
    int units = CalcUnits();
    int stripY = (units - 1) * _rect.Height;

    if (units == 0) {
        /* The mute OSD should be shown here, but we'll do something sane
         * rather than go negative. */
        stripY = 0;
    }

    graphics->DrawImage(_bitmap, _rect,
        0, stripY, _rect.Width, _rect.Height, Gdiplus::UnitPixel);

    UpdateDrawnValues();
}

// Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#include "Bitstrip.h"

Bitstrip::Bitstrip(std::wstring bitmapName, int x, int y, int units) :
Meter(bitmapName, x, y, units) {
    _rect.Height = _bitmap->GetHeight() / _units;
}

void Bitstrip::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) {
    int units = CalcUnits();
    int stripY = (units - 1) * _rect.Height;

    if (units == 0) {
        /* The mute OSD should be shown here, but we'll do something sane
         * rather than go negative. */
        stripY = 0;
    }

    graphics->DrawImage(_bitmap, _rect, 0, stripY, _rect.Width, _rect.Height,
        Gdiplus::UnitPixel, &_imageAttributes, NULL, NULL);

    UpdateDrawnValues();
}

Enable color transformations for bitstrips


// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
// CHECK-NOT:              DIFlagFwdDecl
// CHECK-SAME:             ){{$}}
class A {
public:
  int z;
};

A *foo (A* x) {
  A *a = new A(*x);
  return a;
}

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B"
// CHECK-SAME:             flags: DIFlagFwdDecl

class B {
public:
  int y;
};

extern int bar(B *b);
int baz(B *b) {
  return bar(b);
}

// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "C"
// CHECK-SAME:             flags: DIFlagFwdDecl

struct C {
};

C (*x)(C);

// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck --check-prefix=CHECK-C %s

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
// CHECK-NOT:              DIFlagFwdDecl
// CHECK-SAME:             ){{$}}
class A {
public:
  int z;
};

A *foo (A* x) {
  A *a = new A(*x);
  return a;
}

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B"
// CHECK-SAME:             flags: DIFlagFwdDecl

class B {
public:
  int y;
};

extern int bar(B *b);
int baz(B *b) {
  return bar(b);
}

// CHECK-C: !DICompositeType(tag: DW_TAG_structure_type, name: "C"
// CHECK-C-SAME:             flags: DIFlagFwdDecl

struct C {
};

C (*x)(C);

Fix testcase for MSVC targets where the output ordering is different.

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


// Copyright (c) 20109 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"
#include "net/base/mock_host_resolver.h"

// This test failed at times on the Vista dbg builder and has been marked as
// flaky for now. Bug http://code.google.com/p/chromium/issues/detail?id=28630
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_ExecuteScript) {
  // We need a.com to be a little bit slow to trigger a race condition.
  host_resolver()->AddRuleWithLatency("a.com", "127.0.0.1", 500);
  host_resolver()->AddRule("b.com", "127.0.0.1");
  host_resolver()->AddRule("c.com", "127.0.0.1");
  StartHTTPServer();

  ASSERT_TRUE(RunExtensionTest("executescript/basic")) << message_;
  ASSERT_TRUE(RunExtensionTest("executescript/in_frame")) << message_;
  ASSERT_TRUE(RunExtensionTest("executescript/permissions")) << message_;
}

// Copyright (c) 20109 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"
#include "net/base/mock_host_resolver.h"

// EXTREMELY flaky, crashy, and bad. See http://crbug.com/28630 and don't dare
// to re-enable without a real fix or at least adding more debugging info.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_ExecuteScript) {
  // We need a.com to be a little bit slow to trigger a race condition.
  host_resolver()->AddRuleWithLatency("a.com", "127.0.0.1", 500);
  host_resolver()->AddRule("b.com", "127.0.0.1");
  host_resolver()->AddRule("c.com", "127.0.0.1");
  StartHTTPServer();

  ASSERT_TRUE(RunExtensionTest("executescript/basic")) << message_;
  ASSERT_TRUE(RunExtensionTest("executescript/in_frame")) << message_;
  ASSERT_TRUE(RunExtensionTest("executescript/permissions")) << message_;
}

Mark ExtensionApiTest.ExecuteScript DISABLED because it's not only flaky,
but crashy and it has been ignored for weeks!

It's EXTREMELY flaky, #1 flaky test of all time with over 600 flips
in the last three weeks. This test seriously needs some love.

TBR=rafaelw
TEST=none
BUG=28630

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

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


#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/surface/mls.h>

int
main (int argc, char** argv)
{
  // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
  // Load bun0.pcd -- should be available with the PCL archive in test
  pcl::io::loadPCDFile ("bun0.pcd", *cloud);

  // Create a KD-Tree
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);

  // Output has the PointNormal type in order to store the normals calculated by MLS
  pcl::PointCloud<pcl::PointNormal> mls_points;

  // Init object (second point type is for the normals, even if unused)
  pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;

  mls.setComputeNormals (true);

  // Set parameters
  mls.setInputCloud (cloud);
  mls.setPolynomialFit (true);
  mls.setSearchMethod (tree);
  mls.setSearchRadius (0.03);

  // Reconstruct
  mls.process (mls_points);

  // Save output
  pcl::io::savePCDFile ("bun0-mls.pcd", mls_points);
}

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/surface/mls.h>

int
main (int argc, char** argv)
{
  // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
  // Load bun0.pcd -- should be available with the PCL archive in test
  pcl::io::loadPCDFile ("bun0.pcd", *cloud);

  // Create a KD-Tree
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);

  // Output has the PointNormal type in order to store the normals calculated by MLS
  pcl::PointCloud<pcl::PointNormal> mls_points;

  // Init object (second point type is for the normals, even if unused)
  pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;

  mls.setComputeNormals (true);

  // Set parameters
  mls.setInputCloud (cloud);
  mls.setPolynomialOrder (2);
  mls.setSearchMethod (tree);
  mls.setSearchRadius (0.03);

  // Reconstruct
  mls.process (mls_points);

  // Save output
  pcl::io::savePCDFile ("bun0-mls.pcd", mls_points);
}

Fix deprecation warning in "Resampling" tutorial


// Copyright (c) 2012 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-CHROMIUM file.

#include "browser/browser_main_parts.h"

#include "browser/browser_context.h"
#include "browser/web_ui_controller_factory.h"
#include "net/proxy/proxy_resolver_v8.h"

namespace brightray {

BrowserMainParts::BrowserMainParts() {
}

BrowserMainParts::~BrowserMainParts() {
}

void BrowserMainParts::PreMainMessageLoopRun() {
  browser_context_.reset(CreateBrowserContext());
  browser_context_->Initialize();

  web_ui_controller_factory_.reset(
      new WebUIControllerFactory(browser_context_.get()));
  content::WebUIControllerFactory::RegisterFactory(
      web_ui_controller_factory_.get());
}

void BrowserMainParts::PostMainMessageLoopRun() {
  browser_context_.reset();
}

int BrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN)
  net::ProxyResolverV8::CreateIsolate();
#else
  net::ProxyResolverV8::RememberDefaultIsolate();
#endif
  return 0;
}

BrowserContext* BrowserMainParts::CreateBrowserContext() {
  return new BrowserContext;
}

}  // namespace brightray

// Copyright (c) 2012 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-CHROMIUM file.

#include "browser/browser_main_parts.h"

#include "browser/browser_context.h"
#include "browser/web_ui_controller_factory.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"

namespace brightray {

BrowserMainParts::BrowserMainParts() {
}

BrowserMainParts::~BrowserMainParts() {
}

void BrowserMainParts::PreMainMessageLoopRun() {
  browser_context_.reset(CreateBrowserContext());
  browser_context_->Initialize();

  web_ui_controller_factory_.reset(
      new WebUIControllerFactory(browser_context_.get()));
  content::WebUIControllerFactory::RegisterFactory(
      web_ui_controller_factory_.get());

#if defined(OS_WIN)
  gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
#endif
}

void BrowserMainParts::PostMainMessageLoopRun() {
  browser_context_.reset();
}

int BrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN)
  net::ProxyResolverV8::CreateIsolate();
#else
  net::ProxyResolverV8::RememberDefaultIsolate();
#endif
  return 0;
}

BrowserContext* BrowserMainParts::CreateBrowserContext() {
  return new BrowserContext;
}

}  // namespace brightray

Set up a native screen on Windows

Set up a native screen on Windows

This is needed to prevent a crash inside aura::WindowTreeHost::InitCompositor.