/**
 *  @copyright Copyright 2017 The J-PET Framework Authors. All rights reserved.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may find a copy of the License in the LICENCE file.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *  @file main.cpp
 */

#include "JPetManager/JPetManager.h"
#include "ImageReco.h"
#include "SinogramCreator.h"
using namespace std;

int main(int argc, const char* argv[])
{
  JPetManager& manager = JPetManager::getManager();

  manager.registerTask<ImageReco>("ImageReco");
  manager.registerTask<SinogramCreator>("SinogramCreator");

  manager.useTask("ImageReco", "unk.evt", "reco");
  manager.useTask("SinogramCreator", "unk.evt", "sino");

  manager.run(argc, argv);
}

/**
 *  @copyright Copyright 2017 The J-PET Framework Authors. All rights reserved.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may find a copy of the License in the LICENCE file.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *  @file main.cpp
 */

#include "JPetManager/JPetManager.h"
#include "ImageReco.h"
#include "SinogramCreator.h"
#include "SinogramCreatorMC.h"
using namespace std;

int main(int argc, const char* argv[])
{
  JPetManager& manager = JPetManager::getManager();

  manager.registerTask<ImageReco>("ImageReco");
  manager.registerTask<SinogramCreator>("SinogramCreator");
  manager.registerTask<SinogramCreator>("SinogramCreatorMC");

  manager.useTask("ImageReco", "unk.evt", "reco");
  manager.useTask("SinogramCreator", "unk.evt", "sino");
  manager.useTask("SinogramCreatorMC", "unk.evt", "sino");

  manager.run(argc, argv);
}

Add SinogramCreatorMC to manager list


#include <cstdarg>
#include <ncurses.h>

static const char* mes = NULL;
extern bool showing_message;
bool showing_message = false;

static void showmes() {
    int y,x,rows,_;
    getyx(stdscr,y,x);
    getmaxyx(stdscr,rows,_);
    move(rows-1,0);

    clrtoeol();
    printw(mes);

    move(y,x);
}

void hook_show_message() {
    if(showing_message) {
        showmes();
        showing_message = false;
    }
}

void show_message(const char* message) {
    showing_message = true;
    mes = message;
    showmes();
}

void clear_message() {
    mes = "";
    showmes();
}

#include <cstdarg>
#include <ncurses.h>

static const char* mes = NULL;
extern bool showing_message;
bool showing_message = false;

static void showmes() {
    int y,x,rows,_;
    getyx(stdscr,y,x);
    getmaxyx(stdscr,rows,_);
    move(rows-1,0);

    clrtoeol();
    printw("%s",mes);

    move(y,x);
}

void hook_show_message() {
    if(showing_message) {
        showmes();
        showing_message = false;
    }
}

void show_message(const char* message) {
    showing_message = true;
    mes = message;
    showmes();
}

void clear_message() {
    mes = "";
    showmes();
}

Use ``%s`` in first arg of ``printw`` to prevent errors


// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instr-generate | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Complete dtor
// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"

// Deleting dtor
// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"

// Complete dtor counters and profile data
// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK: @__llvm_profile_data__ZN1BD1Ev =

// Deleting dtor counters and profile data
// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK: @__llvm_profile_data__ZN1BD0Ev =

B::~B() { }

// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instr-generate | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Complete dtor
// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"

// Deleting dtor
// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"

// Complete dtor counters and profile data
// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK: @__llvm_profile_data__ZN1BD1Ev =

// Deleting dtor counters and profile data
// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK: @__llvm_profile_data__ZN1BD0Ev =

B::~B() { }

Change this triple back to %itanium_abi_triple


//===-- Passes.cpp - Target independent code generation passes ------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines interfaces to access the target independent code
// generation passes provided by the LLVM backend.
//
//===---------------------------------------------------------------------===//

#include "llvm/CodeGen/Passes.h"
#include "Support/CommandLine.h"
#include <iostream>
using namespace llvm;

namespace {
  enum RegAllocName { simple, local, linearscan, iterativescan };

  cl::opt<RegAllocName>
  RegAlloc(
    "regalloc",
    cl::desc("Register allocator to use: (default = simple)"),
    cl::Prefix,
    cl::values(
       clEnumVal(simple,        "  simple register allocator"),
       clEnumVal(local,         "  local register allocator"),
       clEnumVal(linearscan,    "  linear scan register allocator"),
       clEnumVal(iterativescan, "  iterative scan register allocator"),
       clEnumValEnd),
    cl::init(local));
}

FunctionPass *llvm::createRegisterAllocator() {
  switch (RegAlloc) {
  default:
    std::cerr << "no register allocator selected";
    abort();
  case simple:
    return createSimpleRegisterAllocator();
  case local:
    return createLocalRegisterAllocator();
  case linearscan:
    return createLinearScanRegisterAllocator();
  case iterativescan:
    return createIterativeScanRegisterAllocator();
  }
}

//===-- Passes.cpp - Target independent code generation passes ------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines interfaces to access the target independent code
// generation passes provided by the LLVM backend.
//
//===---------------------------------------------------------------------===//

#include "llvm/CodeGen/Passes.h"
#include "Support/CommandLine.h"
#include <iostream>
using namespace llvm;

namespace {
  enum RegAllocName { simple, local, linearscan, iterativescan };

  cl::opt<RegAllocName>
  RegAlloc(
    "regalloc",
    cl::desc("Register allocator to use: (default = simple)"),
    cl::Prefix,
    cl::values(
       clEnumVal(simple,        "  simple register allocator"),
       clEnumVal(local,         "  local register allocator"),
       clEnumVal(linearscan,    "  linear scan register allocator"),
       clEnumVal(iterativescan, "  iterative scan register allocator"),
       clEnumValEnd),
    cl::init(linearscan));
}

FunctionPass *llvm::createRegisterAllocator() {
  switch (RegAlloc) {
  default:
    std::cerr << "no register allocator selected";
    abort();
  case simple:
    return createSimpleRegisterAllocator();
  case local:
    return createLocalRegisterAllocator();
  case linearscan:
    return createLinearScanRegisterAllocator();
  case iterativescan:
    return createIterativeScanRegisterAllocator();
  }
}

Make linear scan the default


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

#include "base/native_library.h"

#include <dlfcn.h>

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

namespace base {

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

  return dl;
}

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

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

}  // namespace base

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

#include "base/native_library.h"

#include <dlfcn.h>

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

namespace base {

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

  return dl;
}

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

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

}  // namespace base

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


#include<string>
using namespace std;

class CCipher {
public:
	string decode(string cipherText, int shift) {
		string orig;
		for (char c : cipherText) {
			orig += 'A' + (c - 'A' - shift) % 26 ;
			//orig.append();
		}
		return orig;
	}
};

#include<cassert>
#include<string>
using namespace std;

class CCipher {
public:
  string decode(string cipherText, int shift) {
    string orig;
    for (char c : cipherText) {
      orig += 'A' + (c - 'A' - shift + 26) % 26 ;
    }
    return orig;
  }
};

int main() {
  CCipher cc;
  assert(cc.decode("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10) == "QRSTUVWXYZABCDEFGHIJKLMNOP");
}

Fix SRM 147, Div 2, Problem CCipher


// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)"
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=

// dr412: yes
// lwg404: yes
// lwg2340: yes

// REQUIRES: LP64
typedef __SIZE_TYPE__ size_t;
namespace std { struct bad_alloc {}; }
int x;
inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#if __cplusplus >= 201402L
inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#endif

// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)"
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=

// dr412: yes
// lwg404: yes
// lwg2340: yes

// REQUIRES: LP64
typedef __SIZE_TYPE__ size_t;
namespace std { struct bad_alloc {}; }

inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#if __cplusplus >= 201402L
inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#endif

Remove unused variable from test.


/*
 *
 * Copyright (C) 2020 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "source/loader/driver_discovery.h"

#include "source/inc/ze_util.h"

namespace loader {

static const char *knownDriverNames[] = {
    MAKE_LIBRARY_NAME("ze_intel_gpu", "1"),
};

std::vector<DriverLibraryPath> discoverEnabledDrivers() {
    std::vector<DriverLibraryPath> enabledDrivers;
    for (auto path : knownDriverNames) {
        enabledDrivers.emplace_back(path);
    }
    return enabledDrivers;
}

} // namespace loader

/*
 *
 * Copyright (C) 2020 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "source/loader/driver_discovery.h"

#include "source/inc/ze_util.h"
#include <iostream>
#include <sstream>
#include <string>

namespace loader {

static const char *knownDriverNames[] = {
    MAKE_LIBRARY_NAME("ze_intel_gpu", "1"),
};

std::vector<DriverLibraryPath> discoverEnabledDrivers() {
  std::vector<DriverLibraryPath> enabledDrivers;
  const char *altDrivers = nullptr;

  // ZE_ENABLE_ALT_DRIVERS is for development/debug only
  altDrivers = getenv("ZE_ENABLE_ALT_DRIVERS");
  if (altDrivers == nullptr) {
    for (auto path : knownDriverNames) {
      enabledDrivers.emplace_back(path);
    }
  } else {
    std::stringstream ss(altDrivers);
    while (ss.good()) {
      std::string substr;
      getline(ss, substr, ',');
      enabledDrivers.emplace_back(substr);
    }
  }
  return enabledDrivers;
}

} // namespace loader

Add environment variable for alternate drivers


// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"

namespace {

void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
                v8::Handle<v8::Context> context, void* priv) {
  gfx::Screen* screen = gfx::Screen::GetNativeScreen();
  mate::Dictionary dict(context->GetIsolate(), exports);
  dict.SetMethod("getCursorScreenPoint",
                 base::Bind(&gfx::Screen::GetCursorScreenPoint,
                            base::Unretained(screen)));
  dict.SetMethod("getPrimaryDisplay",
                 base::Bind(&gfx::Screen::GetPrimaryDisplay,
                            base::Unretained(screen)));
}

}  // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)

// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/node_includes.h"

namespace {

void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
                v8::Handle<v8::Context> context, void* priv) {
  auto screen = base::Unretained(gfx::Screen::GetNativeScreen());
  mate::Dictionary dict(context->GetIsolate(), exports);
  dict.SetMethod("getCursorScreenPoint",
                 base::Bind(&gfx::Screen::GetCursorScreenPoint, screen));
  dict.SetMethod("getPrimaryDisplay",
                 base::Bind(&gfx::Screen::GetPrimaryDisplay, screen));
  dict.SetMethod("getAllDisplays",
                 base::Bind(&gfx::Screen::GetAllDisplays, screen));
  dict.SetMethod("getDisplayNearestPoint",
                 base::Bind(&gfx::Screen::GetDisplayNearestPoint, screen));
  dict.SetMethod("getDisplayMatching",
                 base::Bind(&gfx::Screen::GetDisplayMatching, screen));
}

}  // namespace

NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)

Add a few more API bindings


// PR1013
// Check to make sure debug symbols use the correct name for globals and
// functions.  Will not assemble if it fails to.
// RUN: %clang_cc1 -emit-llvm -g -o - %s | FileCheck %s

// CHECK: @"\01f\01oo"
int foo __asm__("f\001oo");

int bar() {
  return foo;
}

// PR1013
// Check to make sure debug symbols use the correct name for globals and
// functions.  Will not assemble if it fails to.
// RUN: %clang_cc1 -emit-llvm -g -o - %s | FileCheck %s

// CHECK: f\01oo"
int foo __asm__("f\001oo");

int bar() {
  return foo;
}

Modify the check line to be happier on windows.


#include <cuda_runtime_api.h>
#include <stdio.h>

int main(void)
{
  int num_devices = 0;
  cudaGetDeviceCount(&num_devices);
  if(num_devices > 0)
  {
    cudaDeviceProp properties;
    cudaGetDeviceProperties(&properties, 0);
    printf("--gpu-architecture=sm_%d%d", properties.major, properties.minor);
    return 0;
  } // end if

  return -1;
}

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

void usage(const char *name)
{
  printf("usage: %s [device_id]\n", name);
}

int main(int argc, char **argv)
{
  int num_devices = 0;
  int device_id = 0;
  if(argc == 2)
  {
    device_id = atoi(argv[1]);
  }
  else if(argc > 2)
  {
    usage(argv[0]);
    exit(-1);
  }

  cudaGetDeviceCount(&num_devices);
  if(num_devices > device_id)
  {
    cudaDeviceProp properties;
    cudaGetDeviceProperties(&properties, device_id);
    printf("--gpu-architecture=sm_%d%d", properties.major, properties.minor);
    return 0;
  } // end if
  else
  {
    printf("No available device with id %d\n", device_id);
  }

  return -1;
}

Add an optional device_id command line argument.


// RUN: CINDEXTEST_EDITING=1 c-index-test -test-load-source local %s -Wuninitialized -Werror=unused 2>&1 | FileCheck -check-prefix=DIAGS %s

// Make sure -Wuninitialized works even though the header had a warn-as-error occurrence.

// DIAGS: error: unused variable 'x'
// DIAGS: warning: variable 'x1' is uninitialized
// DIAGS-NOT: error: use of undeclared identifier
// DIAGS: warning: variable 'x1' is uninitialized

#include "pch-warn-as-error-code-split.h"

void test() {
  int x1; // expected-note {{initialize}}
  int x2 = x1; // expected-warning {{uninitialized}}
  (void)x2;
  foo_head();
}

// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source local %s -Wuninitialized -Werror=unused 2>&1 | FileCheck -check-prefix=DIAGS %s

// Make sure -Wuninitialized works even though the header had a warn-as-error occurrence.

// DIAGS: error: unused variable 'x'
// DIAGS: warning: variable 'x1' is uninitialized
// DIAGS-NOT: error: use of undeclared identifier
// DIAGS: warning: variable 'x1' is uninitialized

#include "pch-warn-as-error-code-split.h"

void test() {
  int x1; // expected-note {{initialize}}
  int x2 = x1; // expected-warning {{uninitialized}}
  (void)x2;
  foo_head();
}

Add 'env' to fix test failures in windows bots.


#include "common.th"

.global putnum
    // putnum takes number in C, (row,col) in D,E, and field width in F
putnum:
    pushall(h,i,j,k,l,m)
    h <- 0x100
    h <- h << 8         // h is video base
    k <- d * 80 + e     // k is offset into display
    k <- k + f          // start at right side of field
    i <- rel(hexes)     // i is base of hex transform

putnumloop:
    j <- [c & 0xf + i]  // j is character for bottom 4 bits of c
    j -> [h + k]        // write character to display
    k <- k - 1          // go to the left one character
    c <- c >>> 4        // shift down for next iteration
    l <- c == 0         // shall we loop ?
    jzrel(l,putnumloop)

putnumdone:
    popall_ret(h,i,j,k,l,m)

hexes:
    .word '0', '1', '2', '3', '4', '5', '6', '7'
    .word '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'

#include "common.th"

.global putnum
    // putnum takes number in C, (row,col) in D,E, and field width in F
putnum:
    pushall(h,i,j,k,l,m)
    h <- 0x10000        // h is video base
    k <- d * 80 + e     // k is offset into display
    k <- k + f          // start at right side of field
    i <- rel(hexes)     // i is base of hex transform

putnumloop:
    j <- [c & 0xf + i]  // j is character for bottom 4 bits of c
    j -> [h + k]        // write character to display
    k <- k - 1          // go to the left one character
    c <- c >>> 4        // shift down for next iteration
    l <- c == 0         // shall we loop ?
    jzrel(l,putnumloop)

putnumdone:
    popall_ret(h,i,j,k,l,m)

hexes:
    .word '0', '1', '2', '3', '4', '5', '6', '7'
    .word '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'

Use type3 to simplify expressions


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

#include "views/events/event.h"

#include "base/logging.h"
#include "ui/aura/event.h"

namespace views {

////////////////////////////////////////////////////////////////////////////////
// LocatedEvent, protected:

LocatedEvent::LocatedEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      location_(static_cast<aura::LocatedEvent*>(native_event)->location()) {
}

////////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:

KeyEvent::KeyEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      key_code_(static_cast<aura::KeyEvent*>(native_event)->key_code()),
      character_(GetCharacterFromKeyCode(key_code_, flags())),
      unmodified_character_(0) {
}

uint16 KeyEvent::GetCharacter() const {
  return character_;
}

uint16 KeyEvent::GetUnmodifiedCharacter() const {
  return unmodified_character_;
}

////////////////////////////////////////////////////////////////////////////////
// MouseWheelEvent, public:

MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event)
    : MouseEvent(native_event),
      offset_(ui::GetMouseWheelOffset(native_event->native_event())) {
}

}  // namespace views

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

#include "views/events/event.h"

#include "base/logging.h"
#include "ui/aura/event.h"

namespace views {

////////////////////////////////////////////////////////////////////////////////
// LocatedEvent, protected:

LocatedEvent::LocatedEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      location_(static_cast<aura::LocatedEvent*>(native_event)->location()) {
}

////////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:

KeyEvent::KeyEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      key_code_(static_cast<aura::KeyEvent*>(native_event)->key_code()),
      character_(GetCharacterFromKeyCode(key_code_, flags())),
      unmodified_character_(0) {
}

uint16 KeyEvent::GetCharacter() const {
  return character_;
}

uint16 KeyEvent::GetUnmodifiedCharacter() const {
  if (unmodified_character_)
    return unmodified_character_;

  return GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN);
}

////////////////////////////////////////////////////////////////////////////////
// MouseWheelEvent, public:

MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event)
    : MouseEvent(native_event),
      offset_(ui::GetMouseWheelOffset(native_event->native_event())) {
}

}  // namespace views

Fix the KeyEvent unit test failure due to the aura implementation of GetUnmodifiedCharacter().


// Nikita Kouevda
// 2013/11/04

#include <iostream>

#include "prime.hpp"

using namespace std;

int main(int argc, char *argv[]) {
  int i, n;
  char *endptr;

  if (argc < 2) {
    cerr << "usage: prime number ..." << endl;
    return 1;
  }

  for (i = 1; i < argc; ++i) {
    n = strtol(argv[i], &endptr, 10);

    if (*endptr) {
      cerr << "prime: illegal argument: " << argv[i] << endl;
      continue;
    }

    cout << argv[i] << " is";

    if (!isPrime(n)) {
      cout << " not";
    }

    cout << " prime" << endl;
  }

  return 0;
}

// Nikita Kouevda
// 2013/11/04

#include <cstdlib>
#include <iostream>

#include "prime.hpp"

using namespace std;

int main(int argc, char *argv[]) {
  int i, n;
  char *endptr;

  if (argc < 2) {
    cerr << "usage: prime number ..." << endl;
    return 1;
  }

  for (i = 1; i < argc; ++i) {
    n = strtol(argv[i], &endptr, 10);

    if (*endptr) {
      cerr << "prime: illegal argument: " << argv[i] << endl;
      continue;
    }

    cout << argv[i] << " is";

    if (!isPrime(n)) {
      cout << " not";
    }

    cout << " prime" << endl;
  }

  return 0;
}

Include cstdlib just in case.


#include <curses.h>
#include <iostream>
#include "mopViewer.h"
#include <string>

int main() {
        mopViewer mopViewers;
        std::string fileName;
        int skipCount;
        std::cout << "Enter the MopFile Name (No need to use extension/location: ";
        std::cin >> fileName;
        std::cout << std::endl << "Enter Required Skip Count: ";
        std::cin >> skipCount;
        mopViewers.selectGame(fileName, skipCount);
        return 0;
}

#include <curses.h>
#include <iostream>
#include "mopViewer.h"
#include <string>

int main() {
        mopViewer mopViewers;
        std::string fileName;
        int skipCount;
        std::cout << "Enter the MopFile Name (No need to use extension/location: ";
        std::cin >> fileName;
        std::cout << std::endl << "Enter Required Skip Count: ";
        std::cin >> skipCount;
        if(skipCount < 0){
        	std::cout << "Skip Count Must be 0 or larger" << std::endl;
        	std::cout << "Exiting Now!" << std::endl;
        	return 0;
        }
        mopViewers.selectGame(fileName, skipCount);
        return 0;
}

Add some minor error checking


#include <catch.hpp>

#include <chi/Context.hpp>
#include <chi/DataType.hpp>
#include <chi/LangModule.hpp>
#include <chi/NodeType.hpp>
#include <chi/Support/Result.hpp>
#include <chi/Fetcher/Fetcher.hpp>

#include <llvm/IR/DerivedTypes.h>

using namespace chi;
namespace fs = boost::filesystem;

TEST_CASE("Contexts can fetch remote modules", "[Context]") {
	// create a temporary directory for a workspace
	fs::path workspaceDir =
	    boost::filesystem::temp_directory_path() / fs::unique_path();  // this is a tmp file
	fs::create_directories(workspaceDir);

	// create the .chigraphworkspace file
	{ fs::ofstream stream{workspaceDir / ".chigraphworkspace"}; }

	auto res = fetchModule(workspaceDir, "github.com/russelltg/hellochigraph/hello/main", true);
	REQUIRE(res.dump() == "");

	REQUIRE(fs::is_directory(workspaceDir / "src" / "github.com" / "russelltg" / "hellochigraph"));
}

#include <catch.hpp>

#include <chi/Context.hpp>
#include <chi/DataType.hpp>
#include <chi/LangModule.hpp>
#include <chi/NodeType.hpp>
#include <chi/Support/Result.hpp>
#include <chi/Fetcher/Fetcher.hpp>

#include <llvm/IR/DerivedTypes.h>

using namespace chi;
namespace fs = boost::filesystem;

TEST_CASE("Contexts can fetch remote modules", "[Context]") {
	// create a temporary directory for a workspace
	fs::path workspaceDir =
	    boost::filesystem::temp_directory_path() / fs::unique_path();  // this is a tmp file
	fs::create_directories(workspaceDir);

	// create the .chigraphworkspace file
	{ fs::ofstream stream{workspaceDir / ".chigraphworkspace"}; }

	auto res = fetchModule(workspaceDir, "github.com/chigraph/hellochigraph/hello/main", true);
	REQUIRE(res.dump() == "");

	REQUIRE(fs::is_directory(workspaceDir / "src" / "github.com" / "chigraph" / "hellochigraph"));
}

Fix test because repo moved


#include "includes/SWidgets/SSearchArea.hpp"
#include "includes/SMainWindow.hpp"

SSearchArea::SSearchArea(const QIcon & icon, SMainWindow * parent) :
	QLineEdit(parent),
	m_parent(parent),
	m_icon(icon)
{
	setTextMargins(18, 0, 0, 0);
	connect(this, &SSearchArea::returnPressed, this, &SSearchArea::loadSearch);
	setClearButtonEnabled(true);
}

SSearchArea::~SSearchArea()
{
	// Empty
}

void SSearchArea::paintEvent(QPaintEvent * event)
{
	// Paint the shearch icon before the line edit
	QLineEdit::paintEvent(event);
	QPainter painter(this);
	m_icon.paint(&painter, (height() - 16) / 2, (height() - 16) / 2, 16, 16);
}

void SSearchArea::loadSearch()
{
	// Load the search
	// TODO: fix the bug when we seach with "+"
	QString search{ text() };
	search.replace(" ", "+");
	m_parent->currentPage()->load(QUrl("http://www.google.com/search?q=" + search));
}

#include "includes/SWidgets/SSearchArea.hpp"
#include "includes/SMainWindow.hpp"

SSearchArea::SSearchArea(const QIcon & icon, SMainWindow * parent) :
	QLineEdit(parent),
	m_parent(parent),
	m_icon(icon)
{
	setTextMargins(18, 0, 0, 0);
	connect(this, &SSearchArea::returnPressed, this, &SSearchArea::loadSearch);
	setClearButtonEnabled(true);

    setStyleSheet("QLineEdit{ border: none; background-color: #FFFFFF; }");
}

SSearchArea::~SSearchArea()
{
	// Empty
}

void SSearchArea::paintEvent(QPaintEvent * event)
{
	// Paint the shearch icon before the line edit
	QLineEdit::paintEvent(event);
	QPainter painter(this);
	m_icon.paint(&painter, (height() - 16) / 2, (height() - 16) / 2, 16, 16);
}

void SSearchArea::loadSearch()
{
	// Load the search
	// TODO: fix the bug when we seach with "+"
	QString search{ text() };
	search.replace(" ", "+");
	m_parent->currentPage()->load(QUrl("http://www.google.com/search?q=" + search));
}

UPDATE the style of the search bar


#include "Course.h"

#include <iostream>

using namespace std;

int main() {
  // test instantiation of a Course object.
  cout << "Testing instantiation of a Course object:" << endl;
  Course course("test-0");
  cout << "Created " << course.getName() << endl;

  cout << "All Assignments:" << endl;

  for (auto it : course.assignments) {
    cout << it.first << "=>" << it.second << '\n';
  }
}

#include "Course.h"

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  if (remove("test-0.sqlite") != 0) {
    cout << "Error with deletion of database file\n";
  } else {
    cout << "Database file successfully deleted\n";
  }

  // test instantiation of a Course object.
  cout << "Testing instantiation of a Course object:" << endl;
  Course course("test-0");
  cout << "Created " << course.getName() << endl;

  cout << "All Assignments:" << endl;

  for (auto it : course.assignments) {
    cout << it.first << "=>" << it.second << '\n';
  }
}

Remove database file before Course instantiation


// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "media/base/closure_thread.h"

namespace media {

ClosureThread::ClosureThread(
    const std::string& name_prefix,
    const base::Closure& task)
    : base::SimpleThread(name_prefix), task_(task) {}

ClosureThread::~ClosureThread() {
  if (!HasBeenJoined())
    Join();
}

void ClosureThread::Run() { task_.Run(); }

}  // namespace media

// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "media/base/closure_thread.h"

namespace media {

ClosureThread::ClosureThread(
    const std::string& name_prefix,
    const base::Closure& task)
    : base::SimpleThread(name_prefix), task_(task) {}

ClosureThread::~ClosureThread() {
  if (HasBeenStarted() && !HasBeenJoined())
    Join();
}

void ClosureThread::Run() { task_.Run(); }

}  // namespace media

Fix ClosureThread unittest crash in release build


#include "catch.hpp"
#include "library.hpp"
#include <functional>

namespace {
#ifdef _WIN32
	const std::string testlibname("testlib.dll");
#else
	const std::string testlibname("libtestlib.so");
#endif
}
SCENARIO("Loading a shared library")
{
	GIVEN("library is loaded successfully")
	{
		loader::Library lib(testlibname);
		REQUIRE(lib.loaded() == true);

		WHEN("symbol is loaded successfully")
		{
			auto testfunc = lib.func<int(int)>("test");

			THEN("function pointed by symbol is called successfully")
			{
				REQUIRE(testfunc(3) == 3);
			}
		}
	}
}

SCENARIO("Loading non-existent library")
{
	GIVEN("a non-existing library name")
	{
		WHEN("an attempt is made to load the library")
		{
			loader::Library lib("not there");
			THEN("library is not loaded")
			{
				REQUIRE(lib.loaded() == false);
			}
			THEN("symbol loads return null")
			{
				REQUIRE(lib.func<int(int)>("test") == nullptr);
			}
		}
	}
}

#include "catch.hpp"
#include "library.hpp"
#include <functional>

namespace {
#ifdef _WIN32
	const std::string testlibname("testlib.dll");
#else
	const std::string testlibname("libtestlib.so");
#endif
}
SCENARIO("Loading a shared library")
{
	GIVEN("library is loaded successfully")
	{
		loader::Library lib(testlibname);
		REQUIRE(lib.loaded() == true);

		WHEN("symbol is loaded successfully")
		{
			auto testfunc = lib.func<int(int)>("test");

			THEN("function pointed by symbol is called successfully")
			{
				REQUIRE(testfunc(3) == 3);
			}
		}
	}
}

SCENARIO("Loading non-existent library")
{
	GIVEN("a non-existing library name")
	{
		WHEN("an attempt is made to load the library")
		{
			loader::Library lib("not there");
			THEN("library is not loaded")
			{
				REQUIRE(lib.loaded() == false);
			}
			THEN("symbol loads return null")
			{
				REQUIRE(!lib.func<int(int)>("test"));
			}
		}
	}
}

Use bool operator instead of null-check for std::function


#include "tcframe/aggregator.hpp"
#include "tcframe/evaluator.hpp"
#include "tcframe/generator.hpp"
#include "tcframe/grader.hpp"
#include "tcframe/os.hpp"
#include "tcframe/runner.hpp"
#include "tcframe/spec.hpp"

#include __TCFRAME_SPEC_FILE__

using tcframe::Runner;

int main(int argc, char* argv[]) {
    Runner<ProblemSpec> runner(
            __TCFRAME_SPEC_FILE__,
            new TestSpec(),
            new SimpleLoggerEngine(),
            new OperatingSystem(),
            new RunnerLoggerFactory(),
            new GraderLoggerFactory(),
            new GeneratorFactory(),
            new GraderFactory(),
            new EvaluatorRegistry(new EvaluatorHelperRegistry()),
            new AggregatorRegistry());

    return runner.run(argc, argv);
}

#include "tcframe/runner.hpp"

#include __TCFRAME_SPEC_FILE__

using tcframe::Runner;

int main(int argc, char* argv[]) {
    Runner<ProblemSpec> runner(
            __TCFRAME_SPEC_FILE__,
            new TestSpec(),
            new SimpleLoggerEngine(),
            new OperatingSystem(),
            new RunnerLoggerFactory(),
            new GraderLoggerFactory(),
            new GeneratorFactory(),
            new GraderFactory(),
            new EvaluatorRegistry(new EvaluatorHelperRegistry()),
            new AggregatorRegistry());

    return runner.run(argc, argv);
}

Use only single header in main file


#include "include/vortex.hpp"
#include "include/app.hpp"
#include "include/logger.hpp"

#include "common_def_priv.hpp"

#include <memory>

namespace vtx
{
	struct PRIVATE_STRUCT_NAME(Vortex)
	{
		std::unique_ptr<Application> m_application;
	};

	void Vortex::setApplication(Application &&app)
	{
		m_private->m_application.reset(&app);
	}

	Vortex::Vortex() : m_private{ new PRIVATE_STRUCT_NAME(Vortex) }
	{
		Logger::createInstance();
		ldebug() << "Vortex library instance created" << endline();
	}

	Vortex::~Vortex()
	{
		ldebug() << "Vortex library instance beeing deleted" << endline();
		DELETE_PRIVATE_MPRIVATE_PIMPL(Vortex);
		ldebug() << "Vortex library instance deleted" << endline();
	}

	void Vortex::initialize()
	{
		linfo() << "Initializing Vortex library..." << endline();
	}

	void Vortex::deinitialize()
	{
		linfo() << "Deinitializing Vortex library..." << endline();
	}
}

#include "include/vortex.hpp"
#include "include/app.hpp"
#include "include/logger.hpp"

#include "common_def_priv.hpp"

#include <memory>

namespace vtx
{
	struct PRIVATE_STRUCT_NAME(Vortex)
	{
		std::unique_ptr<Application> m_application;
	};

	void Vortex::setApplication(Application &&app)
	{
		m_private->m_application.reset(&app);
	}

	Vortex::Vortex() : m_private{ new PRIVATE_STRUCT_NAME(Vortex) }
	{
		Logger::createInstance();
		ldebug() << "Vortex library instance created" << endline();
	}

	Vortex::~Vortex()
	{
		ldebug() << "Vortex library instance beeing deleted" << endline();
		DELETE_PRIVATE_MPRIVATE_PIMPL(Vortex);
		ldebug() << "Vortex library instance deleted" << endline();
	}

	void Vortex::initialize()
	{
		linfo() << "Initializing Vortex library..." << endline();
		if (!m_private->m_application) {
			lerror() << "No application set" << endline();
			return;
		}
	}

	void Vortex::deinitialize()
	{
		linfo() << "Deinitializing Vortex library..." << endline();
	}
}

Check that an application has been set


#include <iostream>
#include "Room.h"
#include "XMLParser.cpp"

int main() {
	Room current_room;

	current_room.loadFromXMLFile("Speelveld1.0.xml");
	current_room.loadMovesFromXMLFile("Bewegingen1.0.xml");

	current_room.executeAllMoves("HuidigSpeelveld.txt", "ResterendeBewegingen.txt");

	return 0;
}

#include <iostream>
#include "Room.h"
#include "XMLParser.cpp"

int main() {
	Room current_room;

	current_room.loadFromXMLFile("xmlfiles/Speelveld1.0.xml");
	current_room.loadMovesFromXMLFile("xmlfiles/Bewegingen1.0.xml");

	current_room.executeAllMoves("HuidigSpeelveld.txt", "ResterendeBewegingen.txt");

	return 0;
}

Set xml files to moved files


#include <QCoreApplication>
#include "Network/NetworkBalancer.hpp"

int main(int argc, char *argv[])
{
    Network::NetworkBalancer aBalancerExample = Network::NetworkBalancer();

    return( 0 );
}

#include <QCoreApplication>
#include "Tests/Unit/Network/TestNetworkBalancer.hpp"

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

using namespace std;
using namespace CppUnit;

int main(int argc, char *argv[])
{
    // Initialice test runner
    CppUnit::TextUi::TestRunner aRunner;
    // Add network balancer test suite
    aRunner.addTest( TestNetworkBalancer::suite() );
    // Start test runner
    aRunner.run();

    return( 0 );
}

Test Runner added to check the NetworkBalancer class


/**********************************************************************
 *
 * 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


#include "glfwApp.h"
#include "linuxPlatform.h"
#include "log.h"
#include "map.h"
#include <memory>
#include <signal.h>
#include <stdlib.h>

using namespace Tangram;

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

    auto platform = std::make_shared<LinuxPlatform>();

    // Create the windowed app.
    GlfwApp::create(platform, sceneUrl.string(), 1024, 768);

    GlfwApp::parseArgs(argc, argv);

    Url baseUrl = Url(GlfwApp::sceneFile).resolved("file:///");
    Url sceneUrl = Url(inputString).resolved(baseUrl);
    GlfwApp::sceneFile = sceneUrl.string();

    // Give it a chance to shutdown cleanly on CTRL-C
    signal(SIGINT, &GlfwApp::stop);

    // Loop until the user closes the window
    GlfwApp::run();

    // Clean up.
    GlfwApp::destroy();

}

#include "glfwApp.h"
#include "linuxPlatform.h"
#include "log.h"
#include "map.h"
#include <memory>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace Tangram;

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

    auto platform = std::make_shared<LinuxPlatform>();

    // Create the windowed app.
    GlfwApp::create(platform, 1024, 768);

    GlfwApp::parseArgs(argc, argv);

    // Resolve the input path against the current directory.
    Url baseUrl("file:///");
    char pathBuffer[PATH_MAX] = {0};
    if (getcwd(pathBuffer, PATH_MAX) != nullptr) {
        baseUrl = Url(std::string(pathBuffer) + "/").resolved(baseUrl);
    }

    LOG("Base URL: %s", baseUrl.string().c_str());

    Url sceneUrl = Url(GlfwApp::sceneFile).resolved(baseUrl);
    GlfwApp::sceneFile = sceneUrl.string();

    // Give it a chance to shutdown cleanly on CTRL-C
    signal(SIGINT, &GlfwApp::stop);

    // Loop until the user closes the window
    GlfwApp::run();

    // Clean up.
    GlfwApp::destroy();

}

Fix linux base URL for demo executable


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

#include "remoting/host/capturer.h"

namespace remoting {

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

Capturer::~Capturer() {
}

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

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

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

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

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

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

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

}  // namespace remoting

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

#include "remoting/host/capturer.h"

namespace remoting {

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

Capturer::~Capturer() {
}

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

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

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

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

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

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

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

}  // namespace remoting

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


#include "test.h"
#include "lcg.h"
#include <cassert>
#include <limits>

template <class T>
void boxmuller(T* data, size_t count) {
	assert(count % 2 == 0);
	static const T twopi = T(2.0 * 3.14159265358979323846);

	LCG r;
	for (size_t i = 0; i < count; i += 2) {
        T u1, u2;
        do {
            u1 = r();
            u2 = r();
        } while (u1 <= std::numeric_limits<T>::min());

		T radius = std::sqrt(-2 * std::log(u1));
		T theta = twopi * u2;
		data[i    ] = radius * std::cos(theta);
		data[i + 1] = radius * std::sin(theta);
	}
}

static void normaldistf_boxmuller(float* data, size_t count) {
    boxmuller(data, count);
}

static void normaldist_boxmuller(double* data, size_t count) {
    boxmuller(data, count);
}

REGISTER_TEST(boxmuller);

#include "test.h"
#include "lcg.h"
#include <cassert>
#include <limits>
#include <algorithm>

template <class T>
void boxmuller(T* data, size_t count) {
	assert(count % 2 == 0);
	static const T twopi = T(2.0 * 3.14159265358979323846);

	LCG r;
	for (size_t i = 0; i < count; i += 2) {
        T u1, u2;
        u1 = r();
        u2 = r();
        u1  = std::max(u1, std::numeric_limits<T>::min());

		T radius = std::sqrt(-2 * std::log(u1));
		T theta = twopi * u2;
		data[i    ] = radius * std::cos(theta);
		data[i + 1] = radius * std::sin(theta);
	}
}

static void normaldistf_boxmuller(float* data, size_t count) {
    boxmuller(data, count);
}

static void normaldist_boxmuller(double* data, size_t count) {
    boxmuller(data, count);
}

REGISTER_TEST(boxmuller);

Use minimum instead of do-while in Box-Muller


#include <QCoreApplication>
#include <QTest>
#include "test_engine.hpp"

int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);
    QTest::qExec( new Test_Engine, argc, argv );

    return a.exec();
}

#include <QApplication>
#include <QTest>
#include "test_engine.hpp"

int main( int argc, char *argv[] ) {
    QApplication a( argc, argv );
    QTest::qExec( new Test_Engine, argc, argv );

    return a.exec();
}

Replace QCoreApplication to QAppliation for QWidget work.


#include <tiramisu/tiramisu.h>

using namespace tiramisu;

void gen(std::string name, int size, int val0, int val1)
{
    tiramisu::init(name);

    tiramisu::function *function0 = global::get_implicit_function();

    tiramisu::constant N("N", tiramisu::expr((int32_t) size), p_int32, true, NULL, 0, &function0);

    tiramisu::var i("i", 0, 10), j("j", 0, 10);
    tiramisu::var i0("i0"), j0("j0"), i1("i1"), j1("j1");

    tiramisu::computation S0(tiramisu::expr((uint8_t) (val0 + val1)), i, j);

    //S0.tile(i, j, 2, 2, i0, j0, i1, j1);
    S0.tag_parallel_level(i);

    tiramisu::buffer buf0("buf0", {size, size}, tiramisu::p_uint8, a_output, &function0);
    S0.store_in(&buf0, {i ,j});

    function0.codegen({&buf0}, "build/generated_fct_test_114.o");
}

int main(int argc, char **argv)
{
    gen("func", 10, 3, 4);

    return 0;
}

#include <tiramisu/tiramisu.h>

using namespace tiramisu;

void gen(std::string name, int size, int val0, int val1)
{
    tiramisu::init(name);

    tiramisu::function *function0 = global::get_implicit_function();

    tiramisu::constant N("N", tiramisu::expr((int32_t) size), p_int32, true, NULL, 0, function0);

    tiramisu::var i("i", 0, 10), j("j", 0, 10);
    tiramisu::var i0("i0"), j0("j0"), i1("i1"), j1("j1");

    tiramisu::computation S0(tiramisu::expr((uint8_t) (val0 + val1)), i, j);

    //S0.tile(i, j, 2, 2, i0, j0, i1, j1);
    S0.tag_parallel_level(i);

    tiramisu::buffer buf0("buf0", {size, size}, tiramisu::p_uint8, a_output, function0);
    S0.store_in(&buf0, {i ,j});

    function0->codegen({&buf0}, "build/generated_fct_test_114.o");
}

int main(int argc, char **argv)
{
    gen("func", 10, 3, 4);

    return 0;
}

Add support for implicit function


/*----------------------------------------*/
// Test sending messages from master.
//
// In this script, master sends a message (command = 0x01)
// with alternating 0s and 1s for each node on the bus.
//
/*----------------------------------------*/

#include <stdint.h>
#include <util/delay.h>

#include "MultidropMaster.h"
#include "MultidropDataUart.h"

#define NODE_COUNT 1

int main() {
  MultidropDataUart serial;
  serial.begin(9600);
	MultidropMaster master(&serial);

  uint8_t iteration = 1, i = 0;
  master.setNodeLength(NODE_COUNT);
  while(1) {

    master.startMessage(0x01, MultidropMaster::BROADCAST_ADDRESS, 1, true);

    // Send alternating 1s and 0s
    for (i = 0; i < NODE_COUNT; i++) {
      if ((i + iteration) % 2 == 0) {
        master.sendData(0x01);
      } else {
        master.sendData(0x00);
      }
    }

    master.finishMessage();

    iteration++;
    _delay_ms(1000);
  }
}

/*----------------------------------------*/
// Test sending messages from master.
//
// In this script, master sends a message (command = 0x01)
// with alternating 0s and 1s for each node on the bus.
//
/*----------------------------------------*/

#include <stdint.h>
#include <util/delay.h>

#include "MultidropMaster.h"
#include "MultidropDataUart.h"

#define NODE_COUNT 1

int main() {
  uint8_t iteration = 1, i = 0;

  MultidropDataUart serial;
	MultidropMaster master(&serial);

  serial.begin(9600);
  master.setNodeLength(NODE_COUNT);

  while(1) {
    master.startMessage(0x01, MultidropMaster::BROADCAST_ADDRESS, 1, true);

    // Send alternating 1s and 0s
    for (i = 0; i < NODE_COUNT; i++) {
      if ((i + iteration) % 2 == 0) {
        master.sendData(0x01);
      } else {
        master.sendData(0x00);
      }
    }

    master.finishMessage();

    iteration++;
    _delay_ms(1000);
  }
}

Rearrange code to be clearer


/*! \file PathToImage.cpp
 *  \author Jared Hoberock
 *  \brief Implementation of PathToImage class.
 */

#include "PathToImage.h"

void PathToImage
  ::evaluate(const PathSampler::Result &r,
             const PathSampler::HyperPoint &x,
             const Path &xPath,
             float &u,
             float &v) const
{
  if(r.mEyeLength == 0)
  {
    std::cerr << "PathToImage::evaluate(): Implement me!" << std::endl;
  } // end if
  else if(r.mEyeLength == 1)
  {
    // we need to invert the sensor function
    unsigned int endOfLightPath = xPath.getSubpathLengths().sum() - r.mLightLength;
    ::Vector w = xPath[endOfLightPath].mDg.getPoint();
    w -= xPath[0].mDg.getPoint();
    xPath[0].mSensor->invert(w, xPath[0].mDg,
                             u, v);
  } // end if
  else
  {
    // the first coordinate naturally corresponds to (u,v)
    u = x[0][0];
    v = x[0][1];
  } // end else
} // end PathToImage::evaluate()

void PathToImage
  ::operator()(const PathSampler::Result &r,
               const PathSampler::HyperPoint &x,
               const Path &xPath,
               float &u,
               float &v) const
{
  return evaluate(r,x,xPath,u,v);
} // end PathToImage::operator()()

/*! \file PathToImage.cpp
 *  \author Jared Hoberock
 *  \brief Implementation of PathToImage class.
 */

#include "PathToImage.h"

void PathToImage
  ::evaluate(const PathSampler::Result &r,
             const PathSampler::HyperPoint &x,
             const Path &xPath,
             float &u,
             float &v) const
{
  if(r.mEyeLength <= 1)
  {
    // we need to invert the sensor function
    unsigned int endOfLightPath = xPath.getSubpathLengths().sum() - r.mLightLength;
    ::Vector w = xPath[endOfLightPath].mDg.getPoint();
    w -= xPath[0].mDg.getPoint();
    xPath[0].mSensor->invert(w, xPath[0].mDg,
                             u, v);
  } // end if
  else
  {
    // the first coordinate naturally corresponds to (u,v)
    u = x[0][0];
    v = x[0][1];
  } // end else
} // end PathToImage::evaluate()

void PathToImage
  ::operator()(const PathSampler::Result &r,
               const PathSampler::HyperPoint &x,
               const Path &xPath,
               float &u,
               float &v) const
{
  return evaluate(r,x,xPath,u,v);
} // end PathToImage::operator()()

Allow mapping for paths with no eye subpath.


#include <cmath>
#include "lights/light.h"
#include "material/blinn_phong.h"

BlinnPhong::BlinnPhong(const Colorf &diffuse, const Colorf &specular, float gloss)
	: diffuse(diffuse), specular(specular), gloss(gloss)
{}
Colorf BlinnPhong::shade(const Ray &r, const HitInfo &hitinfo, const LightCache &lights) const {
	Colorf illum;
	for (const auto &lit : lights){
		const auto &light = lit.second;
		if (light->is_ambient()){
			illum += diffuse * light->illuminate(hitinfo.point);
		}
		else {
			Vector l = -light->direction(hitinfo.point);
			Vector v = -r.d.normalized();
			Vector h = (l + v).normalized();
			//Normal may not be normalized due to translation into world space
			Normal n = hitinfo.normal.normalized();
			float dif = std::max(l.dot(n), 0.f);
			float spec = std::pow(std::max(n.dot(h), 0.f), gloss);
			illum += (diffuse * dif + specular * spec) * light->illuminate(hitinfo.point);
		}
	}
	illum.normalize();
	return illum;
}

#include <cmath>
#include "lights/light.h"
#include "material/blinn_phong.h"

BlinnPhong::BlinnPhong(const Colorf &diffuse, const Colorf &specular, float gloss)
	: diffuse(diffuse), specular(specular), gloss(gloss)
{}
Colorf BlinnPhong::shade(const Ray &r, const HitInfo &hitinfo, const LightCache &lights) const {
	Colorf illum;
	for (const auto &lit : lights){
		const auto &light = lit.second;
		if (light->is_ambient()){
			illum += diffuse * light->illuminate(hitinfo.point);
		}
		else {
			Vector l = -light->direction(hitinfo.point);
			Vector v = -r.d.normalized();
			Vector h = (l + v).normalized();
			//Normal may not be normalized due to translation into world space
			Normal n = hitinfo.normal.normalized();
			float dif = std::max(l.dot(n), 0.f);
			float spec = std::pow(std::max(n.dot(h), 0.f), gloss);
			illum += diffuse * dif * light->illuminate(hitinfo.point)
				+ specular * spec * light->illuminate(hitinfo.point);
		}
	}
	illum.normalize();
	return illum;
}

Fix some issue with coloring of specular highlights


/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

#include <string>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "cirkit_unit03_driver_node");
  ROS_INFO("cirkit unit03 robot driver for ROS.");

  ros::NodeHandle n {"~"};
  std::string imcs01_port {"/dev/urbtc0"};
  n.param<std::string>("imcs01_port", imcs01_port, imcs01_port);

  cirkit::CirkitUnit03Driver driver(std::move(imcs01_port), ros::NodeHandle {});
  driver.run();

  return 0;
}

/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

#include <string>
#include <utility>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "cirkit_unit03_driver_node");
  ROS_INFO("cirkit unit03 robot driver for ROS.");

  ros::NodeHandle n {"~"};
  std::string imcs01_port {"/dev/urbtc0"};
  n.param<std::string>("imcs01_port", imcs01_port, imcs01_port);

  cirkit::CirkitUnit03Driver driver(std::move(imcs01_port), ros::NodeHandle {});
  driver.run();

  return 0;
}

Add include file is utility


// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =

// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =

// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =

B::~B() { }

// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Base dtor
// CHECK: @__profn__ZN1BD2Ev = private constant [9 x i8] c"_ZN1BD2Ev"

// Complete dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"

// Deleting dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"

// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =

// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =

// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =

B::~B() { }

Revert "[profiling] Update test case to deal with name variable change (NFC)"


//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    Referenced(),
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0) {}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    Referenced(),
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup) {}

BlinkSequence::SequenceGroup::SequenceGroup():
    Referenced()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    Referenced(),
    _baseTime(baseTime) {}

//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0)
{
}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup)
{
}

BlinkSequence::SequenceGroup::SequenceGroup()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    _baseTime(baseTime)
{
}

Fix for compile problems under IRIX.


/**
 * @file   equationTest.cpp
 * @brief  equation header tester.
 * @author zer0
 * @date   2016-08-26
 */

#include <gtest/gtest.h>
#include <libtbag/math/equation.hpp>

using namespace libtbag;
using namespace libtbag::math;

TEST(equationTest, getLinearEquationWithTwoPoint)
{
    auto e = getLinearEquationWithTwoPoint(1, 1, 2, 2);
    ASSERT_EQ(1, e.a);
    ASSERT_EQ(0, e.b);
}

TEST(equationTest, getIntersectionWithTwoLinearEquation)
{
    LinearEquation<double> e1{ 2,  0};
    LinearEquation<double> e2{-2,  2};
    auto p = getIntersectionWithTwoLinearEquation(e1, e2);
    ASSERT_NEAR(0.5, p.x, 1);
    ASSERT_NEAR(1.0, p.y, 1);
}

/**
 * @file   equationTest.cpp
 * @brief  equation header tester.
 * @author zer0
 * @date   2016-08-26
 */

#include <gtest/gtest.h>
#include <libtbag/math/equation.hpp>

using namespace libtbag;
using namespace libtbag::math;

TEST(equationTest, getLinearEquationWithTwoPoint)
{
    auto e = getLinearEquationWithTwoPoint(1, 1, 2, 2);
    ASSERT_EQ(1, e.a);
    ASSERT_EQ(0, e.b);
}

TEST(equationTest, isParallelWithTwoLinearEquation)
{
    LinearEquation<double> e1{2.4, 1};
    LinearEquation<double> e2{2.4, 2};
    ASSERT_TRUE(isParallelWithTwoLinearEquation(e1, e2));
}

TEST(equationTest, getIntersectionWithTwoLinearEquation)
{
    LinearEquation<double> e1{ 2, 0};
    LinearEquation<double> e2{-2, 2};
    auto p = getIntersectionWithTwoLinearEquation(e1, e2);
    ASSERT_NEAR(0.5, p.x, 0.1);
    ASSERT_NEAR(1.0, p.y, 0.1);
}

Fix the ASSERT_NEAR() parameter bug.


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

#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

// http://crbug.com/111165
#if defined(OS_WIN)
#define MAYBE_WebSocket FAILS_WebSocket
#else
#define MAYBE_WebSocket WebSocket
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WebSocket) {
  FilePath websocket_root_dir;
  ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
  // TODO(toyoshim): Remove following logging after a bug investigation.
  // http://crbug.com/107836 .
  LOG(INFO) << "Assume LayoutTests in " << websocket_root_dir.MaybeAsASCII();

  ui_test_utils::TestWebSocketServer server;
  ASSERT_TRUE(server.Start(websocket_root_dir));
  ASSERT_TRUE(RunExtensionTest("websocket")) << message_;
}

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

#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

// http://crbug.com/111165
#if defined(OS_WIN)
#define MAYBE_WebSocket DISABLED_WebSocket
#else
#define MAYBE_WebSocket WebSocket
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WebSocket) {
  FilePath websocket_root_dir;
  ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
  // TODO(toyoshim): Remove following logging after a bug investigation.
  // http://crbug.com/107836 .
  LOG(INFO) << "Assume LayoutTests in " << websocket_root_dir.MaybeAsASCII();

  ui_test_utils::TestWebSocketServer server;
  ASSERT_TRUE(server.Start(websocket_root_dir));
  ASSERT_TRUE(RunExtensionTest("websocket")) << message_;
}

Disable ExtensionApiTest.WebSocket instead of marked as FAILS_


// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "commctrl.h"
#include "accctrl.h"
#include "shellapi.h"
#include "shlobj.h"
#include "aclapi.h"
#include "lm.h"
#include "d2d1.h"
#include "dwrite.h"

BOOL APIENTRY DllMain(
    HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }

    return TRUE;
}

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "commctrl.h"
#include "accctrl.h"
#include "shellapi.h"
#include "shlobj.h"
#include "aclapi.h"
#include "lm.h"
#include "d2d1.h"
#include "dwrite.h"
#include "richedit.h"
#include "shlwapi.h"
#include "uxtheme.h"
#include "Mshtmhst.h"
#include "richole.h"
#include "OleCtl.h"
#include "winternl.h"

BOOL APIENTRY DllMain(
    HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }

    return TRUE;
}

Add a few more headers to the native test project


//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011 Utku Aydın <utkuaydin34@gmail.com>
//

#include "GeoSceneGeodata.h"
#include "GeoSceneTypes.h"

namespace Marble
{
GeoSceneGeodata::GeoSceneGeodata( QString name )
    : GeoSceneAbstractDataset( name ),
      m_name( name ),
      m_sourceFile( QString() ),
      m_sourceFileFormat( QString() )
{
}

GeoSceneGeodata::~GeoSceneGeodata()
{
}

const char* GeoSceneGeodata::nodeType() const
{
    return GeoSceneTypes::GeoSceneGeodataType;
}

QString GeoSceneGeodata::name() const
{
    return m_name;
}

QString GeoSceneGeodata::sourceFile() const
{
    return m_sourceFile;
}

void GeoSceneGeodata::setSourceFile(QString sourceFile)
{
    m_sourceFile = sourceFile;
}

QString GeoSceneGeodata::sourceFileFormat() const
{
    return m_sourceFileFormat;
}

void GeoSceneGeodata::setSourceFileFormat(QString format)
{
    m_sourceFileFormat = format;
}

QString GeoSceneGeodata::type()
{
    return "geodata";
}

}

#include "GeoSceneGeodata.moc"

//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011 Utku Aydın <utkuaydin34@gmail.com>
//

#include "GeoSceneGeodata.h"
#include "GeoSceneTypes.h"

namespace Marble
{
GeoSceneGeodata::GeoSceneGeodata( QString name )
    : GeoSceneAbstractDataset( name ),
      m_name( name ),
      m_sourceFile( QString() ),
      m_sourceFileFormat( QString() )
{
}

GeoSceneGeodata::~GeoSceneGeodata()
{
}

const char* GeoSceneGeodata::nodeType() const
{
    return GeoSceneTypes::GeoSceneGeodataType;
}

QString GeoSceneGeodata::name() const
{
    return m_name;
}

QString GeoSceneGeodata::sourceFile() const
{
    return m_sourceFile;
}

void GeoSceneGeodata::setSourceFile(QString sourceFile)
{
    m_sourceFile = sourceFile;
}

QString GeoSceneGeodata::sourceFileFormat() const
{
    return m_sourceFileFormat;
}

void GeoSceneGeodata::setSourceFileFormat(QString format)
{
    m_sourceFileFormat = format;
}

QString GeoSceneGeodata::type()
{
    return "geodata";
}

}

// #include "GeoSceneGeodata.moc"

Fix compiler warning (moc has nothing to generate)


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

#include "chrome/browser/printing/print_error_dialog.h"

namespace chrome {

void ShowPrintErrorDialog() {}

}  // namespace chrome

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

#include "chrome/browser/printing/print_error_dialog.h"

void ShowPrintErrorDialog() {}

Move chrome/browser/printing out of the chrome namespace


// Copyright (c) 2011 Timur Iskhodzhanov and MIPT students. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gtest/gtest.h"

#include "base/common.h"

TEST(CheckTest, CheckTrueSucceedsTest) {
  CHECK(1);
  CHECK(42);
}

TEST(CheckTest, AssertionsAndChecksTest) {
  CHECK(2 + 2 == 4);        // NOLINT
  ASSERT_TRUE(2 + 2 == 4);  // NOLINT
  ASSERT_EQ(5, 2 + 2);
  ASSERT_LE(2 + 2, 5);
  printf("Passed all ASSERT macros, now EXPECT macros\n");
  EXPECT_EQ(4, 2 + 2);
  printf("End of test\n");
}

// C preprocessor magic, see
// http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define __FILE_LINE__ __FILE__ ":" TOSTRING(__LINE__)

TEST(CheckTest, CheckFalseDeathTest) {
  ASSERT_DEATH(CHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

TEST(CheckTest, DCheckFalseDeathTest) {
  ASSERT_DEBUG_DEATH(DCHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

// Copyright (c) 2011 Timur Iskhodzhanov and MIPT students. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gtest/gtest.h"

#include "base/common.h"

TEST(CheckTest, CheckTrueSucceedsTest) {
  CHECK(1);
  CHECK(42);
}

TEST(CheckTest, AssertionsAndChecksTest) {
  CHECK(2 + 2 == 4);        // NOLINT
  ASSERT_TRUE(2 + 2 == 4);  // NOLINT
  ASSERT_EQ(4, 2 + 2);
  ASSERT_LE(2 + 2, 5);
  printf("Passed all ASSERT macros, now EXPECT macros\n");
  EXPECT_EQ(4, 2 + 2);
  printf("End of test\n");
}

// C preprocessor magic, see
// http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define __FILE_LINE__ __FILE__ ":" TOSTRING(__LINE__)

TEST(CheckTest, CheckFalseDeathTest) {
  ASSERT_DEATH(CHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

TEST(CheckTest, DCheckFalseDeathTest) {
  ASSERT_DEBUG_DEATH(DCHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

Revert r247, unbreak the build


#include "ImwWindowManagerOGL.h"
#include "ImwPlatformWindowOGL.h"

#include "windows.h"

using namespace ImWindow;

ImwWindowManagerOGL::ImwWindowManagerOGL()
{
}

ImwWindowManagerOGL::~ImwWindowManagerOGL()
{
	Destroy();
}

ImwPlatformWindow* ImwWindowManagerOGL::CreatePlatformWindow(EPlatformWindowType eType, ImwPlatformWindow* pParent)
{
	IM_ASSERT(m_pCurrentPlatformWindow == NULL);
	ImwPlatformWindowOGL* pWindow = new ImwPlatformWindowOGL(eType, CanCreateMultipleWindow());
	if (pWindow->Init(pParent))
	{
		return (ImwPlatformWindow*)pWindow;
	}
	else
	{
		delete pWindow;
		return NULL;
	}
}

ImVec2 ImwWindowManagerOGL::GetCursorPos()
{
	POINT oPoint;
	::GetCursorPos(&oPoint);
	return ImVec2(oPoint.x, oPoint.y);
}

bool ImwWindowManagerOGL::IsLeftClickDown()
{
	return GetAsyncKeyState(VK_LBUTTON);
}

#include "ImwWindowManagerOGL.h"
#include "ImwPlatformWindowOGL.h"

#include "windows.h"

using namespace ImWindow;

ImwWindowManagerOGL::ImwWindowManagerOGL()
{
}

ImwWindowManagerOGL::~ImwWindowManagerOGL()
{
	Destroy();
}

ImwPlatformWindow* ImwWindowManagerOGL::CreatePlatformWindow(EPlatformWindowType eType, ImwPlatformWindow* pParent)
{
	IM_ASSERT(m_pCurrentPlatformWindow == NULL);
	ImwPlatformWindowOGL* pWindow = new ImwPlatformWindowOGL(eType, CanCreateMultipleWindow());
	if (pWindow->Init(pParent))
	{
		return (ImwPlatformWindow*)pWindow;
	}
	else
	{
		delete pWindow;
		return NULL;
	}
}

ImVec2 ImwWindowManagerOGL::GetCursorPos()
{
	POINT oPoint;
	::GetCursorPos(&oPoint);
	return ImVec2((float)oPoint.x, (float)oPoint.y);
}

bool ImwWindowManagerOGL::IsLeftClickDown()
{
	return GetAsyncKeyState(VK_LBUTTON) != 0;
}

Fix warnings in OpenGL backend


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

#include "ltac/Register.hpp"

using namespace eddic;

ltac::Register::Register(){
    //Nothing to init
}

ltac::Register::Register(unsigned short reg) : reg(reg) {
    //Nothing to init
}

ltac::Register::operator int(){
    return reg;
}

bool ltac::Register::operator<(const Register& rhs) const {
    return reg > rhs.reg;
}

bool ltac::Register::operator>(const Register& rhs) const {
    return reg < rhs.reg;
}

bool ltac::Register::operator==(const Register& rhs) const {
    return reg == rhs.reg;
}

bool ltac::Register::operator!=(const Register& rhs) const {
    return !(*this == rhs);
}

std::ostream& ltac::operator<<(std::ostream& out, const ltac::Register& reg){
    return out << "r" << reg.reg;
}

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

#include "ltac/Register.hpp"

using namespace eddic;

ltac::Register::Register(){
    //Nothing to init
}

ltac::Register::Register(unsigned short reg) : reg(reg) {
    //Nothing to init
}

ltac::Register::operator int(){
    return reg;
}

bool ltac::Register::operator<(const Register& rhs) const {
    return reg > rhs.reg;
}

bool ltac::Register::operator>(const Register& rhs) const {
    return reg < rhs.reg;
}

bool ltac::Register::operator==(const Register& rhs) const {
    return reg == rhs.reg;
}

bool ltac::Register::operator!=(const Register& rhs) const {
    return !(*this == rhs);
}

std::ostream& ltac::operator<<(std::ostream& out, const ltac::Register& reg){
    if(reg == ltac::BP){
        return out << "bp";
    } else if(reg == ltac::SP){
        return out << "sp";
    }

    return out << "r" << reg.reg;
}

Complete printing of SP/BP registers


#include "aquila/global.h"
#include "aquila/source/generator/WhiteNoiseGenerator.h"
#include <unittestpp.h>
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <ctime>

SUITE(WhiteNoiseGenerator)
{
    // sample frequency is fixed at 1 kHz
    Aquila::WhiteNoiseGenerator gen(1000);

    TEST(DoesNotOverrunAplitude)
    {
        std::srand(std::time(0));
        Aquila::SampleType amplitude = 1000;
        gen.setAmplitude(amplitude).generate(2048);
        auto result = std::minmax_element(std::begin(gen), std::end(gen));
        CHECK(*result.first > -amplitude);
        CHECK(*result.second < amplitude);
    }
}

#include "aquila/global.h"
#include "aquila/source/generator/WhiteNoiseGenerator.h"
#include <unittestpp.h>
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <ctime>

SUITE(WhiteNoiseGenerator)
{
    // sample frequency is fixed at 1 kHz
    Aquila::WhiteNoiseGenerator gen(1000);

    TEST(DoesNotOverrunAplitude)
    {
        std::srand(std::time(0));
        Aquila::SampleType amplitude = 1000;
        gen.setAmplitude(amplitude).generate(2048);
        auto result = std::minmax_element(std::begin(gen), std::end(gen));
        CHECK(*result.first > -amplitude);
        CHECK(*result.second < amplitude);
    }

    TEST(ZeroMean)
    {
        std::srand(std::time(0));
        gen.setAmplitude(1).generate(2048);
        auto mean = Aquila::mean(gen);
        CHECK_CLOSE(0.0, mean, 0.01);
    }
}

Check that white noise mean value is close to 0.


#include "c_bmp_decoder.h"

namespace Img
{
	namespace Internal
	{
		using namespace Geom;

		bool BmpDataDecoder::Process()
		{
			return OnProcess();
		}

		BmpDataDecoder::BmpDataDecoder(std::shared_ptr<Img::Surface> destination, BMPHeader header):
			m_header{ header },
			m_destination{ destination }
		{

		}

		std::shared_ptr<Img::Surface::LockedArea> BmpDataDecoder::GetScanlinePtr(int row)
		{
			if (m_header.FlipVertical)
			{
				row = m_destination->Height() - row - 1;
			}
			return m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
		}
	}
}

#include "c_bmp_decoder.h"

namespace Img
{
	namespace Internal
	{
		using namespace Geom;

		bool BmpDataDecoder::Process()
		{
			return OnProcess();
		}

		BmpDataDecoder::BmpDataDecoder(std::shared_ptr<Img::Surface> destination, BMPHeader header):
			m_header{ header },
			m_destination{ destination }
		{

		}

		std::shared_ptr<Img::Surface::LockedArea> BmpDataDecoder::GetScanlinePtr(int row)
		{
			if (m_header.FlipVertical)
			{
				row = m_destination->Height() - row - 1;
			}
			return m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
			auto area = m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
			if(area == nullptr)
			{
				DO_THROW(Err::CriticalError, "Could not get scanline ptr");
			}
			return area;
		}
	}
}

Make BMP decoder handle failed surface locks


// Test that no data is collected without a runtime flag.
//
// RUN: %clangxx_asan -fsanitize-coverage=1 %s -o %t
//
// RUN: rm -rf %T/coverage-disabled
//
// RUN: mkdir -p %T/coverage-disabled/normal
// RUN: ASAN_OPTIONS=coverage_direct=0:coverage_dir=%T/coverage-disabled/normal:verbosity=1 %run %t
// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
//
// RUN: mkdir -p %T/coverage-disabled/direct
// RUN: ASAN_OPTIONS=coverage_direct=1:coverage_dir=%T/coverage-disabled/direct:verbosity=1 %run %t
// RUN: cd %T/coverage-disabled/direct
// RUN: not %sancov rawunpack *.sancov

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

// Test that no data is collected without a runtime flag.
//
// RUN: %clangxx_asan -fsanitize-coverage=1 %s -o %t
//
// RUN: rm -rf %T/coverage-disabled
//
// RUN: mkdir -p %T/coverage-disabled/normal
// RUN: ASAN_OPTIONS=coverage_direct=0:coverage_dir=%T/coverage-disabled/normal:verbosity=1 %run %t
// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
//
// RUN: mkdir -p %T/coverage-disabled/direct
// RUN: ASAN_OPTIONS=coverage_direct=1:coverage_dir=%T/coverage-disabled/direct:verbosity=1 %run %t
// RUN: cd %T/coverage-disabled/direct
// RUN: not %sancov rawunpack *.sancov
//
// XFAIL: android

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

Disable one test on Android.


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

// Malloc/free hooks are not supported on Windows.
// XFAIL: win32

#include <stdlib.h>
#include <unistd.h>
#include <sanitizer/allocator_interface.h>

extern "C" {
const volatile void *global_ptr;

// Note: avoid calling functions that allocate memory in malloc/free
// to avoid infinite recursion.
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) {
  if (__sanitizer_get_ownership(ptr)) {
    write(1, "MallocHook\n", sizeof("MallocHook\n"));
    global_ptr = ptr;
  }
}
void __sanitizer_free_hook(const volatile void *ptr) {
  if (__sanitizer_get_ownership(ptr) && ptr == global_ptr)
    write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}  // extern "C"

int main() {
  volatile int *x = new int;
  // CHECK: MallocHook
  // Check that malloc hook was called with correct argument.
  if (global_ptr != (void*)x) {
    _exit(1);
  }
  *x = 0;
  delete x;
  // CHECK: FreeHook
  return 0;
}

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

// Malloc/free hooks are not supported on Windows.
// XFAIL: win32

#include <stdlib.h>
#include <unistd.h>
#include <sanitizer/allocator_interface.h>

extern "C" {
const volatile void *global_ptr;

// Note: avoid calling functions that allocate memory in malloc/free
// to avoid infinite recursion.
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) {
  if (__sanitizer_get_ownership(ptr) && sz == 4) {
    write(1, "MallocHook\n", sizeof("MallocHook\n"));
    global_ptr = ptr;
  }
}
void __sanitizer_free_hook(const volatile void *ptr) {
  if (__sanitizer_get_ownership(ptr) && ptr == global_ptr)
    write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}  // extern "C"

volatile int *x;

// Call this function with uninitialized arguments to poison
// TLS shadow for function parameters before calling operator
// new and, eventually, user-provided hook.
__attribute__((noinline)) void allocate(int *unused1, int *unused2) {
  x = new int;
}

int main() {
  int *undef1, *undef2;
  allocate(undef1, undef2);
  // CHECK: MallocHook
  // Check that malloc hook was called with correct argument.
  if (global_ptr != (void*)x) {
    _exit(1);
  }
  *x = 0;
  delete x;
  // CHECK: FreeHook
  return 0;
}

Add a test case for r258339.


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Disable ExtensionApiTest.WebNavigationEvents1, flakily exceeds test timeout


#include <iostream>
#include <vector>
#include <fstream>

#include "errors/RuntimeError.h"
#include "execution/Program.h"
#include "loader/ProgramReader.h"

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

    if (argc != 2) {
        std::cerr << "Usage: thingc filename.thingc" << std::endl;
        return 1;
    }

    auto reader = ProgramReader(argv[1]);

    try {
        auto info = reader.process();
        Program::load(info);
        Program::start();
    } catch (const RuntimeError &err) {
        std::cerr << "Error during execution: " << err.what() << std::endl;
        return 1;
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <fstream>

#include "errors/RuntimeError.h"
#include "execution/Program.h"
#include "loader/ProgramReader.h"

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

    if (argc != 2) {
        std::cerr << "Usage: thingc filename.thingc" << std::endl;
        return 1;
    }

    auto filename = std::string(argv[1]);

    if(filename == "--build-only"){
        std::cerr << "Build completed, not executing." << std::endl;
        return 0;
    }

    auto reader = filename == "-" ? ProgramReader() : ProgramReader(filename);

    try {
        auto info = reader.process();
        Program::load(info);
        Program::start();
    } catch (const RuntimeError &err) {
        std::cerr << "Error during execution: " << err.what() << std::endl;
        return 1;
    }

    return 0;
}

Allow thinglang bytecode to be piped directly into the VM


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <px4iofirmware/px4io.h>
#include "../../src/systemcmds/tests/tests.h"
#include <geo/geo.h>

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

	if (argc < 3)
		errx(1, "Need lat/lon!");

	char* p_end;

	float lat = strtod(argv[1], &p_end);
	float lon = strtod(argv[2], &p_end);

	float declination = get_mag_declination(lat, lon);

	printf("lat: %f lon: %f, dec: %f\n", lat, lon, declination);

}

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <px4iofirmware/px4io.h>
// #include "../../src/systemcmds/tests/tests.h"
#include <geo/geo.h>

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

	char* latstr = 0;
	char* lonstr = 0;
	char* declstr = 0;

	if (argc < 4) {
		warnx("Too few arguments. Using default lat / lon and declination");
		latstr = "47.0";
		lonstr = "8.0";
		declstr = "0.6";
	} else {
		latstr = argv[1];
		lonstr = argv[2];
		declstr = argv[3];
	}

	char* p_end;

	float lat = strtod(latstr, &p_end);
	float lon = strtod(lonstr, &p_end);
	float decl_truth = strtod(declstr, &p_end);

	float declination = get_mag_declination(lat, lon);

	printf("lat: %f lon: %f, expected dec: %f, estimated dec: %f\n", lat, lon, declination, decl_truth);

	int ret = 0;

	// Fail if the declination differs by more than one degree
	float decldiff = fabs(decl_truth - declination);
	if (decldiff > 0.5f) {
		warnx("declination differs more than 1 degree: difference: %12.8f", decldiff);
		ret = 1;
	}

	return ret;
}

Improve auto declination test, not great coverage yet.


#include <gloperate/input/MouseDevice.h>

#include <gloperate/input/MouseEvent.h>
#include <gloperate/input/InputManager.h>

namespace gloperate
{

MouseDevice::MouseDevice(InputManager * inputManager, const std::string & deviceDescriptor)
: AbstractDevice(inputManager, deviceDescriptor)
{
}

MouseDevice::~MouseDevice()
{
}

void MouseDevice::move(const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonPress(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonRelease(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonRelease,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::wheelScroll(const glm::vec2 & delta, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseWheelScroll,
        this,
        pos,
        delta
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::update()
{
}

} // namespace gloperate

#include <gloperate/input/MouseDevice.h>

#include <gloperate/input/MouseEvent.h>
#include <gloperate/input/InputManager.h>

namespace gloperate
{

MouseDevice::MouseDevice(InputManager * inputManager, const std::string & deviceDescriptor)
: AbstractDevice(inputManager, deviceDescriptor)
{
}

MouseDevice::~MouseDevice()
{
}

void MouseDevice::move(const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseMove,
        this,
        pos
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonPress(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonRelease(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonRelease,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::wheelScroll(const glm::vec2 & delta, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseWheelScroll,
        this,
        pos,
        delta
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::update()
{
}

} // namespace gloperate

Fix wrong event type for mouse move events


#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();
    std::map<std::string, Machine>::iterator iter;

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    std::map<std::string, Machine>::iterator iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

Move iterator variable declaration to the point of use.


#include <chrono>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
#include <vector>

std::mutex output;

void func(unsigned int value) {
	using std::chrono::seconds;
	using std::cout;
	using std::endl;
	using std::lock_guard;
	using std::mutex;

	std::this_thread::sleep_for(seconds(value));

	{
		lock_guard<mutex> lock{output};
		cout << value << endl;
	}
}

int main(int argc, char** argv) {
	using std::cout;
	using std::endl;
	using std::string;
	using std::stringstream;
	using std::thread;
	using std::vector;

	vector<thread>::size_type amount = argc - 1;
	vector<thread> threads;
	threads.reserve(amount);
	for (auto i = 1; i < argc; ++i) {
		stringstream ss;
		ss << argv[i];

		unsigned int value;
		if (!(ss >> value)) {
			string invalid;
			ss >> invalid;
			cout << "You input a non-integer: " << invalid << endl;
		} else {
			threads.emplace_back(func, value);
		}
	}

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

	return 0;
}

#include <chrono>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
#include <vector>

std::mutex output;

void func(unsigned int value) {
	using std::chrono::seconds;
	using std::cout;
	using std::endl;
	using std::lock_guard;
	using std::mutex;

	std::this_thread::sleep_for(seconds(value));

	{
		lock_guard<mutex> lock{output};
		cout << value << endl;
	}
}

int main(int argc, char** argv) {
	using std::cout;
	using std::endl;
	using std::string;
	using std::stringstream;
	using std::thread;
	using std::vector;

	vector<thread>::size_type amount = argc - 1;
	vector<thread> threads;
	threads.reserve(amount);
	for (auto i = 1; i < argc; ++i) {
		stringstream ss;
		ss << argv[i];

		unsigned int value;
		if (!(ss >> value)) {
			cout << "You input a non-integer: " << argv[i] << endl;
		} else {
			threads.emplace_back(func, value);
		}
	}

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

	return 0;
}

Fix output of non-integer parameters


#include "config.h"
#ifdef HAVE_ASPRINTF
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "globit.c"
#endif

#include "config.h"
#ifdef HAVE_ASPRINTF
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include "globit.c"
#endif

Fix build failure with GCC <= 4.7


// __BEGIN_LICENSE__
// Copyright (C) 2006-2011 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__

#include <vw/Plate/detail/Seed.h>
#include <vw/Core/Thread.h>
#include <boost/cast.hpp>

namespace {
  vw::RunOnce seed_once = VW_RUNONCE_INIT;

  void hidden_seed_random() {
    srandom(boost::numeric_cast<unsigned int>(clock()));
  }
}

namespace vw {
namespace platefile {

  void plate_seed_random() {
    seed_once.run( hidden_seed_random );
  }

}}

// __BEGIN_LICENSE__
// Copyright (C) 2006-2011 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__

#include <vw/Plate/detail/Seed.h>
#include <vw/Core/Thread.h>
#include <vw/Core/Stopwatch.h>
#include <sys/types.h>

namespace {
  vw::RunOnce seed_once = VW_RUNONCE_INIT;

  void hidden_seed_random() {
    srandom(vw::Stopwatch::microtime()*::getpid());
  }
}

namespace vw {
namespace platefile {

  void plate_seed_random() {
    seed_once.run( hidden_seed_random );
  }

}}

Replace random seed with something more unique


// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include <bandit/bandit.h>
#include "core/math/vector2.h"

using namespace bandit;
using namespace snowhouse;
using namespace CodeHero;

go_bandit([]() {
    describe("Vector2", []() {
        describe("Constructor", []() {
            it("should initialize vector with 0s if no arguments", [] {
                Vector2 test;

                AssertThat(test.x(), Equals(0.0f));
            });

            it("should initialize vector with correct x and y if provided", [] {
                float x = 1.5f;
                float y = 1.5f;
                Vector2 test(x, y);

                AssertThat(test.x(), Equals(x));
                AssertThat(test.y(), Equals(y));
            });
        });

        describe("::Length", [] {
            it("should compute the proper length", [] {
                float x = 2.0f;
                float y = 2.0f;
                Vector2 test(x, y);

                float res = 2.8284271247461903f;
                AssertThat(test.Length(), Equals(res));
            });
        });
    });
});

// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include <bandit/bandit.h>
#include "core/math/vector2.h"

using namespace bandit;
using namespace snowhouse;
using namespace CodeHero;

go_bandit([]() {
    describe("Vector2", []() {
        describe("Constructor", []() {
            it("should initialize vector with 0s if no arguments", [] {
                Vector2 test;

                AssertThat(test.x(), Equals(0.0f));
            });

            it("should initialize vector with correct x and y if provided", [] {
                float x = 1.5f;
                float y = 1.5f;
                Vector2 test(x, y);

                AssertThat(test.x(), Equals(x));
                AssertThat(test.y(), Equals(y));
            });
        });

        describe("::Length", [] {
            it("should compute the proper length", [] {
                float x = 2.0f;
                float y = 2.0f;
                Vector2 test(x, y);

                float res = 2.8284271247461903f;
                AssertThat(test.Length(), Equals(res));
            });
        });

        describe("::Normalize", [] {
            it("should compute the normalized vector", [] {
                Vector2 test(1.0f, 1.0f);

                float res = 0.70710678118f;
                test.Normalize();
                AssertThat(test.x(), Equals(res));
                AssertThat(test.y(), Equals(res));
            });
        });
    });
});

Normalize tested for vector2. vector2 tested fully