// Copyright (c) 2018 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <boost/test/unit_test.hpp>
#include <tinyformat.h>
#include <utilmoneystr.h>
#include "masternode-budget.h"

BOOST_AUTO_TEST_SUITE(budget_tests)

void CheckBudgetValue(int nHeight, std::string strNetwork, CAmount nExpectedValue)
{
    CBudgetManager budget;
    CAmount nBudget = budget.GetTotalBudget(nHeight);
    std::string strError = strprintf("Budget is not as expected for %s. Result: %s, Expected: %s", strNetwork, FormatMoney(nBudget), FormatMoney(nExpectedValue));
    BOOST_CHECK_MESSAGE(nBudget == nExpectedValue, strError);
}

BOOST_AUTO_TEST_CASE(budget_value)
{
    SelectParams(CBaseChainParams::MAIN);
    int nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
    CheckBudgetValue(nHeightTest, "mainnet", 43200*COIN);

    SelectParams(CBaseChainParams::TESTNET);
    nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
    CheckBudgetValue(nHeightTest, "testnet", 7300*COIN);
}

BOOST_AUTO_TEST_SUITE_END()

// Copyright (c) 2018 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "masternode-budget.h"
#include "tinyformat.h"
#include "utilmoneystr.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(budget_tests)

void CheckBudgetValue(int nHeight, std::string strNetwork, CAmount nExpectedValue)
{
    CBudgetManager budget;
    CAmount nBudget = budget.GetTotalBudget(nHeight);
    std::string strError = strprintf("Budget is not as expected for %s. Result: %s, Expected: %s", strNetwork, FormatMoney(nBudget), FormatMoney(nExpectedValue));
    BOOST_CHECK_MESSAGE(nBudget == nExpectedValue, strError);
}

BOOST_AUTO_TEST_CASE(budget_value)
{
    SelectParams(CBaseChainParams::TESTNET);
    int nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
    CheckBudgetValue(nHeightTest, "testnet", 7300*COIN);

    SelectParams(CBaseChainParams::MAIN);
    nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
    CheckBudgetValue(nHeightTest, "mainnet", 43200*COIN);
}

BOOST_AUTO_TEST_SUITE_END()

Fix chain ordering in budget tests

[Tests] Fix chain ordering in budget tests

check testnet params first, then check mainnet so as to not interfere
with subsequent unit tests that rely on mainnet params.

Also clean up include ordering.


//
// Created by Chris Richards on 27/04/2016.
//

#include <iomanip>
#include <sstream>
#include "DbfColumn.h"
#include "DbfUtils.h"

const int kDbfFieldDescriptorSize = 32;

DbfColumn::DbfColumn(std::istream &stream, int index)
        : index_(index) {
    read(stream);
}

void DbfColumn::read(std::istream &stream) {
    name_.clear();
    name_.resize(10);

    stream.read(&name_[0], 11);

    std::vector<char>::iterator it = std::find(name_.begin(), name_.end(), '\0');
    if (it != name_.end()) {
        name_.erase(it, name_.end());
    }

    type_ = (DbfColumnType)read_raw<uint8_t>(stream);
    uint32_t address = read_raw<uint32_t>(stream);
    length_ = read_raw<uint8_t>(stream);
    decimal_ = read_raw<uint8_t>(stream);

    // skip the next 14 bytes
    stream.seekg(14, std::ios_base::cur);
}

int DbfColumn::index() const {
    return index_;
}

std::string DbfColumn::name() const {
    return name_;
}

DbfColumn::DbfColumnType DbfColumn::type() const {
    return type_;
}

int DbfColumn::length() const {
    return length_;
}

int DbfColumn::decimal() const {
    return decimal_;
}

//
// Created by Chris Richards on 27/04/2016.
//

#include <iomanip>
#include <sstream>
#include "DbfColumn.h"
#include "DbfUtils.h"

const int kDbfFieldDescriptorSize = 32;

DbfColumn::DbfColumn(std::istream &stream, int index)
        : index_(index) {
    read(stream);
}

void DbfColumn::read(std::istream &stream) {
    name_.clear();
    name_.resize(10);

    stream.read(&name_[0], 11);

    size_t pos = name_.find('\0');
    if (pos != std::string::npos) {
        name_.erase(pos);
    }

    type_ = (DbfColumnType)read_raw<uint8_t>(stream);
    uint32_t address = read_raw<uint32_t>(stream);
    length_ = read_raw<uint8_t>(stream);
    decimal_ = read_raw<uint8_t>(stream);

    // skip the next 14 bytes
    stream.seekg(14, std::ios_base::cur);
}

int DbfColumn::index() const {
    return index_;
}

std::string DbfColumn::name() const {
    return name_;
}

DbfColumn::DbfColumnType DbfColumn::type() const {
    return type_;
}

int DbfColumn::length() const {
    return length_;
}

int DbfColumn::decimal() const {
    return decimal_;
}

Fix to removing nulls from column names

Fix to removing nulls from column names


#include "myapplication.h"
#include "eventdispatcher_libevent.h"
#include "msghandler.h"

int main(int argc, char** argv)
{
#if QT_VERSION < 0x050000
	qInstallMsgHandler(messageHandler);
#else
	qInstallMessageHandler(messageHandler);
#endif

#if QT_VERSION >= 0x050000
	QCoreApplication::setEventDispatcher(new EventDispatcherLibEvent());
#else
	EventDispatcherLibEvent e;
#endif

	QCoreApplication::setApplicationName(QLatin1String("Proxy"));
	QCoreApplication::setOrganizationName(QLatin1String("Goldbar Enterprises"));
	QCoreApplication::setOrganizationDomain(QLatin1String("goldbar.net"));
#if QT_VERSION >= 0x040400
	QCoreApplication::setApplicationVersion(QLatin1String("0.0.1"));
#endif

	MyApplication app(argc, argv);
	return app.exec();
}

#include "myapplication.h"
#include "eventdispatcher_libevent.h"
#include "msghandler.h"
#include "qt4compat.h"

int main(int argc, char** argv)
{
#if QT_VERSION < 0x050000
	qInstallMsgHandler(messageHandler);
#else
	qInstallMessageHandler(messageHandler);
#endif

#if QT_VERSION >= 0x050000
	QCoreApplication::setEventDispatcher(new EventDispatcherLibEvent());
#else
	EventDispatcherLibEvent e;
#endif

	QCoreApplication::setApplicationName(QLatin1String("Proxy"));
	QCoreApplication::setOrganizationName(QLatin1String("Goldbar Enterprises"));
	QCoreApplication::setOrganizationDomain(QLatin1String("goldbar.net"));
#if QT_VERSION >= 0x040400
#if defined(REPWATCHPROXY_VERSION)
#define RPV QT_STRINGIFY(REPWATCHPROXY_VERSION)
	QCoreApplication::setApplicationVersion(QLatin1String(RPV));
#undef RPV
#else
	QCoreApplication::setApplicationVersion(QLatin1String("0.0.1"));
#endif
#endif

	MyApplication app(argc, argv);
	return app.exec();
}

Use version number from qmake if possible


#include <QtQuick>

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

#include "factor.h"

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

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

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

    view->setTitle("Sailfactor");

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

    view->show();

    return app->exec();
}

#include <QtQuick>

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

#include "factor.h"

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

    loadTranslations();

    Factorizer fact;

#ifdef QT_QML_DEBUG
    runUnitTests();
#endif

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

    view->setTitle("Sailfactor");

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

    view->show();

    return app->exec();
}

Load the appropriate translation at startup, based on current locale.


// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
struct S {
  virtual void final() final;
  virtual void override() override;
  virtual void n() new;
};

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
struct S {
  virtual void final() final;
  virtual void override() override;
  virtual void n() new;
  int i : 3 new;
  int j new;
};

struct T {
  // virt-specifier-seq is only valid in member-declarators, and a function definition is not a member-declarator.
  virtual void f() const override { } // expected-error {{expected ';' at end of declaration list}}
};

Add more parser tests for the override control keywords.

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


// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <util/validation.h>

#include <consensus/validation.h>
#include <tinyformat.h>

/** Convert ValidationState to a human-readable message for logging */
std::string FormatStateMessage(const ValidationState &state)
{
    return strprintf("%s%s",
        state.GetRejectReason(),
        state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage());
}

const std::string strMessageMagic = "Bitcoin Signed Message:\n";

// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <util/validation.h>

#include <consensus/validation.h>
#include <tinyformat.h>

/** Convert ValidationState to a human-readable message for logging */
std::string FormatStateMessage(const ValidationState &state)
{
    if (state.IsValid()) {
        return "Valid";
    }

    return strprintf("%s%s",
        state.GetRejectReason(),
        state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage());
}

const std::string strMessageMagic = "Bitcoin Signed Message:\n";

Format CValidationState properly in all cases

FormatStateMessage does not properly handle the case where
CValidationState::IsValid() returns true. Use "Valid" for the state in
this case.


//#include "InstructionParser.h"

#include <string>
#include <stdexcept>

#include "gtest/gtest.h"

class InstructionParser
{
public:
  class UnknownInstruction : public std::runtime_error
  {
  public:
    UnknownInstruction(const std::string& msg) : std::runtime_error{msg}
    {}
  };

  void parseInstructions(const std::string& instruction)
  {
    const std::vector<std::string> acceptableInstructions{"ld a,", "out (0),a"};
    if (std::find(acceptableInstructions.begin(), acceptableInstructions.end(), instruction) == acceptableInstructions.end())
    {
      throw UnknownInstruction{"Unknown instruction" + instruction};
    }
  }

};

TEST(InstructionParser, ParserShouldDeclineUnknownInstruction)
{
  InstructionParser parser;
  EXPECT_THROW(parser.parseInstructions("Instructions"), InstructionParser::UnknownInstruction);
}

TEST(InstructionParser, ParserShouldAcceptInstuctionLd)
{
  InstructionParser parser;
  EXPECT_NO_THROW(parser.parseInstructions("ld a,"));
}

TEST(InstructionParser, ParserShouldAcceptInstructionOut)
{
  InstructionParser parser;
  EXPECT_NO_THROW(parser.parseInstructions("out (0),a"));
}

//#include "InstructionParser.h"

#include <string>
#include <stdexcept>

#include "gtest/gtest.h"

class InstructionParser
{
public:
  class UnknownInstruction : public std::runtime_error
  {
  public:
    UnknownInstruction(const std::string& msg) : std::runtime_error{msg}
    {}
  };

  void parseInstructions(const std::string& instruction)
  {
    const std::vector<std::string> acceptableInstructions{"ld a,", "out (0),a"};
    if (std::find(acceptableInstructions.begin(), acceptableInstructions.end(), instruction) == acceptableInstructions.end())
    {
      throw UnknownInstruction{"Unknown instruction" + instruction};
    }
  }

};

using namespace ::testing;

struct InstructionParserTest : public Test
{
  InstructionParser parser;
};

TEST(InstructionParserTest, ParserShouldDeclineUnknownInstruction)
{
  EXPECT_THROW(parser.parseInstructions("Instructions"), InstructionParser::UnknownInstruction);
}

TEST(InstructionParserTest, ParserShouldAcceptInstuctionLd)
{
  EXPECT_NO_THROW(parser.parseInstructions("ld a,"));
}

TEST(InstructionParserTest, ParserShouldAcceptInstructionOut)
{
  EXPECT_NO_THROW(parser.parseInstructions("out (0),a"));
}

Use container to store acceptable instructions


#include "mainwindow.h"
#include <QApplication>
#include <QDialog>
#include <QGridLayout>
#include <QLayout>
#include <QDebug>

#include "application.h"

int main(int argc, char *argv[])
{
	QCoreApplication::setOrganizationName("JASP");
	QCoreApplication::setOrganizationDomain("jasp-stats.org");
	QCoreApplication::setApplicationName("JASP");

	Application a(argc, argv);
	MainWindow w;

	w.show();

	QStringList args = QApplication::arguments();

	if (args.length() > 1)
		w.open(args.at(1));

    return a.exec();
}

#include "mainwindow.h"
#include <QApplication>
#include <QDialog>
#include <QGridLayout>
#include <QLayout>
#include <QDebug>

#include "application.h"

int main(int argc, char *argv[])
{
	QCoreApplication::setOrganizationName("JASP");
	QCoreApplication::setOrganizationDomain("jasp-stats.org");
	QCoreApplication::setApplicationName("JASP");

	QLocale::setDefault(QLocale(QLocale::English)); // make decimal points == .

	Application a(argc, argv);
	MainWindow w;

	w.show();

	QStringList args = QApplication::arguments();

	if (args.length() > 1)
		w.open(args.at(1));

    return a.exec();
}

Fix to decimal point rejection in float fields

fixes #549


#include "bundle.h"
#include "exec.h"

int main(int argc, char *argv[])
{
    bool enable_assert = true;
    unsigned short debug_port = 0;

    run_from_bundle(argv[0], enable_assert, debug_port, argc, argv);

    return 0;
}

#include "bundle.h"
#include "exec.h"

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

int main(int argc, char *argv[])
{
    bool enable_assert = true;
    unsigned short debug_port = 0;

    const char *exe = argv[0];
    #ifdef _WIN32
        char buf[MAX_PATH];
        GetModuleFileName(NULL, buf, sizeof(buf));
        exe = buf;
    #endif
    run_from_bundle(exe, enable_assert, debug_port, argc, argv);

    return 0;
}

Use GetModuleFileName on win32 to get exe name


#include <iostream>
#include <yaml-cpp/yaml.h>

int main()
{
   YAML::Emitter out;
   out << "Hello, World!";

   std::cout << "Here's the output YAML:\n" << out.c_str();

   return 0;
}

#include <cassert>
#include <yaml-cpp/yaml.h>

int main()
{
    YAML::Node node = YAML::Load("[1, 2, 3]");

    assert(node.IsSequence());

    return 0;
}

Change the test application to one that works.


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

#include <iostream>

#include "AssemblyFileWriter.hpp"
#include "Functions.hpp"
#include "Utils.hpp"

using namespace eddic;

using std::endl;

void MainDeclaration::write(AssemblyFileWriter& writer){
    writer.stream() << ".text" << endl
                    << ".globl main" << endl
                    << "\t.type main, @function" << endl;
}

void FunctionCall::checkFunctions(Program& program){
    if(!program.exists(m_function)){
        throw CompilerException("The function \"" + m_function + "()\" does not exists at line " + toString<int>(token()->line()) + ":" + toString<int>(token()->col()));
    }
}

void Function::write(AssemblyFileWriter& writer){
    writer.stream() << endl << m_name << ":" << endl;

    writer.stream() << "pushl %ebp" << std::endl;
    writer.stream() << "movl %esp, %ebp" << std::endl;

    ParseNode::write(writer);

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

void FunctionCall::write(AssemblyFileWriter& writer){
    writer.stream() << "call " << m_function << endl;
}

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

#include <iostream>

#include "AssemblyFileWriter.hpp"
#include "Functions.hpp"
#include "Utils.hpp"

using namespace eddic;

using std::endl;

void MainDeclaration::write(AssemblyFileWriter& writer){
    writer.stream() << ".text" << endl
                    << ".globl main" << endl
                    << "\t.type main, @function" << endl;
}

void FunctionCall::checkFunctions(Program& program){
    if(!program.exists(m_function)){
        throw CompilerException("The function \"" + m_function + "()\" does not exists", token());
    }
}

void Function::write(AssemblyFileWriter& writer){
    writer.stream() << endl << m_name << ":" << endl;

    writer.stream() << "pushl %ebp" << std::endl;
    writer.stream() << "movl %esp, %ebp" << std::endl;

    ParseNode::write(writer);

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

void FunctionCall::write(AssemblyFileWriter& writer){
    writer.stream() << "call " << m_function << endl;
}

Use the next exception for functions error reporting


#include <stdio.h>

#include "../excercise04/make_random_data/make_random_data.hpp"
#include "../excercise04/sort/quick.hpp"

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

    {
    }

    return 0;
}

#include <stdio.h>

#include "../excercise04/make_random_data/make_random_data.hpp"
#include "../excercise04/sort/quick.hpp"

int get_index_smallest(const int k, int *data, const int start, const int end)
{
    if(k < 0 || k > end) return -1; /* Base case */
    int p = partition(data, start, end);

    if(k == 0) return data[start];
    else if(p - start == k) return data[p];
    else if(p - start > k) return get_index_smallest(k, data, start, p - 1);
    else return get_index_smallest(k - p - 1, data, p + 1, end);
}

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

    const int size = 100000;
    int *data = make_random_data(size);
    printf("%d\n", get_index_smallest(k, data, 0, size - 1));

    free_random_data(data);
    return 0;
}

Add body of solution of prob 3

Add body of solution of prob 3


#include "ext_mongo.h"

namespace HPHP {

// PHP Exceptions and Classes
HPHP::Class* MongoException::cls = nullptr;
HPHP::Class* MongoConnectionException::cls = nullptr;
HPHP::Class* MongoCursorTimeoutException::cls = nullptr;
HPHP::Class* MongoDuplicateKeyException::cls = nullptr;
HPHP::Class* MongoExecutionTimeoutException::cls = nullptr;
HPHP::Class* MongoGridFSException::cls = nullptr;
HPHP::Class* MongoProtocolException::cls = nullptr;
HPHP::Class* MongoResultException::cls = nullptr;
HPHP::Class* MongoWriteConcernException::cls = nullptr;

mongoExtension s_mongo_extension;
HHVM_GET_MODULE(mongo);

} // namespace HPHP

#include "ext_mongo.h"

namespace HPHP {

// PHP Exceptions and Classes
HPHP::Class* MongoException::cls = nullptr;
HPHP::Class* MongoConnectionException::cls = nullptr;
HPHP::Class* MongoCursorException::cls = nullptr;
HPHP::Class* MongoCursorTimeoutException::cls = nullptr;
HPHP::Class* MongoDuplicateKeyException::cls = nullptr;
HPHP::Class* MongoExecutionTimeoutException::cls = nullptr;
HPHP::Class* MongoGridFSException::cls = nullptr;
HPHP::Class* MongoProtocolException::cls = nullptr;
HPHP::Class* MongoResultException::cls = nullptr;
HPHP::Class* MongoWriteConcernException::cls = nullptr;

mongoExtension s_mongo_extension;
HHVM_GET_MODULE(mongo);

} // namespace HPHP

Define class pointer for MongoCursorException


#include <stdio.h>

int main(void)
{
    return 0;
}

#include <stdio.h>

#define MAX_LOOP    10000

double formula(const double x, const double k)
{
    return (x * x) / ((2 * k - 1) * (2 * k));
}

int main(void)
{
    double x;
    printf("Enter x= ");
    scanf("%lf", &x);

    double cosx = 1,
           sinx = x;

    int k = 2;
    while(k < MAX_LOOP)
    {
        cosx = cosx - cosx * formula(x, k++);
        sinx = sinx - sinx * formula(x, k++);
        cosx = cosx + cosx * formula(x, k++);
        sinx = sinx + sinx * formula(x, k++);
    }

    printf("Result is: cosx=%f sinx=%f\n", cosx, sinx);

    return 0;
}

Add a body of prob 6

Add a body of prob 6


#include <type/class.hh>

namespace type
{
    Class::Class(const std::string& name)
        : name_(name)
    {}

    Class::~Class()
    {}

    const std::string& Class::name_get() const
    {
        return name_;
    }

    ast::Ast* Class::component_get(const std::string& name)
    {
        return content_[name];
    }

    bool Class::component_add(const std::string& name, ast::Ast* dec)
    {
        // Component already exists
        if (!content_[name])
            return false;

        content_[name] = dec;

        return true;
    }

    std::ostream& Class::dump(std::ostream& o) const
    {
        o << "Class (" << name_ << ")";

        return o;
    }

    std::string Class::cpp_type() const
    {
        return name_ + "*";
    }
} // namespace type

#include <type/class.hh>

namespace type
{
    Class::Class(const std::string& name)
        : name_(name)
    {}

    Class::~Class()
    {}

    const std::string& Class::name_get() const
    {
        return name_;
    }

    ast::Ast* Class::component_get(const std::string& name)
    {
        return content_[name];
    }

    bool Class::component_add(const std::string& name, ast::Ast* dec)
    {
        // Component already exists
        if (content_[name])
            return false;

        content_[name] = dec;

        return true;
    }

    std::ostream& Class::dump(std::ostream& o) const
    {
        o << "Class (" << name_ << ")";

        return o;
    }

    std::string Class::cpp_type() const
    {
        return name_ + "*";
    }
} // namespace type

[TYPE] Fix bug with component_add() on Class type


#include "parserPrivate.h"

complexType getNumber(std::string string, bool negative, bool &a)
{
	complexType complex;
	char haveI = 0;

	size_t size = string.size();
	double value;

	if(string.at(0) == 'i')
	{
		haveI++;
		string.erase(0, 1);
		size--;
	}

	if(string.at(size-1) == 'i')
	{
		haveI++;
		string.erase(size-1, 1);
		size--;
	}

	if(string.at(0) == '[')
	{
		value = 0;
	}
	else
		value = atof(string.c_str());

	if(haveI == 1)
		complex.isComplex = true;
	else
	{
		complex.isComplex = false;
		if(haveI == 2)
			value *= -1;
	}

	if(negative)
		value *= -1;

	complex.coefficient = value;
	return complex;
}

#include "parserPrivate.h"

complexType getNumber(std::string string, bool negative, bool &a)
{
	complexType complex;
	size_t size = string.size();
	double value;
	char haveI = 0;
	bool isComplex;

	if(string.at(0) == 'i')
	{
		haveI++;
		string.erase(0, 1);
		size--;
	}

	if(string.at(size-1) == 'i')
	{
		haveI++;
		string.erase(size-1, 1);
		size--;
	}

	if(string.at(0) == '[')
	{
		value = 0;
	}
	else
		value = atof(string.c_str());

	if(negative)
		value *= -1;

	if(haveI == 1)
		isComplex = true;
	else
	{
		isComplex = false;
		if(haveI == 2)
			value *= -1;
	}

	if(isComplex)
		complex.coefComplex = value;
	else
		complex.coefReal = value;

	return complex;
}

bool isOperator

Use more powerfull complex type

Use more powerfull complex type


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

TEST(sizeof, test1) {
    char str1[10];
    char str2[] = "Hello World!";

    EXPECT_EQ(10, sizeof(str1));
    EXPECT_EQ(13, sizeof(str2));
}

TEST(memcpy, test1) {
    int a[] = {1, 2, 3};
    int b[3];

    memcpy(b, a, sizeof(int) * 3);

    EXPECT_EQ(1, b[0]);
    EXPECT_EQ(2, b[1]);
    EXPECT_EQ(3, b[2]);
}

TEST(swap, test1) {
    int a = 1;
    int b = 2;

    std::swap(a, b);

    EXPECT_EQ(2, a);
    EXPECT_EQ(1, b);
}

TEST(array, test1) {
    int foo[2] = {1};

    EXPECT_EQ(1, foo[0]);
    EXPECT_EQ(0, foo[1]);
}

Add a test of array initialization

Add a test of array initialization


//
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);

  int *A = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }

  int sum = 0;
  int i = 0;
L0:
  if (A[i] % 2 == 0) {
  left0:
    sum += A[i];
  } else {
  right0:
    sum -= A[i];
  }
  printf("%d", sum);
  if (A[i] % 2 == 0) {
    sum += A[i];
    if (++i < n) {
      goto left0;
    }
  } else {
    sum -= A[i];
    if (++i < n) {
      goto right0;
    }
  }

  printf("%d\n", sum);
  delete[] A;
}

// Let's call this CFG the 'butterfly'.
// It looks like this:
//
//     A
// ,. / \,-,
// | B1 B2 |
// |  \ /  |
// |   C   |
// |  / \  |
// | D1 D2 |
// `-`\ /`-`
//     E
//
// Where the edges between B1-D1 and B2-D2 are actually 'back-edges' which is to
// say the direction is from D1 to B1 and from D2 to B2 (illustrated by edges
// always leaving from the bottom of a node and entering through the top).
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);

  int *A = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }

  int sum = 0;
  int i = 0;
A:
  if (A[i] % 2 == 0) {
  B1:
    sum += A[i];
  } else {
  B2:
    sum -= A[i];
  }
C:
  if (A[i] % 2 == 0) {
  D1:
    sum += A[i];
    if (++i < n) {
      goto B1;
    }
  } else {
  D2:
    sum -= A[i];
    if (++i < n) {
      goto B2;
    }
  }
E:

  printf("%d\n", sum);
  delete[] A;
}

Add descriptory comment to specimen4 example


#include <map>

int main()
{
  typedef std::map<int, int> ContainerType;
  typedef std::pair<bool, ContainerType::iterator> EmplaceReturnType;

  ContainerType m;

  // pair move constructor
  EmplaceReturnType aResult = m.emplace(std::make_pair(int(1), int(2)));
  bool aValid = (aResult.first) && ((*(aResult.second)).second == 2);

  // pair converting move constructor
  EmplaceReturnType bResult = m.emplace(std::make_pair(2, 4));
  bool bValid = (bResult.first) && ((*(bResult.second)).second == 4);

  // pair template constructor
  EmplaceReturnType cResult = m.emplace(3, 6);
  bool cValid = (cResult.first) && ((*(cResult.second)).second == 6);

  return (aValid && bValid && cValid) ? 0 : 1;
}

#include <map>

#include <iostream>
int main()
{
  typedef std::map<int, int> ContainerType;
  typedef std::pair<ContainerType::iterator, bool> EmplaceReturnType;

  ContainerType m;

  // pair move constructor
  EmplaceReturnType aResult = m.emplace(std::make_pair(int(1), int(2)));
  bool aValid = (aResult.second) && ((*(aResult.first)).second == 2);

  // pair converting move constructor
  EmplaceReturnType bResult = m.emplace(std::make_pair(2, 4));
  bool bValid = (bResult.second) && ((*(bResult.first)).second == 4);

  // pair template constructor
  EmplaceReturnType cResult = m.emplace(3, 6);
  bool cValid = (cResult.second) && ((*(cResult.first)).second == 6);

  return (aValid && bValid && cValid) ? 0 : 1;
}

Use correct pair type order in map::emplace test

Tests on Mac identified that the incorrect type order is used
in the pair type for testing returns from maps's emplace member
function.

Use correct ordering as defined in the Standard, and update tests
of returned pair to check correct entries.


// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "chrome/common/chrome_constants.h"

namespace browser_sync {

static const double kErrorUploadRatio = 0.0;
void ChromeReportUnrecoverableError() {
  // TODO(lipalani): Add this for other platforms as well.
#if defined(OS_WIN)
  // We only want to upload |kErrorUploadRatio| ratio of errors.
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  // Get the breakpad pointer from chrome.exe
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
      ::GetProcAddress(::GetModuleHandle(
                       chrome::kBrowserProcessExecutableName),
                       "DumpProcessWithoutCrash"));
  if (DumpProcess)
    DumpProcess();
#endif  // OS_WIN

}

}  // namespace browser_sync

// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "chrome/common/chrome_constants.h"

namespace browser_sync {

static const double kErrorUploadRatio = 0.15;
void ChromeReportUnrecoverableError() {
  // TODO(lipalani): Add this for other platforms as well.
#if defined(OS_WIN)
  // We only want to upload |kErrorUploadRatio| ratio of errors.
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  // Get the breakpad pointer from chrome.exe
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
      ::GetProcAddress(::GetModuleHandle(
                       chrome::kBrowserProcessExecutableName),
                       "DumpProcessWithoutCrash"));
  if (DumpProcess)
    DumpProcess();
#endif  // OS_WIN

}

}  // namespace browser_sync

Revert 163344 - [Sync] Disable unrecoverable error uploading.

Disabling for beta channel.

BUG=14723
TBR=tim@chromium.org

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

TBR=zea@chromium.org
Review URL: https://codereview.chromium.org/11234039

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


// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "chrome/common/chrome_constants.h"

namespace browser_sync {

static const double kErrorUploadRatio = 0.15;
void ChromeReportUnrecoverableError() {
  // TODO(lipalani): Add this for other platforms as well.
#if defined(OS_WIN)
  // We only want to upload |kErrorUploadRatio| ratio of errors.
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  // Get the breakpad pointer from chrome.exe
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
      ::GetProcAddress(::GetModuleHandle(
                       chrome::kBrowserProcessExecutableName),
                       "DumpProcessWithoutCrash"));
  if (DumpProcess)
    DumpProcess();
#endif  // OS_WIN

}

}  // namespace browser_sync

// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "chrome/common/chrome_constants.h"

namespace browser_sync {

static const double kErrorUploadRatio = 0.0;
void ChromeReportUnrecoverableError() {
  // TODO(lipalani): Add this for other platforms as well.
#if defined(OS_WIN)
  // We only want to upload |kErrorUploadRatio| ratio of errors.
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  // Get the breakpad pointer from chrome.exe
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
      ::GetProcAddress(::GetModuleHandle(
                       chrome::kBrowserProcessExecutableName),
                       "DumpProcessWithoutCrash"));
  if (DumpProcess)
    DumpProcess();
#endif  // OS_WIN

}

}  // namespace browser_sync

Set error upload rate to 0.

[Sync] Set error upload rate to 0.

This prevents sync from uploading error stacks to breakpad.

BUG=134607
TEST=

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

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


#ifndef _WIN32
#include <specs/specs.h>

go_bandit([]() {
  describe("colorizer: ", [&]() {
    describe("colors enabled", [&]() {
      bandit::detail::colorizer colorizer;

      it("can set color to green", [&]() {
        AssertThat(colorizer.green(), Equals("\033[1;32m"));
      });

      it("set color to red", [&]() {
        AssertThat(colorizer.red(), Equals("\033[1;31m"));
      });
      it("resets color", [&]() {
        AssertThat(colorizer.reset(), Equals("\033[0m"));
      });
    });

    describe("colors disabled", [&]() {
      bandit::detail::colorizer colorizer(false);

      it("ignores setting color to green", [&]() {
        AssertThat(colorizer.green(), Equals(""));
      });

      it("ignores setting color to red", [&]() {
        AssertThat(colorizer.red(), Equals(""));
      });

      it("ignores resetting colors", [&]() {
        AssertThat(colorizer.reset(), Equals(""));
      });
    });
  });
});
#endif

#include <specs/specs.h>

go_bandit([]() {
  describe("colorizer: ", [&]() {
#if !defined(_WIN32) || defined(BANDIT_CONFIG_COLOR_ANSI)
    describe("colors enabled", [&]() {
      bandit::detail::colorizer colorizer;

      it("can set color to green", [&]() {
        AssertThat(colorizer.green(), Equals("\033[1;32m"));
      });

      it("set color to red", [&]() {
        AssertThat(colorizer.red(), Equals("\033[1;31m"));
      });
      it("resets color", [&]() {
        AssertThat(colorizer.reset(), Equals("\033[0m"));
      });
    });
#endif

    describe("colors disabled", [&]() {
      bandit::detail::colorizer colorizer(false);

      it("ignores setting color to green", [&]() {
        AssertThat(colorizer.green(), Equals(""));
      });

      it("ignores setting color to red", [&]() {
        AssertThat(colorizer.red(), Equals(""));
      });

      it("ignores resetting colors", [&]() {
        AssertThat(colorizer.reset(), Equals(""));
      });
    });
  });
});

Test disabled colorizer on Windows

Test disabled colorizer on Windows

Also test enabled colorizer when BANDIT_CONFIG_COLOR_ANSI is set.


#include <common/buffer.h>

#include <event/action.h>
#include <event/callback.h>
#include <event/event_system.h>

#include <io/pipe.h>

#include <xcodec/xcodec.h>
#include <xcodec/xcodec_encoder.h>
#include <xcodec/xcodec_encoder_pipe.h>

XCodecEncoderPipe::XCodecEncoderPipe(XCodec *codec)
: PipeSimple("/xcodec/encoder/pipe"),
  encoder_(codec)
{
	encoder_.set_pipe(this);
}

XCodecEncoderPipe::~XCodecEncoderPipe()
{
	encoder_.set_pipe(NULL);
}

void
XCodecEncoderPipe::output_ready(void)
{
	PipeSimple::output_spontaneous();
}

bool
XCodecEncoderPipe::process(Buffer *out, Buffer *in)
{
	encoder_.encode(out, in);
	return (true);
}

#include <common/buffer.h>

#include <event/action.h>
#include <event/callback.h>
#include <event/event_system.h>

#include <io/pipe.h>

#include <xcodec/xcodec.h>
#include <xcodec/xcodec_encoder.h>
#include <xcodec/xcodec_encoder_pipe.h>

XCodecEncoderPipe::XCodecEncoderPipe(XCodec *codec)
: PipeSimple("/xcodec/encoder/pipe"),
  encoder_(codec)
{
	encoder_.set_pipe(this);
}

XCodecEncoderPipe::~XCodecEncoderPipe()
{
	encoder_.set_pipe(NULL);
}

void
XCodecEncoderPipe::output_ready(void)
{
}

bool
XCodecEncoderPipe::process(Buffer *out, Buffer *in)
{
	encoder_.encode(out, in);
	return (true);
}

Remove output_spontaneous use for now.

Remove output_spontaneous use for now.


#include <chrono>
#include <iostream>
#include <thread>

#include "AHRS.h"
#include "WPILib.h"

/*
 * This program is used to measure the frequency of NavX errors.
 *
 * It prints a stream of millisecond timestamps corresponding to the last good
 * sensor read. Any errors noted by the NavX library are printed to standard
 * output and are interleaved with the timestamps.
 *
 * Excessive SPI errors have been noted while running this when
 * /etc/init.d/nilvrt is running so run `/etc/init.d/nilvrt stop` first.
 *
 * TIMESTAMP_PERIOD_MS = how often a timestamp is printed to standard output
 * LOOP_SLEEP_MS = run loop wait period
 */

static constexpr double TIMESTAMP_PERIOD_MS = 10 / 1000;
static constexpr auto LOOP_SLEEP_MS = std::chrono::milliseconds(1);

class Robot : public SampleRobot {
 public:
  void OperatorControl() {
    AHRS gyro{SPI::Port::kMXP};
    frc::Timer timer;
    timer.Start();
    while (IsEnabled()) {
      if (timer.HasPeriodPassed(TIMESTAMP_PERIOD_MS)) {
        std::cout << gyro.GetLastSensorTimestamp() << std::endl;
      }
      std::this_thread::sleep_for(LOOP_SLEEP_MS);
    }
  }

  void RobotInit() {}

  void Disabled() {
    while (IsDisabled()) {
      std::this_thread::sleep_for(LOOP_SLEEP_MS);
    }
  }
};

START_ROBOT_CLASS(Robot)

#include <chrono>
#include <iostream>
#include <thread>

#include "AHRS.h"
#include "WPILib.h"

/*
 * This program is used to measure the frequency of NavX errors.
 *
 * It prints a stream of millisecond timestamps corresponding to the last good
 * sensor read. Any errors noted by the NavX library are printed to standard
 * output and are interleaved with the timestamps.
 *
 * Excessive SPI errors have been noted while running this when
 * /etc/init.d/nilvrt is running so run `/etc/init.d/nilvrt stop` first.
 *
 * TIMESTAMP_PERIOD_MS = how often a timestamp is printed to standard output
 * LOOP_SLEEP_MS = run loop wait period
 */

static constexpr double TIMESTAMP_PERIOD_MS = 10 / 1000;
static constexpr auto LOOP_SLEEP_MS = std::chrono::milliseconds(1);

class Robot : public SampleRobot {
 public:
  AHRS gyro{SPI::Port::kMXP};

  void OperatorControl() {
    frc::Timer timer;
    timer.Start();
    while (IsEnabled()) {
      if (timer.HasPeriodPassed(TIMESTAMP_PERIOD_MS)) {
        std::cout << gyro.GetLastSensorTimestamp() << std::endl;
      }
      std::this_thread::sleep_for(LOOP_SLEEP_MS);
    }
  }

  void RobotInit() {}

  void Disabled() {
    while (IsDisabled()) {
      std::this_thread::sleep_for(LOOP_SLEEP_MS);
    }
  }
};

START_ROBOT_CLASS(Robot)

Move gyro to class scope.

Move gyro to class scope.


#include "views.h"

using namespace std;

namespace rviews {

void login(JsonValue * message, ServerHandler * handler) {
    JsonDict * dictMessage = JDICT(message);

    if (dictMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON dict");
    }

    bool success = getBool(dictMessage, "success");
    if(success){
        emit handler->getWindow()->loginSuccess();
    }
    else {
        emit handler->getWindow()->loginFailure(getInt(dictMessage, "code"));
    }
}

void signup(JsonValue * message, ServerHandler * handler) {
    JsonDict * dictMessage = JDICT(message);

    if (dictMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON dict");
    }

    bool success = getBool(dictMessage, "success");
    if(success){
        emit handler->getWindow()->registerSuccess();
    }
    else {
        emit handler->getWindow()->registerFailure(getInt(dictMessage, "code"));
    }
}

void userlist(JsonValue * message, ServerHandler * handler) {
    JsonDict * listMessage = JLIST(message);

    if (listMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON list");
    }

    JsonList * jlist = getList(dictMessage, "userlist");
    vector<string> ulist;
    for(int i = 0; i < jlist->size(); i++){
        ulist.push_back(getString(jlist, i));
    }
    emit handler->getWindow()->refreshRegisterList(ulist);
}

#include "views.h"

using namespace std;

namespace rviews {

void login(JsonValue * message, ServerHandler * handler) {
    JsonDict * dictMessage = JDICT(message);

    if (dictMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON dict");
    }

    bool success = getBool(dictMessage, "success");
    if(success){
        emit handler->getWindow()->loginSuccess();
    }
    else {
        emit handler->getWindow()->loginFailure(getInt(dictMessage, "code"));
    }
}

void signup(JsonValue * message, ServerHandler * handler) {
    JsonDict * dictMessage = JDICT(message);

    if (dictMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON dict");
    }

    bool success = getBool(dictMessage, "success");
    if(success){
        emit handler->getWindow()->registerSuccess();
    }
    else {
        emit handler->getWindow()->registerFailure(getInt(dictMessage, "code"));
    }
}

void userlist(JsonValue * message, ServerHandler * handler) {
    JsonDict * dictMessage = JDICT(message);

    if (dictMessage == NULL) {
        throw BadRequest("Malformatted request. Need a JSON list");
    }

    JsonList * jlist = getList(dictMessage, "userlist");
    vector<string> ulist;
    for(int i = 0; i < jlist->size(); i++){
        ulist.push_back(getString(jlist, i));
    }
    emit handler->getWindow()->userList(ulist);
}
}

Use new signals (again) + fix list/dict

Use new signals (again) + fix list/dict


// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc19.0.0 -emit-obj \
// RUN:     -debug-info-kind=line-tables-only -fms-extensions
class __declspec(dllexport) A {
  A(int * = new int) {}
};
// CHECK: define {{.*}}void @"\01??_FA@@AAEXXZ"
// CHECK-SAME: !dbg ![[SP:[0-9]+]]
// CHECK-NOT: {{ret }}
// CHECK: call x86_thiscallcc %class.A* @"\01??0A@@AAE@PAH@Z"(%class.A* %this1, i32* %0)
// CHECK-SAME: !dbg ![[DBG:[0-9]+]]
// CHECK: ret void, !dbg ![[DBG]]
//
// CHECK: ![[SP]] = distinct !DISubprogram(
// CHECK-SAME:          line: 3
// CHECK-SAME:          isDefinition: true
// CHECK-SAME:          DIFlagArtificial
// CHECK-SAME:          ){{$}}
//
// CHECK: ![[DBG]] = !DILocation(line: 0

// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc19.0.0 -emit-llvm \
// RUN:     -debug-info-kind=line-tables-only -fms-extensions -o - | FileCheck %s
class __declspec(dllexport) A {
  A(int * = new int) {}
};
// CHECK: define {{.*}}void @"\01??_FA@@AAEXXZ"
// CHECK-SAME: !dbg ![[SP:[0-9]+]]
// CHECK-NOT: {{ret }}
// CHECK: call x86_thiscallcc %class.A* @"\01??0A@@AAE@PAH@Z"(%class.A* %this1, i32* %0)
// CHECK-SAME: !dbg ![[DBG:[0-9]+]]
// CHECK: ret void, !dbg ![[DBG1:[0-9]+]]
//
// CHECK: ![[SP]] = distinct !DISubprogram(
// CHECK-SAME:          line: 4
// CHECK-SAME:          isDefinition: true
// CHECK-SAME:          DIFlagArtificial
// CHECK-SAME:          ){{$}}
//
// CHECK: ![[DBG1]] = !DILocation(line: 0
// CHECK: ![[DBG]] = !DILocation(line: 0

Add the missing FileCheck invocation to this testcase.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@287139 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 1e8e1a309993503e2f6ea4a71b10b6ca98daf681)


// RUN: rm -rf %t
// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=CHECK_1
// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=CHECK_2 -allow-empty

// For modules, the warning should only fire the first time, when the module is
// built.
// CHECK_1: warning: unused typedef
// CHECK_2-NOT: warning: unused typedef
@import warn_unused_local_typedef;

// RUN: rm -rf %t
// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_1
// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_2 -allow-empty

// For modules, the warning should only fire the first time, when the module is
// built.
// CHECK_1: warning: unused typedef
// CHECK_2-NOT: warning: unused typedef
@import warn_unused_local_typedef;

Fix test to not write output to the test directory, as it may not be writable.

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


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include <cstddef>

#ifndef offsetof
#error offsetof not defined
#endif

int main()
{
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include <cstddef>

#ifndef offsetof
#error offsetof not defined
#endif

struct A
{
    int x;
};

int main()
{
#if (__has_feature(cxx_noexcept))
    static_assert(noexcept(offsetof(A, x)), "");
#endif
}

Add noexcept test for offsetof macro per [support.types]/p4.

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@159846 91177308-0d34-0410-b5e6-96231b3b80d8


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

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

namespace extensions_v8 {

const char* kPlaybackExtensionName = "v8/PlaybackMode";

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

}  // namespace extensions_v8

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

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

namespace extensions_v8 {

const char* kPlaybackExtensionName = "v8/PlaybackMode";

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

}  // namespace extensions_v8

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

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

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


#include "ics3/parameter.hpp"

ics::Parameter ics::Parameter::stretch() noexcept {
  static const Parameter STRETCH(0x01, 1, 127);
  return STRETCH;
}

ics::Parameter ics::Parameter::speed() noexcept {
  static const Parameter SPEED(0x02, 1, 127);
  return SPEED;
}

ics::Parameter ics::Parameter::current() noexcept {
  static const Parameter CURRENT(0x03, 0, 63);
  return CURRENT;
}

ics::Parameter ics::Parameter::temperature() noexcept {
  static const Parameter TEMPERATURE(0x04, 1, 127);
  return TEMPERATURE;
}

unsigned char ics::Parameter::get() const noexcept {
  return data;
}

void ics::Parameter::set(unsigned char input) throw(std::invalid_argument) {
  if (input < min) throw std::invalid_argument("Too small value");
  if (max < input) throw std::invalid_argument("Too big value");
  data = input;
}

ics::parameter::Parameter(unsigned char sc, unsigned char min, unsigned char max)
: sc(sc),
  min(min),
  max(max)
{}

#include "ics3/parameter.hpp"

ics::Parameter ics::Parameter::stretch() noexcept {
  static const Parameter STRETCH(0x01, 1, 127);
  return STRETCH;
}

ics::Parameter ics::Parameter::speed() noexcept {
  static const Parameter SPEED(0x02, 1, 127);
  return SPEED;
}

ics::Parameter ics::Parameter::current() noexcept {
  static const Parameter CURRENT(0x03, 0, 63);
  return CURRENT;
}

ics::Parameter ics::Parameter::temperature() noexcept {
  static const Parameter TEMPERATURE(0x04, 1, 127);
  return TEMPERATURE;
}

unsigned char ics::Parameter::get() const noexcept {
  return data;
}

void ics::Parameter::set(unsigned char input) throw(std::invalid_argument) {
  if (input < min) throw std::invalid_argument("Too small value");
  if (max < input) throw std::invalid_argument("Too big value");
  data = input;
}

ics::Parameter::Parameter(unsigned char sc, unsigned char min, unsigned char max) noexcept
: sc(sc),
  min(min),
  max(max)
{}

Fix constructor with noexcept of Parameter class


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

#define MEM_SIZE (1<<20)
#define CACHE_SIZE (1<<8)
#define DATA_SIZE (1<<8)

using namespace std;

int main() {
	// Variables used
	int dir, cmd, op;
	unsigned char dat, wait;

	// Plant the seed
	srand(time(0));

	// Infinit Loop
	while(true){
		// Each command is 32 bits,
		// 19...0 bits for dir,
		// 27...20 bits for data
		// 28 bit indicates operation type 1:read 0:write
		cmd = rand();
		dir = cmd & 0xFFFFF;
		dat = (cmd & 0xF00000)>>20;
		op = (cmd>>28)&1;
		printf("op=%c on dir(0x%x) data:%d\n","wr"[op],dir,dat);
		wait = getchar();
	}
	return 0;
}

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <deque>

#define MEM_SIZE (1<<20)
#define CACHE_SIZE (1<<8)

using namespace std;

enum{
	read,
	write
};

int main() {
	// Variables used
	int dir, cmd, op;
	unsigned char dat, wait;

	// Memory simulated
	unsigned char rawMemory[MEM_SIZE];
	int cacheDirection[CACHE_SIZE];
	unsigned char cacheData[CACHE_SIZE];

	// To simulate the circular queue
	int front = 0, tail = 0;

	// Initialize the cached Directions
	memset(cacheDirection, -1, sizeof cacheDirection);

	// Plant the seed
	srand(time(0));

	// Infinit Loop
	while(true){
		// Each command is 32 bits,
		cmd = rand();
		// 19...0 bits for dir
		dir = ((cmd)&(0xFFFFF));
		// 27...20 bits for data
		dat = (((cmd)&(0xF00000))>>20);
		// 28 bit indicates operation type 0:read 1:write
		op  = ((cmd>>28)&(1));

		//Perform operation according
		if(op == read) {

		} else { // write

		}

		wait = getchar();
	}
	return 0;
}

Add memory declaration, and refactor comments

Signed-off-by: Ulises Mendez Martinez <64c66da2351c01d4afecd1591810410a1c01865c@gmail.com>


// RUN: cat %s > %t.cpp
// RUN: clang-rename -offset=170 -new-name=hector %t.cpp -i --
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
// REQUIRES: shell
namespace A {
int foo;  // CHECK: int hector;
}
int foo;  // CHECK: int foo;
int bar = foo; // CHECK: bar = foo;
int baz = A::foo; // CHECK: baz = A::hector;
void fun1() {
  struct {
    int foo; // CHECK: int foo;
  } b = { 100 };
  int foo = 100; // CHECK: int foo
  baz = foo; // CHECK: baz = foo;
  {
    extern int foo; // CHECK: int foo;
    baz = foo; // CHECK: baz = foo;
    foo = A::foo + baz; // CHECK: foo = A::hector + baz;
    A::foo = b.foo; // CHECK: A::hector = b.foo;
  }
  foo = b.foo; // CHECK: foo = b.foo;
}
// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing
// this file.

namespace A { int foo;  // CHECK: int hector;
}
// RUN: cat %s > %t.cpp
// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
int foo;  // CHECK: int foo;
int bar = foo; // CHECK: bar = foo;
int baz = A::foo; // CHECK: baz = A::hector;
void fun1() {
  struct {
    int foo; // CHECK: int foo;
  } b = { 100 };
  int foo = 100; // CHECK: int foo
  baz = foo; // CHECK: baz = foo;
  {
    extern int foo; // CHECK: int foo;
    baz = foo; // CHECK: baz = foo;
    foo = A::foo + baz; // CHECK: foo = A::hector + baz;
    A::foo = b.foo; // CHECK: A::hector = b.foo;
  }
  foo = b.foo; // CHECK: foo = b.foo;
}
// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing
// this file.

Make test EOL tolerant by moving the symbol ot the first line
before any EOL changes the byte offset count and enable it on Windows.

git-svn-id: a34e9779ed74578ad5922b3306b3d80a0c825546@245688 91177308-0d34-0410-b5e6-96231b3b80d8


//===-- SparcMCAsmInfo.cpp - Sparc 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 SparcMCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "SparcMCAsmInfo.h"
#include "llvm/ADT/Triple.h"

using namespace llvm;

void SparcELFMCAsmInfo::anchor() { }

SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) {
  IsLittleEndian = false;
  Triple TheTriple(TT);
  if (TheTriple.getArch() == Triple::sparcv9) {
    PointerSize = CalleeSaveStackSlotSize = 8;
  }

  Data16bitsDirective = "\t.half\t";
  Data32bitsDirective = "\t.word\t";
  Data64bitsDirective = 0;  // .xword is only supported by V9.
  ZeroDirective = "\t.skip\t";
  CommentString = "!";
  HasLEB128 = true;
  SupportsDebugInformation = true;

  SunStyleELFSectionSwitchSyntax = true;
  UsesELFSectionDirectiveForBSS = true;

  WeakRefDirective = "\t.weak\t";

  PrivateGlobalPrefix = ".L";
}

//===-- SparcMCAsmInfo.cpp - Sparc 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 SparcMCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "SparcMCAsmInfo.h"
#include "llvm/ADT/Triple.h"

using namespace llvm;

void SparcELFMCAsmInfo::anchor() { }

SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) {
  IsLittleEndian = false;
  Triple TheTriple(TT);
  bool isV9 = (TheTriple.getArch() == Triple::sparcv9);

  if (isV9) {
    PointerSize = CalleeSaveStackSlotSize = 8;
  }

  Data16bitsDirective = "\t.half\t";
  Data32bitsDirective = "\t.word\t";
  // .xword is only supported by V9.
  Data64bitsDirective = (isV9) ? "\t.xword\t" : 0;
  ZeroDirective = "\t.skip\t";
  CommentString = "!";
  HasLEB128 = true;
  SupportsDebugInformation = true;

  SunStyleELFSectionSwitchSyntax = true;
  UsesELFSectionDirectiveForBSS = true;

  WeakRefDirective = "\t.weak\t";

  PrivateGlobalPrefix = ".L";
}

Enable xword directive in sparcv9.

[Sparc] Enable xword directive in sparcv9.

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


#include <gtest/gtest.h>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "Integrator.h"
#include "StateVector.h"

TEST(StateTest, Instantiation) {
    using MyStateVector = UKF::StateVector<
        IntegratorRK4,
        UKF::Field<1, Eigen::Vector2f>,
        UKF::Field<2, Eigen::Vector3f>,
        UKF::Field<3, Eigen::Quaternionf>,
        UKF::Field<4, float>
    >;

    MyStateVector test_state;

    EXPECT_EQ(10, MyStateVector::MaxRowsAtCompileTime);
    EXPECT_EQ(10, test_state.size());
}

#include <gtest/gtest.h>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "Integrator.h"
#include "StateVector.h"

TEST(StateTest, Instantiation) {
	enum MyFields {
		LatLon,
		Altitude,
		Velocity,
		Attitude
	};

    using MyStateVector = UKF::StateVector<
        IntegratorRK4,
        UKF::Field<LatLon, Eigen::Vector2f>,
        UKF::Field<Altitude, Eigen::Vector3f>,
        UKF::Field<Velocity, Eigen::Quaternionf>,
        UKF::Field<Attitude, float>
    >;

    MyStateVector test_state;

    EXPECT_EQ(10, MyStateVector::MaxRowsAtCompileTime);
    EXPECT_EQ(10, test_state.size());
}

Use enums for keys in test

Use enums for keys in test


#include "DSTemperature.h"

DSTemperature::DSTemperature(byte pin) {
  _wire = new OneWire(pin);
  _addresses = (DSAddress*)malloc(sizeof(DSAddress));
}

void DSTemperature::begin(void) {

  DSAddress addr;

  while (_wire->search(addr.value)) {
    if (OneWire::crc8(addr.value, 7) == addr.value[7]) {
      resizeAddresses();
      _addresses[_nSensors++] = addr;
    }
  }

  _wire->reset_search();
  delay(250);
  return;

}

void DSTemperature::resizeAddresses() {

  if (_nSensors == 0)
    return;

  DSAddress* new_addresses = (DSAddress*)malloc(sizeof(DSAddress) * _nSensors);
  for (byte i = 0 ; i < _nSensors ; i++)
    new_addresses[i] = _addresses[i];
  free(_addresses);
  _addresses = new_addresses;

}

float DSTemperature::getCelsius(byte ds) {
  return CELSIUS(getRawTemperature(ds));
}

float DSTemperature::getFahrenheit(byte ds) {
  return FAHRENHEIT(getRawTemperature(ds));
}

#include "DSTemperature.h"

DSTemperature::DSTemperature(byte pin) {
  _wire = new OneWire(pin);
  _addresses = (DSAddress*)malloc(sizeof(DSAddress));
}

void DSTemperature::begin(void) {

  DSAddress addr;

  while (_wire->search(addr.value)) {
    if (OneWire::crc8(addr.value, 7) == addr.value[7]) {
      if (_nSensors != 0)
        resizeAddresses();
      _addresses[_nSensors++] = addr;
    }
  }

  _wire->reset_search();
  delay(250);
  return;

}

void DSTemperature::resizeAddresses() {

  DSAddress* new_addresses = (DSAddress*)malloc(sizeof(DSAddress) * _nSensors);
  for (byte i = 0 ; i < _nSensors ; i++)
    new_addresses[i] = _addresses[i];
  free(_addresses);
  _addresses = new_addresses;

}

float DSTemperature::getCelsius(byte ds) {
  return CELSIUS(getRawTemperature(ds));
}

float DSTemperature::getFahrenheit(byte ds) {
  return FAHRENHEIT(getRawTemperature(ds));
}

Call resizeAddresses only if you manage more than one sensor


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

#include "GrGLConfig.h"
#include "GrGLInterface.h"

void GrGLClearErr(const GrGLInterface* gl) {
    while (GR_GL_NO_ERROR != gl->fGetError()) {}
}

void GrGLCheckErr(const GrGLInterface* gl,
                  const char* location,
                  const char* call) {
    uint32_t err = GR_GL_GET_ERROR(gl);
    if (GR_GL_NO_ERROR != err) {
        GrPrintf("---- glGetError %x", GR_GL_GET_ERROR(gl));
        if (NULL != location) {
            GrPrintf(" at\n\t%s", location);
        }
        if (NULL != call) {
            GrPrintf("\n\t\t%s", call);
        }
        GrPrintf("\n");
    }
}

void GrGLResetRowLength(const GrGLInterface* gl) {
    if (gl->supportsDesktop()) {
        GR_GL_CALL(gl, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
    }
}

///////////////////////////////////////////////////////////////////////////////

#if GR_GL_LOG_CALLS
    bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START);
#endif

#if GR_GL_CHECK_ERROR
    bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START);
#endif

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

#include "GrGLConfig.h"
#include "GrGLInterface.h"

void GrGLClearErr(const GrGLInterface* gl) {
    while (GR_GL_NO_ERROR != gl->fGetError()) {}
}

void GrGLCheckErr(const GrGLInterface* gl,
                  const char* location,
                  const char* call) {
    uint32_t err = GR_GL_GET_ERROR(gl);
    if (GR_GL_NO_ERROR != err) {
        GrPrintf("---- glGetError %x", err);
        if (NULL != location) {
            GrPrintf(" at\n\t%s", location);
        }
        if (NULL != call) {
            GrPrintf("\n\t\t%s", call);
        }
        GrPrintf("\n");
    }
}

void GrGLResetRowLength(const GrGLInterface* gl) {
    if (gl->supportsDesktop()) {
        GR_GL_CALL(gl, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
    }
}

///////////////////////////////////////////////////////////////////////////////

#if GR_GL_LOG_CALLS
    bool gLogCallsGL = !!(GR_GL_LOG_CALLS_START);
#endif

#if GR_GL_CHECK_ERROR
    bool gCheckErrorGL = !!(GR_GL_CHECK_ERROR_START);
#endif

Fix gl error debug print.

Fix gl error debug print.


#include <iostream>
#include <vector>

#include <adios2.h>
#ifdef ADIOS2_HAVE_MPI
#include <mpi.h>
#endif

int main(int argc, char *argv[])
{
    int rank = 0;
    int size = 1;
#ifdef ADIOS2_HAVE_MPI
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
#endif
    adios2::ADIOS ad;
    try
    {
#ifdef ADIOS2_HAVE_MPI
        ad = adios2::ADIOS("does_not_exist.xml", MPI_COMM_WORLD,
                           adios2::DebugON);
#else
        ad = adios2::ADIOS("does_not_exist.xml", adios2::DebugON);
#endif
    }
    catch (std::exception &e)
    {
        if (rank == 0)
        {
            std::cout << e.what() << "\n";
        }
#ifdef ADIOS2_HAVE_MPI
        ad = adios2::ADIOS(MPI_COMM_WORLD, adios2::DebugON);
#else
        ad = adios2::ADIOS(adios2::DebugON);
#endif
    }

#ifdef ADIOS2_HAVE_MPI
    return MPI_Finalize();
#endif
}

#include <iostream>
#include <vector>

#include <adios2.h>
#ifdef ADIOS2_HAVE_MPI
#include <mpi.h>
#endif

int main(int argc, char *argv[])
{
    int rank = 0;
#ifdef ADIOS2_HAVE_MPI
    int size = 1;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
#endif
    adios2::ADIOS ad;
    try
    {
#ifdef ADIOS2_HAVE_MPI
        ad = adios2::ADIOS("does_not_exist.xml", MPI_COMM_WORLD,
                           adios2::DebugON);
#else
        ad = adios2::ADIOS("does_not_exist.xml", adios2::DebugON);
#endif
    }
    catch (std::exception &e)
    {
        if (rank == 0)
        {
            std::cout << e.what() << "\n";
        }
#ifdef ADIOS2_HAVE_MPI
        ad = adios2::ADIOS(MPI_COMM_WORLD, adios2::DebugON);
#else
        ad = adios2::ADIOS(adios2::DebugON);
#endif
    }

#ifdef ADIOS2_HAVE_MPI
    return MPI_Finalize();
#endif
}

Remove unused variable warning when MPI is disabled.


// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "chrome/common/chrome_constants.h"

namespace browser_sync {

void ChromeReportUnrecoverableError() {
  // TODO(lipalani): Add this for other platforms as well.
#if defined(OS_WIN)
  const double kErrorUploadRatio = 0.15;

  // We only want to upload |kErrorUploadRatio| ratio of errors.
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  // Get the breakpad pointer from chrome.exe
  typedef void (__cdecl *DumpProcessFunction)();
  DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
      ::GetProcAddress(::GetModuleHandle(
                       chrome::kBrowserProcessExecutableName),
                       "DumpProcessWithoutCrash"));
  if (DumpProcess)
    DumpProcess();
#endif  // OS_WIN

}

}  // namespace browser_sync

// 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/browser/sync/glue/chrome_report_unrecoverable_error.h"

#include "base/rand_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/dump_without_crashing.h"

namespace browser_sync {

void ChromeReportUnrecoverableError() {
  // Only upload on canary/dev builds to avoid overwhelming crash server.
  chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
  if (channel != chrome::VersionInfo::CHANNEL_CANARY &&
      channel != chrome::VersionInfo::CHANNEL_DEV) {
    return;
  }

  // We only want to upload |kErrorUploadRatio| ratio of errors.
  const double kErrorUploadRatio = 0.15;
  if (kErrorUploadRatio <= 0.0)
    return; // We are not allowed to upload errors.
  double random_number = base::RandDouble();
  if (random_number > kErrorUploadRatio)
    return;

  logging::DumpWithoutCrashing();
}

}  // namespace browser_sync

[Sync] Support unrecoverable error uploading on non-win platforms

We now use chrome/common/dump_without_crashing.h, and only upload on canary/
dev builds.

BUG=127429

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

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


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

#include "base/native_library.h"

#include <dlfcn.h>

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

namespace base {

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

  return dl;
}

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

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

}  // namespace base

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

#include "base/native_library.h"

#include <dlfcn.h>

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

namespace base {

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

  return dl;
}

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

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

}  // namespace base

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

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

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


#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    std::locale::global( std::locale( "C" ) );
    MainWindow w;
    w.show();

    return a.exec();
}

Set local to C. Maybe not the best longterm solution.


#include "ui.hpp"
#include "window.hpp"

namespace rack {

Tooltip::Tooltip() {
}

void Tooltip::draw(NVGcontext *vg) {
	// Wrap size to contents
	box.size.x = bndLabelWidth(vg, -1, text.c_str());
	box.size.y = bndLabelHeight(vg, -1, text.c_str(), INFINITY);

	bndTooltipBackground(vg, 0.0, 0.0, box.size.x, box.size.y);
	bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str());
	Widget::draw(vg);
}

} // namespace rack

#include "ui.hpp"
#include "window.hpp"

namespace rack {

Tooltip::Tooltip() {
}

void Tooltip::draw(NVGcontext *vg) {
	// Wrap size to contents
	box.size.x = bndLabelWidth(vg, -1, text.c_str()) + 10.0;
	box.size.y = bndLabelHeight(vg, -1, text.c_str(), INFINITY);

	bndTooltipBackground(vg, 0.0, 0.0, box.size.x, box.size.y);
	bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str());
	Widget::draw(vg);
}

} // namespace rack

Add 10 pixels to tooltip because of Retina text width bug


#include "zcash/JoinSplit.hpp"

#include <iostream>

int main(int argc, char **argv)
{
    if(argc != 3) {
        std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName" << std::endl;
        return 1;
    }

    std::string pkFile = argv[1];
    std::string vkFile = argv[2];

    auto p = ZCJoinSplit::Generate();

    p->saveProvingKey(pkFile);
    p->saveVerifyingKey(vkFile);

    return 0;
}

#include "zcash/JoinSplit.hpp"

#include <iostream>
#include "sodium.h"

int main(int argc, char **argv)
{
    if (sodium_init() == -1) {
        return 1;
    }

    if(argc != 3) {
        std::cerr << "Usage: " << argv[0] << " provingKeyFileName verificationKeyFileName" << std::endl;
        return 1;
    }

    std::string pkFile = argv[1];
    std::string vkFile = argv[2];

    auto p = ZCJoinSplit::Generate();

    p->saveProvingKey(pkFile);
    p->saveVerifyingKey(vkFile);

    return 0;
}

Initialize libsodium in this routine, which is now necessary because libsnark uses its PRNG.


#include "visionnage.h"
#include "mainwindow.h"

#include <QDebug>
#include <QException>

Visionnage::Visionnage(MainWindow *parent, Projet *projet, int nPreviousImage) :
    QThread(parent),
    _parent(parent),
    _projet(projet),
    _nPreviousImage(nPreviousImage),
    _initFrame(parent->getNbFrame()),
    _stop(false)
{
}

void Visionnage::run()
{
    int frame = _initFrame;

    while(!_stop)
    {
        _parent->loadFrame(frame);

        if(_nPreviousImage == -1)
        {
            if(frame == _projet->getNbFrameVideo())
            {
                frame = 0;
            }
            else
            {
                frame += 1;
            }
        }
        else
        {
            if(frame == _initFrame)
            {
                frame -= _nPreviousImage;

                if(frame < 0)
                    frame = 0;
            }
            else
            {
                frame += 1;
            }
        }

        msleep(20);
    }
}

void Visionnage::stop()
{
    _stop = true;
    msleep(20);
    _parent->loadFrame(_initFrame);
}

#include "visionnage.h"
#include "mainwindow.h"

#include <QDebug>
#include <QException>

Visionnage::Visionnage(MainWindow *parent, Projet *projet, int nPreviousImage) :
    QThread(parent),
    _parent(parent),
    _projet(projet),
    _nPreviousImage(nPreviousImage),
    _initFrame(parent->getNbFrame()),
    _stop(false)
{
}

void Visionnage::run()
{
    int frame = _initFrame;

    while(!_stop)
    {
        _parent->loadFrame(frame);

        if(_nPreviousImage == -1)
        {
            if(frame == _projet->getNbFrameVideo())
            {
                frame = 0;
            }
            else
            {
                frame += 1;
            }
        }
        else
        {
            if(frame == _initFrame)
            {
                frame -= _nPreviousImage;

                if(frame < 0)
                    frame = 0;
            }
            else
            {
                frame += 1;
            }
        }

        msleep(100);
    }
}

void Visionnage::stop()
{
    _stop = true;
    msleep(20);
    _parent->loadFrame(_initFrame);
}

Change time pause while visionning

Change time pause while visionning


// Copyright 2015 Matt Heard
// http://mattheard.net
// matt@mattheard.net
// @mattheard

#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>

using cv::Mat;

Mat buildLookUpTable(const int divideWith) {
    return Mat();
}

int main(int argc, char **argv) {
    using std::string;
    const int expectedNumArgs = 3;
    if (argc != expectedNumArgs) {
        const string cmdName = "ConvertToGrey";
        const string argsDesc = " <Image_Path> <Reduce_By>";
        std::cout << "Usage: " << cmdName << argsDesc << std::endl;
        return -1;
    }
    const string inputFilename = argv[1];
    const Mat srcImg = cv::imread(inputFilename);
    if (!srcImg.data) {
        const string err = "No image data";
        std::cerr << err << std::cout;
        return -1;
    }
    const int divideWith = atoi(argv[2]);
    if (divideWith < 1) {
        std::cout << "Invalid number entered for dividing." << std::endl;
        return -1;
    }
    const Mat lookUpTable = buildLookUpTable(divideWith);
    return 0;
}

// Copyright 2015 Matt Heard
// http://mattheard.net
// matt@mattheard.net
// @mattheard

#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>

using cv::Mat;

Mat buildLookUpTable(const int divideWith) {
    const int rows = 1;
    const int cols = 256;
    const int type = CV_8U;
    const Mat table(rows, cols, type);
    for (int i = 0; i < 256; ++i) {
        const int reduced = divideWith * (i / divideWith);
        table.data[i] = (uchar) reduced;
    }
    return table;
}

int main(int argc, char **argv) {
    using std::string;
    const int expectedNumArgs = 3;
    if (argc != expectedNumArgs) {
        const string cmdName = "ConvertToGrey";
        const string argsDesc = " <Image_Path> <Reduce_By>";
        std::cout << "Usage: " << cmdName << argsDesc << std::endl;
        return -1;
    }
    const string inputFilename = argv[1];
    const Mat srcImg = cv::imread(inputFilename);
    if (!srcImg.data) {
        const string err = "No image data";
        std::cerr << err << std::cout;
        return -1;
    }
    const int divideWith = atoi(argv[2]);
    if (divideWith < 1) {
        std::cout << "Invalid number entered for dividing." << std::endl;
        return -1;
    }
    const Mat lookUpTable = buildLookUpTable(divideWith);
    return 0;
}

Implement fn to build lookup table

Implement fn to build lookup table


// 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/ui/views/frame/browser_non_client_frame_view.h"

#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h"

namespace browser {

BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
    BrowserFrame* frame, BrowserView* browser_view) {
  if (browser_view->IsBrowserTypePopup() ||
      browser_view->IsBrowserTypePanel()) {
    // TODO(anicolao): implement popups for touch
    NOTIMPLEMENTED();
    return new PopupNonClientFrameView(frame);
  } else {
    return new TouchBrowserFrameView(frame, browser_view);
  }
}

}  // browser

// 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/ui/views/frame/browser_non_client_frame_view.h"

#include "base/command_line.h"
#include "chrome/browser/ui/panels/panel_browser_frame_view.h"
#include "chrome/browser/ui/panels/panel_browser_view.h"
#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h"
#include "chrome/common/chrome_switches.h"

namespace browser {

BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
    BrowserFrame* frame, BrowserView* browser_view) {
  Browser::Type type = browser_view->browser()->type();
  switch (type) {
    case Browser::TYPE_PANEL:
      if (CommandLine::ForCurrentProcess()->HasSwitch(
              switches::kEnablePanels)) {
        return new PanelBrowserFrameView(
            frame, static_cast<PanelBrowserView*>(browser_view));
      }  // else, fall-through and treat as popup
    case Browser::TYPE_POPUP:
      // TODO(anicolao): implement popups for touch
      NOTIMPLEMENTED();
      return new PopupNonClientFrameView(frame);
    default:
      return new TouchBrowserFrameView(frame, browser_view);
  }
}

}  // browser

Use the normal panel-frame until there's a touch-friendly version.

BUG=none
TEST=browser_test:WindowOpenPanel

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

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


// RUN: not %clang_cc1 -triple i686-pc-win32 -emit-llvm -fno-rtti %s 2>&1 | FileCheck %s

// CHECK: error: v-table layout for classes with non-virtual base classes that override methods in virtual bases is not supported yet

struct A {
  virtual int foo() { return a; }
  int a;
};
struct B : virtual A {
  B() : b(1) {}
  virtual int bar() { return b; }
  int b;
};
struct C : virtual A {
  C() : c(2) {}
  virtual int foo() { return c; }
  int c;
};
struct D : B, C {
  D() : d(3) {}
  virtual int bar() { return d; }
  int d;
};
int main() {
  D d;
  return d.foo();
}

// RUN: not %clang_cc1 -triple i686-pc-win32 -emit-llvm-only -fno-rtti %s 2>&1 | FileCheck %s

// CHECK: error: v-table layout for classes with non-virtual base classes that override methods in virtual bases is not supported yet

struct A {
  virtual int foo() { return a; }
  int a;
};
struct B : virtual A {
  B() : b(1) {}
  virtual int bar() { return b; }
  int b;
};
struct C : virtual A {
  C() : c(2) {}
  virtual int foo() { return c; }
  int c;
};
struct D : B, C {
  D() : d(3) {}
  virtual int bar() { return d; }
  int d;
};
int main() {
  D d;
  return d.foo();
}

Change this test to not try to emit any IR. (It should fail to, but it tries to create an output file before encountering the error.)

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


#include "nucleus/Config.h"
#include "nucleus/Files/FilePath.h"

#if OS(POSIX)
#include <unistd.h>
#endif

namespace nu {

#if OS(POSIX)
FilePath getCurrentWorkingDirectory(Allocator* allocator) {
  char buf[PATH_MAX] = {0};
  const char* result = ::getcwd(buf, PATH_MAX);
  return FilePath{String{result, String::npos, allocator}, allocator};
}
#endif

}  // namespace nu

#include "nucleus/Config.h"
#include "nucleus/Files/FilePath.h"

#if OS(POSIX)
#include <unistd.h>
#elif OS(WIN)
#include "nucleus/Win/WindowsMixin.h"
#endif

namespace nu {

FilePath getCurrentWorkingDirectory(Allocator* allocator) {
#if OS(POSIX)
  char buf[PATH_MAX] = {0};
  const char* result = ::getcwd(buf, PATH_MAX);
  return FilePath{String{result, String::npos, allocator}, allocator};
#elif OS(WIN)
  char buf[MAX_PATH] = {0};
  DWORD result = ::GetCurrentDirectoryA(MAX_PATH, buf);
  return FilePath{String{buf, static_cast<I32>(result), allocator}, allocator};
#endif
}

}  // namespace nu

Add GetCurrentWorkingDirectory for Windows platform


#include "Bootstrapper.hpp"

#include <functional>

#include <lua-cxx/LuaValue.hpp>
#include <lua-cxx/loaders.hpp>
#include <lua-cxx/userdata.hpp>

#include "LuaPainter.hpp"
#include "LuaFont.hpp"

Bootstrapper::Bootstrapper() :
    _lua(),
    _desktop(_lua),
    _rainback(_lua)
{
    _rainback.setWidget(&_desktop);
    lua::load_file(_lua, "../../demo/init.lua");
}

QWidget& Bootstrapper::mainWidget()
{
    return _desktop;
}

// vim: set ts=4 sw=4 :

#include "Bootstrapper.hpp"

#include <functional>

#include <lua-cxx/LuaValue.hpp>
#include <lua-cxx/loaders.hpp>
#include <lua-cxx/userdata.hpp>

#include "LuaPainter.hpp"
#include "LuaFont.hpp"

Bootstrapper::Bootstrapper() :
    _lua(),
    _desktop(_lua),
    _rainback(_lua)
{
    _rainback.setWidget(&_desktop);
    QFile file("../../demo/init.lua");
    _lua(file);
}

QWidget& Bootstrapper::mainWidget()
{
    return _desktop;
}

// vim: set ts=4 sw=4 :

Use Qt to load init.lua

Use Qt to load init.lua


#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <stdlib.h>
#include <QtGlobal>
#include <QtWidgets>
#include <QtSingleApplication>

int main(int argc, char *argv[])
{
    QtSingleApplication app(argc, argv);
    if (app.isRunning()) {
        return 0;
    }
    QQmlApplicationEngine engine;
    app.setWindowIcon(QIcon("resources/icons/ykman.png"));
    QString pythonNoBytecode = "PYTHONDONTWRITEBYTECODE=1";
    putenv(pythonNoBytecode.toUtf8().data());
    QString frameworks = "DYLD_LIBRARY_PATH=" + app.applicationDirPath() + "/../Frameworks";
    putenv(frameworks.toUtf8().data());
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    return app.exec();
}

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <stdlib.h>
#include <QtGlobal>
#include <QtWidgets>
#include <QtSingleApplication>

int main(int argc, char *argv[])
{
    // Only allow a single instance running.
    QtSingleApplication app(argc, argv);
    if (app.sendMessage("")) {
        return 0;
    }

    QQmlApplicationEngine engine;
    app.setWindowIcon(QIcon("resources/icons/ykman.png"));
    QString pythonNoBytecode = "PYTHONDONTWRITEBYTECODE=1";
    putenv(pythonNoBytecode.toUtf8().data());
    QString frameworks = "DYLD_LIBRARY_PATH=" + app.applicationDirPath() + "/../Frameworks";
    putenv(frameworks.toUtf8().data());
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));

    // Raise the root window on a message from new instance.
    for (auto object : engine.rootObjects()) {
        if (QWindow *window = qobject_cast<QWindow*>(object)) {
            QObject::connect(&app, &QtSingleApplication::messageReceived, [window]() {
                window->raise();
            });
        }
    }
    return app.exec();
}

Raise window if new instance is started

Raise window if new instance is started


#include "math_container.h"

using std::complex;

/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
complex<double> coshx_eq_expy(double y)
{
    complex<double> ey={exp(y),0};
    complex<double> gamma=log(ey-sqrt(ey*ey-1.0));

    //Since gamma is pure real or pure imaginary, set it:
    if( abs( gamma.real() ) < abs( gamma.imag() ) )  gamma=complex<double>( 0, gamma.imag() );
    else                                             gamma=complex<double>( gamma.real(), 0 );

    return gamma;
}

#include "math_container.h"

using namespace std;

/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
complex<double> coshx_eq_expy(double y)
{
    complex<double> ey={exp(y),0};
    complex<double> gamma=log(ey-sqrt(ey*ey-1.0));

    //Since gamma is pure real or pure imaginary, set it:
    if( abs( gamma.real() ) < abs( gamma.imag() ) )  gamma=complex<double>( 0, gamma.imag() );
    else                                             gamma=complex<double>( gamma.real(), 0 );

    return gamma;
}

Use namespace std, if we do not set this there is a bug?.


#ifdef __unix__

#include <iostream>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

#include "Tools.h"

void StartBotProcess(const std::string& CommandLine)
{
    FILE* pipe = popen(CommandLine.c_str(), "r");
    if (!pipe)
    {
        std::cerr << "Can't launch command '" <<
            CommandLine << "'" << std::endl;
        return;
    }

    int returnCode = pclose(pipe);
    if (returnCode != 0)
    {
        std::cerr << "Failed to finish command '" <<
            CommandLine << "', code: " << returnCode << std::endl;
    }
}

void SleepFor(int seconds)
{
    sleep(seconds);
}

void KillSc2Process(unsigned long pid)
{
    kill(pid, SIGKILL);
}

bool MoveReplayFile(char* lpExistingFileName, char* lpNewFileName)
{
	// todo
	throw "MoveFile is not implemented for linux yet.";
}

#endif

#ifdef __unix__

#include <iostream>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

#include "Tools.h"

void StartBotProcess(const std::string& CommandLine)
{
    FILE* pipe = popen(CommandLine.c_str(), "r");
    if (!pipe)
    {
        std::cerr << "Can't launch command '" <<
            CommandLine << "'" << std::endl;
        return;
    }

    int returnCode = pclose(pipe);
    if (returnCode != 0)
    {
        std::cerr << "Failed to finish command '" <<
            CommandLine << "', code: " << returnCode << std::endl;
    }
}

void SleepFor(int seconds)
{
    sleep(seconds);
}

void KillSc2Process(unsigned long pid)
{
    kill(pid, SIGKILL);
}

bool MoveReplayFile(const char* lpExistingFileName, const  char* lpNewFileName)
{
	// todo
	throw "MoveFile is not implemented for linux yet.";
}

#endif

Fix linking error (again, but for Unix this time)


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

#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>

int main (int argc, char **argv) {
    CppUnit::TextUi::TestRunner runner;
    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
    runner.addTest( registry.makeTest() );
    return runner.run( "" );
}

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

#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>

int main (int argc, char **argv) {
    CppUnit::TextUi::TestRunner runner;
    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
    runner.addTest( registry.makeTest() );
    return !runner.run( "" );
}

Make cpptest main return 0 for SUCCESS.

Make cpptest main return 0 for SUCCESS.


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

#include "chrome/browser/extensions/extension_apitest.h"
#include "net/base/mock_host_resolver.h"

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

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

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

#include "chrome/browser/extensions/extension_apitest.h"
#include "net/base/mock_host_resolver.h"

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

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

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

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

TBR=rafaelw
TEST=none
BUG=28630

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

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

Former-commit-id: 3972e4921c74503f7cf51f22ccea2d7ed7b2efa2


/*
 * INTEL CONFIDENTIAL
 * Copyright © 2011 Intel
 * Corporation All Rights Reserved.
 *
 * The source code contained or described herein and all documents related to
 * the source code ("Material") are owned by Intel Corporation or its suppliers
 * or licensors. Title to the Material remains with Intel Corporation or its
 * suppliers and licensors. The Material contains trade secrets and proprietary
 * and confidential information of Intel or its suppliers and licensors. The
 * Material is protected by worldwide copyright and trade secret laws and
 * treaty provisions. No part of the Material may be used, copied, reproduced,
 * modified, published, uploaded, posted, transmitted, distributed, or
 * disclosed in any way without Intel’s prior express written permission.
 *
 * No license under any patent, copyright, trade secret or other intellectual
 * property right is granted to or conferred upon you by disclosure or delivery
 * of the Materials, either expressly, by implication, inducement, estoppel or
 * otherwise. Any license under such intellectual property rights must be
 * express and approved by Intel in writing.
 *
 * CREATED: 2012-03-29
 * UPDATED: 2012-03-29
 */
#include "SubsystemLibrary.h"
#include "NamedElementBuilderTemplate.h"
#include "FSSubsystem.h"

extern "C"
{
void getFSSubsystemBuilder(CSubsystemLibrary* pSubsystemLibrary)
{
    pSubsystemLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFSSubsystem>("FS"));
}
}

/*
 * INTEL CONFIDENTIAL
 * Copyright © 2011 Intel
 * Corporation All Rights Reserved.
 *
 * The source code contained or described herein and all documents related to
 * the source code ("Material") are owned by Intel Corporation or its suppliers
 * or licensors. Title to the Material remains with Intel Corporation or its
 * suppliers and licensors. The Material contains trade secrets and proprietary
 * and confidential information of Intel or its suppliers and licensors. The
 * Material is protected by worldwide copyright and trade secret laws and
 * treaty provisions. No part of the Material may be used, copied, reproduced,
 * modified, published, uploaded, posted, transmitted, distributed, or
 * disclosed in any way without Intel’s prior express written permission.
 *
 * No license under any patent, copyright, trade secret or other intellectual
 * property right is granted to or conferred upon you by disclosure or delivery
 * of the Materials, either expressly, by implication, inducement, estoppel or
 * otherwise. Any license under such intellectual property rights must be
 * express and approved by Intel in writing.
 *
 * CREATED: 2012-03-29
 * UPDATED: 2012-03-29
 */
#include "SubsystemLibrary.h"
#include "NamedElementBuilderTemplate.h"
#include "FSSubsystem.h"

extern "C"
{
void getFSSubsystemBuilder(CSubsystemLibrary* pSubsystemLibrary)
{
    pSubsystemLibrary->addElementBuilder("FS", new TNamedElementBuilderTemplate<CFSSubsystem>());
}
}

Change the element builder semantic

Change the element builder semantic

BZ: 122982

To parse XML, the PFW uses factories containing a map of XML tags and
their associated builder builder. The builders used to contain the XML
tag of the XML element that it will use in the context of the factory.
A builder and an XML tag are already linked by the factory, thus the tag
member in the builder is redundant.

Remove the XML tag builder attribute and provide it on factory filling.

Change-Id: I827c3b34dffb23bc850316d0b092b31c21987ac2
Signed-off-by: Kevin Rocard <bd9a896220d78c7807307c046053ff427b594938@intel.com>


// 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/ui/views/frame/browser_non_client_frame_view.h"

#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"

namespace browser {

BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
    BrowserFrame* frame, BrowserView* browser_view) {
  if (browser_view->IsBrowserTypePopup() ||
      browser_view->IsBrowserTypePanel()) {
    // TODO(anicolao): implement popups for touch
    NOTIMPLEMENTED();
    return NULL;
  } else {
    return new TouchBrowserFrameView(frame, browser_view);
  }
}

}  // browser

// 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/ui/views/frame/browser_non_client_frame_view.h"

#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h"

namespace browser {

BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
    BrowserFrame* frame, BrowserView* browser_view) {
  if (browser_view->IsBrowserTypePopup() ||
      browser_view->IsBrowserTypePanel()) {
    // TODO(anicolao): implement popups for touch
    NOTIMPLEMENTED();
    return new PopupNonClientFrameView(frame);
  } else {
    return new TouchBrowserFrameView(frame, browser_view);
  }
}

}  // browser

Use the non-touch popup frame instead of NULL.

While this change isn't really all that usable in chrome itself, it fixes a
number of the tests in browser_tests and ui_tests, and fixes a crash in some
other tests to unmask other failures.

BUG=none
TEST=some failing tests (e.g. BrowserNavigatorTest.*) should pass on the touch buildbot.

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

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