Enable colorful logs in tests

Enable colorful logs in tests

Relates: #272

--- src/tests/test_main.cpp
+++ src/tests/test_main.cpp
@@ -9,6 +9,7 @@
 #include <CppUTest/CommandLineArguments.h>
 #include <CppUTest/CommandLineTestRunner.h>

+#include "roc_core/colors.h"
 #include "roc_core/crash.h"
 #include "roc_core/exit.h"
 #include "roc_core/log.h"
@@ -24,6 +25,10 @@
         roc::core::Logger::instance().set_level(roc::LogNone);
     }

+    roc::core::Logger::instance().set_colors(roc::core::colors_available()
+                                                 ? roc::core::ColorsEnabled
+                                                 : roc::core::ColorsDisabled);
+
     MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();

     const int code = CommandLineTestRunner::RunAllTests(argc, argv);

<|original_code|>
/*
 * Copyright (c) 2015 Roc authors
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <CppUTest/CommandLineArguments.h>
#include <CppUTest/CommandLineTestRunner.h>

#include "roc_core/crash.h"
#include "roc_core/exit.h"
#include "roc_core/log.h"

int main(int argc, const char** argv) {
    roc::core::CrashHandler crash_handler;

    CommandLineArguments args(argc, argv);

    if (args.parse(NULL) && args.isVerbose()) {
        roc::core::Logger::instance().set_level(roc::LogDebug);
    } else {
        roc::core::Logger::instance().set_level(roc::LogNone);
    }

    MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();

    const int code = CommandLineTestRunner::RunAllTests(argc, argv);
    if (code != 0) {
        roc::core::fast_exit(code);
    }

    return 0;
}

<|edits_diff|>
--- src/tests/test_main.cpp
+++ src/tests/test_main.cpp
@@ -9,6 +9,7 @@
 #include <CppUTest/CommandLineArguments.h>
 #include <CppUTest/CommandLineTestRunner.h>

+#include "roc_core/colors.h"
 #include "roc_core/crash.h"
 #include "roc_core/exit.h"
 #include "roc_core/log.h"
<|current_version|>
/*
 * Copyright (c) 2015 Roc authors
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <CppUTest/CommandLineArguments.h>
#include <CppUTest/CommandLineTestRunner.h>

#include "roc_core/colors.h"
#include "roc_core/crash.h"
#include "roc_core/exit.h"
#include "roc_core/log.h"

int main(int argc, const char** argv) {
    roc::core::CrashHandler crash_handler;

    CommandLineArguments args(argc, argv);

    if (args.parse(NULL) && args.isVerbose()) {
        roc::core::Logger::instance().set_level(roc::LogDebug);
    } else {
        roc::core::Logger::instance().set_level(roc::LogNone);
    }

    MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();

    const int code = CommandLineTestRunner::RunAllTests(argc, argv);
    if (code != 0) {
        roc::core::fast_exit(code);
    }

    return 0;
}

<|next_version|>
/*
 * Copyright (c) 2015 Roc authors
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <CppUTest/CommandLineArguments.h>
#include <CppUTest/CommandLineTestRunner.h>

#include "roc_core/colors.h"
#include "roc_core/crash.h"
#include "roc_core/exit.h"
#include "roc_core/log.h"

int main(int argc, const char** argv) {
    roc::core::CrashHandler crash_handler;

    CommandLineArguments args(argc, argv);

    if (args.parse(NULL) && args.isVerbose()) {
        roc::core::Logger::instance().set_level(roc::LogDebug);
    } else {
        roc::core::Logger::instance().set_level(roc::LogNone);
    }

    roc::core::Logger::instance().set_colors(roc::core::colors_available()
                                                 ? roc::core::ColorsEnabled
                                                 : roc::core::ColorsDisabled);

    MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();

    const int code = CommandLineTestRunner::RunAllTests(argc, argv);
    if (code != 0) {
        roc::core::fast_exit(code);
    }

    return 0;
}


Add trasparency support for the app cover

--- main.cpp
+++ main.cpp
@@ -2,12 +2,14 @@
 #include <QGuiApplication>
 #include <QQuickView>
 #include <QQmlContext>
+#include <QQuickWindow>

 #include "sailfishapplication.h"
 #include "servercomm.h"

 Q_DECL_EXPORT int main(int argc, char *argv[])
 {
+    QQuickWindow::setDefaultAlphaBuffer(true);
     QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
     QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

<|original_code|>

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>

#include "sailfishapplication.h"
#include "servercomm.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    ServerComm sc;
    view->rootContext()->setContextProperty("serverComm", &sc);

    Sailfish::showView(view.data());

    return app->exec();
}

<|edits_diff|>
--- main.cpp
+++ main.cpp
@@ -2,6 +2,7 @@
 #include <QGuiApplication>
 #include <QQuickView>
 #include <QQmlContext>
+#include <QQuickWindow>

 #include "sailfishapplication.h"
 #include "servercomm.h"
<|current_version|>

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QQuickWindow>

#include "sailfishapplication.h"
#include "servercomm.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    ServerComm sc;
    view->rootContext()->setContextProperty("serverComm", &sc);

    Sailfish::showView(view.data());

    return app->exec();
}

<|next_version|>

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QQuickWindow>

#include "sailfishapplication.h"
#include "servercomm.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QQuickWindow::setDefaultAlphaBuffer(true);
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    ServerComm sc;
    view->rootContext()->setContextProperty("serverComm", &sc);

    Sailfish::showView(view.data());

    return app->exec();
}


Fix missing symbols in thread cache.

Fix missing symbols in thread cache.

Signed-off-by: Michael Lippautz <0d543840881a2c189b4f7636b15eebd6a8f60ace@gmail.com>

--- src/thread_cache.cc
+++ src/thread_cache.cc
@@ -13,6 +13,9 @@

 namespace scalloc {

+bool ThreadCache::module_init_;
+__thread ThreadCache* ThreadCache::tl_cache_ TLS_MODE;
+
 void ThreadCache::InitModule() {
   SpinLockHolder holder(&g_threadcache_lock);
   CompilerBarrier();
@@ -20,6 +23,8 @@
     RuntimeVars::InitModule();
     SlabScAllocator::InitModule();
     DQScAllocator::InitModule();
+
+    SizeMap::Instance().Init();

     g_threadcache_alloc.Init(RuntimeVars::SystemPageSize());

<|original_code|>
#include "thread_cache.h"

#include "allocators/dq_sc_allocator.h"
#include "runtime_vars.h"

namespace {

cache_aligned SpinLock g_threadcache_lock(LINKER_INITIALIZED);
cache_aligned scalloc::PageHeapAllocator<scalloc::ThreadCache, 64> g_threadcache_alloc;
cache_aligned uint64_t g_thread_id;

}  // namespace

namespace scalloc {

void ThreadCache::InitModule() {
  SpinLockHolder holder(&g_threadcache_lock);
  CompilerBarrier();
  if(!module_init_) {
    RuntimeVars::InitModule();
    SlabScAllocator::InitModule();
    DQScAllocator::InitModule();

    g_threadcache_alloc.Init(RuntimeVars::SystemPageSize());

    module_init_  = true;
  }
}

ThreadCache* ThreadCache::NewCache() {
  ThreadCache* cache = NULL;
  {
    SpinLockHolder holder(&g_threadcache_lock);
    CompilerBarrier();
    cache = g_threadcache_alloc.New();
  }
  cache->allocator_.Init(__sync_fetch_and_add(&g_thread_id, 1));
  return cache;
}

}  // namespace scalloc

<|edits_diff|>
--- src/thread_cache.cc
+++ src/thread_cache.cc
@@ -12,6 +12,9 @@
 }  // namespace

 namespace scalloc {
+
+bool ThreadCache::module_init_;
+__thread ThreadCache* ThreadCache::tl_cache_ TLS_MODE;

 void ThreadCache::InitModule() {
   SpinLockHolder holder(&g_threadcache_lock);
<|current_version|>
#include "thread_cache.h"

#include "allocators/dq_sc_allocator.h"
#include "runtime_vars.h"

namespace {

cache_aligned SpinLock g_threadcache_lock(LINKER_INITIALIZED);
cache_aligned scalloc::PageHeapAllocator<scalloc::ThreadCache, 64> g_threadcache_alloc;
cache_aligned uint64_t g_thread_id;

}  // namespace

namespace scalloc {

bool ThreadCache::module_init_;
__thread ThreadCache* ThreadCache::tl_cache_ TLS_MODE;

void ThreadCache::InitModule() {
  SpinLockHolder holder(&g_threadcache_lock);
  CompilerBarrier();
  if(!module_init_) {
    RuntimeVars::InitModule();
    SlabScAllocator::InitModule();
    DQScAllocator::InitModule();

    g_threadcache_alloc.Init(RuntimeVars::SystemPageSize());

    module_init_  = true;
  }
}

ThreadCache* ThreadCache::NewCache() {
  ThreadCache* cache = NULL;
  {
    SpinLockHolder holder(&g_threadcache_lock);
    CompilerBarrier();
    cache = g_threadcache_alloc.New();
  }
  cache->allocator_.Init(__sync_fetch_and_add(&g_thread_id, 1));
  return cache;
}

}  // namespace scalloc

<|next_version|>
#include "thread_cache.h"

#include "allocators/dq_sc_allocator.h"
#include "runtime_vars.h"

namespace {

cache_aligned SpinLock g_threadcache_lock(LINKER_INITIALIZED);
cache_aligned scalloc::PageHeapAllocator<scalloc::ThreadCache, 64> g_threadcache_alloc;
cache_aligned uint64_t g_thread_id;

}  // namespace

namespace scalloc {

bool ThreadCache::module_init_;
__thread ThreadCache* ThreadCache::tl_cache_ TLS_MODE;

void ThreadCache::InitModule() {
  SpinLockHolder holder(&g_threadcache_lock);
  CompilerBarrier();
  if(!module_init_) {
    RuntimeVars::InitModule();
    SlabScAllocator::InitModule();
    DQScAllocator::InitModule();

    SizeMap::Instance().Init();

    g_threadcache_alloc.Init(RuntimeVars::SystemPageSize());

    module_init_  = true;
  }
}

ThreadCache* ThreadCache::NewCache() {
  ThreadCache* cache = NULL;
  {
    SpinLockHolder holder(&g_threadcache_lock);
    CompilerBarrier();
    cache = g_threadcache_alloc.New();
  }
  cache->allocator_.Init(__sync_fetch_and_add(&g_thread_id, 1));
  return cache;
}

}  // namespace scalloc


Add a test case for PR22431

[ASan/Win] Add a test case for PR22431

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

--- test/asan/TestCases/Windows/iostream_sbo.cc
+++ test/asan/TestCases/Windows/iostream_sbo.cc
@@ -1,5 +1,10 @@
+// First, check this works with the default blacklist:
 // RUN: %clang_cl_asan -O0 %s -Fe%t
 // RUN: echo "42" | %run %t 2>&1 | FileCheck %s
+//
+// Then, make sure it still works when a user uses his own blacklist file:
+// RUN: %clang_cl_asan -O0 %s -fsanitize-blacklist=%p/../Helpers/initialization-blacklist.txt -Fe%t2
+// RUN: echo "42" | %run %t2 2>&1 | FileCheck %s

 #include <iostream>

<|original_code|>
// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: echo "42" | %run %t 2>&1 | FileCheck %s

#include <iostream>

int main() {
  int i;
  std::cout << "Type i: ";
  std::cin >> i;
  return 0;
// CHECK: Type i:
// CHECK-NOT: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
}

<|edits_diff|>
--- test/asan/TestCases/Windows/iostream_sbo.cc
+++ test/asan/TestCases/Windows/iostream_sbo.cc
@@ -1,3 +1,4 @@
+// First, check this works with the default blacklist:
 // RUN: %clang_cl_asan -O0 %s -Fe%t
 // RUN: echo "42" | %run %t 2>&1 | FileCheck %s

<|current_version|>
// First, check this works with the default blacklist:
// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: echo "42" | %run %t 2>&1 | FileCheck %s

#include <iostream>

int main() {
  int i;
  std::cout << "Type i: ";
  std::cin >> i;
  return 0;
// CHECK: Type i:
// CHECK-NOT: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
}

<|next_version|>
// First, check this works with the default blacklist:
// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: echo "42" | %run %t 2>&1 | FileCheck %s
//
// Then, make sure it still works when a user uses his own blacklist file:
// RUN: %clang_cl_asan -O0 %s -fsanitize-blacklist=%p/../Helpers/initialization-blacklist.txt -Fe%t2
// RUN: echo "42" | %run %t2 2>&1 | FileCheck %s

#include <iostream>

int main() {
  int i;
  std::cout << "Type i: ";
  std::cin >> i;
  return 0;
// CHECK: Type i:
// CHECK-NOT: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
}


[video] Fix help system which was not registering factory methods before trying to enumerate them.

--- components/pango_video/src/video_help.cpp
+++ components/pango_video/src/video_help.cpp
@@ -1,5 +1,8 @@
 #include <pangolin/video/video_help.h>
 #include <pangolin/video/video_interface.h>
+
+#include <pangolin/factory/RegisterFactoriesVideoInterface.h>
+#include <pangolin/factory/RegisterFactoriesVideoOutputInterface.h>

 namespace pangolin
 {
@@ -19,6 +22,8 @@

 void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
 {
+    RegisterFactoriesVideoInterface();
+
 #ifndef _WIN32_
     const bool use_color = true;
 #else

<|original_code|>
#include <pangolin/video/video_help.h>
#include <pangolin/video/video_interface.h>

namespace pangolin
{

void PrintPixelFormats(std::ostream& out, bool color)
{
    const std::string c_normal = color ? "\033[0m"  : "";
    const std::string c_alias  = color ? "\033[32m" : "";

   out << "Supported pixel format codes (and their respective bits-per-pixel):" << std::endl;
   std::vector<pangolin::PixelFormat> pixelFormats = pangolin::GetSupportedPixelFormats();
   for(const auto& format: pixelFormats ){
       out << c_alias << format.format << c_normal << " (" << format.bpp << "), ";
   }
   out << std::endl;
}

void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
{
#ifndef _WIN32_
    const bool use_color = true;
#else
    const bool use_color = false;
#endif

    if( verbosity >= HelpVerbosity::SYNOPSIS ) {
        PrintSchemeHelp(out, use_color);
        out << std::endl;
    }

    PrintFactoryRegistryDetails(out, *FactoryRegistry::I(), typeid(VideoInterface), scheme_filter, verbosity, use_color);

    if( verbosity >= HelpVerbosity::PARAMS ) {
        PrintPixelFormats(out, use_color);
    }
}

}

<|edits_diff|>
--- components/pango_video/src/video_help.cpp
+++ components/pango_video/src/video_help.cpp
@@ -1,5 +1,8 @@
 #include <pangolin/video/video_help.h>
 #include <pangolin/video/video_interface.h>
+
+#include <pangolin/factory/RegisterFactoriesVideoInterface.h>
+#include <pangolin/factory/RegisterFactoriesVideoOutputInterface.h>

 namespace pangolin
 {
<|current_version|>
#include <pangolin/video/video_help.h>
#include <pangolin/video/video_interface.h>

#include <pangolin/factory/RegisterFactoriesVideoInterface.h>
#include <pangolin/factory/RegisterFactoriesVideoOutputInterface.h>

namespace pangolin
{

void PrintPixelFormats(std::ostream& out, bool color)
{
    const std::string c_normal = color ? "\033[0m"  : "";
    const std::string c_alias  = color ? "\033[32m" : "";

   out << "Supported pixel format codes (and their respective bits-per-pixel):" << std::endl;
   std::vector<pangolin::PixelFormat> pixelFormats = pangolin::GetSupportedPixelFormats();
   for(const auto& format: pixelFormats ){
       out << c_alias << format.format << c_normal << " (" << format.bpp << "), ";
   }
   out << std::endl;
}

void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
{
#ifndef _WIN32_
    const bool use_color = true;
#else
    const bool use_color = false;
#endif

    if( verbosity >= HelpVerbosity::SYNOPSIS ) {
        PrintSchemeHelp(out, use_color);
        out << std::endl;
    }

    PrintFactoryRegistryDetails(out, *FactoryRegistry::I(), typeid(VideoInterface), scheme_filter, verbosity, use_color);

    if( verbosity >= HelpVerbosity::PARAMS ) {
        PrintPixelFormats(out, use_color);
    }
}

}

<|next_version|>
#include <pangolin/video/video_help.h>
#include <pangolin/video/video_interface.h>

#include <pangolin/factory/RegisterFactoriesVideoInterface.h>
#include <pangolin/factory/RegisterFactoriesVideoOutputInterface.h>

namespace pangolin
{

void PrintPixelFormats(std::ostream& out, bool color)
{
    const std::string c_normal = color ? "\033[0m"  : "";
    const std::string c_alias  = color ? "\033[32m" : "";

   out << "Supported pixel format codes (and their respective bits-per-pixel):" << std::endl;
   std::vector<pangolin::PixelFormat> pixelFormats = pangolin::GetSupportedPixelFormats();
   for(const auto& format: pixelFormats ){
       out << c_alias << format.format << c_normal << " (" << format.bpp << "), ";
   }
   out << std::endl;
}

void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
{
    RegisterFactoriesVideoInterface();

#ifndef _WIN32_
    const bool use_color = true;
#else
    const bool use_color = false;
#endif

    if( verbosity >= HelpVerbosity::SYNOPSIS ) {
        PrintSchemeHelp(out, use_color);
        out << std::endl;
    }

    PrintFactoryRegistryDetails(out, *FactoryRegistry::I(), typeid(VideoInterface), scheme_filter, verbosity, use_color);

    if( verbosity >= HelpVerbosity::PARAMS ) {
        PrintPixelFormats(out, use_color);
    }
}

}


Add timer to Linux example

Add timer to Linux example

--- linux/main.cpp
+++ linux/main.cpp
@@ -25,6 +25,8 @@

 #include <BlynkWidgets.h>

+BlynkTimer tmr;
+
 BLYNK_WRITE(V1)
 {
     printf("Got a value: %s\n", param[0].asStr());
@@ -33,11 +35,15 @@
 void setup()
 {
     Blynk.begin(auth, serv, port);
+    tmr.setInterval(1000, [](){
+      Blynk.virtualWrite(V0, BlynkMillis()/1000);
+    });
 }

 void loop()
 {
     Blynk.run();
+    tmr.run();
 }

<|original_code|>
/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
  #include <BlynkApiWiringPi.h>
#else
  #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

static const char *auth, *serv;
static uint16_t port;

#include <BlynkWidgets.h>

BLYNK_WRITE(V1)
{
    printf("Got a value: %s\n", param[0].asStr());
}

void setup()
{
    Blynk.begin(auth, serv, port);
}

void loop()
{
    Blynk.run();
}

int main(int argc, char* argv[])
{
    parse_options(argc, argv, auth, serv, port);

    setup();
    while(true) {
        loop();
    }

    return 0;
}

<|edits_diff|>
--- linux/main.cpp
+++ linux/main.cpp
@@ -25,6 +25,8 @@

 #include <BlynkWidgets.h>

+BlynkTimer tmr;
+
 BLYNK_WRITE(V1)
 {
     printf("Got a value: %s\n", param[0].asStr());
@@ -33,6 +35,9 @@
 void setup()
 {
     Blynk.begin(auth, serv, port);
+    tmr.setInterval(1000, [](){
+      Blynk.virtualWrite(V0, BlynkMillis()/1000);
+    });
 }

 void loop()
<|current_version|>
/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
  #include <BlynkApiWiringPi.h>
#else
  #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

static const char *auth, *serv;
static uint16_t port;

#include <BlynkWidgets.h>

BlynkTimer tmr;

BLYNK_WRITE(V1)
{
    printf("Got a value: %s\n", param[0].asStr());
}

void setup()
{
    Blynk.begin(auth, serv, port);
    tmr.setInterval(1000, [](){
      Blynk.virtualWrite(V0, BlynkMillis()/1000);
    });
}

void loop()
{
    Blynk.run();
}

int main(int argc, char* argv[])
{
    parse_options(argc, argv, auth, serv, port);

    setup();
    while(true) {
        loop();
    }

    return 0;
}

<|next_version|>
/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
  #include <BlynkApiWiringPi.h>
#else
  #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

static const char *auth, *serv;
static uint16_t port;

#include <BlynkWidgets.h>

BlynkTimer tmr;

BLYNK_WRITE(V1)
{
    printf("Got a value: %s\n", param[0].asStr());
}

void setup()
{
    Blynk.begin(auth, serv, port);
    tmr.setInterval(1000, [](){
      Blynk.virtualWrite(V0, BlynkMillis()/1000);
    });
}

void loop()
{
    Blynk.run();
    tmr.run();
}

int main(int argc, char* argv[])
{
    parse_options(argc, argv, auth, serv, port);

    setup();
    while(true) {
        loop();
    }

    return 0;
}


Add an example of how to use the logging library.

See the complete documentation at
https://github.com/easylogging/easyloggingpp.

--- src/client/main.cc
+++ src/client/main.cc
@@ -3,8 +3,15 @@
 #include <QPushButton>
 #include "src/common/Game.h"

+#include "easylogging++.h"
+
+_INITIALIZE_EASYLOGGINGPP
+
 int main(int argc, char *argv[]) {
     std::cout << "Welcome to the client interface of Bomberman :)" << std::endl;
+
+    _START_EASYLOGGINGPP(argc, argv);
+    LOG(INFO) << "Started client";

     // This part should be moved to another class, that's just for test
     QApplication app(argc, argv);

<|original_code|>
#include <iostream>
#include <QApplication>
#include <QPushButton>
#include "src/common/Game.h"

int main(int argc, char *argv[]) {
    std::cout << "Welcome to the client interface of Bomberman :)" << std::endl;

    // This part should be moved to another class, that's just for test
    QApplication app(argc, argv);
    QWidget mainWindow;
    mainWindow.setFixedSize(300, 300);

    QPushButton createGameButton("Create game", &mainWindow);
    createGameButton.setCursor(Qt::PointingHandCursor);
    createGameButton.move(100, 75);

    QPushButton joinGameButton("Join game", &mainWindow);
    joinGameButton.setCursor(Qt::PointingHandCursor);
    joinGameButton.move(100, 150);

    QPushButton quitWindowButton("Quit Bomberman", &mainWindow);
    quitWindowButton.setCursor(Qt::PointingHandCursor);
    quitWindowButton.move(100, 225);

    QObject::connect(&quitWindowButton, SIGNAL(clicked()), &app, SLOT(quit()));

    mainWindow.show();

    return app.exec();
}

<|edits_diff|>
--- src/client/main.cc
+++ src/client/main.cc
@@ -2,6 +2,10 @@
 #include <QApplication>
 #include <QPushButton>
 #include "src/common/Game.h"
+
+#include "easylogging++.h"
+
+_INITIALIZE_EASYLOGGINGPP

 int main(int argc, char *argv[]) {
     std::cout << "Welcome to the client interface of Bomberman :)" << std::endl;
<|current_version|>
#include <iostream>
#include <QApplication>
#include <QPushButton>
#include "src/common/Game.h"

#include "easylogging++.h"

_INITIALIZE_EASYLOGGINGPP

int main(int argc, char *argv[]) {
    std::cout << "Welcome to the client interface of Bomberman :)" << std::endl;

    // This part should be moved to another class, that's just for test
    QApplication app(argc, argv);
    QWidget mainWindow;
    mainWindow.setFixedSize(300, 300);

    QPushButton createGameButton("Create game", &mainWindow);
    createGameButton.setCursor(Qt::PointingHandCursor);
    createGameButton.move(100, 75);

    QPushButton joinGameButton("Join game", &mainWindow);
    joinGameButton.setCursor(Qt::PointingHandCursor);
    joinGameButton.move(100, 150);

    QPushButton quitWindowButton("Quit Bomberman", &mainWindow);
    quitWindowButton.setCursor(Qt::PointingHandCursor);
    quitWindowButton.move(100, 225);

    QObject::connect(&quitWindowButton, SIGNAL(clicked()), &app, SLOT(quit()));

    mainWindow.show();

    return app.exec();
}

<|next_version|>
#include <iostream>
#include <QApplication>
#include <QPushButton>
#include "src/common/Game.h"

#include "easylogging++.h"

_INITIALIZE_EASYLOGGINGPP

int main(int argc, char *argv[]) {
    std::cout << "Welcome to the client interface of Bomberman :)" << std::endl;

    _START_EASYLOGGINGPP(argc, argv);
    LOG(INFO) << "Started client";

    // This part should be moved to another class, that's just for test
    QApplication app(argc, argv);
    QWidget mainWindow;
    mainWindow.setFixedSize(300, 300);

    QPushButton createGameButton("Create game", &mainWindow);
    createGameButton.setCursor(Qt::PointingHandCursor);
    createGameButton.move(100, 75);

    QPushButton joinGameButton("Join game", &mainWindow);
    joinGameButton.setCursor(Qt::PointingHandCursor);
    joinGameButton.move(100, 150);

    QPushButton quitWindowButton("Quit Bomberman", &mainWindow);
    quitWindowButton.setCursor(Qt::PointingHandCursor);
    quitWindowButton.move(100, 225);

    QObject::connect(&quitWindowButton, SIGNAL(clicked()), &app, SLOT(quit()));

    mainWindow.show();

    return app.exec();
}


Set up a native screen on Windows

Set up a native screen on Windows

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

--- brightray/browser/browser_main_parts.cc
+++ brightray/browser/browser_main_parts.cc
@@ -7,6 +7,8 @@
 #include "browser/browser_context.h"
 #include "browser/web_ui_controller_factory.h"
 #include "net/proxy/proxy_resolver_v8.h"
+#include "ui/gfx/screen.h"
+#include "ui/views/widget/desktop_aura/desktop_screen.h"

 namespace brightray {

@@ -24,6 +26,10 @@
       new WebUIControllerFactory(browser_context_.get()));
   content::WebUIControllerFactory::RegisterFactory(
       web_ui_controller_factory_.get());
+
+#if defined(OS_WIN)
+  gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
+#endif
 }

 void BrowserMainParts::PostMainMessageLoopRun() {

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

#include "browser/browser_main_parts.h"

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

namespace brightray {

BrowserMainParts::BrowserMainParts() {
}

BrowserMainParts::~BrowserMainParts() {
}

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

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

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

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

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

}  // namespace brightray

<|edits_diff|>
--- brightray/browser/browser_main_parts.cc
+++ brightray/browser/browser_main_parts.cc
@@ -7,6 +7,8 @@
 #include "browser/browser_context.h"
 #include "browser/web_ui_controller_factory.h"
 #include "net/proxy/proxy_resolver_v8.h"
+#include "ui/gfx/screen.h"
+#include "ui/views/widget/desktop_aura/desktop_screen.h"

 namespace brightray {

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

#include "browser/browser_main_parts.h"

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

namespace brightray {

BrowserMainParts::BrowserMainParts() {
}

BrowserMainParts::~BrowserMainParts() {
}

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

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

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

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

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

}  // namespace brightray

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

#include "browser/browser_main_parts.h"

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

namespace brightray {

BrowserMainParts::BrowserMainParts() {
}

BrowserMainParts::~BrowserMainParts() {
}

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

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

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

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

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

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

}  // namespace brightray


Improve on my last test for patch for // rdar://12897704

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

--- test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
+++ test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
 // RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
 // RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
 // RUN: diff %t.ll  %t-c++11.ll
@@ -10,8 +11,10 @@
 };

 static volatile struct sAFSearchPos testPositions;
+// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

 static volatile struct sAFSearchPos arrayPositions[100][10][5];
+// CHECK: @_ZL14arrayPositions = internal global [100 x [10 x [5 x %struct.sAFSearchPos]]] zeroinitializer

 int main() {
   return testPositions.count + arrayPositions[10][4][3].count;

<|original_code|>
// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;

static volatile struct sAFSearchPos arrayPositions[100][10][5];

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

<|edits_diff|>
--- test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
+++ test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
 // RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
 // RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
 // RUN: diff %t.ll  %t-c++11.ll
@@ -10,6 +11,7 @@
 };

 static volatile struct sAFSearchPos testPositions;
+// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

 static volatile struct sAFSearchPos arrayPositions[100][10][5];

<|current_version|>
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;
// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

static volatile struct sAFSearchPos arrayPositions[100][10][5];

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

<|next_version|>
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;
// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

static volatile struct sAFSearchPos arrayPositions[100][10][5];
// CHECK: @_ZL14arrayPositions = internal global [100 x [10 x [5 x %struct.sAFSearchPos]]] zeroinitializer

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}


Add forgotten include and return.

Add forgotten include and return.

	* lib/libport/backtrace.cc: Here.

--- lib/libport/backtrace.cc
+++ lib/libport/backtrace.cc
@@ -5,6 +5,7 @@

 #if LIBPORT_HAVE_EXECINFO_H
 # include <execinfo.h>
+# include <cstdlib>

 namespace libport
 {
@@ -34,6 +35,7 @@
   {
     std::vector<const char*> res;
     res.push_back("(no avaible backtrace)");
+    return res;
   }
 }

<|original_code|>
#include <cstdlib>

#include <libport/backtrace.hh>
#include <libport/config.h>

#if LIBPORT_HAVE_EXECINFO_H
# include <execinfo.h>

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    enum { size = 128 };
    void* callstack[size];
    size_t frames = ::backtrace(callstack, size);
    char** strs = backtrace_symbols(callstack, frames);

    std::vector<const char*> res(frames, 0);
    for (size_t i = 0; i < frames; ++i)
      res[i] = strs[i];

    free(strs);
    return res;
  }
}

#else // ! LIBPORT_HAVE_EXECINFO_H

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    std::vector<const char*> res;
    res.push_back("(no avaible backtrace)");
  }
}

#endif

<|edits_diff|>
--- lib/libport/backtrace.cc
+++ lib/libport/backtrace.cc
@@ -5,6 +5,7 @@

 #if LIBPORT_HAVE_EXECINFO_H
 # include <execinfo.h>
+# include <cstdlib>

 namespace libport
 {
<|current_version|>
#include <cstdlib>

#include <libport/backtrace.hh>
#include <libport/config.h>

#if LIBPORT_HAVE_EXECINFO_H
# include <execinfo.h>
# include <cstdlib>

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    enum { size = 128 };
    void* callstack[size];
    size_t frames = ::backtrace(callstack, size);
    char** strs = backtrace_symbols(callstack, frames);

    std::vector<const char*> res(frames, 0);
    for (size_t i = 0; i < frames; ++i)
      res[i] = strs[i];

    free(strs);
    return res;
  }
}

#else // ! LIBPORT_HAVE_EXECINFO_H

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    std::vector<const char*> res;
    res.push_back("(no avaible backtrace)");
  }
}

#endif

<|next_version|>
#include <cstdlib>

#include <libport/backtrace.hh>
#include <libport/config.h>

#if LIBPORT_HAVE_EXECINFO_H
# include <execinfo.h>
# include <cstdlib>

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    enum { size = 128 };
    void* callstack[size];
    size_t frames = ::backtrace(callstack, size);
    char** strs = backtrace_symbols(callstack, frames);

    std::vector<const char*> res(frames, 0);
    for (size_t i = 0; i < frames; ++i)
      res[i] = strs[i];

    free(strs);
    return res;
  }
}

#else // ! LIBPORT_HAVE_EXECINFO_H

namespace libport
{
  std::vector<const char*>
  backtrace()
  {
    std::vector<const char*> res;
    res.push_back("(no avaible backtrace)");
    return res;
  }
}

#endif


Connect the C++ classes with QML

Connect the C++ classes with QML

--- main.cpp
+++ main.cpp
@@ -1,13 +1,18 @@

 #include <QGuiApplication>
 #include <QQuickView>
+#include <QQmlContext>

 #include "sailfishapplication.h"
+#include "servercomm.h"

 Q_DECL_EXPORT int main(int argc, char *argv[])
 {
     QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
     QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));
+
+    ServerComm sc;
+    view->rootContext()->setContextProperty("serverComm", &sc);

     Sailfish::showView(view.data());

<|original_code|>

#include <QGuiApplication>
#include <QQuickView>

#include "sailfishapplication.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    Sailfish::showView(view.data());

    return app->exec();
}

<|edits_diff|>
--- main.cpp
+++ main.cpp
@@ -1,8 +1,10 @@

 #include <QGuiApplication>
 #include <QQuickView>
+#include <QQmlContext>

 #include "sailfishapplication.h"
+#include "servercomm.h"

 Q_DECL_EXPORT int main(int argc, char *argv[])
 {
<|current_version|>

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>

#include "sailfishapplication.h"
#include "servercomm.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    Sailfish::showView(view.data());

    return app->exec();
}

<|next_version|>

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>

#include "sailfishapplication.h"
#include "servercomm.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
    QScopedPointer<QQuickView> view(Sailfish::createView("main.qml"));

    ServerComm sc;
    view->rootContext()->setContextProperty("serverComm", &sc);

    Sailfish::showView(view.data());

    return app->exec();
}


Hide console window when creating a new window using simple API

--- src/junior-simple.cpp
+++ src/junior-simple.cpp
@@ -1,6 +1,7 @@

 #include "junior-simple.h"
 #include <vector>
+#include <Windows.h>

 namespace junior
@@ -9,6 +10,7 @@

 	window& create_window(const wchar_t* title)
 	{
+		ShowWindow(GetConsoleWindow(), SW_HIDE);
 		windows.push_back(window(title));
 		return windows.back();
 	}

<|original_code|>

#include "junior-simple.h"
#include <vector>

namespace junior
{
	std::vector<window> windows;

	window& create_window(const wchar_t* title)
	{
		windows.push_back(window(title));
		return windows.back();
	}

	inline window& main_window()
	{
		return windows.front();
	}

	void draw_line(const int x1, const int y1, const int x2, const int y2)
	{
		main_window().draw_line(x1, y1, x2, y2);
	}

	void draw_circle(const int x, const int y, const int radius)
	{
		main_window().draw_circle(x, y, radius);
	}

	void write(const wchar_t* text, const int x, const int y)
	{
		main_window().write(text, x, y);
	}
}

<|edits_diff|>
--- src/junior-simple.cpp
+++ src/junior-simple.cpp
@@ -1,6 +1,7 @@

 #include "junior-simple.h"
 #include <vector>
+#include <Windows.h>

 namespace junior
<|current_version|>

#include "junior-simple.h"
#include <vector>
#include <Windows.h>

namespace junior
{
	std::vector<window> windows;

	window& create_window(const wchar_t* title)
	{
		windows.push_back(window(title));
		return windows.back();
	}

	inline window& main_window()
	{
		return windows.front();
	}

	void draw_line(const int x1, const int y1, const int x2, const int y2)
	{
		main_window().draw_line(x1, y1, x2, y2);
	}

	void draw_circle(const int x, const int y, const int radius)
	{
		main_window().draw_circle(x, y, radius);
	}

	void write(const wchar_t* text, const int x, const int y)
	{
		main_window().write(text, x, y);
	}
}

<|next_version|>

#include "junior-simple.h"
#include <vector>
#include <Windows.h>

namespace junior
{
	std::vector<window> windows;

	window& create_window(const wchar_t* title)
	{
		ShowWindow(GetConsoleWindow(), SW_HIDE);
		windows.push_back(window(title));
		return windows.back();
	}

	inline window& main_window()
	{
		return windows.front();
	}

	void draw_line(const int x1, const int y1, const int x2, const int y2)
	{
		main_window().draw_line(x1, y1, x2, y2);
	}

	void draw_circle(const int x, const int y, const int radius)
	{
		main_window().draw_circle(x, y, radius);
	}

	void write(const wchar_t* text, const int x, const int y)
	{
		main_window().write(text, x, y);
	}
}


Add 'break' in switch-case statement

fix: Add 'break' in switch-case statement

--- Sources/Rosetta/Actions/Targeting.cpp
+++ Sources/Rosetta/Actions/Targeting.cpp
@@ -20,6 +20,7 @@
                 {
                     return false;
                 }
+                break;
             }
             case +PlayReq::REQ_ENEMY_TARGET:
             {
@@ -27,6 +28,7 @@
                 {
                     return false;
                 }
+                break;
             }
             case +PlayReq::REQ_TARGET_TO_PLAY:
             {
@@ -34,6 +36,7 @@
                 {
                     return false;
                 }
+                break;
             }
             default:
                 break;

<|original_code|>
// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// Hearthstone++ is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Targeting.hpp>
#include <Rosetta/Games/Game.hpp>

namespace RosettaStone::Generic
{
bool IsValidTarget(Entity* source, Entity* target)
{
    for (auto& requirement : source->card.playRequirements)
    {
        switch (requirement.first)
        {
            case +PlayReq::REQ_MINION_TARGET:
            {
                if (dynamic_cast<Minion*>(target) == nullptr)
                {
                    return false;
                }
            }
            case +PlayReq::REQ_ENEMY_TARGET:
            {
                if (&target->GetOwner() == &source->GetOwner())
                {
                    return false;
                }
            }
            case +PlayReq::REQ_TARGET_TO_PLAY:
            {
                if (dynamic_cast<Character*>(target) == nullptr)
                {
                    return false;
                }
            }
            default:
                break;
        }
    }

    return true;
}
}  // namespace RosettaStone::Generic

<|edits_diff|>
--- Sources/Rosetta/Actions/Targeting.cpp
+++ Sources/Rosetta/Actions/Targeting.cpp
@@ -20,6 +20,7 @@
                 {
                     return false;
                 }
+                break;
             }
             case +PlayReq::REQ_ENEMY_TARGET:
             {
@@ -27,6 +28,7 @@
                 {
                     return false;
                 }
+                break;
             }
             case +PlayReq::REQ_TARGET_TO_PLAY:
             {
<|current_version|>
// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// Hearthstone++ is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Targeting.hpp>
#include <Rosetta/Games/Game.hpp>

namespace RosettaStone::Generic
{
bool IsValidTarget(Entity* source, Entity* target)
{
    for (auto& requirement : source->card.playRequirements)
    {
        switch (requirement.first)
        {
            case +PlayReq::REQ_MINION_TARGET:
            {
                if (dynamic_cast<Minion*>(target) == nullptr)
                {
                    return false;
                }
                break;
            }
            case +PlayReq::REQ_ENEMY_TARGET:
            {
                if (&target->GetOwner() == &source->GetOwner())
                {
                    return false;
                }
                break;
            }
            case +PlayReq::REQ_TARGET_TO_PLAY:
            {
                if (dynamic_cast<Character*>(target) == nullptr)
                {
                    return false;
                }
            }
            default:
                break;
        }
    }

    return true;
}
}  // namespace RosettaStone::Generic

<|next_version|>
// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// Hearthstone++ is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Targeting.hpp>
#include <Rosetta/Games/Game.hpp>

namespace RosettaStone::Generic
{
bool IsValidTarget(Entity* source, Entity* target)
{
    for (auto& requirement : source->card.playRequirements)
    {
        switch (requirement.first)
        {
            case +PlayReq::REQ_MINION_TARGET:
            {
                if (dynamic_cast<Minion*>(target) == nullptr)
                {
                    return false;
                }
                break;
            }
            case +PlayReq::REQ_ENEMY_TARGET:
            {
                if (&target->GetOwner() == &source->GetOwner())
                {
                    return false;
                }
                break;
            }
            case +PlayReq::REQ_TARGET_TO_PLAY:
            {
                if (dynamic_cast<Character*>(target) == nullptr)
                {
                    return false;
                }
                break;
            }
            default:
                break;
        }
    }

    return true;
}
}  // namespace RosettaStone::Generic


Add missing macro check in test

Add missing macro check in test

--- src/tests/test_workfactor.cpp
+++ src/tests/test_workfactor.cpp
@@ -12,6 +12,7 @@

 namespace Botan_Tests {

+#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
 class PK_Workfactor_Tests : public Text_Based_Test
    {
    public:
@@ -41,5 +42,6 @@
    };

 BOTAN_REGISTER_TEST("pk_workfactor", PK_Workfactor_Tests);
+#endif

 }

<|original_code|>
/*
* (C) 2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include "tests.h"

#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
  #include <botan/workfactor.h>
#endif

namespace Botan_Tests {

class PK_Workfactor_Tests : public Text_Based_Test
   {
   public:
      PK_Workfactor_Tests() : Text_Based_Test("pubkey/workfactor.vec",
                                              {"ParamSize", "Workfactor"})
         {}

      Test::Result run_one_test(const std::string& type, const VarMap& vars) override
         {
         const size_t param_size  = get_req_sz(vars, "ParamSize");
         const size_t exp_output  = get_req_sz(vars, "Workfactor");

         size_t output = 0;

         // TODO: test McEliece strength tests also

         if(type == "RSA_Strength")
            output = Botan::if_work_factor(param_size);
         else if(type == "DL_Exponent_Size")
            output = Botan::dl_exponent_size(param_size) / 2;

         Test::Result result(type + " work factor calculation");
         result.test_eq("Calculated workfactor for " + std::to_string(param_size),
                        output, exp_output);
         return result;
         }
   };

BOTAN_REGISTER_TEST("pk_workfactor", PK_Workfactor_Tests);

}

<|edits_diff|>
--- src/tests/test_workfactor.cpp
+++ src/tests/test_workfactor.cpp
@@ -12,6 +12,7 @@

 namespace Botan_Tests {

+#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
 class PK_Workfactor_Tests : public Text_Based_Test
    {
    public:
<|current_version|>
/*
* (C) 2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include "tests.h"

#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
  #include <botan/workfactor.h>
#endif

namespace Botan_Tests {

#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
class PK_Workfactor_Tests : public Text_Based_Test
   {
   public:
      PK_Workfactor_Tests() : Text_Based_Test("pubkey/workfactor.vec",
                                              {"ParamSize", "Workfactor"})
         {}

      Test::Result run_one_test(const std::string& type, const VarMap& vars) override
         {
         const size_t param_size  = get_req_sz(vars, "ParamSize");
         const size_t exp_output  = get_req_sz(vars, "Workfactor");

         size_t output = 0;

         // TODO: test McEliece strength tests also

         if(type == "RSA_Strength")
            output = Botan::if_work_factor(param_size);
         else if(type == "DL_Exponent_Size")
            output = Botan::dl_exponent_size(param_size) / 2;

         Test::Result result(type + " work factor calculation");
         result.test_eq("Calculated workfactor for " + std::to_string(param_size),
                        output, exp_output);
         return result;
         }
   };

BOTAN_REGISTER_TEST("pk_workfactor", PK_Workfactor_Tests);

}

<|next_version|>
/*
* (C) 2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include "tests.h"

#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
  #include <botan/workfactor.h>
#endif

namespace Botan_Tests {

#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
class PK_Workfactor_Tests : public Text_Based_Test
   {
   public:
      PK_Workfactor_Tests() : Text_Based_Test("pubkey/workfactor.vec",
                                              {"ParamSize", "Workfactor"})
         {}

      Test::Result run_one_test(const std::string& type, const VarMap& vars) override
         {
         const size_t param_size  = get_req_sz(vars, "ParamSize");
         const size_t exp_output  = get_req_sz(vars, "Workfactor");

         size_t output = 0;

         // TODO: test McEliece strength tests also

         if(type == "RSA_Strength")
            output = Botan::if_work_factor(param_size);
         else if(type == "DL_Exponent_Size")
            output = Botan::dl_exponent_size(param_size) / 2;

         Test::Result result(type + " work factor calculation");
         result.test_eq("Calculated workfactor for " + std::to_string(param_size),
                        output, exp_output);
         return result;
         }
   };

BOTAN_REGISTER_TEST("pk_workfactor", PK_Workfactor_Tests);
#endif

}


Tweak to indicate that different sizes still work.

--- questions/lineedit-frame-37831979/main.cpp
+++ questions/lineedit-frame-37831979/main.cpp
@@ -30,7 +30,10 @@
    auto w = QUiLoader().load(&buf);
    auto & layout = *static_cast<QFormLayout*>(w->layout());
    QLineEdit edit;
+   layout.itemAt(0)->widget()->setMinimumHeight(50);
    layout.addRow("Edit here", &edit);
+   edit.setMinimumHeight(100);
+   layout.activate();
    w->show();
    return app.exec();
 }

<|original_code|>
// https://github.com/KubaO/stackoverflown/tree/master/questions/lineedit-frame-37831979
#include <QtWidgets>
#include <QtUiTools>

const char ui[] = R"EOF(
 <ui version="4.0">
  <class>Form</class>
  <widget class="QWidget" name="Form">
   <layout class="QFormLayout" name="formLayout">
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>TextLabel</string>
      </property>
     </widget>
    </item>
    <item row="0" column="1">
     <widget class="QLineEdit" name="lineEdit"/>
    </item>
   </layout>
  </widget>
  <resources/>
  <connections/>
 </ui>)EOF";

int main(int argc, char ** argv) {
   QApplication app{argc, argv};
   QBuffer buf;
   buf.setData(ui, sizeof(ui));
   auto w = QUiLoader().load(&buf);
   auto & layout = *static_cast<QFormLayout*>(w->layout());
   QLineEdit edit;
   layout.addRow("Edit here", &edit);
   w->show();
   return app.exec();
}

<|edits_diff|>
--- questions/lineedit-frame-37831979/main.cpp
+++ questions/lineedit-frame-37831979/main.cpp
@@ -30,6 +30,7 @@
    auto w = QUiLoader().load(&buf);
    auto & layout = *static_cast<QFormLayout*>(w->layout());
    QLineEdit edit;
+   layout.itemAt(0)->widget()->setMinimumHeight(50);
    layout.addRow("Edit here", &edit);
    w->show();
    return app.exec();
<|current_version|>
// https://github.com/KubaO/stackoverflown/tree/master/questions/lineedit-frame-37831979
#include <QtWidgets>
#include <QtUiTools>

const char ui[] = R"EOF(
 <ui version="4.0">
  <class>Form</class>
  <widget class="QWidget" name="Form">
   <layout class="QFormLayout" name="formLayout">
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>TextLabel</string>
      </property>
     </widget>
    </item>
    <item row="0" column="1">
     <widget class="QLineEdit" name="lineEdit"/>
    </item>
   </layout>
  </widget>
  <resources/>
  <connections/>
 </ui>)EOF";

int main(int argc, char ** argv) {
   QApplication app{argc, argv};
   QBuffer buf;
   buf.setData(ui, sizeof(ui));
   auto w = QUiLoader().load(&buf);
   auto & layout = *static_cast<QFormLayout*>(w->layout());
   QLineEdit edit;
   layout.itemAt(0)->widget()->setMinimumHeight(50);
   layout.addRow("Edit here", &edit);
   w->show();
   return app.exec();
}

<|next_version|>
// https://github.com/KubaO/stackoverflown/tree/master/questions/lineedit-frame-37831979
#include <QtWidgets>
#include <QtUiTools>

const char ui[] = R"EOF(
 <ui version="4.0">
  <class>Form</class>
  <widget class="QWidget" name="Form">
   <layout class="QFormLayout" name="formLayout">
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>TextLabel</string>
      </property>
     </widget>
    </item>
    <item row="0" column="1">
     <widget class="QLineEdit" name="lineEdit"/>
    </item>
   </layout>
  </widget>
  <resources/>
  <connections/>
 </ui>)EOF";

int main(int argc, char ** argv) {
   QApplication app{argc, argv};
   QBuffer buf;
   buf.setData(ui, sizeof(ui));
   auto w = QUiLoader().load(&buf);
   auto & layout = *static_cast<QFormLayout*>(w->layout());
   QLineEdit edit;
   layout.itemAt(0)->widget()->setMinimumHeight(50);
   layout.addRow("Edit here", &edit);
   edit.setMinimumHeight(100);
   layout.activate();
   w->show();
   return app.exec();
}


Initialize Winsock only on Windows

Initialize Winsock only on Windows

--- ouzel/network/Network.cpp
+++ ouzel/network/Network.cpp
@@ -27,6 +27,7 @@

         bool Network::init()
         {
+#ifdef _WIN32
             WORD sockVersion = MAKEWORD(2, 2);
             WSADATA wsaData;
             int error = WSAStartup(sockVersion, &wsaData);
@@ -42,6 +43,7 @@
                 WSACleanup();
                 return false;
             }
+#endif

             return true;
         }

<|original_code|>
// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.

#ifdef _WIN32
#define NOMINMAX
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <poll.h>
#endif
#include "Network.hpp"
#include "utils/Log.hpp"

namespace ouzel
{
    namespace network
    {
        Network::Network()
        {
        }

        Network::~Network()
        {
            WSACleanup();
        }

        bool Network::init()
        {
            WORD sockVersion = MAKEWORD(2, 2);
            WSADATA wsaData;
            int error = WSAStartup(sockVersion, &wsaData);
            if (error != 0)
            {
                Log(Log::Level::ERR) << "Failed to start Winsock failed, error: " << error;
                return false;
            }

            if (wsaData.wVersion != sockVersion)
            {
                Log(Log::Level::ERR) << "Incorrect Winsock version";
                WSACleanup();
                return false;
            }

            return true;
        }
    } // namespace network
} // namespace ouzel

<|edits_diff|>
--- ouzel/network/Network.cpp
+++ ouzel/network/Network.cpp
@@ -27,6 +27,7 @@

         bool Network::init()
         {
+#ifdef _WIN32
             WORD sockVersion = MAKEWORD(2, 2);
             WSADATA wsaData;
             int error = WSAStartup(sockVersion, &wsaData);
<|current_version|>
// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.

#ifdef _WIN32
#define NOMINMAX
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <poll.h>
#endif
#include "Network.hpp"
#include "utils/Log.hpp"

namespace ouzel
{
    namespace network
    {
        Network::Network()
        {
        }

        Network::~Network()
        {
            WSACleanup();
        }

        bool Network::init()
        {
#ifdef _WIN32
            WORD sockVersion = MAKEWORD(2, 2);
            WSADATA wsaData;
            int error = WSAStartup(sockVersion, &wsaData);
            if (error != 0)
            {
                Log(Log::Level::ERR) << "Failed to start Winsock failed, error: " << error;
                return false;
            }

            if (wsaData.wVersion != sockVersion)
            {
                Log(Log::Level::ERR) << "Incorrect Winsock version";
                WSACleanup();
                return false;
            }

            return true;
        }
    } // namespace network
} // namespace ouzel

<|next_version|>
// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.

#ifdef _WIN32
#define NOMINMAX
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <poll.h>
#endif
#include "Network.hpp"
#include "utils/Log.hpp"

namespace ouzel
{
    namespace network
    {
        Network::Network()
        {
        }

        Network::~Network()
        {
            WSACleanup();
        }

        bool Network::init()
        {
#ifdef _WIN32
            WORD sockVersion = MAKEWORD(2, 2);
            WSADATA wsaData;
            int error = WSAStartup(sockVersion, &wsaData);
            if (error != 0)
            {
                Log(Log::Level::ERR) << "Failed to start Winsock failed, error: " << error;
                return false;
            }

            if (wsaData.wVersion != sockVersion)
            {
                Log(Log::Level::ERR) << "Incorrect Winsock version";
                WSACleanup();
                return false;
            }
#endif

            return true;
        }
    } // namespace network
} // namespace ouzel


Add another guard against multiple definition

--- sm_common/test/assert_macros_always_assert.cpp
+++ sm_common/test/assert_macros_always_assert.cpp
@@ -3,7 +3,9 @@
 #ifndef NDEBUG
 #define NDEBUG
 #endif
+#ifndef SM_ALWAYS_ASSERT
 #define SM_ALWAYS_ASSERT
+#endif
 #include <sm/assert_macros.hpp>

 TEST(SmCommonTestSuite,testAssertMacrosAlwaysAssert)

<|original_code|>
#include <gtest/gtest.h>

#ifndef NDEBUG
#define NDEBUG
#endif
#define SM_ALWAYS_ASSERT
#include <sm/assert_macros.hpp>

TEST(SmCommonTestSuite,testAssertMacrosAlwaysAssert)
{
  SM_DEFINE_EXCEPTION(Exception, std::runtime_error);
  EXPECT_THROW( SM_ASSERT_TRUE_DBG(Exception, false, ""), Exception);
}

<|edits_diff|>
--- sm_common/test/assert_macros_always_assert.cpp
+++ sm_common/test/assert_macros_always_assert.cpp
@@ -3,6 +3,7 @@
 #ifndef NDEBUG
 #define NDEBUG
 #endif
+#ifndef SM_ALWAYS_ASSERT
 #define SM_ALWAYS_ASSERT
 #include <sm/assert_macros.hpp>

<|current_version|>
#include <gtest/gtest.h>

#ifndef NDEBUG
#define NDEBUG
#endif
#ifndef SM_ALWAYS_ASSERT
#define SM_ALWAYS_ASSERT
#include <sm/assert_macros.hpp>

TEST(SmCommonTestSuite,testAssertMacrosAlwaysAssert)
{
  SM_DEFINE_EXCEPTION(Exception, std::runtime_error);
  EXPECT_THROW( SM_ASSERT_TRUE_DBG(Exception, false, ""), Exception);
}

<|next_version|>
#include <gtest/gtest.h>

#ifndef NDEBUG
#define NDEBUG
#endif
#ifndef SM_ALWAYS_ASSERT
#define SM_ALWAYS_ASSERT
#endif
#include <sm/assert_macros.hpp>

TEST(SmCommonTestSuite,testAssertMacrosAlwaysAssert)
{
  SM_DEFINE_EXCEPTION(Exception, std::runtime_error);
  EXPECT_THROW( SM_ASSERT_TRUE_DBG(Exception, false, ""), Exception);
}


Reduce example uses additive calls

Reduce example uses additive calls

--- examples/src/example_reduce.c
+++ examples/src/example_reduce.c
@@ -10,6 +10,7 @@
 #include <stdio.h>

 void recvFunction(void*, NDM_Metadata);
+void additiveRecvFunction(void*, NDM_Metadata);

 int main(int argc, char* argv[]) {
   int provided;
@@ -21,6 +22,9 @@
   ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
   ndmGroupRank(NDM_GLOBAL_GROUP, &data);
   ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
+  data = 5;
+  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
+  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
   ndmFinalise();
   MPI_Finalize();
   return 0;
@@ -29,3 +33,5 @@
 void recvFunction(void* buffer, NDM_Metadata metaData) {
   printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
 }
+
+void additiveRecvFunction(void* buffer, NDM_Metadata metaData) { printf("Got additive data '%d'\n", *((int*)buffer)); }

<|original_code|>
/*
 * example2.c
 *
 *  Created on: 3 May 2016
 *      Author: nick
 */

#include "ndm.h"
#include <mpi.h>
#include <stdio.h>

void recvFunction(void*, NDM_Metadata);

int main(int argc, char* argv[]) {
  int provided;
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
  ndmInit();

  char uuid[10];
  int data = 10;
  ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
  ndmGroupRank(NDM_GLOBAL_GROUP, &data);
  ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
  ndmFinalise();
  MPI_Finalize();
  return 0;
}

void recvFunction(void* buffer, NDM_Metadata metaData) {
  printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
}

<|edits_diff|>
--- examples/src/example_reduce.c
+++ examples/src/example_reduce.c
@@ -10,6 +10,7 @@
 #include <stdio.h>

 void recvFunction(void*, NDM_Metadata);
+void additiveRecvFunction(void*, NDM_Metadata);

 int main(int argc, char* argv[]) {
   int provided;
@@ -21,6 +22,9 @@
   ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
   ndmGroupRank(NDM_GLOBAL_GROUP, &data);
   ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
+  data = 5;
+  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
+  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
   ndmFinalise();
   MPI_Finalize();
   return 0;
<|current_version|>
/*
 * example2.c
 *
 *  Created on: 3 May 2016
 *      Author: nick
 */

#include "ndm.h"
#include <mpi.h>
#include <stdio.h>

void recvFunction(void*, NDM_Metadata);
void additiveRecvFunction(void*, NDM_Metadata);

int main(int argc, char* argv[]) {
  int provided;
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
  ndmInit();

  char uuid[10];
  int data = 10;
  ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
  ndmGroupRank(NDM_GLOBAL_GROUP, &data);
  ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
  data = 5;
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmFinalise();
  MPI_Finalize();
  return 0;
}

void recvFunction(void* buffer, NDM_Metadata metaData) {
  printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
}

<|next_version|>
/*
 * example2.c
 *
 *  Created on: 3 May 2016
 *      Author: nick
 */

#include "ndm.h"
#include <mpi.h>
#include <stdio.h>

void recvFunction(void*, NDM_Metadata);
void additiveRecvFunction(void*, NDM_Metadata);

int main(int argc, char* argv[]) {
  int provided;
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
  ndmInit();

  char uuid[10];
  int data = 10;
  ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
  ndmGroupRank(NDM_GLOBAL_GROUP, &data);
  ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
  data = 5;
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmFinalise();
  MPI_Finalize();
  return 0;
}

void recvFunction(void* buffer, NDM_Metadata metaData) {
  printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
}

void additiveRecvFunction(void* buffer, NDM_Metadata metaData) { printf("Got additive data '%d'\n", *((int*)buffer)); }


Add max length error check

Add max length error check

--- utils/metatag.c
+++ utils/metatag.c
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>

+#define MAX_LEN 1024

 int main(int argc, char** argv){
     char* buffer;
@@ -29,6 +30,10 @@
         strcat(buffer, " ");
     }
     len = strlen(buffer);
+    if(len > MAX_LEN-1){
+        fprintf(stderr, "Input stream exceeds max length\n");
+        exit(1);
+    }
     metawrite(fd,&buffer,len);
     close(fd);
     return 0;

<|original_code|>
/* metatag.c: Program for adding metadata to a file
 * By: Forrest Kerslager, Nick Noto, David Taylor, Kevin Yeap,
 *     Connie Yu
 *
 * 2014/06/06
 * */

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

int main(int argc, char** argv){
    char* buffer;
    int fd, i, len;

    if(argc < 3){
        fprintf(stderr, "Usage: metatag FILE TAG\n");
        exit(1);
    }
    fd=open(argv[1], O_RDWR);
    if(fd == -1){
        fprintf(stderr, "Error, file not found\n");
        exit(1);
    }
    buffer = "";
    for(i=2; i<argc; i++){
        strcat(buffer, argv[i]);
        strcat(buffer, " ");
    }
    len = strlen(buffer);
    metawrite(fd,&buffer,len);
    close(fd);
    return 0;

}

<|edits_diff|>
--- utils/metatag.c
+++ utils/metatag.c
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>

+#define MAX_LEN 1024

 int main(int argc, char** argv){
     char* buffer;
<|current_version|>
/* metatag.c: Program for adding metadata to a file
 * By: Forrest Kerslager, Nick Noto, David Taylor, Kevin Yeap,
 *     Connie Yu
 *
 * 2014/06/06
 * */

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

#define MAX_LEN 1024

int main(int argc, char** argv){
    char* buffer;
    int fd, i, len;

    if(argc < 3){
        fprintf(stderr, "Usage: metatag FILE TAG\n");
        exit(1);
    }
    fd=open(argv[1], O_RDWR);
    if(fd == -1){
        fprintf(stderr, "Error, file not found\n");
        exit(1);
    }
    buffer = "";
    for(i=2; i<argc; i++){
        strcat(buffer, argv[i]);
        strcat(buffer, " ");
    }
    len = strlen(buffer);
    metawrite(fd,&buffer,len);
    close(fd);
    return 0;

}

<|next_version|>
/* metatag.c: Program for adding metadata to a file
 * By: Forrest Kerslager, Nick Noto, David Taylor, Kevin Yeap,
 *     Connie Yu
 *
 * 2014/06/06
 * */

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

#define MAX_LEN 1024

int main(int argc, char** argv){
    char* buffer;
    int fd, i, len;

    if(argc < 3){
        fprintf(stderr, "Usage: metatag FILE TAG\n");
        exit(1);
    }
    fd=open(argv[1], O_RDWR);
    if(fd == -1){
        fprintf(stderr, "Error, file not found\n");
        exit(1);
    }
    buffer = "";
    for(i=2; i<argc; i++){
        strcat(buffer, argv[i]);
        strcat(buffer, " ");
    }
    len = strlen(buffer);
    if(len > MAX_LEN-1){
        fprintf(stderr, "Input stream exceeds max length\n");
        exit(1);
    }
    metawrite(fd,&buffer,len);
    close(fd);
    return 0;

}


Define the method updateNotification in meetingbussiness

--- MeetingApp/Meeting/Protocols/IMeetingDelegate.h
+++ MeetingApp/Meeting/Protocols/IMeetingDelegate.h
@@ -10,6 +10,11 @@

 #import "Meeting.h"

+typedef enum  NotificationType {
+    NOTIFICATION_TYPE_EMAIL,
+    NOTIFICATION_TYPE_CALENDAR
+} NotificationType;
+
 @protocol IMeetingDelegate <NSObject>

 @optional
@@ -21,4 +26,7 @@

 - (void) updateDetail: (MutableMeeting *) meeting;

+// TODO: Send to update the notification
+- (void) updateNotification: (NotificationType) type withCallback:(void (^)(BOOL updated)) callback;
+
 @end

<|original_code|>
//
//  IMeetingDelegate.h
//  MeetingApp
//
//  Created by Estefania Chavez Guardado on 2/27/16.
//  Copyright © 2016 Estefania Chavez Guardado. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "Meeting.h"

@protocol IMeetingDelegate <NSObject>

@optional

- (void) update: (MutableMeeting *) newMeeting;

- (void) moveToInactiveMeetings:(int) indexMeeting
          andInactiveTheMeeting: (NSString *) idMeeting;

- (void) updateDetail: (MutableMeeting *) meeting;

@end
<|edits_diff|>
--- MeetingApp/Meeting/Protocols/IMeetingDelegate.h
+++ MeetingApp/Meeting/Protocols/IMeetingDelegate.h
@@ -9,6 +9,11 @@
 #import <UIKit/UIKit.h>

 #import "Meeting.h"
+
+typedef enum  NotificationType {
+    NOTIFICATION_TYPE_EMAIL,
+    NOTIFICATION_TYPE_CALENDAR
+} NotificationType;

 @protocol IMeetingDelegate <NSObject>

<|current_version|>
//
//  IMeetingDelegate.h
//  MeetingApp
//
//  Created by Estefania Chavez Guardado on 2/27/16.
//  Copyright © 2016 Estefania Chavez Guardado. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "Meeting.h"

typedef enum  NotificationType {
    NOTIFICATION_TYPE_EMAIL,
    NOTIFICATION_TYPE_CALENDAR
} NotificationType;

@protocol IMeetingDelegate <NSObject>

@optional

- (void) update: (MutableMeeting *) newMeeting;

- (void) moveToInactiveMeetings:(int) indexMeeting
          andInactiveTheMeeting: (NSString *) idMeeting;

- (void) updateDetail: (MutableMeeting *) meeting;

@end
<|next_version|>
//
//  IMeetingDelegate.h
//  MeetingApp
//
//  Created by Estefania Chavez Guardado on 2/27/16.
//  Copyright © 2016 Estefania Chavez Guardado. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "Meeting.h"

typedef enum  NotificationType {
    NOTIFICATION_TYPE_EMAIL,
    NOTIFICATION_TYPE_CALENDAR
} NotificationType;

@protocol IMeetingDelegate <NSObject>

@optional

- (void) update: (MutableMeeting *) newMeeting;

- (void) moveToInactiveMeetings:(int) indexMeeting
          andInactiveTheMeeting: (NSString *) idMeeting;

- (void) updateDetail: (MutableMeeting *) meeting;

// TODO: Send to update the notification
- (void) updateNotification: (NotificationType) type withCallback:(void (^)(BOOL updated)) callback;

@end


Fix leak in calloc failure path.

Fix leak in calloc failure path.

--- libraries/datastruct/hash/create.c
+++ libraries/datastruct/hash/create.c
@@ -37,7 +37,10 @@

   bins = calloc(nbins, sizeof(*h->bins));
   if (bins == NULL)
+  {
+    free(h);
     return error_OOM;
+  }

   h->bins          = bins;
   h->nbins         = nbins;

<|original_code|>
/* --------------------------------------------------------------------------
 *    Name: create.c
 * Purpose: Associative array implemented as a hash
 * ----------------------------------------------------------------------- */

#include <stdlib.h>
#include <string.h>

#include "base/memento/memento.h"

#include "base/errors.h"
#include "utils/utils.h"
#include "utils/primes.h"

#include "datastruct/hash.h"

#include "impl.h"

/* ----------------------------------------------------------------------- */

error hash_create(const void         *default_value,
                  int                 nbins,
                  hash_fn            *fn,
                  hash_compare       *compare,
                  hash_destroy_key   *destroy_key,
                  hash_destroy_value *destroy_value,
                  hash_t            **ph)
{
  hash_t        *h;
  hash__node_t **bins;

  h = malloc(sizeof(*h));
  if (h == NULL)
    return error_OOM;

  nbins = prime_nearest(nbins);

  bins = calloc(nbins, sizeof(*h->bins));
  if (bins == NULL)
    return error_OOM;

  h->bins          = bins;
  h->nbins         = nbins;

  h->count         = 0;

  h->default_value = default_value;

  h->hash_fn       = fn;
  h->compare       = compare;
  h->destroy_key   = destroy_key;
  h->destroy_value = destroy_value;

  *ph = h;

  return error_OK;
}

<|edits_diff|>
--- libraries/datastruct/hash/create.c
+++ libraries/datastruct/hash/create.c
@@ -37,6 +37,8 @@

   bins = calloc(nbins, sizeof(*h->bins));
   if (bins == NULL)
+  {
+    free(h);
     return error_OOM;

   h->bins          = bins;
<|current_version|>
/* --------------------------------------------------------------------------
 *    Name: create.c
 * Purpose: Associative array implemented as a hash
 * ----------------------------------------------------------------------- */

#include <stdlib.h>
#include <string.h>

#include "base/memento/memento.h"

#include "base/errors.h"
#include "utils/utils.h"
#include "utils/primes.h"

#include "datastruct/hash.h"

#include "impl.h"

/* ----------------------------------------------------------------------- */

error hash_create(const void         *default_value,
                  int                 nbins,
                  hash_fn            *fn,
                  hash_compare       *compare,
                  hash_destroy_key   *destroy_key,
                  hash_destroy_value *destroy_value,
                  hash_t            **ph)
{
  hash_t        *h;
  hash__node_t **bins;

  h = malloc(sizeof(*h));
  if (h == NULL)
    return error_OOM;

  nbins = prime_nearest(nbins);

  bins = calloc(nbins, sizeof(*h->bins));
  if (bins == NULL)
  {
    free(h);
    return error_OOM;

  h->bins          = bins;
  h->nbins         = nbins;

  h->count         = 0;

  h->default_value = default_value;

  h->hash_fn       = fn;
  h->compare       = compare;
  h->destroy_key   = destroy_key;
  h->destroy_value = destroy_value;

  *ph = h;

  return error_OK;
}

<|next_version|>
/* --------------------------------------------------------------------------
 *    Name: create.c
 * Purpose: Associative array implemented as a hash
 * ----------------------------------------------------------------------- */

#include <stdlib.h>
#include <string.h>

#include "base/memento/memento.h"

#include "base/errors.h"
#include "utils/utils.h"
#include "utils/primes.h"

#include "datastruct/hash.h"

#include "impl.h"

/* ----------------------------------------------------------------------- */

error hash_create(const void         *default_value,
                  int                 nbins,
                  hash_fn            *fn,
                  hash_compare       *compare,
                  hash_destroy_key   *destroy_key,
                  hash_destroy_value *destroy_value,
                  hash_t            **ph)
{
  hash_t        *h;
  hash__node_t **bins;

  h = malloc(sizeof(*h));
  if (h == NULL)
    return error_OOM;

  nbins = prime_nearest(nbins);

  bins = calloc(nbins, sizeof(*h->bins));
  if (bins == NULL)
  {
    free(h);
    return error_OOM;
  }

  h->bins          = bins;
  h->nbins         = nbins;

  h->count         = 0;

  h->default_value = default_value;

  h->hash_fn       = fn;
  h->compare       = compare;
  h->destroy_key   = destroy_key;
  h->destroy_value = destroy_value;

  *ph = h;

  return error_OK;
}


Add method 'RClean' for clean memory

Add method 'RClean' for clean memory

--- src/Core/RAlloc.h
+++ src/Core/RAlloc.h
@@ -1,5 +1,7 @@
 #ifndef RUTIL2_RALLOC_H
 #define RUTIL2_RALLOC_H
+
+#include <memory.h>

 #include "OO.h"

@@ -11,6 +13,8 @@
 #define _aligned_free  __mingw_aligned_free
 #define memalign(align, size) _aligned_malloc(size, align)
 #endif //For MinGW
+
+#define RClean(Ptr) memset(Ptr, 0, sizeof(Ptr));

 #define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
 void __RFree(void* a, ...);

<|original_code|>
#ifndef RUTIL2_RALLOC_H
#define RUTIL2_RALLOC_H

#include "OO.h"

void* RAlloc(int Size);
void* RAlign(int Align, int Size);

#if defined(__MINGW32__)
#define _aligned_malloc __mingw_aligned_malloc
#define _aligned_free  __mingw_aligned_free
#define memalign(align, size) _aligned_malloc(size, align)
#endif //For MinGW

#define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
void __RFree(void* a, ...);

#define RAlloc_Class(Name, Size) \
    (Name*)__RAlloc_Class(Size, sizeof(Name), _C(__ClassID_, Name, __));
void* __RAlloc_Class(int Size, int UnitSize, int ClassID);

#if 0
#include "_RAlloc.h"
#endif
#ifdef __RUtil2_Install
#define _RTAddress "RUtil2/Core/_RAlloc.h"
#else
#define _RTAddress "Core/_RAlloc.h"
#endif

#define _ClassName
#define _Attr 1

#include "Include_T1AllTypes.h"

#endif //RUTIL2_RALLOC_H

<|edits_diff|>
--- src/Core/RAlloc.h
+++ src/Core/RAlloc.h
@@ -1,5 +1,7 @@
 #ifndef RUTIL2_RALLOC_H
 #define RUTIL2_RALLOC_H
+
+#include <memory.h>

 #include "OO.h"

<|current_version|>
#ifndef RUTIL2_RALLOC_H
#define RUTIL2_RALLOC_H

#include <memory.h>

#include "OO.h"

void* RAlloc(int Size);
void* RAlign(int Align, int Size);

#if defined(__MINGW32__)
#define _aligned_malloc __mingw_aligned_malloc
#define _aligned_free  __mingw_aligned_free
#define memalign(align, size) _aligned_malloc(size, align)
#endif //For MinGW

#define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
void __RFree(void* a, ...);

#define RAlloc_Class(Name, Size) \
    (Name*)__RAlloc_Class(Size, sizeof(Name), _C(__ClassID_, Name, __));
void* __RAlloc_Class(int Size, int UnitSize, int ClassID);

#if 0
#include "_RAlloc.h"
#endif
#ifdef __RUtil2_Install
#define _RTAddress "RUtil2/Core/_RAlloc.h"
#else
#define _RTAddress "Core/_RAlloc.h"
#endif

#define _ClassName
#define _Attr 1

#include "Include_T1AllTypes.h"

#endif //RUTIL2_RALLOC_H

<|next_version|>
#ifndef RUTIL2_RALLOC_H
#define RUTIL2_RALLOC_H

#include <memory.h>

#include "OO.h"

void* RAlloc(int Size);
void* RAlign(int Align, int Size);

#if defined(__MINGW32__)
#define _aligned_malloc __mingw_aligned_malloc
#define _aligned_free  __mingw_aligned_free
#define memalign(align, size) _aligned_malloc(size, align)
#endif //For MinGW

#define RClean(Ptr) memset(Ptr, 0, sizeof(Ptr));

#define RFree(...) __RFree(__VA_ARGS__, (void*)(- 1))
void __RFree(void* a, ...);

#define RAlloc_Class(Name, Size) \
    (Name*)__RAlloc_Class(Size, sizeof(Name), _C(__ClassID_, Name, __));
void* __RAlloc_Class(int Size, int UnitSize, int ClassID);

#if 0
#include "_RAlloc.h"
#endif
#ifdef __RUtil2_Install
#define _RTAddress "RUtil2/Core/_RAlloc.h"
#else
#define _RTAddress "Core/_RAlloc.h"
#endif

#define _ClassName
#define _Attr 1

#include "Include_T1AllTypes.h"

#endif //RUTIL2_RALLOC_H


Set up a client id and a client secret for production environment

--- PHPHub/Constants/SecretConstant.example.h
+++ PHPHub/Constants/SecretConstant.example.h
@@ -6,8 +6,14 @@
 //  Copyright (c) 2015 ESTGroup. All rights reserved.
 //

+#if DEBUG
 #define Client_id       @"kHOugsx4dmcXwvVbmLkd"
 #define Client_secret   @"PuuFCrF94MloSbSkxpwS"
+#else
+#define Client_id       @"Set up a client id for production env"
+#define Client_secret   @"Set up a client secret for production env"
+#endif
+
 #define UMENG_APPKEY    @"Set up UMEng App Key"
 #define UMENG_QQ_ID     @"Set up qq id"
 #define UMENG_QQ_APPKEY @"Set up qq appkey"

<|original_code|>
//
//  SecretConstant.example.h
//  PHPHub
//
//  Created by Aufree on 9/30/15.
//  Copyright (c) 2015 ESTGroup. All rights reserved.
//

#define Client_id       @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret   @"PuuFCrF94MloSbSkxpwS"
#define UMENG_APPKEY    @"Set up UMEng App Key"
#define UMENG_QQ_ID     @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID       @"Set up weixin app id"
#define WX_APP_SECRET   @"Set up weixin app secret"
#define TRACKING_ID     @"Set up google anlytics tracking id"
<|edits_diff|>
--- PHPHub/Constants/SecretConstant.example.h
+++ PHPHub/Constants/SecretConstant.example.h
@@ -6,6 +6,7 @@
 //  Copyright (c) 2015 ESTGroup. All rights reserved.
 //

+#if DEBUG
 #define Client_id       @"kHOugsx4dmcXwvVbmLkd"
 #define Client_secret   @"PuuFCrF94MloSbSkxpwS"
 #define UMENG_APPKEY    @"Set up UMEng App Key"
<|current_version|>
//
//  SecretConstant.example.h
//  PHPHub
//
//  Created by Aufree on 9/30/15.
//  Copyright (c) 2015 ESTGroup. All rights reserved.
//

#if DEBUG
#define Client_id       @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret   @"PuuFCrF94MloSbSkxpwS"
#define UMENG_APPKEY    @"Set up UMEng App Key"
#define UMENG_QQ_ID     @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID       @"Set up weixin app id"
#define WX_APP_SECRET   @"Set up weixin app secret"
#define TRACKING_ID     @"Set up google anlytics tracking id"
<|next_version|>
//
//  SecretConstant.example.h
//  PHPHub
//
//  Created by Aufree on 9/30/15.
//  Copyright (c) 2015 ESTGroup. All rights reserved.
//

#if DEBUG
#define Client_id       @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret   @"PuuFCrF94MloSbSkxpwS"
#else
#define Client_id       @"Set up a client id for production env"
#define Client_secret   @"Set up a client secret for production env"
#endif

#define UMENG_APPKEY    @"Set up UMEng App Key"
#define UMENG_QQ_ID     @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID       @"Set up weixin app id"
#define WX_APP_SECRET   @"Set up weixin app secret"
#define TRACKING_ID     @"Set up google anlytics tracking id"


Define functions for polling of sockets.

--- server.h
+++ server.h
@@ -4,8 +4,13 @@
 #include <sys/epoll.h>
 #include "list.h"
 #include "threadpool.h"
+struct http_socket;
+
 int open_listenfd(int port);
 void* check_connections(void* data);
+int watch_read(struct http_socket* http);
+int watch_write(struct http_socket* http);
+int destroy_socket(struct http_socket* http);

 struct http_socket {
     int fd;

<|original_code|>
#ifndef _SERVER_H
#define _SERVER_H
#include <time.h>
#include <sys/epoll.h>
#include "list.h"
#include "threadpool.h"
int open_listenfd(int port);
void* check_connections(void* data);

struct http_socket {
    int fd;
    /*struct pollfd* poll_fd;*/
    struct epoll_event event;
    char* read_buffer;
    int read_buffer_size;
    time_t last_access;
    struct list_elem elem;
};

struct future_elem {
    struct future* future;
    struct list_elem elem;
};
#endif

<|edits_diff|>
--- server.h
+++ server.h
@@ -4,6 +4,8 @@
 #include <sys/epoll.h>
 #include "list.h"
 #include "threadpool.h"
+struct http_socket;
+
 int open_listenfd(int port);
 void* check_connections(void* data);

<|current_version|>
#ifndef _SERVER_H
#define _SERVER_H
#include <time.h>
#include <sys/epoll.h>
#include "list.h"
#include "threadpool.h"
struct http_socket;

int open_listenfd(int port);
void* check_connections(void* data);

struct http_socket {
    int fd;
    /*struct pollfd* poll_fd;*/
    struct epoll_event event;
    char* read_buffer;
    int read_buffer_size;
    time_t last_access;
    struct list_elem elem;
};

struct future_elem {
    struct future* future;
    struct list_elem elem;
};
#endif

<|next_version|>
#ifndef _SERVER_H
#define _SERVER_H
#include <time.h>
#include <sys/epoll.h>
#include "list.h"
#include "threadpool.h"
struct http_socket;

int open_listenfd(int port);
void* check_connections(void* data);
int watch_read(struct http_socket* http);
int watch_write(struct http_socket* http);
int destroy_socket(struct http_socket* http);

struct http_socket {
    int fd;
    /*struct pollfd* poll_fd;*/
    struct epoll_event event;
    char* read_buffer;
    int read_buffer_size;
    time_t last_access;
    struct list_elem elem;
};

struct future_elem {
    struct future* future;
    struct list_elem elem;
};
#endif


Add comment for added macros.

Add comment for added macros.

--- pblib/pblib/PBMacros.h
+++ pblib/pblib/PBMacros.h
@@ -9,7 +9,16 @@
 #ifndef pblib_PBMacros_h
 #define pblib_PBMacros_h

+/**
+ Check against NSNull.
+ If input obj is NSNull then return YES, otherwise return NO.
+ */
 #define PB_IS_NSNull(obj)   ((obj == (id)[NSNull null]) ? YES : NO)

+/**
+ Check against nil or NSNull.
+ If input obj is nil, or NSNull then return YES, otherwise return NO.
+ */
 #define PB_IS_NIL_OR_NSNull(obj)    ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
+
 #endif

<|original_code|>
//
//  PBMacros.h
//  pblib
//
//  Created by haxpor on 3/5/15.
//  Copyright (c) 2015 Maethee Chongchitnant. All rights reserved.
//

#ifndef pblib_PBMacros_h
#define pblib_PBMacros_h

#define PB_IS_NSNull(obj)   ((obj == (id)[NSNull null]) ? YES : NO)

#define PB_IS_NIL_OR_NSNull(obj)    ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
#endif

<|edits_diff|>
--- pblib/pblib/PBMacros.h
+++ pblib/pblib/PBMacros.h
@@ -9,7 +9,15 @@
 #ifndef pblib_PBMacros_h
 #define pblib_PBMacros_h

+/**
+ Check against NSNull.
+ If input obj is NSNull then return YES, otherwise return NO.
+ */
 #define PB_IS_NSNull(obj)   ((obj == (id)[NSNull null]) ? YES : NO)

+/**
+ Check against nil or NSNull.
+ If input obj is nil, or NSNull then return YES, otherwise return NO.
+ */
 #define PB_IS_NIL_OR_NSNull(obj)    ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
 #endif
<|current_version|>
//
//  PBMacros.h
//  pblib
//
//  Created by haxpor on 3/5/15.
//  Copyright (c) 2015 Maethee Chongchitnant. All rights reserved.
//

#ifndef pblib_PBMacros_h
#define pblib_PBMacros_h

/**
 Check against NSNull.
 If input obj is NSNull then return YES, otherwise return NO.
 */
#define PB_IS_NSNull(obj)   ((obj == (id)[NSNull null]) ? YES : NO)

/**
 Check against nil or NSNull.
 If input obj is nil, or NSNull then return YES, otherwise return NO.
 */
#define PB_IS_NIL_OR_NSNull(obj)    ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)
#endif

<|next_version|>
//
//  PBMacros.h
//  pblib
//
//  Created by haxpor on 3/5/15.
//  Copyright (c) 2015 Maethee Chongchitnant. All rights reserved.
//

#ifndef pblib_PBMacros_h
#define pblib_PBMacros_h

/**
 Check against NSNull.
 If input obj is NSNull then return YES, otherwise return NO.
 */
#define PB_IS_NSNull(obj)   ((obj == (id)[NSNull null]) ? YES : NO)

/**
 Check against nil or NSNull.
 If input obj is nil, or NSNull then return YES, otherwise return NO.
 */
#define PB_IS_NIL_OR_NSNull(obj)    ((obj == nil) || (obj == (id)[NSNull null]) ? YES : NO)

#endif


Update RingOpenGL 1.1 - Add Constant (Source Code) : GL_TEXTURE_COMPONENTS

--- extensions/ringopengl/opengl11/ring_opengl11.c
+++ extensions/ringopengl/opengl11/ring_opengl11.c
@@ -30,10 +30,16 @@
 	RING_API_RETNUMBER(GL_NONE);
 }

+RING_FUNC(ring_get_gl_texture_components)
+{
+	RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
+}
+
 RING_API void ringlib_init(RingState *pRingState)
 {
 	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
 	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
 	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
 	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
+	ring_vm_funcregister("get_gl_texture_components",ring_get_gl_texture_components);
 }

<|original_code|>
#include "ring.h"

/*
	OpenGL 1.1 Extension
	Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/

#include <GL/glew.h>
#include <GL/glut.h>

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_FUNC(ring_get_gl_false)
{
	RING_API_RETNUMBER(GL_FALSE);
}

RING_FUNC(ring_get_gl_logic_op)
{
	RING_API_RETNUMBER(GL_LOGIC_OP);
}

RING_FUNC(ring_get_gl_none)
{
	RING_API_RETNUMBER(GL_NONE);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
}

<|edits_diff|>
--- extensions/ringopengl/opengl11/ring_opengl11.c
+++ extensions/ringopengl/opengl11/ring_opengl11.c
@@ -30,6 +30,11 @@
 	RING_API_RETNUMBER(GL_NONE);
 }

+RING_FUNC(ring_get_gl_texture_components)
+{
+	RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
+}
+
 RING_API void ringlib_init(RingState *pRingState)
 {
 	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
<|current_version|>
#include "ring.h"

/*
	OpenGL 1.1 Extension
	Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/

#include <GL/glew.h>
#include <GL/glut.h>

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_FUNC(ring_get_gl_false)
{
	RING_API_RETNUMBER(GL_FALSE);
}

RING_FUNC(ring_get_gl_logic_op)
{
	RING_API_RETNUMBER(GL_LOGIC_OP);
}

RING_FUNC(ring_get_gl_none)
{
	RING_API_RETNUMBER(GL_NONE);
}

RING_FUNC(ring_get_gl_texture_components)
{
	RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
}

<|next_version|>
#include "ring.h"

/*
	OpenGL 1.1 Extension
	Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/

#include <GL/glew.h>
#include <GL/glut.h>

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_FUNC(ring_get_gl_false)
{
	RING_API_RETNUMBER(GL_FALSE);
}

RING_FUNC(ring_get_gl_logic_op)
{
	RING_API_RETNUMBER(GL_LOGIC_OP);
}

RING_FUNC(ring_get_gl_none)
{
	RING_API_RETNUMBER(GL_NONE);
}

RING_FUNC(ring_get_gl_texture_components)
{
	RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
	ring_vm_funcregister("get_gl_texture_components",ring_get_gl_texture_components);
}


Add visibility to epoll headers

Add visibility to epoll headers

The odp_epoll_* symbols were not visible in the final library built with
GCC.

Signed-off-by: Oriol Arcas <a98c9d4e37de3d71db2e1a293b51c579a914c4ae@starflownetworks.com>
Reviewed-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>

--- include/api/ofp_epoll.h
+++ include/api/ofp_epoll.h
@@ -9,6 +9,10 @@
 #define __OFP_EPOLL_H__

 #include <stdint.h>
+
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif

 typedef union ofp_epoll_data {
 	void    *ptr;
@@ -37,4 +41,8 @@

 int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

+#if __GNUC__ >= 4
+#pragma GCC visibility pop
 #endif
+
+#endif

<|original_code|>
/* Copyright (c) 2016, Nokia
 * Copyright (c) 2016, ENEA Software AB
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__

#include <stdint.h>

typedef union ofp_epoll_data {
	void    *ptr;
	int      fd;
	uint32_t u32;
	uint64_t u64;
} ofp_epoll_data_t;

struct ofp_epoll_event {
	uint32_t events;
	ofp_epoll_data_t data;
};

enum OFP_EPOLL_EVENTS {
	OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};

#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3

int ofp_epoll_create(int size);

int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);

int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

#endif

<|edits_diff|>
--- include/api/ofp_epoll.h
+++ include/api/ofp_epoll.h
@@ -9,6 +9,10 @@
 #define __OFP_EPOLL_H__

 #include <stdint.h>
+
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif

 typedef union ofp_epoll_data {
 	void    *ptr;
@@ -37,4 +41,6 @@

 int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

+#if __GNUC__ >= 4
+#pragma GCC visibility pop
 #endif
<|current_version|>
/* Copyright (c) 2016, Nokia
 * Copyright (c) 2016, ENEA Software AB
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__

#include <stdint.h>

#if __GNUC__ >= 4
#pragma GCC visibility push(default)
#endif

typedef union ofp_epoll_data {
	void    *ptr;
	int      fd;
	uint32_t u32;
	uint64_t u64;
} ofp_epoll_data_t;

struct ofp_epoll_event {
	uint32_t events;
	ofp_epoll_data_t data;
};

enum OFP_EPOLL_EVENTS {
	OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};

#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3

int ofp_epoll_create(int size);

int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);

int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif

<|next_version|>
/* Copyright (c) 2016, Nokia
 * Copyright (c) 2016, ENEA Software AB
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__

#include <stdint.h>

#if __GNUC__ >= 4
#pragma GCC visibility push(default)
#endif

typedef union ofp_epoll_data {
	void    *ptr;
	int      fd;
	uint32_t u32;
	uint64_t u64;
} ofp_epoll_data_t;

struct ofp_epoll_event {
	uint32_t events;
	ofp_epoll_data_t data;
};

enum OFP_EPOLL_EVENTS {
	OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};

#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3

int ofp_epoll_create(int size);

int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);

int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif

#endif


Set prgname to stub while in daemon

Set prgname to stub while in daemon

--- cmd_start_daemon.c
+++ cmd_start_daemon.c
@@ -30,12 +30,15 @@
 int
 start_daemon_main(const struct cmd_start_daemon_info* info)
 {
+    SCOPED_RESLIST(rl);
+
     struct cmd_stub_info sinfo = {
         .stub.listen = true,
         .stub.daemonize = true,
         .stub.replace = info->start_daemon.replace,
     };

+    set_prgname(xaprintf("%s stub", xbasename(orig_argv0)));
     return stub_main(&sinfo);
 }

<|original_code|>
/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"

FORWARD(start_daemon);

#if !FBADB_MAIN
#include "stubdaemon.h"

int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
    struct cmd_stub_info sinfo = {
        .stub.listen = true,
        .stub.daemonize = true,
        .stub.replace = info->start_daemon.replace,
    };

    return stub_main(&sinfo);
}

#endif

<|edits_diff|>
--- cmd_start_daemon.c
+++ cmd_start_daemon.c
@@ -30,6 +30,8 @@
 int
 start_daemon_main(const struct cmd_start_daemon_info* info)
 {
+    SCOPED_RESLIST(rl);
+
     struct cmd_stub_info sinfo = {
         .stub.listen = true,
         .stub.daemonize = true,
<|current_version|>
/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"

FORWARD(start_daemon);

#if !FBADB_MAIN
#include "stubdaemon.h"

int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
    SCOPED_RESLIST(rl);

    struct cmd_stub_info sinfo = {
        .stub.listen = true,
        .stub.daemonize = true,
        .stub.replace = info->start_daemon.replace,
    };

    return stub_main(&sinfo);
}

#endif

<|next_version|>
/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"

FORWARD(start_daemon);

#if !FBADB_MAIN
#include "stubdaemon.h"

int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
    SCOPED_RESLIST(rl);

    struct cmd_stub_info sinfo = {
        .stub.listen = true,
        .stub.daemonize = true,
        .stub.replace = info->start_daemon.replace,
    };

    set_prgname(xaprintf("%s stub", xbasename(orig_argv0)));
    return stub_main(&sinfo);
}

#endif