#include <string>
#include <vector>
#include <unistd.h>
#include <gtest/gtest.h>
#include <scxcorelib/scxstrencodingconv.h>
#include "getusername.h"

TEST(GetUserName,simple)
{
	// allocate a WCHAR_T buffer to receive username
	DWORD lpnSize = L_cuserid;
	WCHAR_T lpBuffer[lpnSize];

	BOOL result = GetUserName(lpBuffer, &lpnSize);

	// GetUserName returns 1 on success
	ASSERT_EQ(1, result);

	// get expected username
	std::string username(getlogin());

	// GetUserName sets lpnSize to length of username including null
	ASSERT_EQ(username.size()+1, lpnSize);

	// copy UTF-16 bytes (excluding null) from lpBuffer to vector for conversion
	unsigned char *begin = reinterpret_cast<unsigned char *>(&lpBuffer[0]);
	// -1 to skip null; *2 because UTF-16 encodes two bytes per character
	unsigned char *end = begin + (lpnSize-1)*2;
	std::vector<unsigned char> input(begin, end);
	// convert to UTF-8 for assertion
	std::string output;
	SCXCoreLib::Utf16leToUtf8(input, output);

	EXPECT_EQ(username, output);
}

#include <string>
#include <vector>
#include <unistd.h>
#include <gtest/gtest.h>
#include <scxcorelib/scxstrencodingconv.h>
#include "getusername.h"

class GetUserNameTest : public ::testing::Test {
protected:
	DWORD lpnSize;
	std::vector<WCHAR_T> lpBuffer;
	BOOL result;
	std::string userName;

	GetUserNameTest(): userName(std::string(getlogin())) {}

	void GetUserNameWithSize(DWORD size) {
		lpnSize = size;
		// allocate a WCHAR_T buffer to receive username
		lpBuffer.assign(lpnSize, '\0');
		result = GetUserName(&lpBuffer[0], &lpnSize);
	}
};

TEST_F(GetUserNameTest, NormalUse) {
	GetUserNameWithSize(L_cuserid);

	// GetUserName returns 1 on success
	ASSERT_EQ(1, result);

	// GetUserName sets lpnSize to length of username including null
	ASSERT_EQ(userName.size()+1, lpnSize);

	// copy UTF-16 bytes (excluding null) from lpBuffer to vector for conversion
	unsigned char *begin = reinterpret_cast<unsigned char *>(&lpBuffer[0]);
	// -1 to skip null; *2 because UTF-16 encodes two bytes per character
	unsigned char *end = begin + (lpnSize-1)*2;
	std::vector<unsigned char> input(begin, end);
	// convert to UTF-8 for assertion
	std::string output;
	SCXCoreLib::Utf16leToUtf8(input, output);

	EXPECT_EQ(userName, output);
}

Use test fixture in GetUserName unit tests


#include "KVProxy.h"
#include "KVProxy_p.h"
#include <iostream>

KVProxy::KVProxy(QObject *parent, unsigned short port) :
	QObject(parent), p("127.0.0.1", port)
{
	// Make the poll timer tell the proxy to poll; this will be started with
	// a timeout of 0, so it will effectively poll on every event loop tick
	connect(&pollTimer, SIGNAL(timeout()), this, SLOT(poll()));

	// Pass on new connections to a function in KVProxy_p
	p.on_connection([this](HttpProxy::Connection::Ptr con) {
		proxyHandleConnection(this, con);
	});
}

KVProxy::~KVProxy()
{

}

int KVProxy::port()
{
	return p.get_local_port_number();
}

void KVProxy::run(bool async)
{
	if(async)
		pollTimer.start(20);
	else
		p.run();
}

void KVProxy::poll()
{
	p.poll();
}

#include "KVProxy.h"
#include "KVProxy_p.h"
#include <iostream>
#include <string>

KVProxy::KVProxy(QObject *parent, unsigned short port) :
	QObject(parent), p("127.0.0.1", port)
{
	// Make the poll timer tell the proxy to poll; this will be started with
	// a timeout of 0, so it will effectively poll on every event loop tick
	connect(&pollTimer, SIGNAL(timeout()), this, SLOT(poll()));

	// Pass on new connections to a function in KVProxy_p
	p.on_connection([this](HttpProxy::Connection::Ptr con) {
		proxyHandleConnection(this, con);
	});

	p.on_error([](std::string str, bool){
		qDebug() << "Proxy Error: " << str.c_str();
	});
}

KVProxy::~KVProxy()
{

}

int KVProxy::port()
{
	return p.get_local_port_number();
}

void KVProxy::run(bool async)
{
	if(async)
		pollTimer.start(20);
	else
		p.run();
}

void KVProxy::poll()
{
	p.poll();
}

Print proxy errors to qDebug

Print proxy errors to qDebug


#include <QGuiApplication>
#include <QQuickView>

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

    QQuickView view;
    view.setSource(QUrl::fromLocalFile("GameWindow.qml"));
    view.show();

    return app.exec();
}

#include <QGuiApplication>
#include <QQuickView>
#include <QDeclarativeEngine>
#include <QDir>

int main(int argc, char *argv[]) {
    QByteArray data = "1";
    qputenv("QML_IMPORT_TRACE", data);

    QGuiApplication app(argc, argv);

    QQuickView view;

    view.engine()->addImportPath("../../imports");

    view.setSource(QUrl::fromLocalFile("GameWindow.qml"));
    view.show();

    return app.exec();
}

Add import path to gamewindow example

Add import path to gamewindow example


//Precompiled header are used in this project
#include "stdafx.h"

//Include Annwvyn Engine.
#include <Annwvyn.h>
//Every Annwvyn classes are in the Annwvyn namespace
using namespace Annwvyn;

//Include our level/stages here
#include "myLevel.hpp"

AnnMain() //The application entry point is "AnnMain()". return type int.
{
	//Initialize the engine
	new AnnEngine("A game using Annwvyn");

	//Load your ressources here
	AnnEngine::Instance()->initResources();
	AnnEngine::Instance()->oculusInit();
	//If the player has to folow the integrated physics scheme
	AnnEngine::Instance()->initPlayerPhysics();
	//Do the other initialization herttEventListener(); //Basic events

	//Intentiate and register our basic level
	AnnEngine::Instance()->getLevelManager()->addLevel(new MyLevel);
	//This will make the game load and start the 1st we have registered
	AnnEngine::Instance()->getLevelManager()->jumpToFirstLevel();

	//This will recenter the facing direction of the player
	//in the real world with the VR
	AnnEngine::Instance()->resetOculusOrientation();

	//The game is rendering here now:
	AnnEngine::Instance()->startGameplayLoop();

	//destroy the engine
	delete AnnEngine::Instance();
	return EXIT_SUCCESS;
}

//Precompiled header are used in this project
#include "stdafx.h"

//Include Annwvyn Engine.
#include <Annwvyn.h>
//Every Annwvyn classes are in the Annwvyn namespace
using namespace Annwvyn;

//Include our level/stages here
#include "myLevel.hpp"

AnnMain() //The application entry point is "AnnMain()". return type int.
{
	//Initialize the engine
	AnnEngine::openConsole();
	new AnnEngine("A game using Annwvyn");

	//Load your ressources here
	AnnEngine::Instance()->initResources();
	AnnEngine::Instance()->oculusInit();
	//If the player has to folow the integrated physics scheme
	AnnEngine::Instance()->initPlayerPhysics();
	//Do the other initialization herttEventListener(); //Basic events

	//Intentiate and register our basic level
	AnnEngine::Instance()->getLevelManager()->addLevel(new MyLevel);
	//This will make the game load and start the 1st we have registered
	AnnEngine::Instance()->getLevelManager()->jumpToFirstLevel();

	//This will recenter the facing direction of the player
	//in the real world with the VR
	AnnEngine::Instance()->resetOculusOrientation();

	//The game is rendering here now:
	AnnEngine::Instance()->useDefaultEventListener();
	AnnEngine::Instance()->startGameplayLoop();

	//destroy the engine
	delete AnnEngine::Instance();
	return EXIT_SUCCESS;
}

Fix template game by using default event listener


#include <string>
#include <fstream>
#include <streambuf>

#include "exceptions.h"
#include "file_utils.h"

namespace file_utils {

std::vector<unicode> read_lines(const unicode& filename) {
    unicode contents = read(filename);

    return unicode(contents).split("\n");
}

unicode read(const unicode& filename) {

    std::ifstream t(filename.encode().c_str());
    if(!t) {
        throw IOError(_u("Unable to load file") + filename);
    }

    std::string str((std::istreambuf_iterator<char>(t)),
                 std::istreambuf_iterator<char>());

    return unicode(str);
}

}

#include <string>
#include <fstream>
#include <streambuf>

#include "exceptions.h"
#include "file_utils.h"

namespace file_utils {

std::vector<unicode> read_lines(const unicode& filename) {
    unicode contents = read(filename);

    return unicode(contents).split("\n");
}

unicode read(const unicode& filename) {

    std::ifstream in(filename.encode().c_str());
    if(!in) {
        throw IOError(_u("Unable to load file") + filename);
    }

    auto str = [&in]{
      std::ostringstream ss{};
      ss << in.rdbuf();
      return ss.str();
    }();

    return unicode(str);
}

}

Improve the file reading code to not be so buggy


// Copyright 2014 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 "ppapi/tests/mojo/test_mojo.h"

#include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h"

REGISTER_TEST_CASE(Mojo);

TestMojo::TestMojo(TestingInstance* instance) : TestCase(instance) { }
bool TestMojo::Init() {
  return true;
}

void TestMojo::RunTests(const std::string& filter) {
  RUN_TEST(CreateMessagePipe, filter);
}

std::string TestMojo::TestCreateMessagePipe() {
  mojo::MessagePipe pipe;
  PASS();
}

// Copyright 2014 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 "ppapi/tests/mojo/test_mojo.h"

#include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h"

REGISTER_TEST_CASE(Mojo);

TestMojo::TestMojo(TestingInstance* instance) : TestCase(instance) { }
bool TestMojo::Init() {
  return true;
}

void TestMojo::RunTests(const std::string& filter) {
  RUN_TEST(CreateMessagePipe, filter);
}

std::string TestMojo::TestCreateMessagePipe() {
  MojoHandle h0;
  MojoHandle h1;
  ASSERT_EQ(MOJO_RESULT_OK, MojoCreateMessagePipe(NULL, &h0, &h1));
  PASS();
}

Make Mojo test more strict.

Pepper: Make Mojo test more strict.

Mojo's MessagePipe constructor uses assert() to check that
MojoCreateMessagePipe returns OK. This change makes the test explicitly
check the return value of MojoCreateMessagePipe, giving more correct
test behavior for Release builds.

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#315168}


#include <mettle.hpp>
using namespace mettle;

struct my_type {};

namespace my_namespace {
  struct another_type {};
}

suite<> test_type_name("type_name()", [](auto &_) {
  _.test("primitives", []() {
    expect(type_name<int>(), equal_to("int"));
    expect(type_name<int &>(), regex_match("int\\s*&"));
    expect(type_name<int &&>(), regex_match("int\\s*&&"));
    expect(type_name<const int>(), equal_to("const int"));
    expect(type_name<volatile int>(), equal_to("volatile int"));
    expect(type_name<const volatile int>(), equal_to("const volatile int"));
  });

  _.test("custom types", []() {
    expect(type_name<my_type>(), equal_to("my_type"));
    expect(type_name<my_namespace::another_type>(),
           equal_to("my_namespace::another_type"));
  });
});

#include <mettle.hpp>
using namespace mettle;

struct my_type {};

namespace my_namespace {
  struct another_type {};
}

suite<> test_type_name("type_name()", [](auto &_) {
  _.test("primitives", []() {
    expect(type_name<int>(), equal_to("int"));
    expect(type_name<int &>(), regex_match("int\\s*&"));
    expect(type_name<int &&>(), regex_match("int\\s*&&"));
    expect(type_name<const int>(), equal_to("const int"));
    expect(type_name<volatile int>(), equal_to("volatile int"));
    expect(type_name<const volatile int>(), any(
      equal_to("const volatile int"),
      equal_to("volatile const int")
    ));
  });

  _.test("custom types", []() {
    expect(type_name<my_type>(), regex_match("(struct )?my_type$"));
    expect(type_name<my_namespace::another_type>(),
           regex_match("(struct )?my_namespace::another_type$"));
  });
});

Fix type_name tests under Windows

Fix type_name tests under Windows


#include "About.h"

#include "../../3RVX/Updater.h"

#include "../resource.h"

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

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

void About::LoadSettings() {

}

void About::SaveSettings() {

}

#include "About.h"

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

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

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

void About::LoadSettings() {

}

void About::SaveSettings() {

}

Update about tab for Updater move

Update about tab for Updater move


// Copyright (c) 2015-2017 William W. Fisher (at gmail dot com)
// This file is distributed under the MIT License.

#include "ofp/driver.h"
#include "ofp/unittest.h"

using namespace ofp;

class MockChannelListener : public ChannelListener {
 public:
  void onChannelUp(Channel *channel) override {}
  void onChannelDown(Channel *channel) override {}
  void onMessage(const Message *message) override;
};

void MockChannelListener::onMessage(const Message *message) {}

TEST(driver, test) {
  Driver driver;

  // Test installing signal handlers more than once.
  driver.installSignalHandlers();
  driver.installSignalHandlers();

  std::error_code err;

  UInt64 connId = driver.listen(
      ChannelOptions::FEATURES_REQ, 0, IPv6Endpoint{OFPGetDefaultPort()},
      ProtocolVersions::All, [] { return new MockChannelListener; }, err);

  EXPECT_NE(0, connId);

  // Don't call driver.run(). This test just tests initialization.
  // driver.run();
}

// Copyright (c) 2015-2017 William W. Fisher (at gmail dot com)
// This file is distributed under the MIT License.

#include "ofp/driver.h"
#include "ofp/unittest.h"

using namespace ofp;

class MockChannelListener : public ChannelListener {
 public:
  void onChannelUp(Channel *channel) override {}
  void onChannelDown(Channel *channel) override {}
  void onMessage(const Message *message) override;
};

void MockChannelListener::onMessage(const Message *message) {}

TEST(driver, test) {
  Driver driver;

  // Test installing signal handlers more than once.
  driver.installSignalHandlers();
  driver.installSignalHandlers();

  std::error_code err;
  UInt16 listenPort = UInt16_narrow_cast(OFPGetDefaultPort() + 10000);

  UInt64 connId = driver.listen(
      ChannelOptions::FEATURES_REQ, 0, {"127.0.0.1", listenPort},
      ProtocolVersions::All, [] { return new MockChannelListener; }, err);

  EXPECT_NE(0, connId);

  // Don't call driver.run(). This test just tests initialization.
  // driver.run();
}

Fix driver test so it doesn't fail if another oftr process is running.


#include "sieve.h"
#include <cmath>

namespace
{
bool is_prime(int n)
{
    if (n % 2 == 0) {
        return false;
    }
    const int max_factor = static_cast<int>(std::sqrt(n));
    for (int probe = 2; probe <= max_factor; ++probe) {
        if (n % probe == 0) {
            return false;
        }
    }
    return true;
}
}

namespace sieve
{

std::vector<int> primes(int n)
{
    std::vector<int> result;
    if (n >= 2) {
        result.push_back(2);
    }
    for (int candidate = 3; candidate < n; ++candidate) {
        if (is_prime(candidate)) {
            result.push_back(candidate);
        }
    }
    return result;
}

}

#include "sieve.h"
#include <algorithm>
#include <list>
#include <numeric>

namespace sieve
{

std::vector<int> primes(int n)
{
    std::vector<int> result;
    std::list<int> candidates(n-1);
    std::iota(candidates.begin(), candidates.end(), 2);
    while (!candidates.empty()) {
        const int next = candidates.front();
        candidates.pop_front();
        result.push_back(next);
        candidates.remove_if([next](int n) { return n % next == 0; });
    }
    return result;
}

}

Implement the algorithm as described in the problem


#include <gloperate/painter/Painter.h>

namespace gloperate
{

Painter::Painter(const std::string & name, ResourceManager & resourceManager, const std::string & relDataPath)
: Object(name)
, m_resourceManager(resourceManager)
, m_relDataPath(relDataPath)
, m_backgroundColor(1.0, 1.0, 1.0)
{
}

Painter::~Painter()
{
    for (auto & capability : m_capabilities)
    {
        delete capability;
    }
}

void Painter::initialize()
{
    onInitialize();
}

void Painter::paint()
{
    onPaint();
}

glm::vec3 Painter::backgroundColor() const
{
	return m_backgroundColor;
}

void Painter::setBackgroundColor(const glm::vec3 & color)
{
	m_backgroundColor = color;
}

AbstractCapability * Painter::addCapability(AbstractCapability * capability)
{
    m_capabilities.push_back(capability);

    return capability;
}

} // namespace gloperate

#include <gloperate/painter/Painter.h>

namespace gloperate
{

Painter::Painter(const std::string & name, ResourceManager & resourceManager, const std::string & relDataPath)
: Object(name)
, m_resourceManager(resourceManager)
, m_relDataPath(relDataPath)
, m_backgroundColor(0.0, 0.0, 0.0)
{
}

Painter::~Painter()
{
    for (auto & capability : m_capabilities)
    {
        delete capability;
    }
}

void Painter::initialize()
{
    onInitialize();
}

void Painter::paint()
{
    onPaint();
}

glm::vec3 Painter::backgroundColor() const
{
	return m_backgroundColor;
}

void Painter::setBackgroundColor(const glm::vec3 & color)
{
	m_backgroundColor = color;
}

AbstractCapability * Painter::addCapability(AbstractCapability * capability)
{
    m_capabilities.push_back(capability);

    return capability;
}

} // namespace gloperate

Change default background color to black


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

#ifdef SK_BUILD_FOR_ANDROID
#include "SkPicturePlayback.h"
#endif
#include "SkPictureRecorder.h"

SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
                                            SkBBHFactory* bbhFactory /* = NULL */,
                                            uint32_t recordFlags /* = 0 */) {
    fPicture.reset(SkNEW(SkPicture));
    return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
}

#ifdef SK_BUILD_FOR_ANDROID
void SkPictureRecorder::partialReplay(SkCanvas* canvas) {
    if (NULL == fPicture.get() || NULL == canvas) {
        // Not recording or nothing to replay into
        return;
    }

    SkASSERT(NULL != fPicture->fRecord);

    SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture,
                                                                          *fPicture->fRecord,
                                                                          false));
    playback->draw(*canvas, NULL);
}
#endif

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

// Need to include SkTypes first, so that SK_BUILD_FOR_ANDROID is defined.
#include "SkTypes.h"
#ifdef SK_BUILD_FOR_ANDROID
#include "SkPicturePlayback.h"
#endif
#include "SkPictureRecorder.h"

SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
                                            SkBBHFactory* bbhFactory /* = NULL */,
                                            uint32_t recordFlags /* = 0 */) {
    fPicture.reset(SkNEW(SkPicture));
    return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
}

#ifdef SK_BUILD_FOR_ANDROID
void SkPictureRecorder::partialReplay(SkCanvas* canvas) {
    if (NULL == fPicture.get() || NULL == canvas) {
        // Not recording or nothing to replay into
        return;
    }

    SkASSERT(NULL != fPicture->fRecord);

    SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture,
                                                                          *fPicture->fRecord,
                                                                          false));
    playback->draw(*canvas, NULL);
}
#endif

Include SkTypes to fix Android frameworks build

Since Android's defines are included in SkUserConfig (rather than
being defined in the build file), we need to include something that
includes SkUserConfig (transitively; meaning just about anything)
before we can use any build macros. Include SkTypes, "the correct
way to get access to the config system" so that
SK_BUILD_FOR_ANDROID is defined before querying it.

R=robertphillips@google.com, djsollen@google.com, mtklein@google.com

Author: scroggo@google.com

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

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


#include "blif_lexer.hpp"
#include "blif_lexer.gen.hpp" //For blifparse_lex_*()

extern YY_DECL; //For blifparse_lex()

namespace blifparse {

Lexer::Lexer(FILE* file, Callback& callback)
    : callback_(callback) {
    blifparse_lex_init(&state_);
    blifparse_set_in(file, state_);
}

Lexer::~Lexer() {
    blifparse_lex_destroy(state_);
}

Parser::symbol_type Lexer::next_token() {
    return blifparse_lex(state_, callback_);
}

const char* Lexer::text() const {
    return blifparse_get_text(state_);
}

int Lexer::lineno() const {
    return blifparse_get_lineno(state_);
}

}

#include "blif_lexer.hpp"

//Windows doesn't have unistd.h, so we set '%option nounistd'
//in blif_lexer.l, but flex still includes it in the generated
//header unless YY_NO_UNISTD_H is defined to 1
#define YY_NO_UNISTD_H 1
#include "blif_lexer.gen.hpp" //For blifparse_lex_*()

extern YY_DECL; //For blifparse_lex()

namespace blifparse {

Lexer::Lexer(FILE* file, Callback& callback)
    : callback_(callback) {
    blifparse_lex_init(&state_);
    blifparse_set_in(file, state_);
}

Lexer::~Lexer() {
    blifparse_lex_destroy(state_);
}

Parser::symbol_type Lexer::next_token() {
    return blifparse_lex(state_, callback_);
}

const char* Lexer::text() const {
    return blifparse_get_text(state_);
}

int Lexer::lineno() const {
    return blifparse_get_lineno(state_);
}

}

Remove unistd.h inclusion for Windows

Remove unistd.h inclusion for Windows


#include <ncurses.h>

#include "../../../src/contents.hh"
#include "../../../src/key_aliases.hh"
#include "../../vick-move/src/move.hh"

void enter_insert_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        contents.cont[contents.y].insert(contents.x, 1, ch);
        mvf(contents);
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

void enter_replace_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        if(contents.x >= contents.cont[contents.y].size()) {
            contents.cont[contents.y].push_back(ch);
        } else {
            contents.cont[contents.y][contents.x] = ch;
        }
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

#include <ncurses.h>

#include "../../../src/contents.hh"
#include "../../../src/key_aliases.hh"
#include "../../vick-move/src/move.hh"

void enter_insert_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        contents.cont[contents.y].insert(contents.x, 1, ch);
        mvf(contents);
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

void enter_replace_mode(contents& contents, boost::optional<int>) {
    char ch;
    contents.is_inserting = true;
    while((ch = getch()) != _escape) {
        if(contents.x >= contents.cont[contents.y].size()) {
            contents.cont[contents.y].push_back(ch);
            contents.x = contents.cont[contents.y].size();
        } else {
            contents.cont[contents.y][contents.x] = ch;
            contents.x++;
        }
        if(get_contents().refresh) {
            print_contents(get_contents());
        }
    }
    contents.is_inserting = false;
}

Fix ``enter_replace_mode`` so that it works properly


#include "Penguin.h"

void Penguin::processEvents(SDL_Event* a_event)
{
	if (a_event->type == SDL_KEYDOWN)
	{
		switch (a_event->key.keysym.sym)
		{
			case SDLK_LEFT:
			{

			} break;

			case SDLK_RIGHT:
			{

			} break;
		}
	}
}

void Penguin::update(float a_deltaT)
{

}

void Penguin::startJump()
{
	if (m_onTheGround == true)
	{
		m_onTheGround = false;
	}
}

void Peguin::endJump()
{

}

#include "Penguin.h"

void Penguin::processEvents(SDL_Event* a_event)
{
	if (a_event->type == SDL_KEYDOWN)
	{
		switch (a_event->key.keysym.sym)
		{
			case SDLK_LEFT:
			{

			} break;

			case SDLK_RIGHT:
			{

			} break;
		}
	}
}

void Penguin::update(float a_deltaT)
{

}

void Penguin::startJump()
{
	if (m_jumping == false)
	{
		m_jumping = true;
	}
}

void Penguin::endJump()
{

}

Fix compile error on penguin sample game


// Copyright 2020 The Google Research Authors.
//
// 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 "benchmark_utils.h"

#include <utility>

#include "benchmark/benchmark.h"
#include "sketch.h"
#include "utils.h"

namespace sketch {

void Add(benchmark::State& state, Sketch* sketch) {
  for (auto _ : state) {
    state.PauseTiming();
    sketch->Reset();
    auto data = sketch::CreateStream(state.range(0)).first;
    state.ResumeTiming();
    for (const auto& [item, freq] : data) {
      sketch->Add(item, freq);
    }
  }
}

}  // namespace sketch

// Copyright 2020 The Google Research Authors.
//
// 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 "benchmark_utils.h"

#include <utility>

#include "benchmark/benchmark.h"
#include "sketch.h"
#include "utils.h"

namespace sketch {

constexpr int kAddBatchSize = 32;

auto MakeAddStreams(int count) {
  std::vector<std::vector<IntFloatPair>> streams(kAddBatchSize);
  for (auto& stream : streams) {
    stream = CreateStream(count).first;
  }
  return streams;
}

void Add(benchmark::State& state, Sketch* sketch) {
  auto streams = MakeAddStreams(state.range(0));
  while (state.KeepRunningBatch(kAddBatchSize)) {
    for (const auto& stream : streams) {
      for (const auto& [item, freq] : stream) {
        sketch->Add(item, freq);
      }
    }
  }
}

}  // namespace sketch

Improve benchmarks by batching data.

Improve benchmarks by batching data.

PiperOrigin-RevId: 304062816


#include "msglistener.h"

#include <ei_connect.h>

namespace Mailbox {

MsgListener::MsgListener(int fd, QObject *parent) :
    QThread(parent),
    m_fd(fd)
{

}

void MsgListener::run()
{

}

} // namespace Mailbox

#include "msglistener.h"

#include <ei_connect.h>

namespace Mailbox {

MsgListener::MsgListener(int fd, QObject *parent) :
    QThread(parent),
    m_fd(fd)
{

}

void MsgListener::run()
{
    int length;
    erlang_msg msg;
    ei_x_buff buff;

    ei_x_new(&buff);

    length = ei_xreceive_msg_tmo(m_fd, &msg, &buff, 1000);

    if (length > 0 && (msg.msgtype == ERL_SEND || msg.msgtype == ERL_REG_SEND))
        emit messageRecieved();

    ei_x_free(&buff);
}

} // namespace Mailbox

Add Basic Message Recieve implementation

Single shot message recieve implementation added


// Copyright (c) 2011 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 "content/browser/renderer_host/render_view_host_observer.h"

#include "content/browser/renderer_host/render_view_host.h"

RenderViewHostObserver::RenderViewHostObserver(RenderViewHost* render_view_host)
    : render_view_host_(render_view_host),
      routing_id_(render_view_host->routing_id()) {
  render_view_host_->AddObserver(this);
}

RenderViewHostObserver::~RenderViewHostObserver() {
  if (render_view_host_)
    render_view_host_->RemoveObserver(this);
}

void RenderViewHostObserver::RenderViewHostDestroyed() {
  delete this;
}

bool RenderViewHostObserver::OnMessageReceived(const IPC::Message& message) {
  return false;
}

bool RenderViewHostObserver::Send(IPC::Message* message) {
  if (!render_view_host_) {
    delete message;
    return false;
  }

  return render_view_host_->Send(message);
}

void RenderViewHostObserver::RenderViewHostDestruction() {
  render_view_host_->RemoveObserver(this);
  RenderViewHostDestroyed();
  render_view_host_ = NULL;
}

// Copyright (c) 2011 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 "content/browser/renderer_host/render_view_host_observer.h"

#include "content/browser/renderer_host/render_view_host.h"

RenderViewHostObserver::RenderViewHostObserver(RenderViewHost* render_view_host)
    : render_view_host_(render_view_host),
      routing_id_(render_view_host->routing_id()) {
  render_view_host_->AddObserver(this);
}

RenderViewHostObserver::~RenderViewHostObserver() {
  if (render_view_host_)
    render_view_host_->RemoveObserver(this);
}

void RenderViewHostObserver::RenderViewHostDestroyed() {
  delete this;
}

bool RenderViewHostObserver::OnMessageReceived(const IPC::Message& message) {
  return false;
}

bool RenderViewHostObserver::Send(IPC::Message* message) {
  if (!render_view_host_) {
    delete message;
    return false;
  }

  return render_view_host_->Send(message);
}

void RenderViewHostObserver::RenderViewHostDestruction() {
  render_view_host_ = NULL;
  RenderViewHostDestroyed();
}

Fix heap corruption that occurs when RenderViewHostObserver calls RenderViewHost to unregister when the latter is in its destructor.

TBR=dmichael
Review URL: http://codereview.chromium.org/6813043

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@80946 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


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

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

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

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

#include "tensorflow/core/profiler/utils/errors.h"

namespace tensorflow {
namespace profiler {

const absl::string_view kErrorIncompleteStep =
    "Visualization based on incomplete step. No step markers observed and "
    "hence the step time is actually unknown. Instead, we use the trace "
    "duration as the step time. This may happen if your profiling duration "
    "is shorter than the step time. In that case, you may try to profile "
    "longer.";

const absl::string_view kErrorNoStepMarker =
    "Visualization contains on step based analysis. No step markers observed "
    "and hence the step time is actually unknown. This may happen if your "
    "profiling duration is shorter than the step time. In that case, you may "
    "try to profile longer.";

}  // namespace profiler
}  // namespace tensorflow

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

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

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

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

#include "tensorflow/core/profiler/utils/errors.h"

namespace tensorflow {
namespace profiler {

const absl::string_view kErrorIncompleteStep =
    "Incomplete step observed and hence the step time is unknown."
    "Instead, we use the trace duration as the step time. This may happen"
    " if your profiling duration is shorter than the step time. In this"
    " case, you may try to profile longer.";

const absl::string_view kErrorNoStepMarker =
    "No step marker observed and hence the step time is unknown."
    " This may happen if (1) training steps are not instrumented (e.g., if"
    " you are not using Keras) or (2) the profiling duration is shorter"
    " than the step time. For (1), you need to add step instrumentation;"
    " for (2), you may try to profile longer.";

}  // namespace profiler
}  // namespace tensorflow

Improve error messages of the Profiler.

Improve error messages of the Profiler.

PiperOrigin-RevId: 306947180
Change-Id: Idbebe90f3d29c6a2234424852b1dcfb06507af8d


#include <algorithm>

#include "url.h"

#include "agent.h"
#include "directive.h"

namespace Rep
{
    Agent& Agent::allow(const std::string& query)
    {
        directives_.push_back(Directive(escape(query), true));
        sorted_ = false;
        return *this;
    }

    Agent& Agent::disallow(const std::string& query)
    {
        if (query.empty())
        {
            // Special case: "Disallow:" means "Allow: /"
            directives_.push_back(Directive(query, true));
        }
        else
        {
            directives_.push_back(Directive(escape(query), false));
        }
        sorted_ = false;
        return *this;
    }

    const std::vector<Directive>& Agent::directives() const
    {
        if (!sorted_)
        {
            std::sort(directives_.begin(), directives_.end(), [](const Directive& a, const Directive& b) {
                return b.priority() < a.priority();
            });
            sorted_ = true;
        }
        return directives_;
    }

    bool Agent::allowed(const std::string& query) const
    {
        std::string path(escape(query));

        if (path.compare("/robots.txt") == 0)
        {
            return true;
        }

        std::string escaped = escape(path);
        for (auto directive : directives())
        {
            if (directive.match(escaped))
            {
                return directive.allowed();
            }
        }
        return true;
    }

    std::string Agent::escape(const std::string& query)
    {
        return Url::Url(query).defrag().escape().fullpath();
    }
}

#include <algorithm>

#include "url.h"

#include "agent.h"
#include "directive.h"

namespace Rep
{
    Agent& Agent::allow(const std::string& query)
    {
        directives_.push_back(Directive(escape(query), true));
        sorted_ = false;
        return *this;
    }

    Agent& Agent::disallow(const std::string& query)
    {
        if (query.empty())
        {
            // Special case: "Disallow:" means "Allow: /"
            directives_.push_back(Directive(query, true));
        }
        else
        {
            directives_.push_back(Directive(escape(query), false));
        }
        sorted_ = false;
        return *this;
    }

    const std::vector<Directive>& Agent::directives() const
    {
        if (!sorted_)
        {
            std::sort(directives_.begin(), directives_.end(), [](const Directive& a, const Directive& b) {
                return b.priority() < a.priority();
            });
            sorted_ = true;
        }
        return directives_;
    }

    bool Agent::allowed(const std::string& query) const
    {
        std::string path(escape(query));

        if (path.compare("/robots.txt") == 0)
        {
            return true;
        }

        for (auto directive : directives())
        {
            if (directive.match(path))
            {
                return directive.allowed();
            }
        }
        return true;
    }

    std::string Agent::escape(const std::string& query)
    {
        return Url::Url(query).defrag().escape().fullpath();
    }
}

Remove redundant escaping in allowed check.


// Copyright 2015 Adam Grandquist

#include "./test.hpp"

#include "./ReQL.hpp"

void
consume(ReQL::Cursor<ReQL::Result> cursor) {
  for (auto && : cursor) {}
}

// Copyright 2015 Adam Grandquist

#include "./test.hpp"

#include "./ReQL.hpp"

void
consume(ReQL::Cursor<ReQL::Result> cursor) {
  for (auto &&_ : cursor) {}
}

Add blank name for loop syntax.

Add blank name for loop syntax.


// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from wallet.djinni

#include "CosmosConfigurationDefaults.hpp"  // my header

namespace ledger { namespace core { namespace api {

std::string const CosmosConfigurationDefaults::COSMOS_DEFAULT_API_ENDPOINT = {"http://lite-client-0e27eefb-4031-4859-a88e-249fd241989d.cosmos.bison.run:1317"};

std::string const CosmosConfigurationDefaults::COSMOS_OBSERVER_WS_ENDPOINT = {""};

} } }  // namespace ledger::core::api

// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from wallet.djinni

#include "CosmosConfigurationDefaults.hpp"  // my header

namespace ledger { namespace core { namespace api {

std::string const CosmosConfigurationDefaults::COSMOS_DEFAULT_API_ENDPOINT = {"https://cosmos.coin.staging.aws.ledger.com"};

std::string const CosmosConfigurationDefaults::COSMOS_OBSERVER_WS_ENDPOINT = {""};

} } }  // namespace ledger::core::api

Fix forgetting generating interfaces for explorer


//
// Created by Alex Gurung
//
#include "helper.h"

void testnums(unsigned long long int hail){
    unsigned long long int orghail = hail;
    while(hail!= 0){
        hail = testHail(hail); //Within helper.h file, testHail returns the next hailstone number, or 0 if you get to 4
    }
    cout << orghail << endl;
}
int main(){
    unsigned long long int counter = 10000;
    for(unsigned long long int i = 5476377146882523136; i<18446744073709551615 ; i++){
//18446744073709551615 is the largest value available for an unsigned long long int, and 5476377146882523136 was the previous largest tested value
        testnums(i);
    }
    return 0;
}

//
// Created by Alex Gurung
//
#include "helper.h"

void testnums(unsigned long long int hail){
    unsigned long long int orghail = hail;
    while(hail!= 0){
        hail = testHail(hail); //Within helper.h file, testHail returns the next hailstone number, or 0 if you get to 4
    }
    cout << orghail << endl; //This is a test commit
}
int main(){
    unsigned long long int counter = 10000;
    for(unsigned long long int i = 5476377146882523136; i<18446744073709551615 ; i++){
//18446744073709551615 is the largest value available for an unsigned long long int, and 5476377146882523136 was the previous largest tested value
        testnums(i);
    }
    return 0;
}

Test commit EMAIL PROBLEM MEANS COMMITS DONT COUNT


#include <cstring>
#include "Vector.h"

Vector::Vector() {
  capacity = 8;
  data = new int[8];
}

void Vector::add(int value) {
  size += 1;
  if (size > capacity) {
    reserve(capacity * 2);
  }
  data[size - 1] = value;
}

void Vector::reserve(int newCapacity) {
  capacity = newCapacity;
  int* newData = new int[capacity];
  memcpy(newData, data, sizeof(int) * size);
  data = newData;
}

int Vector::getCapacity() {
  return capacity;
}

#include <cstring>
#include "Vector.h"

Vector::Vector() {
  capacity = 8;
  data = new int[8];
}

void Vector::add(int value) {
  size += 1;
  if (size > capacity) {
    reserve(capacity * 2);
  }
  data[size - 1] = value;
}

void Vector::reserve(int newCapacity) {
  capacity = newCapacity;
  int* newData = new int[capacity];
  memcpy(newData, data, sizeof(int) * size);
  delete[] data;
  data = newData;
}

int Vector::getCapacity() {
  return capacity;
}

Fix memory leak for reserving new arrays


/**
  ******************************************************************************
  * @file    main.c
  * @author  Ac6
  * @version V1.0
  * @date    01-December-2013
  * @brief   Default main function.
  ******************************************************************************
*/

#include "stm32f4xx.h"
#include "stm32f4xx_nucleo.h"
#include "stm32f4xx_hal.h"
#include "PWM_Generator.h"

extern "C" void initialise_monitor_handles(void);

int main(void)
{
	HAL_Init();
	//initialise_monitor_handles();

	PWM_Generator *pwm = PWM_Generator::Instance();

	pwm->Init();
	pwm->Arm(NULL);

	pwm->SetPulse(1050, 1);
	pwm->SetPulse(1050, 2);
	pwm->SetPulse(1050, 3);
	pwm->SetPulse(1050, 4);

	for(;;);
}

Add sample code for PWM

Add sample code for PWM


/*
 * DesktopNetworkAccessManager.cpp
 *
 * Copyright (C) 2009-11 by RStudio, Inc.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include "DesktopNetworkAccessManager.hpp"
#include <QNetworkDiskCache>
#include <QDesktopServices>

#include <core/FilePath.hpp>

using namespace core;

NetworkAccessManager::NetworkAccessManager(QString secret, QObject *parent) :
    QNetworkAccessManager(parent), secret_(secret)
{
   setProxy(QNetworkProxy::NoProxy);

   // initialize cache
   QString cacheDir =
         QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
   FilePath cachePath(cacheDir.toUtf8().constData());
   FilePath browserCachePath = cachePath.complete("RStudioWebkit");
   Error error = browserCachePath.ensureDirectory();
   if (!error)
   {
      QNetworkDiskCache* pCache = new QNetworkDiskCache(parent);
      QString browserCacheDir = QString::fromUtf8(
                                    browserCachePath.absolutePath().c_str());
      pCache->setCacheDirectory(browserCacheDir);
      setCache(pCache);
   }
   else
   {
      LOG_ERROR(error);
   }
}

QNetworkReply* NetworkAccessManager::createRequest(
      Operation op,
      const QNetworkRequest& req,
      QIODevice* outgoingData)
{
   QNetworkRequest req2 = req;
   req2.setRawHeader("X-Shared-Secret",
                     secret_.toAscii());
   return this->QNetworkAccessManager::createRequest(op, req2, outgoingData);
}

/*
 * DesktopNetworkAccessManager.cpp
 *
 * Copyright (C) 2009-11 by RStudio, Inc.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include "DesktopNetworkAccessManager.hpp"

NetworkAccessManager::NetworkAccessManager(QString secret, QObject *parent) :
    QNetworkAccessManager(parent), secret_(secret)
{
   setProxy(QNetworkProxy::NoProxy);
}

QNetworkReply* NetworkAccessManager::createRequest(
      Operation op,
      const QNetworkRequest& req,
      QIODevice* outgoingData)
{
   QNetworkRequest req2 = req;
   req2.setRawHeader("X-Shared-Secret",
                     secret_.toAscii());
   return this->QNetworkAccessManager::createRequest(op, req2, outgoingData);
}

Revert "use file based webkit cache in desktop mode" (was crashing when opening the history pane on linux)


// Check that --gc-sections does not throw away (or localize) parts of sanitizer
// interface.
// RUN: %clang_asan -m64 %s -Wl,--gc-sections -o %t
// RUN: %clang_asan -m64 %s -DBUILD_SO -fPIC -o %t-so.so -shared
// RUN: %t 2>&1

#ifndef BUILD_SO
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  char path[4096];
  snprintf(path, sizeof(path), "%s-so.so", argv[0]);

  void *handle = dlopen(path, RTLD_LAZY);
  if (!handle) fprintf(stderr, "%s\n", dlerror());
  assert(handle != 0);

  typedef void (*F)();
  F f = (F)dlsym(handle, "call_rtl_from_dso");
  printf("%s\n", dlerror());
  assert(dlerror() == 0);
  f();

  dlclose(handle);
  return 0;
}

#else // BUILD_SO

#include <sanitizer/msan_interface.h>
extern "C" void call_rtl_from_dso() {
  volatile int32_t x;
  volatile int32_t y = __sanitizer_unaligned_load32((void *)&x);
}

#endif // BUILD_SO

// Check that --gc-sections does not throw away (or localize) parts of sanitizer
// interface.
// RUN: %clang_asan %s -Wl,--gc-sections -o %t
// RUN: %clang_asan %s -DBUILD_SO -fPIC -o %t-so.so -shared
// RUN: %t 2>&1

// REQUIRES: asan-64-bits

#ifndef BUILD_SO
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  char path[4096];
  snprintf(path, sizeof(path), "%s-so.so", argv[0]);

  void *handle = dlopen(path, RTLD_LAZY);
  if (!handle) fprintf(stderr, "%s\n", dlerror());
  assert(handle != 0);

  typedef void (*F)();
  F f = (F)dlsym(handle, "call_rtl_from_dso");
  printf("%s\n", dlerror());
  assert(dlerror() == 0);
  f();

  dlclose(handle);
  return 0;
}

#else // BUILD_SO

#include <sanitizer/asan_interface.h>
extern "C" void call_rtl_from_dso() {
  volatile int32_t x;
  volatile int32_t y = __sanitizer_unaligned_load32((void *)&x);
}

#endif // BUILD_SO

Mark this test as 64-bit specific

Mark this test as 64-bit specific

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


#include <iostream>

using namespace std;

int main() {
  int a[100][100];
  int d[100][100];

  a = d;

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

#include <iostream>

using namespace std;

int main() {
  int n = 4;
  int a[n][n];
  int d[n][n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      d[i][j] = a[i][j];
    }
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << d[i][j] << ' ';
    }
    cout << endl;
  }
}

Update Floyd with input output

Update Floyd with input output


/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "SimplifyCFG.h"

#include "ControlFlow.h"
#include "DexClass.h"
#include "IRCode.h"
#include "Walkers.h"

void SimplifyCFGPass::run_pass(DexStoresVector& stores,
                           ConfigFiles& /* unused */,
                           PassManager& mgr) {
  const auto& scope = build_class_scope(stores);
  auto total_insns_removed =
      walk::parallel::reduce_methods<std::nullptr_t, int64_t, Scope>(
          scope,
          [](std::nullptr_t, DexMethod* m) {
            auto code = m->get_code();
            if (code == nullptr) {
              return 0l;
            }

            int64_t before_insns = code->count_opcodes();

            // build and linearize the CFG
            code->build_cfg(/* editable */ true);
            code->clear_cfg();

            int64_t after_insns = code->count_opcodes();
            return before_insns - after_insns;
          },
          [](int64_t a, int64_t b) { return a + b; },
          [](int) { return nullptr; }, 0);
  mgr.set_metric("insns_removed", total_insns_removed);
}

static SimplifyCFGPass s_pass;

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "SimplifyCFG.h"

#include "ControlFlow.h"
#include "DexClass.h"
#include "IRCode.h"
#include "Walkers.h"

void SimplifyCFGPass::run_pass(DexStoresVector& stores,
                           ConfigFiles& /* unused */,
                           PassManager& mgr) {
  const auto& scope = build_class_scope(stores);
  auto total_insns_removed =
      walk::parallel::reduce_methods<std::nullptr_t, int64_t, Scope>(
          scope,
          [](std::nullptr_t, DexMethod* m) -> int64_t {
            auto code = m->get_code();
            if (code == nullptr) {
              return 0;
            }

            int64_t before_insns = code->count_opcodes();

            // build and linearize the CFG
            code->build_cfg(/* editable */ true);
            code->clear_cfg();

            int64_t after_insns = code->count_opcodes();
            return before_insns - after_insns;
          },
          [](int64_t a, int64_t b) { return a + b; },
          [](int) { return nullptr; }, 0);
  mgr.set_metric("insns_removed", total_insns_removed);
}

static SimplifyCFGPass s_pass;

Fix integer casting issues in Mac OSS build

Summary:
We were getting the following error:

```
error: return type 'long long' must match previous return
      type 'long' when lambda expression has unspecified explicit return type
```

Addresses https://github.com/facebook/redex/issues/328.

Reviewed By: minjang

Differential Revision: D8733385

fbshipit-source-id: a893b627aa784ba3e82b2dda6c66ffe9b967882f


/* -*- mode:linux -*- */
/**
 * \file closed_list.cc
 *
 *
 *
 * \author Ethan Burns
 * \date 2008-10-09
 */

#include <map>

#include "state.h"
#include "closed_list.h"

void ClosedList::add(const State *s)
{
	m[s->hash()] = s;
}

const State *ClosedList::lookup(const State *c) const
{
	// this is stupid: apparently you can't do an assignment with
	// iterators, so instead we need to do two lookups.

	if (m.find(c->hash()) == m.end())
		return NULL;

	return m.find(c->hash())->second;
}

/**
 * Delete (free up the memory for) all states in the closed list.
 */
void ClosedList::delete_all_states(void)
{
	map<int, const State *>::iterator iter;

	for (iter = m.begin(); iter != m.end(); iter++)
		delete iter->second;
}

/* -*- mode:linux -*- */
/**
 * \file closed_list.cc
 *
 *
 *
 * \author Ethan Burns
 * \date 2008-10-09
 */

#include <map>

#include "state.h"
#include "closed_list.h"

void ClosedList::add(const State *s)
{
	m[s->hash()] = s;
}

const State *ClosedList::lookup(const State *c) const
{
	map<int, const State *>::const_iterator iter;

	iter = m.find(c->hash());

	if (iter == m.end())
		return NULL;

	return iter->second;
}

/**
 * Delete (free up the memory for) all states in the closed list.
 */
void ClosedList::delete_all_states(void)
{
	map<int, const State *>::iterator iter;

	for (iter = m.begin(); iter != m.end(); iter++)
		delete iter->second;
}

Use a const_iterator in ClosedList::lookup.


/**************************************************
 * Source Code for the Original Compiler for the
 * Programming Language Wake
 *
 * EarlyBailoutMethodInvecation.cpp
 *
 * Licensed under the MIT license
 * See LICENSE.TXT for details
 *
 * Author: Michael Fairhurst
 * Revised By:
 *
 **************************************************/

#include "ast/EarlyBailoutMethodInvocation.h"
#include "TypeError.h"

using namespace wake;

PureType<QUALIFIED>* ast::EarlyBailoutMethodInvocation::typeCheck(bool forceArrayIdentifier) {
	PureType<QUALIFIED> subject = *auto_ptr<PureType<QUALIFIED> >(subjectExpr->typeCheck(false));
	if(subject.type == TYPE_MATCHALL) {
		return new PureType<QUALIFIED>(subject);
	} else if(subject.type != TYPE_OPTIONAL) {
		errors->addError(new SemanticError(OPTIONAL_USE_OF_NONOPTIONAL_TYPE, "using .? on a nonoptional", node));
		return new PureType<QUALIFIED>(TYPE_MATCHALL);
	} else {
		PureType<QUALIFIED>* ret = new PureType<QUALIFIED>(TYPE_OPTIONAL);
		PureType<QUALIFIED>* nonoptional = subject.typedata.optional.contained;

		while(nonoptional->type == TYPE_OPTIONAL) {
			nonoptional = nonoptional->typedata.optional.contained;
		}

		ret->typedata.optional.contained = typeCheckMethodInvocation(*nonoptional);

		return ret;
	}
}

/**************************************************
 * Source Code for the Original Compiler for the
 * Programming Language Wake
 *
 * EarlyBailoutMethodInvecation.cpp
 *
 * Licensed under the MIT license
 * See LICENSE.TXT for details
 *
 * Author: Michael Fairhurst
 * Revised By:
 *
 **************************************************/

#include "ast/EarlyBailoutMethodInvocation.h"
#include "TypeError.h"

using namespace wake;

PureType<QUALIFIED>* ast::EarlyBailoutMethodInvocation::typeCheck(bool forceArrayIdentifier) {
	PureType<QUALIFIED> subject = *auto_ptr<PureType<QUALIFIED> >(subjectExpr->typeCheck(false));
	addSubNode(node, makeNodeFromPureType((PureType<UNQUALIFIED>*) new PureType<QUALIFIED>(subject), node->loc));
	if(subject.type == TYPE_MATCHALL) {
		return new PureType<QUALIFIED>(subject);
	} else if(subject.type != TYPE_OPTIONAL) {
		errors->addError(new SemanticError(OPTIONAL_USE_OF_NONOPTIONAL_TYPE, "using .? on a nonoptional", node));
		return new PureType<QUALIFIED>(TYPE_MATCHALL);
	} else {
		PureType<QUALIFIED>* ret = new PureType<QUALIFIED>(TYPE_OPTIONAL);
		PureType<QUALIFIED>* nonoptional = subject.typedata.optional.contained;

		while(nonoptional->type == TYPE_OPTIONAL) {
			nonoptional = nonoptional->typedata.optional.contained;
		}

		ret->typedata.optional.contained = typeCheckMethodInvocation(*nonoptional);

		return ret;
	}
}

Add type hint for java codegen

Add type hint for java codegen


/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2013 BMW Car IT GmbH
 * %%
 * 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.
 * #L%
 */
#include "joynr/JoynrRuntime.h"
#include "JoynrClusterControllerRuntime.h"
#include "joynr/SettingsMerger.h"

namespace joynr
{
JoynrRuntime* JoynrRuntime::createRuntime(const QString& pathToLibjoynrSettings,
                                          const QString& pathToMessagingSettings)
{
    QSettings* settings = SettingsMerger::mergeSettings(pathToLibjoynrSettings);
    SettingsMerger::mergeSettings(pathToMessagingSettings, settings);
    return JoynrClusterControllerRuntime::create(settings);
}
} // namespace joynr

/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2013 BMW Car IT GmbH
 * %%
 * 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.
 * #L%
 */
#include "joynr/JoynrRuntime.h"
#include "JoynrClusterControllerRuntime.h"
#include "joynr/SettingsMerger.h"

namespace joynr
{
JoynrRuntime* JoynrRuntime::createRuntime(const QString& pathToLibjoynrSettings,
                                          const QString& pathToMessagingSettings)
{
    QSettings* settings = SettingsMerger::mergeSettings(pathToLibjoynrSettings);
    SettingsMerger::mergeSettings(pathToMessagingSettings, settings);
    return JoynrClusterControllerRuntime::create(settings);
}

void JoynrRuntime::addBroadcastFilter(QSharedPointer<IBroadcastFilter> filter)
{
    if (!publicationManager) {
        throw JoynrException("Exception in JoynrRuntime: PublicationManager not created yet.");
    }
    publicationManager->addBroadcastFilter(filter);
}
} // namespace joynr

[cpp] Fix cluster controller runtime not defining addBroadcast()

Change-Id: Ie28ecd9b6139672315704ff1f0d7b2b2ba4d9c85


// REQUIRES: shell

// MSYS doesn't emulate umask.
// FIXME: Could we introduce another feature for it?
// REQUIRES: shell-preserves-root'

// RUN: umask 000
// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
// RUN: ls -l %t | FileCheck --check-prefix=CHECK000 %s
// CHECK000: rw-rw-rw-

// RUN: umask 002
// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
// RUN: ls -l %t | FileCheck --check-prefix=CHECK002 %s
// CHECK002: rw-rw-r--

// REQUIRES: shell

// MSYS doesn't emulate umask.
// FIXME: Could we introduce another feature for it?
// REQUIRES: shell-preserves-root

// RUN: umask 000
// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
// RUN: ls -l %t | FileCheck --check-prefix=CHECK000 %s
// CHECK000: rw-rw-rw-

// RUN: umask 002
// RUN: %clang_cc1 -emit-llvm-bc %s -o %t
// RUN: ls -l %t | FileCheck --check-prefix=CHECK002 %s
// CHECK002: rw-rw-r--

Fix typo in test's REQUIRES line

Fix typo in test's REQUIRES line

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


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

// This file contains LLVM stub functions - these are functions that are never
// called and are declared to satisfy the linker.

#include <assert.h>

#define STUB() assert(!"Stub function. Should not be called");

#include "llvm/Transforms/IPO/PassManagerBuilder.h"

namespace llvm
{

void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { STUB(); }

} // namespace llvm

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

// This file contains LLVM stub functions - these are functions that are never
// called and are declared to satisfy the linker.

#include <assert.h>

#define STUB() assert(false); // Stub function. Should not be called

#include "llvm/Transforms/IPO/PassManagerBuilder.h"

namespace llvm
{

void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { STUB(); }

} // namespace llvm

Fix warning treated as error

Fix warning treated as error

Bug: chromium:963658
Change-Id: I7db9bd4b5cec57c65298cdef512d18e31d4182f5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31594
Presubmit-Ready: Ben Clayton <1f693eb7158dc33015048c09d6712f74dabddf79@google.com>
Kokoro-Presubmit: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Tested-by: Ben Clayton <1f693eb7158dc33015048c09d6712f74dabddf79@google.com>


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

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

#include "chrome/browser/browser.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"

// TODO(skerner): This test is flaky in chromeos.  Figure out why and fix.
#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs) {
  StartHTTPServer();

  // The test creates a tab and checks that the URL of the new tab
  // is that of the new tab page.  Make sure the pref that controls
  // this is set.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kHomePageIsNewTabPage, true);

  ASSERT_TRUE(RunExtensionTest("tabs/basics")) << message_;
}

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

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

#include "chrome/browser/browser.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"

// TODO(skerner): This test is flaky in chromeos and on Mac OS X 10.6.  Figure
// out why and fix.
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(OS_MACOSX)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs) {
  StartHTTPServer();

  // The test creates a tab and checks that the URL of the new tab
  // is that of the new tab page.  Make sure the pref that controls
  // this is set.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kHomePageIsNewTabPage, true);

  ASSERT_TRUE(RunExtensionTest("tabs/basics")) << message_;
}

Disable ExtensionApiTest.Tabs on Mac.
TEST=no random redness on Mac OS X 10.6 bot
BUG=37387
TBR=skerner@

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


/**
 * Copyright 2014 Truphone
 */
#include "XmppHarness.h"

#include "CommandFactory.h"
#include "XmppResourceStore.h"
#include "XmppHelpCommand.h"
#include "XmppPresenceCommand.h"
#include "XmppConnectCommand.h"
#include "XmppMessageCommand.h"

namespace truphone
{
namespace test
{
namespace cascades
{
    XmppHarness::XmppHarness(QObject *parent) :
        QObject(parent)
    {
    }
    XmppHarness::~XmppHarness()
    {
    }
    bool XmppHarness::installHarness()
    {
        XMPPResourceStore::initialiseStore(this);
        CommandFactory::installCommand(
                    XMPPHelpCommand::getCmd(),
                    &XMPPHelpCommand::create);
        CommandFactory::installCommand(
                    XMPPConnectCommand::getCmd(),
                    &XMPPConnectCommand::create);
        CommandFactory::installCommand(
                    XMPPPresenceCommand::getCmd(),
                    &XMPPPresenceCommand::create);
        CommandFactory::installCommand(
                    XMPPMessageCommand::getCmd(),
                    &XMPPMessageCommand::create);
        return true;
    }
}  // namespace cascades
}  // namespace test
}  // namespace truphone

/**
 * Copyright 2014 Truphone
 */
#include "XmppHarness.h"

#include "CommandFactory.h"
#include "XmppResourceStore.h"
#include "XmppHelpCommand.h"
#include "XmppPresenceCommand.h"
#include "XmppConnectCommand.h"
#include "XmppMessageCommand.h"
#include "XmppDisconnectCommand.h"

namespace truphone
{
namespace test
{
namespace cascades
{
    XmppHarness::XmppHarness(QObject *parent) :
        QObject(parent)
    {
    }
    XmppHarness::~XmppHarness()
    {
    }
    bool XmppHarness::installHarness()
    {
        XMPPResourceStore::initialiseStore(this);
        CommandFactory::installCommand(
                    XMPPHelpCommand::getCmd(),
                    &XMPPHelpCommand::create);
        CommandFactory::installCommand(
                    XMPPConnectCommand::getCmd(),
                    &XMPPConnectCommand::create);
        CommandFactory::installCommand(
                    XMPPPresenceCommand::getCmd(),
                    &XMPPPresenceCommand::create);
        CommandFactory::installCommand(
                    XMPPMessageCommand::getCmd(),
                    &XMPPMessageCommand::create);
        CommandFactory::installCommand(
                    XMPPDisconnectCommand::getCmd(),
                    &XMPPDisconnectCommand::create);
        return true;
    }
}  // namespace cascades
}  // namespace test
}  // namespace truphone

Add the disconnect command to the factory.


// Copyright (c) 2011 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/metrics/metrics_service.h"

#include <string>

#include "base/base64.h"

#include "testing/gtest/include/gtest/gtest.h"

class MetricsServiceTest : public ::testing::Test {
};

// Ensure the ClientId is formatted as expected.
TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) {
  std::string clientid = MetricsService::GenerateClientID();
  EXPECT_EQ(36U, clientid.length());
  std::string hexchars = "0123456789ABCDEF";
  for (uint32 i = 0; i < clientid.length(); i++) {
    char current = clientid.at(i);
    if (i == 8 || i == 13 || i == 18 || i == 23) {
      EXPECT_EQ('-', current);
    } else {
      EXPECT_TRUE(std::string::npos != hexchars.find(current));
    }
  }
}

TEST(MetricsServiceTest, IsPluginProcess) {
  EXPECT_TRUE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_PLUGIN));
  EXPECT_TRUE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_PPAPI_PLUGIN));
  EXPECT_FALSE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_GPU));
}

// 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 file.

#include <ctype.h>
#include <string>

#include "chrome/browser/metrics/metrics_service.h"
#include "testing/gtest/include/gtest/gtest.h"

// Ensure the ClientId is formatted as expected.
TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) {
  std::string clientid = MetricsService::GenerateClientID();
  EXPECT_EQ(36U, clientid.length());

  for (size_t i = 0; i < clientid.length(); ++i) {
    char current = clientid[i];
    if (i == 8 || i == 13 || i == 18 || i == 23)
      EXPECT_EQ('-', current);
    else
      EXPECT_TRUE(isxdigit(current));
  }
}

TEST(MetricsServiceTest, IsPluginProcess) {
  EXPECT_TRUE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_PLUGIN));
  EXPECT_TRUE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_PPAPI_PLUGIN));
  EXPECT_FALSE(
      MetricsService::IsPluginProcess(content::PROCESS_TYPE_GPU));
}

Clean up MetricsService unit test.

Clean up MetricsService unit test.

BUG=none
TEST=none

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

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


#include "PoissonDiskSampling.h"

PoissonDiskSampling::PoissonDiskSampling(int pointWidth, int pointHeight, double pointMinDist, double pointCount) :
	m_width(pointWidth),
	m_height(pointHeight),
	m_minDist(pointMinDist),
	m_pointCount(pointCount),
	m_cellSize(m_minDist / 1.414214f),
	m_gridWidth(ceil(m_width / m_cellSize)),
	m_gridHeight(ceil(m_height / m_cellSize)),
	m_grid(std::vector<std::vector<std::shared_ptr<Point>>>(m_gridWidth, std::vector<std::shared_ptr<Point>>(m_gridHeight, nullptr)))
{

}

#include "PoissonDiskSampling.h"

#include <random>

PoissonDiskSampling::PoissonDiskSampling(int pointWidth, int pointHeight, double pointMinDist, double pointCount) :
	m_width(pointWidth),
	m_height(pointHeight),
	m_minDist(pointMinDist),
	m_pointCount(pointCount),
	m_cellSize(m_minDist / 1.414214f),
	m_gridWidth(ceil(m_width / m_cellSize)),
	m_gridHeight(ceil(m_height / m_cellSize)),
	m_grid(std::vector<std::vector<std::shared_ptr<Point>>>(m_gridWidth, std::vector<std::shared_ptr<Point>>(m_gridHeight, nullptr)))
{

}

std::vector<std::pair<double, double>> PoissonDiskSampling::Generate()
{
	std::random_device rd;
	std::mt19937 gen(rd());

	Point firstPoint(gen() / m_width, gen() / m_height);

	m_process.push_back(firstPoint);
	m_sample.push_back(std::make_pair(firstPoint.x, firstPoint.y));
	int firstPointX = firstPoint.x / m_cellSize;
	int firstPointY = firstPoint.y / m_cellSize;
	m_grid[firstPointX][firstPointY] = std::make_shared<Point>(firstPoint);

	while (!m_process.empty())
	{

	}
}

Implement Generate() : create firstPoint and assign it


#include "main_action_planner_node.hpp"

int main(int argc, char** argv) {
  ros::init(argc, argv, "test_action_planner_node");
  ros::NodeHandle nh {"~"};
  StateChecker status {nh};

  while (ros::ok()) {
    auto posture_key = status.getPostureKey();
    RequestPosture* rp_p = RequestPostureFactory::get(posture_key[0], nh);
    if (!rp_p) {
      ROS_INFO("Error: get nullptr by RP Factory: arg is [%s]", posture_key[0].c_str());
      return -1;
    }

    SendPosture* sp_p = SendPostureFactory::get(posture_key[1], nh);
    if (!sp_p) {
      ROS_INFO("Error: get nullptr by SP Factory: arg is [%s]", posture_key[1].c_str());
      return -1;
    }

    std::vector<double> angles;
    rp_p->requestPosture(angles);
    sp_p->sendPosture(angles);

    ros::spinOnce();
  }
  return 0;
}

#include "main_action_planner_node.hpp"

int main(int argc, char** argv) {
  ros::init(argc, argv, "test_action_planner_node");
  ros::NodeHandle nh {};
  StateChecker status {nh};

  while (ros::ok()) {
    auto posture_key = status.getPostureKey();
    RequestPosture* rp_p = RequestPostureFactory::get(posture_key[0], nh);
    if (!rp_p) {
      ROS_INFO("Error: get nullptr by RP Factory: arg is [%s]", posture_key[0].c_str());
      return -1;
    }

    SendPosture* sp_p = SendPostureFactory::get(posture_key[1], nh);
    if (!sp_p) {
      ROS_INFO("Error: get nullptr by SP Factory: arg is [%s]", posture_key[1].c_str());
      return -1;
    }

    std::vector<double> angles;
    rp_p->requestPosture(angles);
    sp_p->sendPosture(angles);

    ros::spinOnce();
  }
  return 0;
}

Use relational node handle for topic communicate


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

  Program:   Converter Base Class
  Language:  C++

  Copyright (c) Brigham and Women's Hospital. All rights reserved.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

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

#include "rib_converter_base.h"

RIBConverterBase::RIBConverterBase()
{
  this->nodeHandle = NULL;
}

RIBConverterBase::RIBConverterBase(ros::NodeHandle *nh)
{
  this->setNodeHandle(nh);
}

RIBConverterBase::RIBConverterBase(const char* topicPublish, const char* topicSubscribe, ros::NodeHandle *nh)
{
  this->topicPublish = topicPublish;
  this->topicSubscribe = topicSubscribe;
  this->setNodeHandle(nh);
}

RIBConverterBase::~RIBConverterBase()
{
}

void RIBConverterBase::setup(ros::NodeHandle* nh, uint32_t queuSize)
{
  this->setNodeHandle(nh);
  this->setQueueSize(queueSize);
}

//void RIBConverterBase::setup(ros::NodeHandle* nh, igtl::Socket * socket, const char* topicSubscribe, const char* topicPublish)
//{
//  this->nodeHandle = nh;
//  this->socket = socket;
//  this->topicSubscribe = topicSubscribe;
//  this->topicPublish = topicPublish;
//}

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

  Program:   Converter Base Class
  Language:  C++

  Copyright (c) Brigham and Women's Hospital. All rights reserved.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

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

#include "rib_converter_base.h"

RIBConverterBase::RIBConverterBase()
{
  this->nodeHandle = NULL;
}

RIBConverterBase::RIBConverterBase(ros::NodeHandle *nh)
{
  this->setNodeHandle(nh);
}

RIBConverterBase::RIBConverterBase(const char* topicPublish, const char* topicSubscribe, ros::NodeHandle *nh)
{
  this->topicPublish = topicPublish;
  this->topicSubscribe = topicSubscribe;
  this->setNodeHandle(nh);
}

RIBConverterBase::~RIBConverterBase()
{
}

void RIBConverterBase::setup(ros::NodeHandle* nh, uint32_t queuSize)
{
  this->setNodeHandle(nh);
  this->setQueue(nh);
  this->setQueueSize(queueSize);
}

//void RIBConverterBase::setup(ros::NodeHandle* nh, igtl::Socket * socket, const char* topicSubscribe, const char* topicPublish)
//{
//  this->nodeHandle = nh;
//  this->socket = socket;
//  this->topicSubscribe = topicSubscribe;
//  this->topicPublish = topicPublish;
//}

Call setQueue in setup function.

Call setQueue in setup function.


#include "robot_editor.h"
#include "robot_preview.h"

#include <cstdlib>

RobotEditor::RobotEditor()
{
	main_window_ui_.setupUi(&main_window_);
	robot_preview_ = new RobotPreview(main_window_ui_.rvizFrame);

	QObject::connect(main_window_ui_.actionExit, SIGNAL(triggered()), this, SLOT(exitTrigger()));
	QObject::connect(main_window_ui_.actionOpen, SIGNAL(triggered()), this, SLOT(openTrigger()));
	QObject::connect(main_window_ui_.actionSave, SIGNAL(triggered()), this, SLOT(saveTrigger()));
	QObject::connect(main_window_ui_.actionSave_As, SIGNAL(triggered()), this, SLOT(saveAsTrigger()));
}

RobotEditor::~RobotEditor()
{
	delete robot_preview_;
}

void RobotEditor::show()
{
	main_window_.show();
}

void RobotEditor::openTrigger() {
	printf("Open selected\n");
}

void RobotEditor::saveTrigger() {
	printf("Save selected\n");
}

void RobotEditor::saveAsTrigger() {
	printf("Save as selected\n");
}

void RobotEditor::exitTrigger() {
	printf("Exit selected\n");
}

#include "robot_editor.h"
#include "robot_preview.h"

#include <cstdlib>

RobotEditor::RobotEditor()
{
	main_window_ui_.setupUi(&main_window_);
	robot_preview_ = new RobotPreview(main_window_ui_.rvizFrame);

	QObject::connect(main_window_ui_.actionExit, SIGNAL(triggered()), this, SLOT(exitTrigger()));
	QObject::connect(main_window_ui_.actionOpen, SIGNAL(triggered()), this, SLOT(openTrigger()));
	QObject::connect(main_window_ui_.actionSave, SIGNAL(triggered()), this, SLOT(saveTrigger()));
	QObject::connect(main_window_ui_.actionSave_As, SIGNAL(triggered()), this, SLOT(saveAsTrigger()));
}

RobotEditor::~RobotEditor()
{
	delete robot_preview_;
}

void RobotEditor::show()
{
	main_window_.show();
}

void RobotEditor::openTrigger() {
	printf("Open selected\n");
}

void RobotEditor::saveTrigger() {
	printf("Save selected\n");
}

void RobotEditor::saveAsTrigger() {
	printf("Save as selected\n");
}

void RobotEditor::exitTrigger() {
	// quit the application
	exit(0);
}

Exit menu action now works.

Exit menu action now works.


#include <QtQuick>

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

#include "factor.h"

void loadTranslations() {
    QString langCode = QLocale::system().name().mid(0, 2);
    const QString Prefix("sailfactor_");

    if (QFile::exists(QString(":/lang/") + Prefix + langCode + ".qm")) {
        QTranslator *translator = new QTranslator(QCoreApplication::instance());
        translator->load(Prefix + langCode, ":/lang");
        QCoreApplication::installTranslator(translator);
    }
}

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

    loadTranslations();

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

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

    view->setTitle("Sailfactor");

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

    view->show();

    return app->exec();
}

#include <QtQuick>

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

#include "factor.h"

static void loadTranslations() {
    QString langCode = QLocale::system().name().mid(0, 2);
    const QString Prefix("sailfactor_");

    if (QFile::exists(QString(":/lang/") + Prefix + langCode + ".qm")) {
        QTranslator *translator = new QTranslator(QCoreApplication::instance());
        translator->load(Prefix + langCode, ":/lang");
        QCoreApplication::installTranslator(translator);
    }
}

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

    loadTranslations();

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

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

    view->setTitle("Sailfactor");

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

    view->show();

    return app->exec();
}

Make loadTranslations() a static function.


#include <functional>

#include <QApplication>
#include <QMenu>
#include <QObject>
#include <QSystemTrayIcon>
#include <QTranslator>

#include "piemenu.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);

    QTranslator translator;
    translator.load(QLocale(), "", "i18n", ".qm");
    app.installTranslator(&translator);

    PieMenu pieMenu(qApp->applicationDirPath());

    QSystemTrayIcon tray(QIcon(qApp->applicationDirPath() + "/icons/app.png"), &app);

    QMenu trayMenu;
    trayMenu.addAction(QObject::tr("Open menu"), std::bind(&PieMenu::open, &pieMenu));
    trayMenu.addAction(QObject::tr("&Quit"));

    tray.setContextMenu(&trayMenu);
    tray.show();

    return app.exec();
}

#include <functional>

#include <QApplication>
#include <QMenu>
#include <QObject>
#include <QSystemTrayIcon>
#include <QTranslator>

#include "piemenu.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);

    QTranslator translator;
    translator.load(QLocale(), "", "i18n", ".qm");
    app.installTranslator(&translator);

    PieMenu pieMenu(qApp->applicationDirPath());

    QSystemTrayIcon tray(QIcon(qApp->applicationDirPath() + "/icons/app.png"), &app);

    QMenu trayMenu;
    trayMenu.addAction(QObject::tr("Open menu"), std::bind(&PieMenu::open, &pieMenu));
    trayMenu.addAction(QObject::tr("&Quit"), qApp, &QApplication::quit);

    tray.setContextMenu(&trayMenu);
    tray.show();

    return app.exec();
}

Make quit tray menu option work

Make quit tray menu option work


#include <string.h>
#include "ShipBlockPacket.h"

ShipBlockPacket::ShipBlockPacket(uint8_t ip1, uint8_t ip2, uint8_t ip3, uint8_t ip4, uint16_t port) {
    static const uint8_t ipBits[] = { ip1, ip2, ip3, ip4};
    memcpy(this->ipaddr, ipBits, sizeof(ipBits));
    this->port = port;
}

ShipBlockPacket::~ShipBlockPacket() {
    delete[] ipaddr;
}

PacketData ShipBlockPacket::build() {
    PacketData data;
    PacketHeader header(0x90, 0x11, 0x2C, 0x0, 0x0);
    data.appendData(&header, sizeof(header));

    // TODO fill in gap

    // Offset 0x64
    data.appendData(&ipaddr, 4);

    // Offset 0x68
    data.appendData(&port, 2);

    // TODO fill in gap

    return data;
}

Stop deleting my includes clion

Stop deleting my includes clion


//===-- AVRMCAsmInfo.cpp - AVR asm properties -----------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the AVRMCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "AVRMCAsmInfo.h"

#include "llvm/ADT/Triple.h"

namespace llvm {

AVRMCAsmInfo::AVRMCAsmInfo(const Triple &TT) {
  CodePointerSize = 2;
  CalleeSaveStackSlotSize = 2;
  CommentString = ";";
  PrivateGlobalPrefix = ".L";
  UsesELFSectionDirectiveForBSS = true;
  UseIntegratedAssembler = true;
}

} // end of namespace llvm

[AVR] Migrate to new MCAsmInfo CodePointerSize

Reviewers: dylanmckay, rengolin, kzhuravl, jroelofs

Reviewed By: kzhuravl, jroelofs

Subscribers: kzhuravl, llvm-commits

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

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


/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"

#include <cstdlib>

class VoeBaseMiscTest : public BeforeInitializationFixture {
};

using namespace testing;

TEST_F(VoeBaseMiscTest, MaxNumChannelsIs32) {
  EXPECT_EQ(32, voe_base_->MaxNumOfChannels());
}

TEST_F(VoeBaseMiscTest, GetVersionPrintsSomeUsefulInformation) {
  char char_buffer[1024];
  memset(char_buffer, 0, sizeof(char_buffer));
  EXPECT_EQ(0, voe_base_->GetVersion(char_buffer));
  EXPECT_THAT(char_buffer, ContainsRegex("VoiceEngine"));
}

/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"

#include <cstdlib>

class VoeBaseMiscTest : public BeforeInitializationFixture {
};

using namespace testing;

TEST_F(VoeBaseMiscTest, MaxNumChannelsIs100) {
  EXPECT_EQ(100, voe_base_->MaxNumOfChannels());
}

TEST_F(VoeBaseMiscTest, GetVersionPrintsSomeUsefulInformation) {
  char char_buffer[1024];
  memset(char_buffer, 0, sizeof(char_buffer));
  EXPECT_EQ(0, voe_base_->GetVersion(char_buffer));
  EXPECT_THAT(char_buffer, ContainsRegex("VoiceEngine"));
}

Fix MaxChannels test; 32 -> 100.

Fix MaxChannels test; 32 -> 100.

TBR=henrika

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

Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 6ed8ebcef92ed9bbb0e7d50a09295aa216f1422f


#include "Flax/WindowsFiberImpl.h"

#include <cassert>

#include <Windows.h>

namespace flax {

WindowsFiberImpl::WindowsFiberImpl(Fiber* fiber, FiberMainFunction mainFunction, bool isMainFiber)
   : address(nullptr), mainFiber(isMainFiber), fiberAndMain(fiber, mainFunction) {
   assert(fiber && mainFunction);

   if (mainFiber) {
      address = ConvertThreadToFiber(this);
      assert(address);
   } else {
      address = CreateFiber(0, [](LPVOID param) {
         FiberAndMain* fiberAndMain = reinterpret_cast<FiberAndMain*>(param);
         assert(fiberAndMain);

         fiberAndMain->mainFunction(fiberAndMain->fiber);
      }, &fiberAndMain);
   }
}

WindowsFiberImpl::~WindowsFiberImpl() {
   if (mainFiber) {
      assert(address);
      bool success = ConvertFiberToThread() != 0;
      assert(success);
   } else if (address) {
      DeleteFiber(address);
   }

   address = nullptr;
}

void WindowsFiberImpl::swapTo(WindowsFiberImpl& lastFiberImpl) {
   assert(address && GetCurrentFiber() != address && GetCurrentFiber() == lastFiberImpl.address);
   SwitchToFiber(address);
}

} // namespace flax

#include "Flax/WindowsFiberImpl.h"

#include <cassert>

#include <Windows.h>

namespace flax {

WindowsFiberImpl::WindowsFiberImpl(Fiber* fiber, FiberMainFunction mainFunction, bool isMainFiber)
   : address(nullptr), mainFiber(isMainFiber), fiberAndMain(fiber, mainFunction) {
   assert(fiber && mainFunction);

   if (mainFiber) {
      address = ConvertThreadToFiber(this);
      assert(address);
   } else {
      address = CreateFiber(0, [](LPVOID param) {
         FiberAndMain* fiberAndMain = reinterpret_cast<FiberAndMain*>(param);
         assert(fiberAndMain);

         fiberAndMain->mainFunction(fiberAndMain->fiber);
      }, &fiberAndMain);
   }
}

WindowsFiberImpl::~WindowsFiberImpl() {
   if (mainFiber) {
      assert(address);
      bool success = ConvertFiberToThread() != 0;
      assert(success);
   } else if (address) {
      DeleteFiber(address);
   }

   address = nullptr;
}

void WindowsFiberImpl::swapTo(WindowsFiberImpl& lastFiberImpl) {
   assert(address && lastFiberImpl.address && GetCurrentFiber() != address && GetCurrentFiber() == lastFiberImpl.address);
   SwitchToFiber(address);
}

} // namespace flax

Add additional check to assert call

Add additional check to assert call


/*
 * Copyright (c) 2007 Digital Bazaar, Inc.  All rights reserved.
 */

#include <iostream>

#include "db/database/sqlite3/Sqlite3Connection.h"
#include "db/database/sqlite3/Sqlite3Statement.h"

using namespace std;
using namespace db::database;
using namespace db::database::sqlite3;

Sqlite3Connection::Sqlite3Connection(const char* params) :
   Connection(params)
{
   int ret;
   mHandle = NULL;

   if(mInitParams->getScheme() != "sqlite3")
   {
      // FIXME error handling
   }
   else
   {
      string dbFile = mInitParams->getSchemeSpecificPart();
      ret = sqlite3_open(dbFile.c_str(), &mHandle);
      if(ret != SQLITE_OK)
      {
         Sqlite3Connection::close();
         // FIXME error handling
      }
   }
}

Sqlite3Connection::~Sqlite3Connection()
{
   Sqlite3Connection::close();
}

void Sqlite3Connection::close()
{
   if(mHandle != NULL)
   {
      sqlite3_close(mHandle);
   }
}

void Sqlite3Connection::commit()
{
   cout << "FIXME: commit" << endl;
}

void Sqlite3Connection::rollback()
{
   cout << "FIXME: rollback" << endl;
}

Statement* Sqlite3Connection::createStatement(const char* sql)
{
   return new Sqlite3Statement(this, sql);
}

/*
 * Copyright (c) 2007 Digital Bazaar, Inc.  All rights reserved.
 */

#include <iostream>

#include "db/database/sqlite3/Sqlite3Connection.h"
#include "db/database/sqlite3/Sqlite3Statement.h"

using namespace std;
using namespace db::database;
using namespace db::database::sqlite3;

Sqlite3Connection::Sqlite3Connection(const char* params) :
   Connection(params)
{
   int ret;
   mHandle = NULL;

   if(mInitParams->getScheme() != "sqlite3")
   {
      // FIXME error handling
   }
   else
   {
      string dbFile = mInitParams->getSchemeSpecificPart();
      ret = sqlite3_open(dbFile.c_str(), &mHandle);
      if(ret != SQLITE_OK)
      {
         Sqlite3Connection::close();
         // FIXME error handling
      }
   }
}

Sqlite3Connection::~Sqlite3Connection()
{
   Sqlite3Connection::close();
}

void Sqlite3Connection::close()
{
   if(mHandle != NULL)
   {
      sqlite3_close(mHandle);
      mHandle = NULL;
   }
}

void Sqlite3Connection::commit()
{
   cout << "FIXME: commit" << endl;
}

void Sqlite3Connection::rollback()
{
   cout << "FIXME: rollback" << endl;
}

Statement* Sqlite3Connection::createStatement(const char* sql)
{
   return new Sqlite3Statement(this, sql);
}

Set mHandle to NULL after closing.

Set mHandle to NULL after closing.


// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s
// REQUIRES: asan-32-bits

#include <malloc.h>

int main() {
  while (true) {
    void *ptr = malloc(200 * 1024 * 1024);  // 200MB
  }
// CHECK: failed to allocate
}

// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s
// REQUIRES: asan-32-bits

#include <malloc.h>

int main() {
  while (true) {
    void *ptr = malloc(200 * 1024 * 1024);  // 200MB
  }
// CHECK: allocator is terminating the process instead of returning 0
}

Fix allocator OOM test on Windows.

[Sanitizers] Fix allocator OOM test on Windows.

Summary:
Point of failure is different after D34243, hence the change of the
message.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

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


// Copyright (c) 2015 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 "realsense/enhanced_photography/enhanced_photography_extension.h"

#include <string>

#include "realsense/enhanced_photography/enhanced_photography_instance.h"

xwalk::common::Extension* CreateExtension() {
  return new realsense::enhanced_photography::EnhancedPhotographyExtension;
}

// This will be generated from common_api.js
extern const char kSource_common_api[];
// This will be generated from common_promise_api.js
extern const char kSource_common_promise_api[];
// This will be generated from enhanced_photography_api.js.
extern const char kSource_enhanced_photography_api[];

namespace realsense {
namespace enhanced_photography {

EnhancedPhotographyExtension::EnhancedPhotographyExtension() {
  SetExtensionName("realsense.EnhancedPhotography");
  std::string jsapi(kSource_common_api);
  jsapi += kSource_common_promise_api;
  jsapi += kSource_enhanced_photography_api;
  SetJavaScriptAPI(jsapi.c_str());
}

EnhancedPhotographyExtension::~EnhancedPhotographyExtension() {}

xwalk::common::Instance* EnhancedPhotographyExtension::CreateInstance() {
  return new EnhancedPhotographyInstance();
}

}  // namespace enhanced_photography
}  // namespace realsense

// Copyright (c) 2015 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 "realsense/enhanced_photography/enhanced_photography_extension.h"

#include <string>

#include "base/at_exit.h"
#include "realsense/enhanced_photography/enhanced_photography_instance.h"

base::AtExitManager exit_manager;

xwalk::common::Extension* CreateExtension() {
  return new realsense::enhanced_photography::EnhancedPhotographyExtension;
}

// This will be generated from common_api.js
extern const char kSource_common_api[];
// This will be generated from common_promise_api.js
extern const char kSource_common_promise_api[];
// This will be generated from enhanced_photography_api.js.
extern const char kSource_enhanced_photography_api[];

namespace realsense {
namespace enhanced_photography {

EnhancedPhotographyExtension::EnhancedPhotographyExtension() {
  SetExtensionName("realsense.EnhancedPhotography");
  std::string jsapi(kSource_common_api);
  jsapi += kSource_common_promise_api;
  jsapi += kSource_enhanced_photography_api;
  SetJavaScriptAPI(jsapi.c_str());
}

EnhancedPhotographyExtension::~EnhancedPhotographyExtension() {}

xwalk::common::Instance* EnhancedPhotographyExtension::CreateInstance() {
  return new EnhancedPhotographyInstance();
}

}  // namespace enhanced_photography
}  // namespace realsense

Fix DCHECK of AtExitManager failure

[EP][WIN] Fix DCHECK of AtExitManager failure

Fix #113


//===-- sanitizer_allocator.cc --------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
// This allocator that is used inside run-times.
//===----------------------------------------------------------------------===//
#include "sanitizer_common.h"

// FIXME: We should probably use more low-level allocator that would
// mmap some pages and split them into chunks to fulfill requests.
#include <stdlib.h>

namespace __sanitizer {

static const u64 kInternalAllocBlockMagic = 0x7A6CB03ABCEBC042ull;

void *InternalAlloc(uptr size) {
  void *p = malloc(size + sizeof(u64));
  ((u64*)p)[0] = kInternalAllocBlockMagic;
  return (char*)p + sizeof(u64);
}

void InternalFree(void *addr) {
  if (!addr) return;
  addr = (char*)addr - sizeof(u64);
  CHECK_EQ(((u64*)addr)[0], kInternalAllocBlockMagic);
  ((u64*)addr)[0] = 0;
  free(addr);
}

}  // namespace __sanitizer

//===-- sanitizer_allocator.cc --------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
// This allocator that is used inside run-times.
//===----------------------------------------------------------------------===//
#include "sanitizer_common.h"

// FIXME: We should probably use more low-level allocator that would
// mmap some pages and split them into chunks to fulfill requests.
#ifdef __linux__
extern "C" void *__libc_malloc(__sanitizer::uptr size);
extern "C" void __libc_free(void *ptr);
# define LIBC_MALLOC __libc_malloc
# define LIBC_FREE __libc_free
#else  // __linux__
# include <stdlib.h>
# define LIBC_MALLOC malloc
# define LIBC_FREE free
#endif  // __linux__

namespace __sanitizer {

static const u64 kInternalAllocBlockMagic = 0x7A6CB03ABCEBC042ull;

void *InternalAlloc(uptr size) {
  void *p = LIBC_MALLOC(size + sizeof(u64));
  ((u64*)p)[0] = kInternalAllocBlockMagic;
  return (char*)p + sizeof(u64);
}

void InternalFree(void *addr) {
  if (!addr) return;
  addr = (char*)addr - sizeof(u64);
  CHECK_EQ(((u64*)addr)[0], kInternalAllocBlockMagic);
  ((u64*)addr)[0] = 0;
  LIBC_FREE(addr);
}

}  // namespace __sanitizer

[Sanitizer] Use __libc_malloc/__libc_free instead of malloc/free inside internal allocator on Linux (important for TSan)

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


#include <ros/ros.h>
#include <geometry_msgs/Twist.h>

namespace quadrotor_obstacle_avoidance {

int main(int argc, char *argv[]){
    ros::init(argc, argv, "quadrotor_obstacle_avoidance");

    ros::NodeHandle node;
    ros::Publisher cmd_pub = node.advertise<geometry_msgs::Twist>("cmd_vel", 10);

    geometry_msgs::Twist cmd;

    cmd.linear.z = 0.5;
    cmd_pub.publish(cmd);
    ros::Duration(5);

    cmd.linear.z = 0.0;
    cmd_pub.publish(cmd);
    ros::Duration(5);

    return 0;
}

};

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>

int main(int argc, char *argv[]){
    ros::init(argc, argv, "quadrotor_obstacle_avoidance");

    ros::NodeHandle node;
    ros::Publisher cmd_pub = node.advertise<geometry_msgs::Twist>("cmd_vel", 10);

    ros::Duration(1).sleep();

    geometry_msgs::Twist cmd;

    cmd.linear.z = 5;
    cmd_pub.publish(cmd);
    ros::Duration(5).sleep();

    cmd.linear.z = 0.0;
    cmd_pub.publish(cmd);
    ros::Duration(5).sleep();

    return 0;
}

Fix building error of node

Fix building error of node


#include <iostream>
#include <string>

using namespace std;

typedef struct {
    String nome;
    String cpf;
    float saldo;
} Conta;

float get_saldo( Conta &conta ) {
    return conta.saldo;
}

void set_saldo( Conta &conta ) {
    conta.saldo;
}
int main() {
    Conta conta;

    init_conta( conta );

    return 0;
}

#include <iostream>
#include <string>

using namespace std;

typedef struct {
    String nome;
    String cpf;
    float saldo;
} Conta;

int main() {
    Conta conta;

    init_conta( conta );

    return 0;
}

Revert "Criando estruturas de dados"

Revert "Criando estruturas de dados"

This reverts commit d3dd310602e5139dcbfabaca4c4835b064c0b958.


// 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 file.

#include "chrome/common/thumbnail_support.h"

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

#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif

bool ShouldEnableInBrowserThumbnailing() {
  if (CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kDisableInBrowserThumbnailing))
    return false;

#if defined(OS_CHROMEOS)
  return true;
#else
  return false;
#endif
}

// 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 file.

#include "chrome/common/thumbnail_support.h"

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

#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif

bool ShouldEnableInBrowserThumbnailing() {
  if (CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kDisableInBrowserThumbnailing))
    return false;

#if defined(OS_WIN)
  // Disables in-browser thumbnailing on Windows XP where not supported yet.
  if (base::win::GetVersion() < base::win::VERSION_VISTA)
    return false;
  return true;
#elif defined(OS_LINUX) && !defined(USE_AURA)
  // Disables in-browser thumbnailing on non-Aura Linux where not supported yet.
  return false;
#else
  return true;
#endif
}

Revert "Temporarily disable in-browser thumbnailing on Win and Mac."

This reverts commit 4cc7f1d81a2e9a88a25bc211af457ca7af200d0e.

Now the cause of http://crbug.com/130916 was identified and fixed, I'll re-enable in-browser thumbnailer on Win and Mac.

BUG=130916,120003
TEST=Manual

Review URL: https://chromiumcodereview.appspot.com/10554018

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