#include <tabulate/table.hpp>

using namespace tabulate;

int main() {
  Table employees;

  // Add rows
  employees.add_row({"Emp. ID", "First Name", "Last Name", "Department / Business Unit"});
  employees.add_row({"101", "Donald", "Patrick", "Finance"});
  employees.add_row({"102", "Donald", "Patrick", "Marketing and Operational Logistics Planning"});
  employees.add_row({"103", "Ian", "Jacob", "Engineering"});

  employees.format()
    .font_color(Color::cyan)
    .font_background_color(Color::white)
    .corner_color(Color::blue)
    .border_color(Color::yellow)
    .padding_top(1)
    .padding_bottom(1);

  employees.column(3).format()
    .width(16);

  employees[0][3].format()
    .font_color(Color::none)
    .border_color(Color::red)
    .width(20);

  // employees[1].format()
  //   .width(15);

  // employees[1][2].format()
  //   .width(20);

  // // Print the table
  // employees.print(std::cout);

  // // Set width of column 1 to 13
  // employees.column(1).format()
  //   .width(13);

  // Print the table
  employees.print(std::cout);
}

#include <tabulate/table.hpp>

using namespace tabulate;

int main() {
  Table employees;

  // Add rows
  employees.add_row({"Emp. ID", "First Name", "Last Name", "Department / Business Unit"});
  employees.add_row({"101", "Donald", "Patrick", "Finance"});
  employees.add_row({"102", "Donald", "Patrick", "Marketing and Operational Logistics Planning"});
  employees.add_row({"103", "Ian", "Jacob", "Engineering"});

  // Print the table
  employees.print(std::cout);
}

Reset all styles in sample

Reset all styles in sample


#include <iostream>
#include <ctime>
#include <QCPP.h>

int main() {

	// make it more non-deterministic
	srand(time(NULL));

	// initialize Quantum state with 5 qubits
	Quantum qubits(5);

	// turns all qubits into every state with same probabilities
	qubits.Hadamard(0, 1, 2, 3, 4);
	// or
	// for(int i = 0;i < qubits.size();i++) qubits.Hadamard(i);
	// or
	// qubits.Hadamard({0, 1, 2, 3, 4});
	// would result the same

	// the possibility should be the same
	for(int i = 0;i < (1 << qubits.size());i++) {
		std::cout << "Probabilities of being " << i << " : " << qubits.getProbability(i) << std::endl;
	}

	// try to observe
	for(int i = 0;i < 10;i++) {
		std::cout << "State of qubits : " << qubits.getState() << std::endl;
	}

	return 0;
}

#include <iostream>
#include <ctime>
#include <QCPP.h>

int main() {

	// make it more non-deterministic
	srand(time(NULL));

	// initialize Quantum state with 5 qubits
	Quantum qubits(5);

	// turns all qubits into every state with same probabilities
	qubits.hadamard(0, 1, 2, 3, 4);
	// or
	// for(int i = 0;i < qubits.size();i++) qubits.Hadamard(i);
	// or
	// qubits.hadamard({0, 1, 2, 3, 4});
	// would result the same

	// the possibility should be the same
	for(int i = 0;i < (1 << qubits.size());i++) {
		std::cout << "Probabilities of being " << i << " : " << qubits.getProbability(i) << std::endl;
	}

	// try to observe
	for(int i = 0;i < 10;i++) {
		std::cout << "State of qubits : " << qubits.getState() << std::endl;
	}

	return 0;
}

Fix functions' names according to last change


#include <iostream>
#include <fstream>
#include <spv_utils.h>
#include <cstdint>

int main() {
  // Read spv binary module from a file
  std::ifstream spv_file("../sample_spv_modules/test.frag.spv", std::ios::binary |
                         std::ios::ate | std::ios::in);
  if (spv_file.is_open()) {
    std::streampos size = spv_file.tellg();

    spv_file.seekg(0, std::ios::beg);
    char *data = new char[size];
    spv_file.read(data, size);
    spv_file.close();

    // Parse the module
    sut::OpcodeStream stream(data, size);
    for (auto &i : stream) {
      if (i.GetOpcode() == spv::Op::OpCapability) {
        uint32_t instruction = 0xDEADBEEF;
        i.InsertAfter(&instruction, 1U);
        i.Remove();
      }
    }
    std::vector<uint32_t> filtered_stream = stream.EmitFilteredStream();

    delete[] data;
    data = nullptr;
  }

  return 0;
};

#include <iostream>
#include <fstream>
#include <spv_utils.h>
#include <cstdint>

int main() {
  // Read spv binary module from a file
  std::ifstream spv_file("../sample_spv_modules/test.frag.spv", std::ios::binary |
                         std::ios::ate | std::ios::in);
  if (spv_file.is_open()) {
    std::streampos size = spv_file.tellg();

    spv_file.seekg(0, std::ios::beg);
    char *data = new char[size];
    spv_file.read(data, size);
    spv_file.close();

    // Parse the module
    sut::OpcodeStream stream(data, size);
    for (auto &i : stream) {
      if (i.GetOpcode() == spv::Op::OpCapability) {
        uint32_t instruction = 0xDEADBEEF;
        std::vector<uint32_t> longer_instruction = {
          0xFFFFEEEE,
          0xFFFFDDDD,
          0xFFFFFFFF,
          0xDEADBEEF
        };
        uint32_t instruction2 = 0xDEADBEEF;
        i.InsertBefore(longer_instruction.data(), longer_instruction.size());
        i.InsertAfter(&instruction, 1U);
        i.Remove();
      }
    }
    std::vector<uint32_t> filtered_stream = stream.EmitFilteredStream();

    delete[] data;
    data = nullptr;
  }

  return 0;
};

Add longer instruction test to sample

Add longer instruction test to sample


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

#include <stdio.h>

#include "Arduino.h"

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

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

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

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

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

#include <stdio.h>

#include "Arduino.h"

// these are needed by the serializer, so force link
asm(".global _printf_float");
asm(".global _scanf_float");

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

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

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

Add note about _printf_float and _scanf_float


/*********************************************************************
 * thread-sleep: Force Node.js to sleep
 *
 * Copyright (c) 2015 Forbes Lindesay
 * Copyright (c) 2015 Tiancheng "Timothy" Gu
 *
 * MIT License
 ********************************************************************/

#include <nan.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <ctime>
#endif

using v8::FunctionTemplate;
using Nan::GetFunction;
using Nan::New;
using Nan::Set;

void SleepSync(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  // expect a number as the first argument
  int millisec = args[0]->Uint32Value();

#ifdef _WIN32
  Sleep(millisec);
#else
  struct timespec req;
  req.tv_sec = millisec / 1000;
  req.tv_nsec = (millisec % 1000) * 1000000L;
  nanosleep(&req, (struct timespec *)NULL);
#endif

  info.GetReturnValue().Set(millisec);
}

// Expose SleepSync() as sleep() in JS
NAN_MODULE_INIT(InitAll) {
  Set(target, New("sleep").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(SleepSync)).ToLocalChecked());
}

NODE_MODULE(thread_sleep, InitAll)

/*********************************************************************
 * thread-sleep: Force Node.js to sleep
 *
 * Copyright (c) 2015 Forbes Lindesay
 * Copyright (c) 2015 Tiancheng "Timothy" Gu
 *
 * MIT License
 ********************************************************************/

#include <nan.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <ctime>
#endif

using v8::FunctionTemplate;
using Nan::GetFunction;
using Nan::New;
using Nan::Set;

void SleepSync(const Nan::FunctionCallbackInfo<v8::Value>& info) {
#ifdef _WIN32
  // expect a number as the first argument
  DWORD millisec = info[0]->Uint32Value();

  Sleep(millisec);
#else
  // expect a number as the first argument
  uint32_t millisec = info[0]->Uint32Value();

  struct timespec req;
  req.tv_sec = millisec / 1000;
  req.tv_nsec = (millisec % 1000) * 1000000L;
  nanosleep(&req, (struct timespec *)NULL);
#endif

  info.GetReturnValue().Set(millisec);
}

// Expose SleepSync() as sleep() in JS
NAN_MODULE_INIT(InitAll) {
  Set(target, New("sleep").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(SleepSync)).ToLocalChecked());
}

NODE_MODULE(thread_sleep, InitAll)

Use correct type for millisec

Use correct type for millisec


// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s
// This test is for a crash when emitting debug info for not-yet-completed types.
// Test that we don't actually emit a forward decl for the offending class:
// CHECK:  [ DW_TAG_class_type ] [Derived<const __CFString, Foo>] {{.*}} [def]
// rdar://problem/15931354
typedef const struct __CFString * CFStringRef;
template <class R> class Returner {};
typedef const __CFString String;

template <class A, class B> class Derived;

template <class A, class B>
class Base
{
  static Derived<A, B>* create();
};

template <class A, class B>
class Derived : public Base<A, B> {
public:
  static void foo();
};

class Foo
{
  Foo();
  static Returner<Base<String,Foo> > all();
};

Foo::Foo(){}

Returner<Base<String,Foo> > Foo::all()
{
  Derived<String,Foo>::foo();
  return Foo::all();
}

// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s
// This test is for a crash when emitting debug info for not-yet-completed types.
// Test that we don't actually emit a forward decl for the offending class:
// CHECK:  [ DW_TAG_class_type ] [Derived<Foo>] {{.*}} [def]
// rdar://problem/15931354
template <class R> class Returner {};
template <class A> class Derived;

template <class A>
class Base
{
  static Derived<A>* create();
};

template <class A>
class Derived : public Base<A> {
public:
  static void foo();
};

class Foo
{
  Foo();
  static Returner<Base<Foo> > all();
};

Foo::Foo(){}

Returner<Base<Foo> > Foo::all()
{
  Derived<Foo>::foo();
  return Foo::all();
}

Simplify testcase from r200797 some more.

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


// Copyright 2015 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 "ui/ozone/platform/drm/gpu/gpu_lock.h"

#include <fcntl.h>
#include <unistd.h>

#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"

namespace ui {

namespace {
const char kGpuLockFile[] = "/run/frecon";
}

GpuLock::GpuLock() {
  fd_ = open(kGpuLockFile, O_RDWR);
  if (fd_ < 0) {
    PLOG(ERROR) << "Failed to open lock file '" << kGpuLockFile << "'";
    return;
  }

  struct flock data;
  memset(&data, 0, sizeof(data));
  data.l_type = F_WRLCK;
  data.l_whence = SEEK_SET;

  VLOG(1) << "Taking write lock on '" << kGpuLockFile << "'";
  if (HANDLE_EINTR(fcntl(fd_, F_SETLKW, &data)))
    PLOG(ERROR) << "Error while trying to get lock on '" << kGpuLockFile << "'";

  VLOG(1) << "Done trying to take write lock on '" << kGpuLockFile << "'";
}

GpuLock::~GpuLock() {
  // Failed to open the lock file, so nothing to do here.
  if (fd_ < 0)
    return;

  VLOG(1) << "Releasing write lock on '" << kGpuLockFile << "'";
  close(fd_);
}

}  // namespace ui

// Copyright 2015 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 "ui/ozone/platform/drm/gpu/gpu_lock.h"

#include <sys/file.h>
#include <unistd.h>

#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"

namespace ui {

namespace {
const char kGpuLockFile[] = "/run/frecon";
}

GpuLock::GpuLock() {
  fd_ = open(kGpuLockFile, O_RDWR);
  if (fd_ < 0) {
    PLOG(ERROR) << "Failed to open lock file '" << kGpuLockFile << "'";
    return;
  }

  VLOG(1) << "Taking write lock on '" << kGpuLockFile << "'";
  if (HANDLE_EINTR(flock(fd_, LOCK_EX)))
    PLOG(ERROR) << "Error while trying to get lock on '" << kGpuLockFile << "'";

  VLOG(1) << "Done trying to take write lock on '" << kGpuLockFile << "'";
}

GpuLock::~GpuLock() {
  // Failed to open the lock file, so nothing to do here.
  if (fd_ < 0)
    return;

  VLOG(1) << "Releasing write lock on '" << kGpuLockFile << "'";
  close(fd_);
}

}  // namespace ui

[Ozone-Drm] Change file locking from Posix to BSD style

Frecon requires BSD style file locks since the lock needs to be held
past forking. So we also need to change the Ozone side since Posix and
BSD locks don't mix.

BUG=463665

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

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


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector < ll > vl;

vl arr(3);
/*
	returs gcd(a,b) and find the coeficcients of bezout
	such that d = ax + by
	arr[0] gcd
	arr[1] x
	arr[2] y
*/
void extended(ll a, ll b){
	ll y =0;
	ll x =1;
	ll xx =0;
	ll yy =1;
	while(b){
		ll	 q = a / b;
		ll t = b;
		b = a%b;
		a = t;

		t = xx;
		xx = x-q*xx;
		x = t;

		t = yy;
		yy = y -q*yy;
		y = t;
	}
	arr[0] = a;
	arr[1] = x;
	arr[2] = y;
}

int main(){
	ll a = 20, b = 50;
	extended(a,b);
	printf("gcd(%lld, %lld) = %lld = %lld * %lld + %lld * %lld\n", a, b, arr[0], a,arr[1], b, arr[2]);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector < ll > vl;

vl arr(3);
/*
	returs gcd(a,b) and find the coeficcients of bezout
	such that d = ax + by
	arr[0] gcd
	arr[1] x
	arr[2] y
*/
void extended(ll a, ll b){
	ll y =0;
	ll x =1;
	ll xx =0;
	ll yy =1;
	while(b){
		ll	 q = a / b;
		ll t = b;
		b = a%b;
		a = t;

		t = xx;
		xx = x-q*xx;
		x = t;

		t = yy;
		yy = y -q*yy;
		y = t;
	}
	arr[0] = a;
	arr[1] = x;
	arr[2] = y;
}
/*

	ax + by  = c
	mcd(a,b) = d
	ax0 + by0 = d
	c = d * c'

	Bezouts identity

		X = x0 * c' - (b/d) * k
		Y = y0 * c' + (a/d) * k

*/

int main(){
	ll a = 20, b = 50;
	extended(a,b);
	printf("gcd(%lld, %lld) = %lld = %lld * %lld + %lld * %lld\n", a, b, arr[0], a,arr[1], b, arr[2]);
	return 0;
}

Add Bezouts identity, very useful.

Add Bezouts identity, very useful.


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define X(a,b) (x[a]*10+x[b])

int mkInt(vector<int> &v) {
    int ret = 0;
    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
        ret = ret * 10 + *it;
    }
    return ret;
}

int main() {
    int init_x[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9 };
    vector<int> x = vector<int>(init_x, init_x + 9);
    do {
        vector<int> vec_ab = vector<int>(x.begin() + 0, x.begin() + 2);
        vector<int> vec_cd = vector<int>(x.begin() + 2, x.begin() + 4);
        vector<int> vec_ef = vector<int>(x.begin() + 4, x.begin() + 6);
        vector<int> vec_gh = vector<int>(x.begin() + 6, x.begin() + 8);

        int ab = mkInt(vec_ab), cd = mkInt(vec_cd), ef = mkInt(vec_ef), gh = mkInt(vec_gh);
        if ((ab >= 10 && cd >= 10 && ef >= 10 && gh >= 10) && (ab - cd) == ef && (ef + gh) == 111) {
            cout << ab << " + " << cd << " = " << ef << ", " << ef << " - " << gh << " = 111" << endl;
        }
    } while (next_permutation(x.begin(), x.end()));

    return 0;
}

Refactor C++ code to real C++ code

Refactor C++ code to real C++ code


#include <iostream>

using namespace std;

const int MAX = 100;

struct Person {
  string firstName;
  string lastName;

  void input() {
    cout << "Enter person's first and last names separated by a space: ";
    cin >> firstName >> lastName;
  }

  void print() {
    cout << firstName << ' ' << lastName << '\n';
  }
};

struct Client {
  Person person;
  double account;

  void input() {
    person.input();

    cout << "Enter account: ";
    cin >> account;
  }

  void print() {
    person.print();
    cout << "Account: " << account << '\n';
  };
};

void inputClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].input();
  }
}

void printClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].print();
  }
}

double sumAccounts(Client clients[], int n) {
  double sum = 0;

  for (int i = 0; i < n; ++i) {
    sum += clients[i].account;
  }

  return sum;
}

int main() {
  Client clients[MAX];
  int clientsCount = 3;

  inputClients(clients, clientsCount);
  printClients(clients, clientsCount);
  cout << sumAccounts(clients, clientsCount) << '\n';

  return 0;
}

#include <iostream>

using namespace std;

struct Person {
  char firstName[32];
  char lastName[32];

  void input() {
    cout << "Enter person's first and last names separated by a space: ";
    cin >> firstName >> lastName;
  }

  void print() {
    cout << firstName << ' ' << lastName << '\n';
  }
};

struct Client {
  Person person;
  double account;

  void input() {
    person.input();

    cout << "Enter account: ";
    cin >> account;
  }

  void print() {
    person.print();
    cout << "Account: " << account << '\n';
  };
};

void inputClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].input();
  }
}

void printClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].print();
  }
}

double sumAccounts(Client clients[], int n) {
  double sum = 0;

  for (int i = 0; i < n; ++i) {
    sum += clients[i].account;
  }

  return sum;
}

int main() {
  Client clients[100];
  int clientsCount = 3;

  inputClients(clients, clientsCount);
  printClients(clients, clientsCount);
  cout << sumAccounts(clients, clientsCount) << '\n';

  return 0;
}

Use char[] instead of std::string

Use char[] instead of std::string


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

#include "remoting/host/event_executor_mac.h"

namespace remoting {

EventExecutorMac::EventExecutorMac(Capturer* capturer)
  : EventExecutor(capturer) {
}

EventExecutorMac::~EventExecutorMac() {
}

void EventExecutorMac::HandleInputEvent(ChromotingClientMessage* message) {
  delete message;
}

}  // namespace remoting

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

#include "remoting/host/event_executor_mac.h"

#include "remoting/protocol/messages_decoder.h"

namespace remoting {

EventExecutorMac::EventExecutorMac(Capturer* capturer)
  : EventExecutor(capturer) {
}

EventExecutorMac::~EventExecutorMac() {
}

void EventExecutorMac::HandleInputEvent(ChromotingClientMessage* message) {
  delete message;
}

}  // namespace remoting

Fix build break on mac. TBR=ajwong

Fix build break on mac.
TBR=ajwong

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


// 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 "net/disk_cache/cache_util.h"

#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_util.h"

namespace disk_cache {

bool MoveCache(const FilePath& from_path, const FilePath& to_path) {
  // Just use the version from base.
  return file_util::Move(from_path, to_path);
}

void DeleteCache(const FilePath& path, bool remove_folder) {
  file_util::FileEnumerator iter(path,
                                 /* recursive */ false,
                                 file_util::FileEnumerator::FILES);
  for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) {
    if (!file_util::Delete(file, /* recursive */ false))
      NOTREACHED();
  }

  if (remove_folder) {
    if (!file_util::Delete(path, /* recursive */ false))
      NOTREACHED();
  }
}

bool DeleteCacheFile(const FilePath& name) {
  return file_util::Delete(name, false);
}

}  // namespace disk_cache

// 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 "net/disk_cache/cache_util.h"

#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_util.h"

namespace disk_cache {

bool MoveCache(const FilePath& from_path, const FilePath& to_path) {
  // Just use the version from base.
  return file_util::Move(from_path, to_path);
}

void DeleteCache(const FilePath& path, bool remove_folder) {
  file_util::FileEnumerator iter(path,
                                 /* recursive */ false,
                                 file_util::FileEnumerator::FILES);
  for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) {
    if (!file_util::Delete(file, /* recursive */ false)) {
      LOG(WARNING) << "Unable to delete cache.";
      return;
    }
  }

  if (remove_folder) {
    if (!file_util::Delete(path, /* recursive */ false)) {
      LOG(WARNING) << "Unable to delete cache folder.";
      return;
    }
  }
}

bool DeleteCacheFile(const FilePath& name) {
  return file_util::Delete(name, false);
}

}  // namespace disk_cache

Change NOTREACHED for a LOG(WARNING) when we can't delete
the cache. This should help the unit tests.

BUG:38562
Review URL: http://codereview.chromium.org/1594002

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


#include <QApplication>
#include <QSettings>
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>

#include "trayicon.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setOrganizationName("Restnotifier");
    app.setQuitOnLastWindowClosed(false);

    // Set language
    QSettings settings;
    QString lang;
    QTranslator translator, qtTranslator;
    if (settings.contains("lang"))
        lang = settings.value("lang").toString();
    else
        lang = QLocale::languageToString(QLocale::system().language());
    if (lang == "ru")
    {
        QLocale::setDefault(QLocale("ru"));

        // install qt translator
#if defined Q_WS_X11
        const QString loc = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#elif defined Q_WS_WIN
        const QString loc();
#endif
        qtTranslator.load("qt_ru", loc);
        app.installTranslator(&qtTranslator);

        // install app translator
        translator.load("restnotifier_ru");
        app.installTranslator(&translator);
    }

    TrayIcon *trayIcon = new TrayIcon();
    trayIcon->show();
    QObject::connect(trayIcon, SIGNAL(quitScheduled()), &app, SLOT(quit()));
    int code = app.exec();
    delete trayIcon;
    return code;
}

#include <QApplication>
#include <QSettings>
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>

#include "trayicon.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setOrganizationName("Restnotifier");
    app.setQuitOnLastWindowClosed(false);

    // Set language
    QSettings settings;
    QString lang;
    QTranslator translator, qtTranslator;
    if (settings.contains("lang"))
        lang = settings.value("lang").toString();
    else
        lang = QLocale::languageToString(QLocale::system().language());
    if (lang == "ru")
    {
        QLocale::setDefault(QLocale("ru"));

        // install qt translator
#if defined Q_WS_X11
        const QString loc = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#elif defined Q_WS_WIN
        const QString loc();
#endif
        qtTranslator.load("qt_ru", loc);
        app.installTranslator(&qtTranslator);

        // install app translator
        QString translationsPath = settings.value("tr_path", QString()).toString();
        translator.load("restnotifier_ru", translationsPath);
        app.installTranslator(&translator);
    }

    TrayIcon *trayIcon = new TrayIcon();
    trayIcon->show();
    QObject::connect(trayIcon, SIGNAL(quitScheduled()), &app, SLOT(quit()));
    int code = app.exec();
    delete trayIcon;
    return code;
}

Allow to change path to translations

Allow to change path to translations


#include "common/application_info.h"

#include "base/file_version_info.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"

namespace brightray {

std::string GetApplicationName() {
  auto module = GetModuleHandle(nullptr);
  auto info = make_scoped_ptr(
      FileVersionInfo::CreateFileVersionInfoForModule(module));
  return UTF16ToUTF8(info->product_name());
}

std::string GetApplicationVersion() {
  auto module = GetModuleHandle(nullptr);
  auto info = make_scoped_ptr(
      FileVersionInfo::CreateFileVersionInfoForModule(module));
  return UTF16ToUTF8(info->product_version());
}

}  // namespace brightray

#include "common/application_info.h"

#include "base/file_version_info.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"

namespace brightray {

std::string GetApplicationName() {
  auto module = GetModuleHandle(nullptr);
  auto info = make_scoped_ptr(
      FileVersionInfo::CreateFileVersionInfoForModule(module));
  return base::UTF16ToUTF8(info->product_name());
}

std::string GetApplicationVersion() {
  auto module = GetModuleHandle(nullptr);
  auto info = make_scoped_ptr(
      FileVersionInfo::CreateFileVersionInfoForModule(module));
  return base::UTF16ToUTF8(info->product_version());
}

}  // namespace brightray

Update for move of string conversion functions into base::


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

#include "GrDrawBatch.h"

GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { }

GrDrawBatch::~GrDrawBatch() {
    if (fPipelineInstalled) {
        this->pipeline()->~GrPipeline();
    }
}

void GrDrawBatch::getPipelineOptimizations(GrPipelineOptimizations* opt) const {
    GrInitInvariantOutput color;
    GrInitInvariantOutput coverage;
    this->computePipelineOptimizations(&color, &coverage, &opt->fOverrides);
    opt->fColorPOI.initUsingInvariantOutput(color);
    opt->fCoveragePOI.initUsingInvariantOutput(coverage);
}

bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) {
    GrXPOverridesForBatch overrides;
    void* location = fPipelineStorage.get();
    if (!GrPipeline::CreateAt(location, args, &overrides)) {
        return false;
    }
    this->initBatchTracker(overrides);
    fPipelineInstalled = true;
    return true;
}

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

#include "GrDrawBatch.h"

GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { }

GrDrawBatch::~GrDrawBatch() {
    if (fPipelineInstalled) {
        this->pipeline()->~GrPipeline();
    }
}

void GrDrawBatch::getPipelineOptimizations(GrPipelineOptimizations* opt) const {
    GrInitInvariantOutput color;
    GrInitInvariantOutput coverage;
    this->computePipelineOptimizations(&color, &coverage, &opt->fOverrides);
    opt->fColorPOI.initUsingInvariantOutput(color);
    opt->fCoveragePOI.initUsingInvariantOutput(coverage);
}

bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) {
    GrXPOverridesForBatch overrides;
    void* location = fPipelineStorage.get();
    if (!GrPipeline::CreateAt(location, args, &overrides)) {
        return false;
    }
    fPipelineInstalled = true;
    this->initBatchTracker(overrides);
    return true;
}

Fix assert accessing pipeline from initBatchTracker

Marks fPipelineInstalled as true before calling initBatchTracker. The
batch subclass ought to be able to access the newly constructed
pipeline object during its init.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1666813002

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


// This file is part of the GLERI project
//
// Copyright (c) 2012 by Mike Sharov <msharov@users.sourceforge.net>
// This file is free software, distributed under the MIT License.

#include "rglrp.h"

#define N(n,s)	#n "\0" #s "\0"
/*static*/ const char PRGLR::_cmdNames[] =
     "\0"	// Dirty trick: object name is 4 bytes, but must be zero terminated
     N(GLError,s)
     N(Restate,(nnqqyyyy))
     N(Expose,)
     N(Event,(unnuu))
;
#undef N

/*static*/ inline const char* PRGLR::LookupCmdName (ECmd cmd, size_type& sz) noexcept
{
    return (CCmdBuf::LookupCmdName((unsigned)cmd,sz,_cmdNames+1,sizeof(_cmdNames)-2));
}

/*static*/ PRGLR::ECmd PRGLR::LookupCmd (const char* name, size_type bleft) noexcept
{
    return (ECmd(CCmdBuf::LookupCmd(name+1,bleft,_cmdNames+1,sizeof(_cmdNames)-2)));
}

bstro PRGLR::CreateCmd (ECmd cmd, size_type sz) noexcept
{
    size_type msz;
    const char* m = LookupCmdName(cmd, msz);
    return (CCmdBuf::CreateCmd (RGLRObject, m-1, msz+1, sz));
}

// This file is part of the GLERI project
//
// Copyright (c) 2012 by Mike Sharov <msharov@users.sourceforge.net>
// This file is free software, distributed under the MIT License.

#include "rglrp.h"

#define N(n,s)	#n "\0" #s "\0"
/*static*/ const char PRGLR::_cmdNames[] =
     N(Error,s)
     N(Restate,(nnqqyyyy))
     N(Expose,)
     N(Event,(unnuu))
;
#undef N

/*static*/ inline const char* PRGLR::LookupCmdName (ECmd cmd, size_type& sz) noexcept
{
    return (CCmdBuf::LookupCmdName((unsigned)cmd,sz,_cmdNames+1,sizeof(_cmdNames)-2));
}

/*static*/ PRGLR::ECmd PRGLR::LookupCmd (const char* name, size_type bleft) noexcept
{
    return (ECmd(CCmdBuf::LookupCmd(name+1,bleft,_cmdNames+1,sizeof(_cmdNames)-2)));
}

bstro PRGLR::CreateCmd (ECmd cmd, size_type sz) noexcept
{
    size_type msz;
    const char* m = LookupCmdName(cmd, msz);
    return (CCmdBuf::CreateCmd (RGLRObject, m-1, msz+1, sz));
}

Revert "Rename Error call to GLError"

Revert "Rename Error call to GLError"

This reverts commit c216af3d3f0e910ba95eabe6d2f5a3574f051bd4.


#include "forth_common.th"

// A little Forth.

.set link, 0
.global __zero
__zero:
__boot:
    S <- [reloc(_PSPinit)]
    R <- [reloc(_RSPinit)]
    I <- reloc(QUIT)        // enter text interpreter
    goto(NEXT)

    .global _PSPinit
    .global _RSPinit
_PSPinit:   .word   0x007fffff
_RSPinit:   .word   0x00ffffff

// TODO smudge internal words
head(RESET_RSP,RESET_RSP): .word . + 1
    R <- [reloc(_RSPinit)]
    goto(NEXT)

head(NEXT,NEXT):
    W  <- [I]
    W  <-  rel(W)
    I  <-  I + 1
    X  <- [W]
    jmp(X)

head(ENTER,ENTER):
    .word . + 1
    push(R,I)
    I  <- W + 1
    goto(NEXT)

head(EXIT,EXIT):
    .word . + 1
    pop(R,I)
    goto(NEXT)

    .global source_id
source_id: .word 0
head(SOURCE_ID,SOURCE-ID): .word
    @ENTER, @LITERAL, @source_id, @RELOC, @EXIT

    .global __done
__done:
    // return to caller of forth, abort, whatever is required
    //p <- reloc(__boot)
    illegal

#include "forth_common.th"

// A little Forth.

.set link, 0
.global __zero
__zero:
__boot:
    S <- [reloc(_PSPinit)]
    R <- [reloc(_RSPinit)]
    I <- reloc(QUIT)        // enter text interpreter
    goto(NEXT)

    .global _PSPinit
    .global _RSPinit
_PSPinit:   .word   0x007fffff
_RSPinit:   .word   0x00ffffff

// TODO smudge internal words
head(RESET_RSP,RESET_RSP): .word . + 1
    R <- [reloc(_RSPinit)]
    goto(NEXT)

head(NEXT,NEXT):
    W  <- [I]
    W  <-  rel(W)
    I  <-  I + 1
    X  <- [W]
    jmp(X)

head(ENTER,ENTER):
    // ENTER is special and does not have an interp-word entry
    push(R,I)
    I  <- W + 1
    goto(NEXT)

head(EXIT,EXIT):
    .word . + 1
    pop(R,I)
    goto(NEXT)

    .global source_id
source_id: .word 0
head(SOURCE_ID,SOURCE-ID): .word
    @ENTER, @LITERAL, @source_id, @RELOC, @EXIT

    .global __done
__done:
    // return to caller of forth, abort, whatever is required
    //p <- reloc(__boot)
    illegal

Drop interp-word pointer in ENTER

Drop interp-word pointer in ENTER


#include <stan/math/rev/scal.hpp>
#include <gtest/gtest.h>
#include <test/unit/math/rev/scal/util.hpp>
#include <limits>

TEST(MathFunctions, is_any_nan_variadic_rev) {
  using stan::math::is_any_nan;

  double dbl_inf = std::numeric_limits<double>::infinity();
  double dbl_nan = std::numeric_limits<double>::quiet_NaN();

  AVAR var_nan(dbl_nan);
  AVAR var_inf(dbl_inf);

  AVAR a = 7.0;
  AVAR b = 2.0;

  EXPECT_TRUE(is_any_nan(var_nan, b, 6, 5.0));
  EXPECT_TRUE(is_any_nan(var_nan, var_inf, 6, 5.0));
  EXPECT_TRUE(is_any_nan(dbl_nan, a, b, 6, 5.0));

  EXPECT_FALSE(is_any_nan(dbl_inf, b, 6, var_inf));
  EXPECT_FALSE(is_any_nan(a, b, 6, 7.0));
}

#include <stan/math/rev/scal.hpp>
#include <gtest/gtest.h>
#include <test/unit/math/rev/scal/util.hpp>
#include <test/unit/math/rev/scal/fun/util.hpp>
#include <limits>

TEST(MathFunctions, is_any_nan_variadic_rev) {
  using stan::math::is_any_nan;

  double dbl_inf = std::numeric_limits<double>::infinity();
  double dbl_nan = std::numeric_limits<double>::quiet_NaN();

  AVAR var_nan(dbl_nan);
  AVAR var_inf(dbl_inf);

  AVAR a = 7.0;
  AVAR b = 2.0;

  EXPECT_TRUE(is_any_nan(var_nan, b, 6, 5.0));
  EXPECT_TRUE(is_any_nan(var_nan, var_inf, 6, 5.0));
  EXPECT_TRUE(is_any_nan(dbl_nan, a, b, 6, 5.0));

  EXPECT_FALSE(is_any_nan(dbl_inf, b, 6, var_inf));
  EXPECT_FALSE(is_any_nan(a, b, 6, 7.0));
}

Fix includes for AVAR typedef.

Fix includes for AVAR typedef.


#include "module_wpad.hpp"
using namespace com::googlecode::libproxy;

static const char *DEFAULT_WPAD_ORDER[] = {
	"wpad_dhcp",
	"wpad_slp",
	"wpad_dns",
	"wpad_dnsdevolution",
	NULL
};

bool wpad_module::operator<(const wpad_module& module) const {
	for (int i=0 ; DEFAULT_WPAD_ORDER[i] ; i++) {
		if (module.get_id() == DEFAULT_WPAD_ORDER[i])
			break;
		if (this->get_id() == DEFAULT_WPAD_ORDER[i])
			return true;
	}
	return false;
}

#include "module_wpad.hpp"
using namespace com::googlecode::libproxy;

static const char *DEFAULT_WPAD_ORDER[] = {
	"wpad_dhcp",
	"wpad_slp",
	"wpad_dns_srv",
	"wpad_dns_txt",
	"wpad_dns_alias",
	NULL
};

bool wpad_module::operator<(const wpad_module& module) const {
	for (int i=0 ; DEFAULT_WPAD_ORDER[i] ; i++) {
		if (module.get_id() == DEFAULT_WPAD_ORDER[i])
			break;
		if (this->get_id() == DEFAULT_WPAD_ORDER[i])
			return true;
	}
	return false;
}

Fix wpad ordering table after wpad_dns -> wpad_dns_alias rename


// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
// RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s

extern "C" int printf(...);

static int count;
static float fcount;

class xpto {
public:
  xpto() : i(count++), f(fcount++) {
    printf("xpto::xpto()\n");
  }
  int i;
  float f;

  ~xpto() {
    printf("xpto::~xpto()\n");
  }
};

int main() {
  xpto array[2][3][4];
  for (int h = 0; h < 2; h++)
   for (int i = 0; i < 3; i++)
    for (int j = 0; j < 4; j++)
       printf("array[%d][%d][%d] = {%d, %f}\n",
              h, i, j, array[h][i][j].i, array[h][i][j].f);
}

// CHECK-LP64: callq    __ZN4xptoC1Ev

// CHECK-LP32: calll     L__ZN4xptoC1Ev

// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \
// RUN: FileCheck %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \
// RUN: FileCheck %s

extern "C" int printf(...);

static int count;
static float fcount;

class xpto {
public:
  xpto() : i(count++), f(fcount++) {
    printf("xpto::xpto()\n");
  }
  int i;
  float f;

  ~xpto() {
    printf("xpto::~xpto()\n");
  }
};

int main() {
  xpto array[2][3][4];
  for (int h = 0; h < 2; h++)
   for (int i = 0; i < 3; i++)
    for (int j = 0; j < 4; j++)
       printf("array[%d][%d][%d] = {%d, %f}\n",
              h, i, j, array[h][i][j].i, array[h][i][j].f);
}

// CHECK: call void @_ZN4xptoC1Ev

Check IR in this test.

Check IR in this test.

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


#include "stdafx.h"
#include "MultipleSenderTest.h"
#include "EventSender.h"

class MultiEventA:
  public virtual EventReceiver
{
public:
  virtual void EventA(void) = 0;
};

class MultiEventB:
  public virtual EventReceiver
{
public:
  virtual void EventB(void) = 0;
};

class MultiSender:
  public EventSender<MultiEventA, MultiEventB>
{
};

MultipleSenderTest::MultipleSenderTest(void) {}

TEST_F(MultipleSenderTest, VerifyMultiSendA) {
  m_sender->Fire(&MultiEventA::EventA)();
}

TEST_F(MultipleSenderTest, VerifyMultiSendB) {
  m_sender->Fire(&MultiEventB::EventB)();
}

#include "stdafx.h"
#include "MultipleSenderTest.h"
#include "EventSender.h"

class MultiEventA:
  public virtual EventReceiver
{
public:
  virtual void Event(void) = 0;
};

class MultiEventB:
  public virtual EventReceiver
{
public:
  virtual void Event(void) = 0;
};

class MultiSender:
  public EventSender<MultiEventA, MultiEventB>
{
};

MultipleSenderTest::MultipleSenderTest(void) {}

TEST_F(MultipleSenderTest, VerifyMultiSendA) {
  m_sender->Fire(&MultiEventA::Event)();
}

TEST_F(MultipleSenderTest, VerifyMultiSendB) {
  m_sender->Fire(&MultiEventB::Event)();
}

Test amended to ensure that potential naming collisions do not necessarily affect execution


// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s

// CHECK: DW_TAG_subrange_type

struct StructName {
  int member[];
};

struct StructName SN;

// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s

// CHECK: metadata !{i32 {{.*}}, i64 1, i64 0}        ; [ DW_TAG_subrange_type ]

struct StructName {
  int member[];
};

struct StructName SN;

Check that we have an unknown upper bound range for our flexible array members.

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


#include "iorequest.h"
#include <QtDebug>
#include "event.h"
#include "actions/action.h"

IORequest::IORequest(Player* source, IORequest::RequestType type, int refCount) :
    QObject(NULL),
    mRefCount(refCount),
    m_source(source),
    m_type(type),
    m_response(NULL)
{
}

IORequest::~IORequest()
{
}

IORequest::RequestType IORequest::type() const
{
    return m_type;
}

void IORequest::putExtra(const QString& key, const QVariant& value)
{
    m_extras.insert(key, value);
}

QVariant IORequest::extra(const QString& key) const
{
    Q_ASSERT(m_extras.contains(key));
    return m_extras.value(key);
}

void IORequest::setResponse(void* r)
{
    m_response = r;
}

void* IORequest::response() const
{
    return m_response;
}

void IORequest::clearRef()
{
    if (mRefCount-- <= 0)
        delete this;
}

#include "iorequest.h"
#include <QtDebug>
#include "event.h"
#include "actions/action.h"

IORequest::IORequest(Player* source, IORequest::RequestType type, int refCount) :
    QObject(NULL),
    mRefCount(refCount),
    m_source(source),
    m_type(type),
    m_response(NULL)
{
}

IORequest::~IORequest()
{
}

IORequest::RequestType IORequest::type() const
{
    return m_type;
}

void IORequest::putExtra(const QString& key, const QVariant& value)
{
    m_extras.insert(key, value);
}

QVariant IORequest::extra(const QString& key) const
{
    Q_ASSERT(m_extras.contains(key));
    return m_extras.value(key);
}

void IORequest::setResponse(void* r)
{
    m_response = r;
}

void* IORequest::response() const
{
    return m_response;
}

void IORequest::clearRef()
{
    if (--mRefCount <= 0)
        delete this;
}

Fix memory leak: IORequest needed 3 calls (instead of 2) to deRef to delete itself


#include "StdAfx.h"
#include "BlackArea.h"
/*
    RawSpeed - RAW file decoder.

    Copyright (C) 2009 Klaus Post

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

    http://www.klauspost.com
*/

namespace RawSpeed {

BlackArea::BlackArea( int _offset, int _size, bool _isVertical ) :
offset(_offset), size(_size), isVertical(isVertical)
{

}

BlackArea::~BlackArea(void)
{
}

} // namespace RawSpeed

#include "StdAfx.h"
#include "BlackArea.h"
/*
    RawSpeed - RAW file decoder.

    Copyright (C) 2009 Klaus Post

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

    http://www.klauspost.com
*/

namespace RawSpeed {

BlackArea::BlackArea( int _offset, int _size, bool _isVertical ) :
offset(_offset), size(_size), isVertical(_isVertical)
{

}

BlackArea::~BlackArea(void)
{
}

} // namespace RawSpeed

Fix orientation of black areas (value left uninitialized).

git-svn-id: 04e88ac4940b0408b73cd6f458a224a262abaaff@355 ec705bc8-faf6-4f9b-9aff-b4916e9bedc3


#include "perf_precomp.hpp"

using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;

CV_ENUM(AgastType, AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d,
                   AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16)

typedef std::tr1::tuple<string, AgastType> File_Type_t;
typedef perf::TestBaseWithParam<File_Type_t> agast;

#define AGAST_IMAGES \
    "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
    "stitching/a3.png"

PERF_TEST_P(agast, detect, testing::Combine(
                            testing::Values(AGAST_IMAGES),
                            AgastType::all()
                          ))
{
    string filename = getDataPath(get<0>(GetParam()));
    int type = get<1>(GetParam());
    Mat frame = imread(filename, IMREAD_GRAYSCALE);

    if (frame.empty())
        FAIL() << "Unable to load source image " << filename;

    declare.in(frame);

    Ptr<FeatureDetector> fd = AgastFeatureDetector::create(20, true, type);
    ASSERT_FALSE( fd.empty() );
    vector<KeyPoint> points;

    TEST_CYCLE() fd->detect(frame, points);

    SANITY_CHECK_KEYPOINTS(points);
}

#include "perf_precomp.hpp"

using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;

CV_ENUM(AgastType, AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d,
                   AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16)

typedef std::tr1::tuple<string, AgastType> File_Type_t;
typedef perf::TestBaseWithParam<File_Type_t> agast;

#define AGAST_IMAGES \
    "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
    "stitching/a3.png"

PERF_TEST_P(agast, detect, testing::Combine(
                            testing::Values(AGAST_IMAGES),
                            AgastType::all()
                          ))
{
    string filename = getDataPath(get<0>(GetParam()));
    int type = get<1>(GetParam());
    Mat frame = imread(filename, IMREAD_GRAYSCALE);

    if (frame.empty())
        FAIL() << "Unable to load source image " << filename;

    declare.in(frame);

    Ptr<FeatureDetector> fd = AgastFeatureDetector::create(70, true, type);
    ASSERT_FALSE( fd.empty() );
    vector<KeyPoint> points;

    TEST_CYCLE() fd->detect(frame, points);

    SANITY_CHECK_KEYPOINTS(points);
}

Adjust AGAST perftest to be at parity (better) with FAST ones.


#include "filename/ast/filename-node-conditional.h"
#include "filename/ast/filename-visitor.h"

FilenameNodeConditional::FilenameNodeConditional(FilenameNodeCondition *condition, FilenameNode *ifTrue, FilenameNode *ifFalse)
	: condition(condition), ifTrue(ifTrue), ifFalse(ifFalse)
{}

FilenameNodeConditional::~FilenameNodeConditional()
{
	delete condition;
	delete ifTrue;
	delete ifFalse;
}

void FilenameNodeConditional::accept(FilenameVisitor &v) const
{
	v.visit(*this);
}

#include "filename/ast/filename-node-conditional.h"
#include "filename/ast/filename-node-condition.h"
#include "filename/ast/filename-visitor.h"

FilenameNodeConditional::FilenameNodeConditional(FilenameNodeCondition *condition, FilenameNode *ifTrue, FilenameNode *ifFalse)
	: condition(condition), ifTrue(ifTrue), ifFalse(ifFalse)
{}

FilenameNodeConditional::~FilenameNodeConditional()
{
	delete condition;
	delete ifTrue;
	delete ifFalse;
}

void FilenameNodeConditional::accept(FilenameVisitor &v) const
{
	v.visit(*this);
}

Fix warning about deleting non full type


#include <cstdlib>

#include "Application/Parameters/ApplicationParameters.h"
#include "Application/Parameters/ApplicationParametersBuilder.h"
#include "Application/Parameters/ApplicationParametersManager.h"
#include "Application/Parameters/ApplicationParametersReader.h"
#include "FileSystem/Entities/Executable.h"
#include "FileSystem/Factories/EntityFactory.h"
#include "FileSystem/Entities/Exceptions/InvalidExecutablePathException.h"
#include <memory>
#include <iostream>

using namespace clt::filesystem;
using namespace clt::filesystem::factories;
using namespace clt::filesystem::entities;
using namespace clt::filesystem::entities::exceptions;
using namespace application::parameters;

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

	if (argc < 2)
	{
		// TODO: real arguments management
		printf("not enough argument, need the path of your executable");
		return EXIT_FAILURE;
	}

	ApplicationParametersManager parametersManager(std::make_unique<ApplicationParametersBuilder>(), std::make_unique<ApplicationParametersReader>());
	parametersManager.start(argc, argv);
	ApplicationParameters parameters = parametersManager.getParameters();

	EntityFactory entityFactory;

	try
	{
		Executable executable = entityFactory.createExecutable(parameters.getExecutablePath());
		executable.execute();
	}
	catch (InvalidExecutablePathException exception) {
		std::cout << "Invalid executable path : " << std::endl << "\t - " << exception.getDescription() << std::endl;
	}

	return EXIT_SUCCESS;
}

#include <cstdlib>

#include "Application/Parameters/ApplicationParameters.h"
#include "Application/Parameters/ApplicationParametersBuilder.h"
#include "Application/Parameters/ApplicationParametersManager.h"
#include "Application/Parameters/ApplicationParametersReader.h"
#include "FileSystem/Entities/Executable.h"
#include "FileSystem/Factories/EntityFactory.h"
#include "FileSystem/Entities/Exceptions/InvalidExecutablePathException.h"
#include <memory>
#include <iostream>

using namespace clt::filesystem;
using namespace clt::filesystem::factories;
using namespace clt::filesystem::entities;
using namespace clt::filesystem::entities::exceptions;
using namespace application::parameters;

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

	ApplicationParametersManager parametersManager(std::make_unique<ApplicationParametersBuilder>(), std::make_unique<ApplicationParametersReader>());
	parametersManager.start(argc, argv);
	ApplicationParameters parameters = parametersManager.getParameters();

	EntityFactory entityFactory;

	try
	{
		Executable executable = entityFactory.createExecutable(parameters.getExecutablePath());
		executable.execute();
	}
	catch (InvalidExecutablePathException exception) {
		std::cout << "Invalid executable path : " << std::endl << "\t - " << exception.getDescription() << std::endl;
	}

	return EXIT_SUCCESS;
}

Remove test that have not to be here

Remove test that have not to be here


#include <stan/prob/distributions/univariate/continuous/Cauchy.hpp>
#include <gtest/gtest.h>

TEST(stanProbDistributionsUnivariateContinuousCauchy,headerParses) {
  EXPECT_TRUE(true);
}

#include <stan/prob/distributions/univariate/continuous/cauchy.hpp>
#include <gtest/gtest.h>

TEST(stanProbDistributionsUnivariateContinuousCauchy,headerParses) {
  EXPECT_TRUE(true);
}

Fix case of cauchy.h header in test to allow to compile on Linux.


// Use RAII types

#include <map>
#include <memory>
#include <string>
#include <vector>

int main()
{
	std::vector<int> vec = {1, 2, 3, 4, 5};
	std::map<std::string, int> map = {{"Foo", 10}, {"Bar", 20}};
	std::string str = "Some text";
	std::unique_ptr<int> ptr1 = std::make_unique<int>(8);
	std::shared_ptr<int> ptr2 = std::make_shared<int>(16);
}

// Avoid manual memory management to improve safety and reduce bugs
// and memory leaks.
//
// Every object created on [10-14] will internally manage some
// dynamically allocated memory (allocated with the `new` keyword).
// They are all, however, implemented such that they deallocate that
// memory when they are destroyed. This practice is known as RAII.
//
// The user of these classes does not need to perform manual memory
// management, reducing the risk of memory leaks and other bugs. In
// fact, the use of `new` and `delete` can be avoided entirely by
// using these RAII types.
//
// Likewise, it is good practice to ensure your own classes also
// implement the RAII idiom with the
// [rule of three](/common-tasks/rule-of-three.html)
// or [rule of zero](/common-tasks/rule-of-zero.html).

// Use RAII types

#include <map>
#include <memory>
#include <string>
#include <vector>

int main()
{
	std::vector<int> vec = {1, 2, 3, 4, 5};
	std::map<std::string, int> map = {{"Foo", 10}, {"Bar", 20}};
	std::string str = "Some text";
	std::unique_ptr<int> ptr1 = std::make_unique<int>(8);
	std::shared_ptr<int> ptr2 = std::make_shared<int>(16);
}

// Avoid manual memory management to improve safety and reduce bugs
// and memory leaks.
//
// Every object created on [10-14] will internally manage some
// dynamically allocated memory (allocated with the `new` keyword).
// They are all, however, implemented such that they deallocate that
// memory when they are destroyed. This practice is known as RAII.
//
// The user of these classes does not need to perform manual memory
// management, reducing the risk of memory leaks and other bugs. In
// fact, the use of `new` and `delete` can be avoided entirely by
// using these RAII types.
//
// Likewise, it is good practice to ensure your own classes also
// implement the RAII idiom with the
// [rule of five](/common-tasks/rule-of-five.html)
// or [rule of zero](/common-tasks/rule-of-zero.html).

Fix link from "use RAII" to rule of five


#include "brents_fun.h"

using namespace std;

double fun1(double x)
{
  return -2.0*x+1;
}

double fun2(double x)
{
  return x*x-2.0*x-3;
}
void brents_fun_test()
{
     double eta=1e-8;
     double x;
     x=brents_fun(fun1,-1.0,5.0,eta);
     if(abs(x-0.5)<eta) cout<<"brents_fun passed quadratic order test!\n";
     else cout<<"Warning!!!!brents_fun failed quadratic order test!!\n";

     x=brents_fun(fun2,1.0,5.0,eta);
     if(abs(x-3.0)<eta) cout<<"brents_fun passed quadratic order test!\n";
     else cout<<"Warning!!!!brents_fun failed quadratic order test!!\n";

}

#include "brents_fun.h"

using namespace std;

double fun1(double x)
{
  return -2.0*x+1;
}

double fun2(double x)
{
  return x*x-2.0*x-3;
}

double fun3(double x,double y)
{
  return x*x-2.0*x-1.0-y;
}

void brents_fun_test()
{
     double eta=1e-8;
     double x;
     x=brents_fun(fun1,-1.0,5.0,eta);
     if(abs(x-0.5)<eta) cout<<"brents_fun passed quadratic order test!\n";
     else cout<<"Warning!!!!brents_fun failed quadratic order test!!\n";

     x=brents_fun(fun2,1.0,5.0,eta);
     if(abs(x-3.0)<eta) cout<<"brents_fun passed quadratic order test!\n";
     else cout<<"Warning!!!!brents_fun failed quadratic order test!!\n";

     x=brents_fun([](double x) { return fun3(x, 7.0); },0.0,5.0,eta);
     if(abs(x-4.0)<eta) cout<<"brents_fun passed partially function quadratic order test!\n";
     else cout<<"Warning!!!!brents_fun failed partially function quadratic order test!!\n";
}

Add one test (example) to use a lamba.

Add one test (example) to use a lamba.


#include "AddChunksStage.h"

#include <globjects/globjects.h>

#include <gloperate/painter/AbstractCameraCapability.h>

using namespace gl;
using namespace glm;
using namespace globjects;

AddChunksStage::AddChunksStage()
:   AbstractStage("AddChunks")
{
    addInput("camera", camera);

    addOutput("chunksToAdd", chunksToAdd);
}

void AddChunksStage::initialize()
{

}

void AddChunksStage::process()
{
    std::queue<vec3> empty;
    std::swap(chunksToAdd.data(), empty);

    int directionMax = 8;
    int upMax = 3;
    int rightMax = 4;

    auto startPosition = camera.data()->eye();

    auto direction = normalize(camera.data()->center() - camera.data()->eye());
    auto up = normalize(camera.data()->up());
    auto right = normalize(cross(up, direction));

    for (int z = 0; z < directionMax; ++z)
    {
        for (int y = -upMax; y < upMax; ++y)
        {
            for (int x = -rightMax; x < rightMax; ++x)
            {
                auto newOffset = ivec3(startPosition + right * float(x) + up * float(y) + direction * float(z));

                chunksToAdd->push(vec3(newOffset));
            }
        }
    }

    invalidateOutputs();
}

#include "AddChunksStage.h"

#include <globjects/globjects.h>

#include <gloperate/painter/AbstractCameraCapability.h>

using namespace gl;
using namespace glm;
using namespace globjects;

AddChunksStage::AddChunksStage()
:   AbstractStage("AddChunks")
{
    addInput("camera", camera);

    addOutput("chunksToAdd", chunksToAdd);
}

void AddChunksStage::initialize()
{

}

void AddChunksStage::process()
{
    std::queue<vec3> empty;
    std::swap(chunksToAdd.data(), empty);

    int directionMax = 8;
    int upMax = 3;
    int rightMax = 4;

    auto startPosition = camera.data()->eye();

    auto direction = normalize(camera.data()->center() - camera.data()->eye());
    auto up = normalize(camera.data()->up());
    auto right = normalize(cross(up, direction));

    for (int z = 0; z < directionMax; ++z)
    {
        for (int y = -upMax; y < upMax; ++y)
        {
            for (int x = -rightMax; x < rightMax; ++x)
            {
                auto pos = startPosition + right * float(x) + up * float(y) + direction * float(z);
                auto newOffset = vec3(floor(pos.x), floor(pos.y), floor(pos.z));

                chunksToAdd->push(newOffset);
            }
        }
    }

    invalidateOutputs();
}

Fix rounding in chunk adding

Fix rounding in chunk adding


#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QTimer>
#include <QJSonDocument>
#include <QJsonObject>
#include <QDebug>

#include "../QPubNub.h"

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

    QNetworkAccessManager networkAccessManager;

    QPubNub pubnub(&networkAccessManager);
    pubnub.connect(&pubnub, &QPubNub::trace, [](QString message) {
      qDebug() << "Trace:" << qPrintable(message);
    });
    pubnub.time();
    pubnub.setPublishKey("demo");
    pubnub.setSubscribeKey("demo");
    pubnub.connect(&pubnub, &QPubNub::error, [](QString message, int code) {
      qDebug() << "error:" << qPrintable(message);
    });
    pubnub.setCipherKey("enigma");
    pubnub.publish("qwertz", QJsonValue(QString("test")));
    pubnub.subscribe("qwertz");
    pubnub.connect(&pubnub, &QPubNub::message, [](QJsonValue value, QString timeToken, QString channel) {
      qDebug().nospace() << "[" << qPrintable(channel) << "]:" << value;
    });

    return a.exec();
}

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QTimer>
#include <QJSonDocument>
#include <QJsonObject>
#include <QDebug>

#include "../QPubNub.h"

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

    QNetworkAccessManager networkAccessManager;

    QPubNub pubnub(&networkAccessManager);
    pubnub.connect(&pubnub, &QPubNub::trace, [](QString message) {
      qDebug() << "Trace:" << qPrintable(message);
    });
    pubnub.time();
    pubnub.setPublishKey("demo");
    pubnub.setSubscribeKey("demo");
    pubnub.connect(&pubnub, &QPubNub::error, [](QString message, int /* code */) {
      qDebug() << "error:" << qPrintable(message);
    });
    pubnub.setCipherKey("enigma");
    pubnub.publish("qwertz", QJsonValue(QString("test")));
    pubnub.subscribe("qwertz");
    pubnub.connect(&pubnub, &QPubNub::message, [](QJsonValue value, QString timeToken, QString channel) {
      qDebug().nospace() << "[" << qPrintable(channel) << "]:" << value;
    });

    return a.exec();
}

Fix warning for unreferenced parameter

Fix warning for unreferenced parameter


// Test for the leak_check_at_exit flag.
// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
// RUN: %clangxx_lsan %s -o %t
// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont

#include <stdio.h>
#include <stdlib.h>
#include <sanitizer/lsan_interface.h>

int main(int argc, char *argv[]) {
  fprintf(stderr, "Test alloc: %p.\n", malloc(1337));
  if (argc > 1)
    __lsan_do_leak_check();
  return 0;
}

// CHECK-do: SUMMARY: {{(Leak|Address)}}Sanitizer:
// CHECK-dont-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:

// Test for the leak_check_at_exit flag.
// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
// RUN: %clangxx_lsan %s -o %t
// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont

#include <stdio.h>
#include <stdlib.h>
#include <sanitizer/lsan_interface.h>

int main(int argc, char *argv[]) {
  fprintf(stderr, "Test alloc: %p.\n", malloc(1337));
  if (argc > 1)
    __lsan_do_leak_check();
  return 0;
}

// CHECK-do: SUMMARY: {{(Leak|Address)}}Sanitizer:
// CHECK-dont-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:

Fix a typo in a test.

[lsan] Fix a typo in a test.

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


#include "TwoLevelDetection.h"
#include <opencv2/imgproc/imgproc.hpp>

void TwoLevelDetection(const cv::Mat& input, cv::Mat& output, double detectionLevel, double measurementLevel, TwoLevelDetectionTemp& temp)
{
    if (measurementLevel > detectionLevel) {
        throw std::runtime_error("TwoLevelDetection: it is required that measurementLevel <= detectionLevel");
    }

    cv::threshold(input, output, measurementLevel, 1, cv::THRESH_BINARY);

    temp.contours.clear();
    cv::findContours(output, temp.contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);

    temp.mask.create(input.size(), CV_8UC1);

    output.setTo(0);

    for (size_t i = 0, end = temp.contours.size(); i < end; ++i) {
        temp.mask.setTo(0);
        cv::drawContours(temp.mask, temp.contours, static_cast<int>(i), 255, -1);

        double minVal, maxVal;
        cv::minMaxIdx(input, &minVal, &maxVal, NULL, NULL, temp.mask);

        if (maxVal >= detectionLevel) {
            output.setTo(1, temp.mask);
        }
    }
}

#include "TwoLevelDetection.h"
#include <opencv2/imgproc/imgproc.hpp>

void TwoLevelDetection(const cv::Mat& input, cv::Mat& output, double detectionLevel, double measurementLevel, TwoLevelDetectionTemp& temp)
{
    if (measurementLevel > detectionLevel) {
        throw std::runtime_error("TwoLevelDetection: it is required that measurementLevel <= detectionLevel");
    }

    cv::threshold(input, output, measurementLevel, 1, cv::THRESH_BINARY);

    temp.contours.clear();
    cv::findContours(output, temp.contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);

    temp.mask.create(input.size(), CV_8UC1);

    output.setTo(0);

    for (size_t i = 0, end = temp.contours.size(); i < end; ++i) {
        temp.mask.setTo(0);
        cv::drawContours(temp.mask, temp.contours, static_cast<int>(i), 255, -1);

        double minVal, maxVal;
        cv::minMaxIdx(input, &minVal, &maxVal, NULL, NULL, temp.mask);

        if (maxVal >= detectionLevel) {
            output.setTo(std::numeric_limits<unsigned char>::max(), temp.mask);
        }
    }
}

Change two-level detection result output to 255 (was 1).


#include "cropview.hpp"

CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene) {
    setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
    setCursor(QCursor(Qt::CrossCursor));
}

void CropView::keyPressEvent(QKeyEvent *e) {
    if (e->key() == Qt::Key_Escape) {
        close();
        e->accept();
        return;
    }
    QGraphicsView::keyPressEvent(e);
}

#include "cropview.hpp"

CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene) {
    setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
    setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
    setCursor(QCursor(Qt::CrossCursor));
}

void CropView::keyPressEvent(QKeyEvent *e) {
    if (e->key() == Qt::Key_Escape) {
        close();
        e->accept();
        return;
    }
    QGraphicsView::keyPressEvent(e);
}

Fix an issue with possible minimizing of CropEditor by a WM


// Copyright (c) 2016-2018 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 <wallet/test/wallet_test_fixture.h>

#include <rpc/server.h>
#include <wallet/db.h>
#include <wallet/wallet.h>

CWallet *pwalletMain;

WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
    TestingSetup(chainName)
{
    bitdb.MakeMock();

    bool fFirstRun;
    std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
    pwalletMain = new CWallet(std::move(dbw));
    pwalletMain->LoadWallet(fFirstRun);
    RegisterValidationInterface(pwalletMain);

    RegisterWalletRPCCommands(tableRPC);
}

WalletTestingSetup::~WalletTestingSetup()
{
    UnregisterValidationInterface(pwalletMain);
    delete pwalletMain;
    pwalletMain = nullptr;

    bitdb.Flush(true);
    bitdb.Reset();
}

// Copyright (c) 2016-2018 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 <wallet/test/wallet_test_fixture.h>

#include <rpc/server.h>
#include <wallet/db.h>
#include <wallet/wallet.h>

std::unique_ptr<CWallet> pwalletMain;

WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
    TestingSetup(chainName)
{
    bitdb.MakeMock();

    bool fFirstRun;
    std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
    pwalletMain = std::unique_ptr<CWallet>(new CWallet(std::move(dbw)));
    pwalletMain->LoadWallet(fFirstRun);
    RegisterValidationInterface(pwalletMain.get());

    RegisterWalletRPCCommands(tableRPC);
}

WalletTestingSetup::~WalletTestingSetup()
{
    UnregisterValidationInterface(pwalletMain.get());
    pwalletMain.reset();

    bitdb.Flush(true);
    bitdb.Reset();
}

Use unique_ptr for pwalletMain (CWallet)


#define SYS_CLOCK_GETTIME 263
#include "linux_clock.cpp"

#ifdef BITS_64
#define SYS_CLOCK_GETTIME 113
#endif

#ifdef BITS_32
#define SYS_CLOCK_GETTIME 263
#endif

#include "linux_clock.cpp"

Fix a syscall number for 64-bit arm

Fix a syscall number for 64-bit arm


#include "Halide.h"
#include <stdio.h>
#include <future>

using namespace Halide;

static std::atomic<int> foo;

int main(int argc, char **argv) {
    // Test if the compiler itself is thread-safe. This test is
    // intended to be run in a thread-sanitizer.
    std::vector<std::future<void>> futures;
    for (int i = 0; i < 1000; i++) {
        futures.emplace_back(std::async(std::launch::async, []{
            Func f;
            Var x;
            f(x) = x;
            f.realize(100);
        }));
    }

    for (auto &f : futures) {
        f.wait();
    }

    printf("Success!\n");

    return 0;
}

#include "Halide.h"
#include <stdio.h>
#include <thread>

using namespace Halide;

int main(int argc, char **argv) {
    // Test if the compiler itself is thread-safe. This test is
    // intended to be run in a thread-sanitizer.

    // std::thread has implementation-dependent behavior; some implementations
    // may refuse to create an arbitrary number. So let's create a smallish
    // number (8) and have each one do enough work that contention is likely
    // to be encountered.
    constexpr int total_iters = 1024;
    constexpr int num_threads = 8;

    std::vector<std::thread> threads;
    for (int i = 0; i < num_threads; i++) {
        threads.emplace_back([]{
            for (int i = 0; i < (total_iters / num_threads); i++) {
                Func f;
                Var x;
                f(x) = x;
                f.realize(100);
            }
        });
    }

    for (auto &t : threads) {
        t.join();
    }

    printf("Success!\n");

    return 0;
}

Use a pool of 8 threads.

Use a pool of 8 threads.


#include "application.hpp"
#include <SDL2/SDL.h>
#include <stdexcept>

Application *Application::instance_ = nullptr;

Application::Application(int &argc, char **argv)
{
    if (instance_ != nullptr)
        throw std::runtime_error("The program can have only one instance of Application");
    instance_ = this;
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
        throw std::runtime_error("SDL_Init Error: " + std::string(SDL_GetError()));
}

Application::~Application()
{
    SDL_Quit();
    instance_ = nullptr;
}

int Application::exec()
{
    bool done = false;
    while (!done)
    {
        SDL_Event e;
        while (SDL_PollEvent(&e))
        {
            switch (e.type)
            {
            case SDL_QUIT:
                done = true;
                break;
            }
        }
    }
    return 0;
}

Application *Application::instance()
{
    return instance_;
}

void Application::addWidget(Widget *)
{

}

void Application::removeWidget(Widget *)
{

}

#include "application.hpp"
#include <SDL2/SDL.h>
#include <stdexcept>
#include <string>

Application *Application::instance_ = nullptr;

Application::Application(int &argc, char **argv)
{
    if (instance_ != nullptr)
        throw std::runtime_error("The program can have only one instance of Application");
    instance_ = this;
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
        throw std::runtime_error("SDL_Init Error: " + std::string(SDL_GetError()));
}

Application::~Application()
{
    SDL_Quit();
    instance_ = nullptr;
}

int Application::exec()
{
    bool done = false;
    while (!done)
    {
        SDL_Event e;
        while (SDL_PollEvent(&e))
        {
            switch (e.type)
            {
            case SDL_QUIT:
                done = true;
                break;
            }
        }
    }
    return 0;
}

Application *Application::instance()
{
    return instance_;
}

void Application::addWidget(Widget *)
{

}

void Application::removeWidget(Widget *)
{

}

Fix build for Mac OS X

Fix build for Mac OS X


#include "TestIODevice.hpp"

#include <iostream>

void TestIODevice::fakeWrite(const QByteArray& data)
{
    readStore.append(data);
    emit readyRead();
}

qint64 TestIODevice::readData(char* data, qint64 maxSize)
{
    auto readData = readStore.left(maxSize);
    //std::cerr << "Read " << readData.size() << " byte(s) from mock IO device, requested " << maxSize << std::endl;
    qstrcpy(data, readData.constData());
    if (readStore.size() == readData.size()) {
        readStore.clear();
    } else {
        readStore = readStore.right(readStore.size() - readData.size());
    }
    return readData.size();
}

qint64 TestIODevice::writeData(const char* data, qint64 maxSize)
{
    writeStore.append(data, maxSize);
    return maxSize;
}

#include "TestIODevice.hpp"

#include <iostream>
#include <cstring>

void TestIODevice::fakeWrite(const QByteArray& data)
{
    readStore.append(data);
    emit readyRead();
}

qint64 TestIODevice::readData(char* data, qint64 maxSize)
{
    auto readData = readStore.left(maxSize);
    //std::cerr << "Read " << readData.size() << " byte(s) from mock IO device, requested " << maxSize << std::endl;
    memcpy(data, readData.constData(), readData.size());
    if (readStore.size() == readData.size()) {
        readStore.clear();
    } else {
        readStore = readStore.right(readStore.size() - readData.size());
    }
    return readData.size();
}

qint64 TestIODevice::writeData(const char* data, qint64 maxSize)
{
    writeStore.append(data, maxSize);
    return maxSize;
}

Use memcpy, not qstrcpy, when copying data in the test device


#include "tests-base.hpp"

#include "helpers-casemapping.hpp"
#include "helpers-strings.hpp"

TEST(SpecialCasing, LithuanianRemoveDotAbove)
{
	// Remove DOT ABOVE after "i" with upper or titlecase

	// U+0049 U+0307
	// U+0069

	EXPECT_STREQ("lt-LT", setlocale(LC_ALL, "lt-LT"));
	EXPECT_CASEMAPPING_EQ("i\xCC\x87", "i\xCC\x87", "I", "I");
	setlocale(LC_ALL, "C");
}

#include "tests-base.hpp"

#include "helpers-casemapping.hpp"
#include "helpers-strings.hpp"

TEST(SpecialCasing, LithuanianRemoveDotAbove)
{
	EXPECT_STREQ("lt-LT", setlocale(LC_ALL, "lt-LT"));

	// Remove DOT ABOVE after "i" with upper or titlecase

	EXPECT_CASEMAPPING_EQ("i\xCC\x87", "i\xCC\x87", "I", "I"); // COMBINING DOT ABOVE

	setlocale(LC_ALL, "C");
}

TEST(SpecialCasing, LithuanianIntroduceExplicitDot)
{
	EXPECT_STREQ("lt-LT", setlocale(LC_ALL, "lt-LT"));

	// Introduce an explicit dot above when lowercasing capital I's and J's
	// whenever there are more accents above.
	// (of the accents used in Lithuanian: grave, acute, tilde above, and ogonek)

	EXPECT_CASEMAPPING_EQ("I", "i\xCC\x87", "I", "I"); // LATIN CAPITAL LETTER I
	EXPECT_CASEMAPPING_EQ("J", "j\xCC\x87", "J", "J"); // LATIN CAPITAL LETTER J
	EXPECT_CASEMAPPING_EQ("\xC4\xAE", "\xC4\xAF\xCC\x87", "\xC4\xAE", "\xC4\xAE"); // LATIN CAPITAL LETTER I WITH OGONEK
	EXPECT_CASEMAPPING_EQ("\xC3\x8C", "i\xCC\x87\xCC\x80", "\xC3\x8C", "\xC3\x8C"); // LATIN CAPITAL LETTER I WITH GRAVE
	EXPECT_CASEMAPPING_EQ("\xC3\x8D", "i\xCC\x87\xCC\x81", "\xC3\x8D", "\xC3\x8D"); // LATIN CAPITAL LETTER I WITH ACUTE
	EXPECT_CASEMAPPING_EQ("\xC4\xA8", "i\xCC\x87\xCC\x83", "\xC4\xA8", "\xC4\xA8"); // LATIN CAPITAL LETTER I WITH TILDE

	setlocale(LC_ALL, "C");
}

Add tests for Lithuanian special case mapping.


/*
 * 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 "SkColorMatrixFilter.h"

static SkScalar byte_to_scale(U8CPU byte) {
    if (0xFF == byte) {
        // want to get this exact
        return 1;
    } else {
        return byte * 0.00392156862745f;
    }
}

SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
    SkColorMatrix matrix;
    matrix.setScale(byte_to_scale(SkColorGetR(mul)),
                    byte_to_scale(SkColorGetG(mul)),
                    byte_to_scale(SkColorGetB(mul)),
                    1);
    matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
                         SkIntToScalar(SkColorGetG(add)),
                         SkIntToScalar(SkColorGetB(add)),
                         0);
    return SkColorMatrixFilter::Create(matrix);
}

/*
 * 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 "SkColorMatrixFilter.h"

static SkScalar byte_to_scale(U8CPU byte) {
    if (0xFF == byte) {
        // want to get this exact
        return 1;
    } else {
        return byte * 0.00392156862745f;
    }
}

SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
    if (0 == add) {
        return SkColorFilter::CreateModeFilter(mul | SK_ColorBLACK,
                                               SkXfermode::Mode::kModulate_Mode);
    }
    SkColorMatrix matrix;
    matrix.setScale(byte_to_scale(SkColorGetR(mul)),
                    byte_to_scale(SkColorGetG(mul)),
                    byte_to_scale(SkColorGetB(mul)),
                    1);
    matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
                         SkIntToScalar(SkColorGetG(add)),
                         SkIntToScalar(SkColorGetB(add)),
                         0);
    return SkColorMatrixFilter::Create(matrix);
}

Simplify LightingFilter in add-free case am: 0698300cc5
am: a184d5e49d

* commit 'a184d5e49d173dd5b783a2022b28f45f70b665ee':
  Simplify LightingFilter in add-free case

Change-Id: I301638b73e0e52e1371063d69a5e7dcdd12edfb7


// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -O3 -emit-llvm -gline-tables-only -S -verify -o /dev/null
// REQUIRES: x86-registered-target

// Test verifies optimization failures generated by the backend are handled
// correctly by clang. LLVM tests verify all of the failure conditions.

void test_switch(int *A, int *B, int Length) {
#pragma clang loop vectorize(enable) unroll(disable)
  for (int i = 0; i < Length; i++) {
    /* expected-warning {{loop not vectorized: failed explicitly specified loop vectorization}} */ switch (A[i]) {
    case 0:
      B[i] = 1;
      break;
    case 1:
      B[i] = 2;
      break;
    default:
      B[i] = 3;
    }
  }
}

// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -O3 -emit-llvm -gline-tables-only -S -verify -o /dev/null
// REQUIRES: x86-registered-target

// Test verifies optimization failures generated by the backend are handled
// correctly by clang. LLVM tests verify all of the failure conditions.

void test_switch(int *A, int *B, int Length) {
#pragma clang loop vectorize(enable) unroll(disable)
  /* expected-warning {{loop not vectorized: failed explicitly specified loop vectorization}} */ for (int i = 0; i < Length; i++) {
    switch (A[i]) {
    case 0:
      B[i] = 1;
      break;
    case 1:
      B[i] = 2;
      break;
    default:
      B[i] = 3;
    }
  }
}

Adjust test to handle fallout from r217102.

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


#include "WindowsAPIs.h"
#include "TaskIcon.h"

INT WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR, INT)
{
    hinstance = hinst;

    TaskIcon().MessageLoop();

    return 0;
}

#include "WindowsAPIs.h"
#include "TaskIcon.h"

INT WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR, INT)
{
    hinstance = hinst;

    XInputEnable(TRUE);
    TaskIcon().MessageLoop();

    return 0;
}

Enable XINPUT right away maybe?

Enable XINPUT right away maybe?


#include <SegmentList.hh>

#include "catch.hpp"

SCENARIO("Kernel heap allocator SegmentList", "[kernelheap]")
{
   GIVEN("A segment list")
   {
      SegmentList list;

      WHEN("The list is empty")
      {
         THEN("The count of the list is zero")
         {
            CHECK(list.count() == 0);
         }

         AND_WHEN("Creating an iterator")
         {
            auto i = list.getIterator();

            THEN("The iterator has no next item")
            {
               CHECK(i.hasNext() == false);
            }
         }
      }
   }
}

#include <SegmentList.hh>

#include "catch.hpp"

SCENARIO("Kernel heap allocator SegmentList", "[kernelheap]")
{
   GIVEN("A segment list")
   {
      SegmentList list;

      WHEN("The list is empty")
      {
         THEN("The count of the list is zero")
         {
            CHECK(list.count() == 0);
         }

         AND_WHEN("Creating an iterator")
         {
            auto i = list.getIterator();

            THEN("The iterator has no next item")
            {
               CHECK(i.hasNext() == false);
            }
         }
      }

      WHEN("An item is added")
      {
         Segment* s1 = new Segment();
         s1->setSize(1);

         list.add(s1);

         AND_WHEN("Creating an iterator")
         {
            auto i = list.getIterator();

            THEN("Iterator has a next item")
            {
               CHECK(i.hasNext() == true);

               AND_THEN("The next item is the item added")
               {
                  CHECK(&i.getNext() == s1);

                  AND_THEN("The iterator has no next item")
                  {
                     CHECK(i.hasNext() == false);
                  }
               }
            }
         }
      }

      WHEN("Three items are present")
      {
         Segment* s2 = new Segment();
         Segment* s3 = new Segment();

         s2->setSize(2);
         s3->setSize(3);

         list.add(s2);
         list.add(s3);
      }
   }
}

Add more tests for iteration

Add more tests for iteration


#include "main_action_planner_node.hpp"

int main(int argc, char** argv) {
  return 0;
}

#include "main_action_planner_node.hpp"

int main(int argc, char** argv) {
  ros::init(argc, argv, "main_action_planner_node");
  ros::NodeHandle nh("~");

  return 0;
}

Add minimum code to main func of MAP node.

Add ros::init.
Add ros::NodeHandle("~").


#include "cg-operator-common.h"
#include <binpac/autogen/operators/function.h>

using namespace binpac;
using namespace binpac::codegen;

void CodeBuilder::visit(expression::operator_::function::Call* i)
{
    auto func = ast::checkedCast<expression::Function>(i->op1());
    auto args = callParameters(i->op2());

    shared_ptr<hilti::Expression> cookie = nullptr;

    if ( in<declaration::Function>() || in<declaration::Hook>() )
        cookie = hilti::builder::id::create("__cookie", i->location());
    else
        cookie = hilti::builder::reference::createNull(i->location());

    auto result = cg()->hiltiCall(func, args, cookie);
    setResult(result);
}

#include "cg-operator-common.h"
#include <binpac/autogen/operators/function.h>

using namespace binpac;
using namespace binpac::codegen;

void CodeBuilder::visit(expression::operator_::function::Call* i)
{
    auto func = ast::checkedCast<expression::Function>(i->op1());
    auto args = callParameters(i->op2());

    shared_ptr<hilti::Expression> cookie = nullptr;

    if ( in<declaration::Function>() || in<declaration::Hook>() || in<declaration::Type>() )
        cookie = hilti::builder::id::create("__cookie", i->location());
    else
        cookie = hilti::builder::reference::createNull(i->location());

    auto result = cg()->hiltiCall(func, args, cookie);
    setResult(result);
}

Fix for in-unit hooks not passing the cookie on to C.


#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;

    runUnitTests();

//    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->show();

    return app->exec();
}

#include <QtQuick>

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

#include "factor.h"

int main(int argc, char *argv[])
{
    // 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;

    runUnitTests();

//    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();
}

Set some names and titles just in case they are useful to set.


//===- IListIterator.cpp --------------------------------------------------===//
//
//                            The Bold Project
//
//  This file is distributed under the New BSD License.
//  See LICENSE for details.
//
//===----------------------------------------------------------------------===//
#include <bold/ADT/IListIterator.h>
#include <cassert>

using namespace bold;

//===----------------------------------------------------------------------===//
// IListIteratorBase
//===----------------------------------------------------------------------===//
IListIteratorBase::IListIteratorBase()
  : m_pNodePtr(NULL) {
}

IListIteratorBase::IListIteratorBase(NodeBase* pNode)
  : m_pNodePtr(pNode) {
}

void IListIteratorBase::advance()
{
  assert(NULL != m_pNodePtr && "trivial iterator can not advance");
  m_pNodePtr = m_pNodePtr->getNext();
}

void IListIteratorBase::retreat()
{
  assert(NULL != m_pNodePtr && "trivial iterator can not retreat");
  m_pNodePtr = m_pNodePtr->getPrev();
}

//===- IListIterator.cpp --------------------------------------------------===//
//
//                            The Bold Project
//
//  This file is distributed under the New BSD License.
//  See LICENSE for details.
//
//===----------------------------------------------------------------------===//
#include <bold/ADT/IListIterator.h>
#include <cassert>

using namespace bold;

//===----------------------------------------------------------------------===//
// IListIteratorBase
//===----------------------------------------------------------------------===//
IListIteratorBase::IListIteratorBase()
  : m_pNodePtr(NULL) {
}

IListIteratorBase::IListIteratorBase(IListNodeBase* pNode)
  : m_pNodePtr(pNode) {
}

void IListIteratorBase::advance()
{
  assert(NULL != m_pNodePtr && "trivial iterator can not advance");
  m_pNodePtr = m_pNodePtr->getNext();
}

void IListIteratorBase::retreat()
{
  assert(NULL != m_pNodePtr && "trivial iterator can not retreat");
  m_pNodePtr = m_pNodePtr->getPrev();
}

Use IListNodeBase instead of type redefinition.


#include <boost/python.hpp>

#include "mue_algorithm.h"
#include "teams.h"
#include "distances.h"
#include "seen_table.h"

char const * peng() {
	return mue::peng().c_str();
}

BOOST_PYTHON_MODULE (_pymue)
{
	using namespace boost::python;

	def ("peng", peng);

	class_<mue::Team>("Team", init<int>())
		.def("id", &mue::Team::id);

	class_<mue::Distance_matrix>("DistanceMatrix", init<int>())
		.def("set_cost", &mue::Distance_matrix::set_cost)
		.def("lookup", &mue::Distance_matrix::lookup);

	class_<mue::Seen_table>("SeenTable", init<int>())
		.def("clone", &mue::Seen_table::clone)
		.def("generation", &mue::Seen_table::generation)
		.def("seen", &mue::Seen_table::seen)
		.def("add_meeting", &mue::Seen_table::add_meeting);
}

#include <boost/python.hpp>

#include "mue_algorithm.h"
#include "teams.h"
#include "distances.h"

#include "seen_table_wrapper.h"

char const * peng() {
	return mue::peng().c_str();
}

BOOST_PYTHON_MODULE (_pymue)
{
	using namespace boost::python;

	def ("peng", peng);

	class_<mue::Team>("Team", init<int>())
		.def("id", &mue::Team::id);

	class_<mue::Distance_matrix>("DistanceMatrix", init<int>())
		.def("set_cost", &mue::Distance_matrix::set_cost)
		.def("lookup", &mue::Distance_matrix::lookup);

	class_<pymue::Seen_table_wrapper>("SeenTable", init<int>())
		.def("clone", &pymue::Seen_table_wrapper::clone)
		.def("generation", &pymue::Seen_table_wrapper::generation)
		.def("seen", &pymue::Seen_table_wrapper::seen)
		.def("add_meeting", &pymue::Seen_table_wrapper::add_meeting);
}

Replace Seen_table with Seen_table_wrapper in the binding

Signed-off-by: Jan Losinski <577c4104c61edf9f052c616c0c23e67bef4a9955@wh2.tu-dresden.de>


//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads

// <mutex>

// class mutex;

// void lock();

#include <mutex>
#include <thread>
#include <cstdlib>
#include <cassert>

#include <iostream>

std::mutex m;

typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef std::chrono::milliseconds ms;
typedef std::chrono::nanoseconds ns;

void f()
{
    time_point t0 = Clock::now();
    m.lock();
    time_point t1 = Clock::now();
    m.unlock();
    ns d = t1 - t0 - ms(250);
    assert(d < ms(50));  // within 50ms
}

int main()
{
    m.lock();
    std::thread t(f);
    std::this_thread::sleep_for(ms(250));
    m.unlock();
    t.join();
}

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads

// FLAKY_TEST.

// <mutex>

// class mutex;

// void lock();

#include <mutex>
#include <thread>
#include <cstdlib>
#include <cassert>

#include <iostream>

std::mutex m;

typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
typedef std::chrono::milliseconds ms;
typedef std::chrono::nanoseconds ns;

void f()
{
    time_point t0 = Clock::now();
    m.lock();
    time_point t1 = Clock::now();
    m.unlock();
    ns d = t1 - t0 - ms(250);
    assert(d < ms(50));  // within 50ms
}

int main()
{
    m.lock();
    std::thread t(f);
    std::this_thread::sleep_for(ms(250));
    m.unlock();
    t.join();
}

Mark another test as flaky

Mark another test as flaky

Reported on the NetBSD 8 buildbot.

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


/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#include <geos/geom/Coordinate.h>
#include <geos/platform.h> // for ISNAN

#include <sstream>
#include <string>

#ifndef GEOS_INLINE
# include <geos/geom/Coordinate.inl>
#endif

using namespace std;

namespace geos {
namespace geom { // geos::geom

Coordinate Coordinate::nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);

Coordinate&
Coordinate::getNull()
{
	return nullCoord;
}

string
Coordinate::toString() const
{
	ostringstream s;
	s<<*this;
	return s.str();
}

std::ostream& operator<< (std::ostream& os, const Coordinate& c)
{
	if ( ISNAN(c.z) )
	{
		os << c.x << " " << c.y;
	} else {
		os << c.x << " " << c.y << " " << c.z;
	}
	return os;
}

} // namespace geos::geom
} // namespace geos

/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#include <geos/geom/Coordinate.h>
#include <geos/platform.h> // for ISNAN

#include <sstream>
#include <string>
#include <iomanip>

#ifndef GEOS_INLINE
# include <geos/geom/Coordinate.inl>
#endif

using namespace std;

namespace geos {
namespace geom { // geos::geom

Coordinate Coordinate::nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);

Coordinate&
Coordinate::getNull()
{
	return nullCoord;
}

string
Coordinate::toString() const
{
	ostringstream s;
	s << std::setprecision(17) << *this;
	return s.str();
}

std::ostream& operator<< (std::ostream& os, const Coordinate& c)
{
	if ( ISNAN(c.z) )
	{
		os << c.x << " " << c.y;
	} else {
		os << c.x << " " << c.y << " " << c.z;
	}
	return os;
}

} // namespace geos::geom
} // namespace geos

Use 18 significant digits for TopologyException point coordinates

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@3522 5242fede-7e19-0410-aef8-94bd7d2200fb


#include "insertion.hpp"
#include "swap.hpp"

void insertion(int *data, const int size_of_data)
{
    for(int i = 0; i < size_of_data; ++i)
    {
        int j;
        for(j = i; j >= 0 && data[j] < data[i]; --j);
        swap(data[i], data[j]);
    }
}

#include "insertion.hpp"
#include "swap.hpp"

void insertion(int *data, const int size_of_data)
{
    for(int i = 0; i < size_of_data; ++i)
    {
        for(int j = i; j > 0 && data[j] < data[j - 1]; --j) swap(data[j], data[j - 1]);
    }
}

Fix the logic of Insertion sort which is not working


#include <Bull/Core/Exception/RuntimeError.hpp>

#include <Bull/Render/Buffer/VertexArrayObject.hpp>
#include <Bull/Render/OpenGL.hpp>

namespace Bull
{
    VertexArrayObject::VertexArrayObject() :
        m_vao(0)
    {
        gl::genVertexArrays(1, &m_vao);

        if(!gl::isVertexArray(m_vao))
        {
            throw RuntimeError("Failed to create VAO");
        }
    }

    VertexArrayObject::~VertexArrayObject()
    {
        gl::deleteVertexArrays(1, &m_vao);
    }

    void VertexArrayObject::runBound(const Functor<void>& functor) const
    {
        gl::bindVertexArray(m_vao);
        functor();
        gl::bindVertexArray(0);
    }
}

#include <Bull/Core/Exception/RuntimeError.hpp>

#include <Bull/Render/Buffer/VertexArrayObject.hpp>
#include <Bull/Render/OpenGL.hpp>

namespace Bull
{
    VertexArrayObject::VertexArrayObject() :
        m_vao(0)
    {
        gl::genVertexArrays(1, &m_vao);

        if(!m_vao)
        {
            throw RuntimeError("Failed to create VAO");
        }
    }

    VertexArrayObject::~VertexArrayObject()
    {
        gl::deleteVertexArrays(1, &m_vao);
    }

    void VertexArrayObject::runBound(const Functor<void>& functor) const
    {
        gl::bindVertexArray(m_vao);
        functor();
        gl::bindVertexArray(0);
    }
}

[Render/Texture] Rename creation method to avoid ambiguity with resource loading


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

BUG=40845
TEST=none
TBR=gman

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

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


// 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/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

// Flaky, http://crbug.com/46601.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_Popup) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_main")) << message_;
}

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

  ASSERT_TRUE(RunExtensionTest("popup/popup_from_infobar")) << message_;
}

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

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

// Times out. See http://crbug.com/46601.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Popup) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("popup/popup_main")) << message_;
}

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

  ASSERT_TRUE(RunExtensionTest("popup/popup_from_infobar")) << message_;
}

Disable ExtensionApiTest.Popup. It's been timing out for the last 750+ runs.

TBR=michaeln

BUG=46601
TEST=ExtensionApiTest.FLAKY_Popup no longer runs
Review URL: http://codereview.chromium.org/3603003

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

Former-commit-id: 8c32ddc645bcc64c776471bb16739520ec1b078b


#include "stdafx.h"
#include <string>
#include "Logger.h"

#ifdef _WIN64
#define PYTHONPATH L"python-embed-amd64"
#else
#define PYTHONPATH L"python-embed-win32"
#endif

EXTERN_C IMAGE_DOS_HEADER __ImageBase;

std::wstring getPythonPath()
{
    // https://stackoverflow.com/questions/6924195/get-dll-path-at-runtime
    WCHAR DllPath[MAX_PATH] = { 0 };
    if (GetModuleFileNameW((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath)) == 0)
    {
        LOG_ERROR("Error getting Pythia DLL path");
        return L"";
    }
    std::wstring DllPath_s = DllPath;

    std::wstring directory;
    const size_t last_slash_idx = DllPath_s.rfind(L'\\');
    if (std::string::npos != last_slash_idx)
    {
        directory = DllPath_s.substr(0, last_slash_idx);
    }

    std::wstring pythonPath = directory + L"\\" + PYTHONPATH;
    return pythonPath;
}

#include "stdafx.h"
#include <string>
#include "Logger.h"

#ifdef _WIN64
#define EMBEDDEDPYTHONPATH L"python-embed-amd64"
#else
#define EMBEDDEDPYTHONPATH L"python-embed-win32"
#endif

EXTERN_C IMAGE_DOS_HEADER __ImageBase;

std::wstring getPythonPath()
{
    // https://stackoverflow.com/questions/6924195/get-dll-path-at-runtime
    WCHAR DllPath[MAX_PATH] = { 0 };
    if (GetModuleFileNameW((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath)) == 0)
    {
        LOG_ERROR("Error getting Pythia DLL path");
        return L"";
    }
    std::wstring DllPath_s = DllPath;

    std::wstring directory;
    const size_t last_slash_idx = DllPath_s.rfind(L'\\');
    if (std::string::npos != last_slash_idx)
    {
        directory = DllPath_s.substr(0, last_slash_idx);
    }

    std::wstring pythonPath = directory + L"\\" + EMBEDDEDPYTHONPATH;
    return pythonPath;
}

Change define name to prevent name clashes with the python interpreter