Print a qDebug saying what player is actually running

--- src/mediaplayer/main.cpp
+++ src/mediaplayer/main.cpp
@@ -29,9 +29,11 @@
     AbstractMediaPlayer *player = 0;
 #ifdef XINE_PLAYER
 #warning using xine backend
+    qDebug() << "Xine player started";
     player = new XinePlayer(&app);
 #else
 #warning using qDebug testing backend
+    qDebug() << "qDebug player started";
     player = new TestingPlayer(&app);
 #endif

<|original_code|>
#include "testingplayer.h"
#ifdef XINE_PLAYER
#include "xineplayer.h"
#endif

#include "qtsingleapplication.h"
#include <QDebug>
#include <QtDBus>

int main(int argc, char** argv)
{
    QtSingleApplication app(argc, argv);
    app.setApplicationName("mediahelper");
    app.setOrganizationName("Nokia");
    app.setOrganizationDomain("nokia.com");

    if (app.isRunning()) {
        qWarning() << app.applicationName() << "is already running, aborting";
        return false;
    }

    bool dbusRegistration = QDBusConnection::sessionBus().registerService(QMH_HELPER_DBUS_SERVICENAME);
    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus service:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    AbstractMediaPlayer *player = 0;
#ifdef XINE_PLAYER
#warning using xine backend
    player = new XinePlayer(&app);
#else
#warning using qDebug testing backend
    player = new TestingPlayer(&app);
#endif

    dbusRegistration = QDBusConnection::sessionBus().registerObject("/", player,
            QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);

    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus object:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    return app.exec();
}

<|edits_diff|>
--- src/mediaplayer/main.cpp
+++ src/mediaplayer/main.cpp
@@ -29,6 +29,7 @@
     AbstractMediaPlayer *player = 0;
 #ifdef XINE_PLAYER
 #warning using xine backend
+    qDebug() << "Xine player started";
     player = new XinePlayer(&app);
 #else
 #warning using qDebug testing backend
<|current_version|>
#include "testingplayer.h"
#ifdef XINE_PLAYER
#include "xineplayer.h"
#endif

#include "qtsingleapplication.h"
#include <QDebug>
#include <QtDBus>

int main(int argc, char** argv)
{
    QtSingleApplication app(argc, argv);
    app.setApplicationName("mediahelper");
    app.setOrganizationName("Nokia");
    app.setOrganizationDomain("nokia.com");

    if (app.isRunning()) {
        qWarning() << app.applicationName() << "is already running, aborting";
        return false;
    }

    bool dbusRegistration = QDBusConnection::sessionBus().registerService(QMH_HELPER_DBUS_SERVICENAME);
    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus service:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    AbstractMediaPlayer *player = 0;
#ifdef XINE_PLAYER
#warning using xine backend
    qDebug() << "Xine player started";
    player = new XinePlayer(&app);
#else
#warning using qDebug testing backend
    player = new TestingPlayer(&app);
#endif

    dbusRegistration = QDBusConnection::sessionBus().registerObject("/", player,
            QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);

    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus object:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    return app.exec();
}

<|next_version|>
#include "testingplayer.h"
#ifdef XINE_PLAYER
#include "xineplayer.h"
#endif

#include "qtsingleapplication.h"
#include <QDebug>
#include <QtDBus>

int main(int argc, char** argv)
{
    QtSingleApplication app(argc, argv);
    app.setApplicationName("mediahelper");
    app.setOrganizationName("Nokia");
    app.setOrganizationDomain("nokia.com");

    if (app.isRunning()) {
        qWarning() << app.applicationName() << "is already running, aborting";
        return false;
    }

    bool dbusRegistration = QDBusConnection::sessionBus().registerService(QMH_HELPER_DBUS_SERVICENAME);
    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus service:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    AbstractMediaPlayer *player = 0;
#ifdef XINE_PLAYER
#warning using xine backend
    qDebug() << "Xine player started";
    player = new XinePlayer(&app);
#else
#warning using qDebug testing backend
    qDebug() << "qDebug player started";
    player = new TestingPlayer(&app);
#endif

    dbusRegistration = QDBusConnection::sessionBus().registerObject("/", player,
            QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);

    if (!dbusRegistration) {
        qDebug()
            << "Can't seem to register dbus object:"
            << QDBusConnection::sessionBus().lastError().message();
        app.exit(-1);
    }
    return app.exec();
}


Initialize the fields of the sigaction structure.

--- src/search/util/timeout.cc
+++ src/search/util/timeout.cc
@@ -33,7 +33,11 @@
 {
 	struct sigaction sa;

+	sa.sa_flags = 0;
+	sa.sa_sigaction = NULL;
+	sa.sa_restorer = NULL;
 	sa.sa_handler = alarm_action;
+	sigfillset(&sa.sa_mask);
 	sigaction(SIGALRM, &sa, NULL);

 	alarm(sec);

<|original_code|>
/* -*- mode:linux -*- */
/**
 * \file timeout.cc
 *
 *
 *
 * \author Ethan Burns
 * \date 2008-12-16
 */

#include <iostream>

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace std;

void alarm_action(int sig)
{
	cout << "No Solution" << endl
	     << "cost: infinity" << endl
	     << "length: infinity" << endl
	     << "wall_time: infinity" << endl
	     << "CPU_time: infinity" << endl
	     << "generated: infinity" << endl
	     << "expanded: infinity" << endl;

	exit(EXIT_SUCCESS);
}

void timeout(unsigned int sec)
{
	struct sigaction sa;

	sa.sa_handler = alarm_action;
	sigaction(SIGALRM, &sa, NULL);

	alarm(sec);
}

<|edits_diff|>
--- src/search/util/timeout.cc
+++ src/search/util/timeout.cc
@@ -33,6 +33,9 @@
 {
 	struct sigaction sa;

+	sa.sa_flags = 0;
+	sa.sa_sigaction = NULL;
+	sa.sa_restorer = NULL;
 	sa.sa_handler = alarm_action;
 	sigaction(SIGALRM, &sa, NULL);

<|current_version|>
/* -*- mode:linux -*- */
/**
 * \file timeout.cc
 *
 *
 *
 * \author Ethan Burns
 * \date 2008-12-16
 */

#include <iostream>

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace std;

void alarm_action(int sig)
{
	cout << "No Solution" << endl
	     << "cost: infinity" << endl
	     << "length: infinity" << endl
	     << "wall_time: infinity" << endl
	     << "CPU_time: infinity" << endl
	     << "generated: infinity" << endl
	     << "expanded: infinity" << endl;

	exit(EXIT_SUCCESS);
}

void timeout(unsigned int sec)
{
	struct sigaction sa;

	sa.sa_flags = 0;
	sa.sa_sigaction = NULL;
	sa.sa_restorer = NULL;
	sa.sa_handler = alarm_action;
	sigaction(SIGALRM, &sa, NULL);

	alarm(sec);
}

<|next_version|>
/* -*- mode:linux -*- */
/**
 * \file timeout.cc
 *
 *
 *
 * \author Ethan Burns
 * \date 2008-12-16
 */

#include <iostream>

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace std;

void alarm_action(int sig)
{
	cout << "No Solution" << endl
	     << "cost: infinity" << endl
	     << "length: infinity" << endl
	     << "wall_time: infinity" << endl
	     << "CPU_time: infinity" << endl
	     << "generated: infinity" << endl
	     << "expanded: infinity" << endl;

	exit(EXIT_SUCCESS);
}

void timeout(unsigned int sec)
{
	struct sigaction sa;

	sa.sa_flags = 0;
	sa.sa_sigaction = NULL;
	sa.sa_restorer = NULL;
	sa.sa_handler = alarm_action;
	sigfillset(&sa.sa_mask);
	sigaction(SIGALRM, &sa, NULL);

	alarm(sec);
}


Use strtoll like strtoimax on Interix.

Use strtoll like strtoimax on Interix.

--- config/config_type_int.cc
+++ config/config_type_int.cc
@@ -1,4 +1,6 @@
+#if !defined(__OPENNT)
 #include <inttypes.h>
+#endif
 #include <stdlib.h>

 #include <config/config_type_int.h>
@@ -15,7 +17,11 @@
 	char *endp;
 	intmax_t imax;

+#if !defined(__OPENNT)
 	imax = strtoimax(str, &endp, 0);
+#else
+	imax = strtoll(str, &endp, 0);
+#endif
 	if (*endp != '\0')
 		return (false);

<|original_code|>
#include <inttypes.h>
#include <stdlib.h>

#include <config/config_type_int.h>

ConfigTypeInt config_type_int;

bool
ConfigTypeInt::set(ConfigValue *cv, const std::string& vstr)
{
	if (ints_.find(cv) != ints_.end())
		return (false);

	const char *str = vstr.c_str();
	char *endp;
	intmax_t imax;

	imax = strtoimax(str, &endp, 0);
	if (*endp != '\0')
		return (false);

	ints_[cv] = imax;

	return (true);
}

<|edits_diff|>
--- config/config_type_int.cc
+++ config/config_type_int.cc
@@ -1,4 +1,6 @@
+#if !defined(__OPENNT)
 #include <inttypes.h>
+#endif
 #include <stdlib.h>

 #include <config/config_type_int.h>
@@ -15,6 +17,7 @@
 	char *endp;
 	intmax_t imax;

+#if !defined(__OPENNT)
 	imax = strtoimax(str, &endp, 0);
 	if (*endp != '\0')
 		return (false);
<|current_version|>
#if !defined(__OPENNT)
#include <inttypes.h>
#endif
#include <stdlib.h>

#include <config/config_type_int.h>

ConfigTypeInt config_type_int;

bool
ConfigTypeInt::set(ConfigValue *cv, const std::string& vstr)
{
	if (ints_.find(cv) != ints_.end())
		return (false);

	const char *str = vstr.c_str();
	char *endp;
	intmax_t imax;

#if !defined(__OPENNT)
	imax = strtoimax(str, &endp, 0);
	if (*endp != '\0')
		return (false);

	ints_[cv] = imax;

	return (true);
}

<|next_version|>
#if !defined(__OPENNT)
#include <inttypes.h>
#endif
#include <stdlib.h>

#include <config/config_type_int.h>

ConfigTypeInt config_type_int;

bool
ConfigTypeInt::set(ConfigValue *cv, const std::string& vstr)
{
	if (ints_.find(cv) != ints_.end())
		return (false);

	const char *str = vstr.c_str();
	char *endp;
	intmax_t imax;

#if !defined(__OPENNT)
	imax = strtoimax(str, &endp, 0);
#else
	imax = strtoll(str, &endp, 0);
#endif
	if (*endp != '\0')
		return (false);

	ints_[cv] = imax;

	return (true);
}


Print proxy errors to qDebug

Print proxy errors to qDebug

--- viewer/KVProxy.cpp
+++ viewer/KVProxy.cpp
@@ -1,6 +1,7 @@
 #include "KVProxy.h"
 #include "KVProxy_p.h"
 #include <iostream>
+#include <string>

 KVProxy::KVProxy(QObject *parent, unsigned short port) :
 	QObject(parent), p("127.0.0.1", port)
@@ -12,6 +13,10 @@
 	// Pass on new connections to a function in KVProxy_p
 	p.on_connection([this](HttpProxy::Connection::Ptr con) {
 		proxyHandleConnection(this, con);
+	});
+
+	p.on_error([](std::string str, bool){
+		qDebug() << "Proxy Error: " << str.c_str();
 	});
 }

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

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

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

KVProxy::~KVProxy()
{

}

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

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

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

<|edits_diff|>
--- viewer/KVProxy.cpp
+++ viewer/KVProxy.cpp
@@ -1,6 +1,7 @@
 #include "KVProxy.h"
 #include "KVProxy_p.h"
 #include <iostream>
+#include <string>

 KVProxy::KVProxy(QObject *parent, unsigned short port) :
 	QObject(parent), p("127.0.0.1", port)
<|current_version|>
#include "KVProxy.h"
#include "KVProxy_p.h"
#include <iostream>
#include <string>

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

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

KVProxy::~KVProxy()
{

}

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

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

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

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

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

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

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

KVProxy::~KVProxy()
{

}

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

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

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


Add the disconnect command to the factory.

--- test-cascades-lib/test-cascades-lib-xmpp/src/XmppHarness.cpp
+++ test-cascades-lib/test-cascades-lib-xmpp/src/XmppHarness.cpp
@@ -9,6 +9,7 @@
 #include "XmppPresenceCommand.h"
 #include "XmppConnectCommand.h"
 #include "XmppMessageCommand.h"
+#include "XmppDisconnectCommand.h"

 namespace truphone
 {
@@ -38,6 +39,9 @@
         CommandFactory::installCommand(
                     XMPPMessageCommand::getCmd(),
                     &XMPPMessageCommand::create);
+        CommandFactory::installCommand(
+                    XMPPDisconnectCommand::getCmd(),
+                    &XMPPDisconnectCommand::create);
         return true;
     }
 }  // namespace cascades

<|original_code|>
/**
 * Copyright 2014 Truphone
 */
#include "XmppHarness.h"

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

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

<|edits_diff|>
--- test-cascades-lib/test-cascades-lib-xmpp/src/XmppHarness.cpp
+++ test-cascades-lib/test-cascades-lib-xmpp/src/XmppHarness.cpp
@@ -9,6 +9,7 @@
 #include "XmppPresenceCommand.h"
 #include "XmppConnectCommand.h"
 #include "XmppMessageCommand.h"
+#include "XmppDisconnectCommand.h"

 namespace truphone
 {
<|current_version|>
/**
 * Copyright 2014 Truphone
 */
#include "XmppHarness.h"

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

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

<|next_version|>
/**
 * Copyright 2014 Truphone
 */
#include "XmppHarness.h"

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

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


Implement getClientHostId with uname() under Linux by default.

Reviewed By: yfeldblum

Differential Revision: D25673372

fbshipit-source-id: c0d8feb89100c1096697ba86ed93dcbf52fe2530

--- thrift/lib/cpp2/async/ClientChannel.cpp
+++ thrift/lib/cpp2/async/ClientChannel.cpp
@@ -16,13 +16,23 @@

 #include <thrift/lib/cpp2/async/ClientChannel.h>

+#ifdef __linux__
+#include <sys/utsname.h>
+#endif
+
 #include <thrift/lib/cpp2/PluggableFunction.h>

 namespace apache {
 namespace thrift {
 namespace {
 THRIFT_PLUGGABLE_FUNC_REGISTER(std::optional<std::string>, getClientHostId) {
+#ifdef __linux__
+  struct utsname bufs;
+  ::uname(&bufs);
+  return bufs.nodename;
+#else
   return {};
+#endif
 }
 } // namespace

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

#include <thrift/lib/cpp2/async/ClientChannel.h>

#include <thrift/lib/cpp2/PluggableFunction.h>

namespace apache {
namespace thrift {
namespace {
THRIFT_PLUGGABLE_FUNC_REGISTER(std::optional<std::string>, getClientHostId) {
  return {};
}
} // namespace

/* static */ const std::optional<std::string>& ClientChannel::getHostId() {
  static const auto& hostId =
      *new std::optional<std::string>{THRIFT_PLUGGABLE_FUNC(getClientHostId)()};
  return hostId;
}
} // namespace thrift
} // namespace apache

<|edits_diff|>
--- thrift/lib/cpp2/async/ClientChannel.cpp
+++ thrift/lib/cpp2/async/ClientChannel.cpp
@@ -16,12 +16,21 @@

 #include <thrift/lib/cpp2/async/ClientChannel.h>

+#ifdef __linux__
+#include <sys/utsname.h>
+#endif
+
 #include <thrift/lib/cpp2/PluggableFunction.h>

 namespace apache {
 namespace thrift {
 namespace {
 THRIFT_PLUGGABLE_FUNC_REGISTER(std::optional<std::string>, getClientHostId) {
+#ifdef __linux__
+  struct utsname bufs;
+  ::uname(&bufs);
+  return bufs.nodename;
+#else
   return {};
 }
 } // namespace
<|current_version|>
/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <thrift/lib/cpp2/async/ClientChannel.h>

#ifdef __linux__
#include <sys/utsname.h>
#endif

#include <thrift/lib/cpp2/PluggableFunction.h>

namespace apache {
namespace thrift {
namespace {
THRIFT_PLUGGABLE_FUNC_REGISTER(std::optional<std::string>, getClientHostId) {
#ifdef __linux__
  struct utsname bufs;
  ::uname(&bufs);
  return bufs.nodename;
#else
  return {};
}
} // namespace

/* static */ const std::optional<std::string>& ClientChannel::getHostId() {
  static const auto& hostId =
      *new std::optional<std::string>{THRIFT_PLUGGABLE_FUNC(getClientHostId)()};
  return hostId;
}
} // namespace thrift
} // namespace apache

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

#include <thrift/lib/cpp2/async/ClientChannel.h>

#ifdef __linux__
#include <sys/utsname.h>
#endif

#include <thrift/lib/cpp2/PluggableFunction.h>

namespace apache {
namespace thrift {
namespace {
THRIFT_PLUGGABLE_FUNC_REGISTER(std::optional<std::string>, getClientHostId) {
#ifdef __linux__
  struct utsname bufs;
  ::uname(&bufs);
  return bufs.nodename;
#else
  return {};
#endif
}
} // namespace

/* static */ const std::optional<std::string>& ClientChannel::getHostId() {
  static const auto& hostId =
      *new std::optional<std::string>{THRIFT_PLUGGABLE_FUNC(getClientHostId)()};
  return hostId;
}
} // namespace thrift
} // namespace apache


Fix corner case of comparing preparedpoint to point

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

--- src/geom/prep/PreparedPoint.cpp
+++ src/geom/prep/PreparedPoint.cpp
@@ -18,6 +18,7 @@

 #include <geos/geom/prep/PreparedPoint.h>
+#include <geos/geom/Point.h>

 namespace geos {
 namespace geom { // geos.geom
@@ -28,6 +29,10 @@
 {
 	if (! envelopesIntersect( g)) return false;

+	const Point *pt_geom = dynamic_cast<const Point *>(g);
+	if (pt_geom)
+        return getGeometry().equals(g);
+
 	// This avoids computing topology for the test geometry
 	return isAnyTargetComponentInTest( g);
 }

<|original_code|>
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************
 *
 * Last port: geom/prep/PreparedPoint.java rev. 1.2 (JTS-1.10)
 *
 **********************************************************************/

#include <geos/geom/prep/PreparedPoint.h>

namespace geos {
namespace geom { // geos.geom
namespace prep { // geos.geom.prep

bool
PreparedPoint::intersects(const geom::Geometry* g) const
{
	if (! envelopesIntersect( g)) return false;

	// This avoids computing topology for the test geometry
	return isAnyTargetComponentInTest( g);
}

} // namespace geos.geom.prep
} // namespace geos.geom
} // namespace geos

<|edits_diff|>
--- src/geom/prep/PreparedPoint.cpp
+++ src/geom/prep/PreparedPoint.cpp
@@ -18,6 +18,7 @@

 #include <geos/geom/prep/PreparedPoint.h>
+#include <geos/geom/Point.h>

 namespace geos {
 namespace geom { // geos.geom
<|current_version|>
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************
 *
 * Last port: geom/prep/PreparedPoint.java rev. 1.2 (JTS-1.10)
 *
 **********************************************************************/

#include <geos/geom/prep/PreparedPoint.h>
#include <geos/geom/Point.h>

namespace geos {
namespace geom { // geos.geom
namespace prep { // geos.geom.prep

bool
PreparedPoint::intersects(const geom::Geometry* g) const
{
	if (! envelopesIntersect( g)) return false;

	// This avoids computing topology for the test geometry
	return isAnyTargetComponentInTest( g);
}

} // namespace geos.geom.prep
} // namespace geos.geom
} // namespace geos

<|next_version|>
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************
 *
 * Last port: geom/prep/PreparedPoint.java rev. 1.2 (JTS-1.10)
 *
 **********************************************************************/

#include <geos/geom/prep/PreparedPoint.h>
#include <geos/geom/Point.h>

namespace geos {
namespace geom { // geos.geom
namespace prep { // geos.geom.prep

bool
PreparedPoint::intersects(const geom::Geometry* g) const
{
	if (! envelopesIntersect( g)) return false;

	const Point *pt_geom = dynamic_cast<const Point *>(g);
	if (pt_geom)
        return getGeometry().equals(g);

	// This avoids computing topology for the test geometry
	return isAnyTargetComponentInTest( g);
}

} // namespace geos.geom.prep
} // namespace geos.geom
} // namespace geos


Update to latest perforce change

[CL-33310] Update to latest perforce change

--- Haxe/Templates/Source/HaxeRuntime/Private/uhx/RuntimeLibrary.cpp
+++ Haxe/Templates/Source/HaxeRuntime/Private/uhx/RuntimeLibrary.cpp
@@ -1,3 +1,5 @@
+#ifndef UHX_NO_UOBJECT
+
 #include "Core.h"
 #include "IntPtr.h"
 #include "uhx/ue/RuntimeLibrary.h"
@@ -26,3 +28,5 @@
 int uhx::ue::RuntimeLibrary_obj::allocTlsSlot() {
   return FPlatformAtomics::InterlockedIncrement(&uhx_tls_slot);
 }
+
+#endif

<|original_code|>
#include "Core.h"
#include "IntPtr.h"
#include "uhx/ue/RuntimeLibrary.h"
#include "HAL/PlatformAtomics.h"

static int uhx_tls_slot = 0;

#if defined(_MSC_VER)
unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#elif defined(__GNUC__)
thread_local unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#else
static int uhx_tls_obj = FPlatformTLS::AllocTlsSlot();

unreal::UIntPtr uhx::ue::RuntimeLibrary_obj::getTlsObj() {
  unreal::UIntPtr *ret = (unreal::UIntPtr *) FPlatformTLS::GetTlsValue(uhx_tls_obj);
  if (!ret) {
    ret = (unreal::UIntPtr*) uhx::GcRef::createRoot();
    FPlatformTLS::SetTlsValue(uhx_tls_obj, (void*) ret);
    return *ret = uhx::expose::HxcppRuntime::createArray();
  }
  return *ret;
}
#endif

int uhx::ue::RuntimeLibrary_obj::allocTlsSlot() {
  return FPlatformAtomics::InterlockedIncrement(&uhx_tls_slot);
}

<|edits_diff|>
--- Haxe/Templates/Source/HaxeRuntime/Private/uhx/RuntimeLibrary.cpp
+++ Haxe/Templates/Source/HaxeRuntime/Private/uhx/RuntimeLibrary.cpp
@@ -1,3 +1,5 @@
+#ifndef UHX_NO_UOBJECT
+
 #include "Core.h"
 #include "IntPtr.h"
 #include "uhx/ue/RuntimeLibrary.h"
<|current_version|>
#ifndef UHX_NO_UOBJECT

#include "Core.h"
#include "IntPtr.h"
#include "uhx/ue/RuntimeLibrary.h"
#include "HAL/PlatformAtomics.h"

static int uhx_tls_slot = 0;

#if defined(_MSC_VER)
unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#elif defined(__GNUC__)
thread_local unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#else
static int uhx_tls_obj = FPlatformTLS::AllocTlsSlot();

unreal::UIntPtr uhx::ue::RuntimeLibrary_obj::getTlsObj() {
  unreal::UIntPtr *ret = (unreal::UIntPtr *) FPlatformTLS::GetTlsValue(uhx_tls_obj);
  if (!ret) {
    ret = (unreal::UIntPtr*) uhx::GcRef::createRoot();
    FPlatformTLS::SetTlsValue(uhx_tls_obj, (void*) ret);
    return *ret = uhx::expose::HxcppRuntime::createArray();
  }
  return *ret;
}
#endif

int uhx::ue::RuntimeLibrary_obj::allocTlsSlot() {
  return FPlatformAtomics::InterlockedIncrement(&uhx_tls_slot);
}

<|next_version|>
#ifndef UHX_NO_UOBJECT

#include "Core.h"
#include "IntPtr.h"
#include "uhx/ue/RuntimeLibrary.h"
#include "HAL/PlatformAtomics.h"

static int uhx_tls_slot = 0;

#if defined(_MSC_VER)
unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#elif defined(__GNUC__)
thread_local unreal::UIntPtr *uhx::ue::RuntimeLibrary_obj::tlsObj = nullptr;
#else
static int uhx_tls_obj = FPlatformTLS::AllocTlsSlot();

unreal::UIntPtr uhx::ue::RuntimeLibrary_obj::getTlsObj() {
  unreal::UIntPtr *ret = (unreal::UIntPtr *) FPlatformTLS::GetTlsValue(uhx_tls_obj);
  if (!ret) {
    ret = (unreal::UIntPtr*) uhx::GcRef::createRoot();
    FPlatformTLS::SetTlsValue(uhx_tls_obj, (void*) ret);
    return *ret = uhx::expose::HxcppRuntime::createArray();
  }
  return *ret;
}
#endif

int uhx::ue::RuntimeLibrary_obj::allocTlsSlot() {
  return FPlatformAtomics::InterlockedIncrement(&uhx_tls_slot);
}

#endif


Call evthread_use_pthreads() in all tests.

--- cpp/util/testing.cc
+++ cpp/util/testing.cc
@@ -1,5 +1,6 @@
 #include "util/testing.h"

+#include <event2/thread.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include <gtest/gtest.h>
@@ -17,6 +18,7 @@
   ::testing::InitGoogleTest(argc, *argv);
   google::ParseCommandLineFlags(argc, argv, remove_flags);
   google::InitGoogleLogging(name);
+  evthread_use_pthreads();
 }

 }  // namespace test

<|original_code|>
#include "util/testing.h"

#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>

namespace cert_trans {
namespace test {

void InitTesting(const char* name, int* argc, char*** argv,
                 bool remove_flags) {
  // Change the defaults. Can be overridden on command line.
  // Log to stderr instead of log files.
  FLAGS_logtostderr = true;
  // Only log fatal messages by default.
  FLAGS_minloglevel = 3;
  ::testing::InitGoogleTest(argc, *argv);
  google::ParseCommandLineFlags(argc, argv, remove_flags);
  google::InitGoogleLogging(name);
}

}  // namespace test
}  // namespace cert_trans

<|edits_diff|>
--- cpp/util/testing.cc
+++ cpp/util/testing.cc
@@ -1,5 +1,6 @@
 #include "util/testing.h"

+#include <event2/thread.h>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include <gtest/gtest.h>
<|current_version|>
#include "util/testing.h"

#include <event2/thread.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>

namespace cert_trans {
namespace test {

void InitTesting(const char* name, int* argc, char*** argv,
                 bool remove_flags) {
  // Change the defaults. Can be overridden on command line.
  // Log to stderr instead of log files.
  FLAGS_logtostderr = true;
  // Only log fatal messages by default.
  FLAGS_minloglevel = 3;
  ::testing::InitGoogleTest(argc, *argv);
  google::ParseCommandLineFlags(argc, argv, remove_flags);
  google::InitGoogleLogging(name);
}

}  // namespace test
}  // namespace cert_trans

<|next_version|>
#include "util/testing.h"

#include <event2/thread.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>

namespace cert_trans {
namespace test {

void InitTesting(const char* name, int* argc, char*** argv,
                 bool remove_flags) {
  // Change the defaults. Can be overridden on command line.
  // Log to stderr instead of log files.
  FLAGS_logtostderr = true;
  // Only log fatal messages by default.
  FLAGS_minloglevel = 3;
  ::testing::InitGoogleTest(argc, *argv);
  google::ParseCommandLineFlags(argc, argv, remove_flags);
  google::InitGoogleLogging(name);
  evthread_use_pthreads();
}

}  // namespace test
}  // namespace cert_trans


Create BasicProtocolCodec if _protocolCodec is null

@ Service::getProtocolCodec()

--- src/nwg_service.cc
+++ src/nwg_service.cc
@@ -1,6 +1,7 @@
 #include "nwg_service.h"

 #include "nwg_eventloop.h"
+#include "nwg_basicprotocolcodec.h"

 namespace Nwg
 {
@@ -38,6 +39,9 @@

 ProtocolCodec &Service::getProtocolCodec()
 {
+    if (_protocolCodec == nullptr) {
+        _protocolCodec = std::make_shared<Nwg::BasicProtocolCodec>();
+    }
     return *_protocolCodec;
 }

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

#include "nwg_eventloop.h"

namespace Nwg
{

Service::Service(EventLoop *eventLoop)
    : _eventLoop(eventLoop),
      _protocolCodec(nullptr),
      _handler(nullptr)
{
}

Service::~Service()
{
    _protocolCodec.reset();
    _handler.reset();
}

void Service::setBuffSize(int buffSize) { _buffSize = buffSize; }
void Service::setReadBuffSize(int readBuffSize) { _readBuffSize = readBuffSize; }

void Service::setProtocolCodec(const std::shared_ptr<ProtocolCodec> &protocolCodec)
{
    _protocolCodec = protocolCodec;
}

void Service::setHandler(const std::shared_ptr<Handler> &handler)
{
    _handler = handler;
}

EventLoop *Service::getEventLoop() const { return _eventLoop; }

size_t Service::getBuffSize() { return _buffSize; }
size_t Service::getReadBuffSize() { return _readBuffSize; }

ProtocolCodec &Service::getProtocolCodec()
{
    return *_protocolCodec;
}

Handler &Service::getHandler()
{
    return *_handler;
}

} /* namespace Nwg */

<|edits_diff|>
--- src/nwg_service.cc
+++ src/nwg_service.cc
@@ -1,6 +1,7 @@
 #include "nwg_service.h"

 #include "nwg_eventloop.h"
+#include "nwg_basicprotocolcodec.h"

 namespace Nwg
 {
<|current_version|>
#include "nwg_service.h"

#include "nwg_eventloop.h"
#include "nwg_basicprotocolcodec.h"

namespace Nwg
{

Service::Service(EventLoop *eventLoop)
    : _eventLoop(eventLoop),
      _protocolCodec(nullptr),
      _handler(nullptr)
{
}

Service::~Service()
{
    _protocolCodec.reset();
    _handler.reset();
}

void Service::setBuffSize(int buffSize) { _buffSize = buffSize; }
void Service::setReadBuffSize(int readBuffSize) { _readBuffSize = readBuffSize; }

void Service::setProtocolCodec(const std::shared_ptr<ProtocolCodec> &protocolCodec)
{
    _protocolCodec = protocolCodec;
}

void Service::setHandler(const std::shared_ptr<Handler> &handler)
{
    _handler = handler;
}

EventLoop *Service::getEventLoop() const { return _eventLoop; }

size_t Service::getBuffSize() { return _buffSize; }
size_t Service::getReadBuffSize() { return _readBuffSize; }

ProtocolCodec &Service::getProtocolCodec()
{
    return *_protocolCodec;
}

Handler &Service::getHandler()
{
    return *_handler;
}

} /* namespace Nwg */

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

#include "nwg_eventloop.h"
#include "nwg_basicprotocolcodec.h"

namespace Nwg
{

Service::Service(EventLoop *eventLoop)
    : _eventLoop(eventLoop),
      _protocolCodec(nullptr),
      _handler(nullptr)
{
}

Service::~Service()
{
    _protocolCodec.reset();
    _handler.reset();
}

void Service::setBuffSize(int buffSize) { _buffSize = buffSize; }
void Service::setReadBuffSize(int readBuffSize) { _readBuffSize = readBuffSize; }

void Service::setProtocolCodec(const std::shared_ptr<ProtocolCodec> &protocolCodec)
{
    _protocolCodec = protocolCodec;
}

void Service::setHandler(const std::shared_ptr<Handler> &handler)
{
    _handler = handler;
}

EventLoop *Service::getEventLoop() const { return _eventLoop; }

size_t Service::getBuffSize() { return _buffSize; }
size_t Service::getReadBuffSize() { return _readBuffSize; }

ProtocolCodec &Service::getProtocolCodec()
{
    if (_protocolCodec == nullptr) {
        _protocolCodec = std::make_shared<Nwg::BasicProtocolCodec>();
    }
    return *_protocolCodec;
}

Handler &Service::getHandler()
{
    return *_handler;
}

} /* namespace Nwg */


Add secure comparator C++ wrapper test

Add secure comparator C++ wrapper test

--- tests/themispp/main.cpp
+++ tests/themispp/main.cpp
@@ -18,12 +18,15 @@
 #include "secure_cell_test.hpp"
 #include "secure_message_test.hpp"
 #include "secure_session_test.hpp"
+#include "secure_comparator_test.hpp"
+

 int main(){
   sput_start_testing();
   themispp::secure_cell_test::run_secure_cell_test();
   themispp::secure_message_test::run_secure_message_test();
   themispp::secure_session_test::run_secure_session_test();
+  themispp::secure_session_test::run_secure_comparator_test();
   sput_finish_testing();
   return sput_get_return_value();
 }

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

#include <common/sput.h>
#include "secure_cell_test.hpp"
#include "secure_message_test.hpp"
#include "secure_session_test.hpp"

int main(){
  sput_start_testing();
  themispp::secure_cell_test::run_secure_cell_test();
  themispp::secure_message_test::run_secure_message_test();
  themispp::secure_session_test::run_secure_session_test();
  sput_finish_testing();
  return sput_get_return_value();
}

<|edits_diff|>
--- tests/themispp/main.cpp
+++ tests/themispp/main.cpp
@@ -18,6 +18,8 @@
 #include "secure_cell_test.hpp"
 #include "secure_message_test.hpp"
 #include "secure_session_test.hpp"
+#include "secure_comparator_test.hpp"
+

 int main(){
   sput_start_testing();
<|current_version|>
/*
 * Copyright (c) 2015 Cossack Labs Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <common/sput.h>
#include "secure_cell_test.hpp"
#include "secure_message_test.hpp"
#include "secure_session_test.hpp"
#include "secure_comparator_test.hpp"

int main(){
  sput_start_testing();
  themispp::secure_cell_test::run_secure_cell_test();
  themispp::secure_message_test::run_secure_message_test();
  themispp::secure_session_test::run_secure_session_test();
  sput_finish_testing();
  return sput_get_return_value();
}

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

#include <common/sput.h>
#include "secure_cell_test.hpp"
#include "secure_message_test.hpp"
#include "secure_session_test.hpp"
#include "secure_comparator_test.hpp"

int main(){
  sput_start_testing();
  themispp::secure_cell_test::run_secure_cell_test();
  themispp::secure_message_test::run_secure_message_test();
  themispp::secure_session_test::run_secure_session_test();
  themispp::secure_session_test::run_secure_comparator_test();
  sput_finish_testing();
  return sput_get_return_value();
}


Add tests for operator bool().

Add tests for operator bool().

--- test/t/basic/runtest.cpp
+++ test/t/basic/runtest.cpp
@@ -11,6 +11,7 @@
     SECTION("empty buffer is okay") {
         std::string buffer;
         mapbox::util::pbf item(buffer.data(), 0);
+        REQUIRE(!item); // test operator bool()
         REQUIRE(!item.next());
     }

@@ -20,6 +21,7 @@
             *buffer = static_cast<char>(i);
             mapbox::util::pbf item(buffer, 1);

+            REQUIRE(!!item); // test operator bool()
             REQUIRE_THROWS({
                 item.next();
                 item.skip();

<|original_code|>

#include <test.hpp>

TEST_CASE("basic") {

    SECTION("default constructed pbf message is okay") {
        mapbox::util::pbf item;
        REQUIRE(!item.next());
    }

    SECTION("empty buffer is okay") {
        std::string buffer;
        mapbox::util::pbf item(buffer.data(), 0);
        REQUIRE(!item.next());
    }

    SECTION("check every possible value for single byte in buffer") {
        char buffer[1];
        for (int i = 0; i <= 255; ++i) {
            *buffer = static_cast<char>(i);
            mapbox::util::pbf item(buffer, 1);

            REQUIRE_THROWS({
                item.next();
                item.skip();
            });
        }
    }

}

<|edits_diff|>
--- test/t/basic/runtest.cpp
+++ test/t/basic/runtest.cpp
@@ -11,6 +11,7 @@
     SECTION("empty buffer is okay") {
         std::string buffer;
         mapbox::util::pbf item(buffer.data(), 0);
+        REQUIRE(!item); // test operator bool()
         REQUIRE(!item.next());
     }

<|current_version|>

#include <test.hpp>

TEST_CASE("basic") {

    SECTION("default constructed pbf message is okay") {
        mapbox::util::pbf item;
        REQUIRE(!item.next());
    }

    SECTION("empty buffer is okay") {
        std::string buffer;
        mapbox::util::pbf item(buffer.data(), 0);
        REQUIRE(!item); // test operator bool()
        REQUIRE(!item.next());
    }

    SECTION("check every possible value for single byte in buffer") {
        char buffer[1];
        for (int i = 0; i <= 255; ++i) {
            *buffer = static_cast<char>(i);
            mapbox::util::pbf item(buffer, 1);

            REQUIRE_THROWS({
                item.next();
                item.skip();
            });
        }
    }

}

<|next_version|>

#include <test.hpp>

TEST_CASE("basic") {

    SECTION("default constructed pbf message is okay") {
        mapbox::util::pbf item;
        REQUIRE(!item.next());
    }

    SECTION("empty buffer is okay") {
        std::string buffer;
        mapbox::util::pbf item(buffer.data(), 0);
        REQUIRE(!item); // test operator bool()
        REQUIRE(!item.next());
    }

    SECTION("check every possible value for single byte in buffer") {
        char buffer[1];
        for (int i = 0; i <= 255; ++i) {
            *buffer = static_cast<char>(i);
            mapbox::util::pbf item(buffer, 1);

            REQUIRE(!!item); // test operator bool()
            REQUIRE_THROWS({
                item.next();
                item.skip();
            });
        }
    }

}


Create a QCoreApplication when testing Lua

--- tests/test_lua.cpp
+++ tests/test_lua.cpp
@@ -3,9 +3,12 @@
 #include <lua-cxx/LuaEnvironment.hpp>
 #include <lua-cxx/LuaValue.hpp>
 #include <QFile>
+#include <QCoreApplication>

 int main(int argc, char* argv[])
 {
+    QCoreApplication app(argc, argv);
+
     Lua lua;
     rainback::Rainback rainback(lua);

<|original_code|>
#include "Rainback.hpp"

#include <lua-cxx/LuaEnvironment.hpp>
#include <lua-cxx/LuaValue.hpp>
#include <QFile>

int main(int argc, char* argv[])
{
    Lua lua;
    rainback::Rainback rainback(lua);

    std::string srcdir(getenv("srcdir"));
    QFile testRunner(QString(srcdir.c_str()) + "/test_lua.lua");
    return (bool)lua(testRunner) ? 0 : 1;
}

<|edits_diff|>
--- tests/test_lua.cpp
+++ tests/test_lua.cpp
@@ -3,6 +3,7 @@
 #include <lua-cxx/LuaEnvironment.hpp>
 #include <lua-cxx/LuaValue.hpp>
 #include <QFile>
+#include <QCoreApplication>

 int main(int argc, char* argv[])
 {
<|current_version|>
#include "Rainback.hpp"

#include <lua-cxx/LuaEnvironment.hpp>
#include <lua-cxx/LuaValue.hpp>
#include <QFile>
#include <QCoreApplication>

int main(int argc, char* argv[])
{
    Lua lua;
    rainback::Rainback rainback(lua);

    std::string srcdir(getenv("srcdir"));
    QFile testRunner(QString(srcdir.c_str()) + "/test_lua.lua");
    return (bool)lua(testRunner) ? 0 : 1;
}

<|next_version|>
#include "Rainback.hpp"

#include <lua-cxx/LuaEnvironment.hpp>
#include <lua-cxx/LuaValue.hpp>
#include <QFile>
#include <QCoreApplication>

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

    Lua lua;
    rainback::Rainback rainback(lua);

    std::string srcdir(getenv("srcdir"));
    QFile testRunner(QString(srcdir.c_str()) + "/test_lua.lua");
    return (bool)lua(testRunner) ? 0 : 1;
}


Call libport::program_initialize in every entry point.

	* src/libuco/urbi-main.cc: Here.

--- sdk-remote/src/libuco/urbi-main.cc
+++ sdk-remote/src/libuco/urbi-main.cc
@@ -19,12 +19,16 @@
   int urbi_main(int argc, const char* argv[],
                 bool block, bool errors)
   {
+    libport::program_initialize(argc, const_cast<char**>(argv));
+
     return urbi::main(argc, argv, block, errors);
   }

   int urbi_main_args(const libport::cli_args_type& args,
                      bool block, bool errors)
   {
+    libport::program_initialize(args);
+
     return urbi::main(args, block, errors);
   }
 }
@@ -35,6 +39,8 @@
   int
   main(int argc, const char* argv[], bool block, bool errors)
   {
+    libport::program_initialize(argc, const_cast<char**>(argv));
+
     libport::cli_args_type args;
     // For some reason, I failed to use std::copy here.
     for (int i = 0; i < argc; ++i)

<|original_code|>
/*
 * Copyright (C) 2009, Gostai S.A.S.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file libuco/urbi-main.cc

#include <libport/cli.hh>
#include <libport/containers.hh>
#include <urbi/umain.hh>

extern "C"
{
  int urbi_main(int argc, const char* argv[],
                bool block, bool errors)
  {
    return urbi::main(argc, argv, block, errors);
  }

  int urbi_main_args(const libport::cli_args_type& args,
                     bool block, bool errors)
  {
    return urbi::main(args, block, errors);
  }
}

namespace urbi
{

  int
  main(int argc, const char* argv[], bool block, bool errors)
  {
    libport::cli_args_type args;
    // For some reason, I failed to use std::copy here.
    for (int i = 0; i < argc; ++i)
      args << std::string(argv[i]);
    return main(args, block, errors);
  }

}

<|edits_diff|>
--- sdk-remote/src/libuco/urbi-main.cc
+++ sdk-remote/src/libuco/urbi-main.cc
@@ -19,12 +19,16 @@
   int urbi_main(int argc, const char* argv[],
                 bool block, bool errors)
   {
+    libport::program_initialize(argc, const_cast<char**>(argv));
+
     return urbi::main(argc, argv, block, errors);
   }

   int urbi_main_args(const libport::cli_args_type& args,
                      bool block, bool errors)
   {
+    libport::program_initialize(args);
+
     return urbi::main(args, block, errors);
   }
 }
<|current_version|>
/*
 * Copyright (C) 2009, Gostai S.A.S.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file libuco/urbi-main.cc

#include <libport/cli.hh>
#include <libport/containers.hh>
#include <urbi/umain.hh>

extern "C"
{
  int urbi_main(int argc, const char* argv[],
                bool block, bool errors)
  {
    libport::program_initialize(argc, const_cast<char**>(argv));

    return urbi::main(argc, argv, block, errors);
  }

  int urbi_main_args(const libport::cli_args_type& args,
                     bool block, bool errors)
  {
    libport::program_initialize(args);

    return urbi::main(args, block, errors);
  }
}

namespace urbi
{

  int
  main(int argc, const char* argv[], bool block, bool errors)
  {
    libport::cli_args_type args;
    // For some reason, I failed to use std::copy here.
    for (int i = 0; i < argc; ++i)
      args << std::string(argv[i]);
    return main(args, block, errors);
  }

}

<|next_version|>
/*
 * Copyright (C) 2009, Gostai S.A.S.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file libuco/urbi-main.cc

#include <libport/cli.hh>
#include <libport/containers.hh>
#include <urbi/umain.hh>

extern "C"
{
  int urbi_main(int argc, const char* argv[],
                bool block, bool errors)
  {
    libport::program_initialize(argc, const_cast<char**>(argv));

    return urbi::main(argc, argv, block, errors);
  }

  int urbi_main_args(const libport::cli_args_type& args,
                     bool block, bool errors)
  {
    libport::program_initialize(args);

    return urbi::main(args, block, errors);
  }
}

namespace urbi
{

  int
  main(int argc, const char* argv[], bool block, bool errors)
  {
    libport::program_initialize(argc, const_cast<char**>(argv));

    libport::cli_args_type args;
    // For some reason, I failed to use std::copy here.
    for (int i = 0; i < argc; ++i)
      args << std::string(argv[i]);
    return main(args, block, errors);
  }

}


tests: Add fuzzing coverage for FormatHDKeypath(...) and WriteHDKeypath(...)

--- src/test/fuzz/parse_hd_keypath.cpp
+++ src/test/fuzz/parse_hd_keypath.cpp
@@ -2,12 +2,22 @@
 // Distributed under the MIT software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.

+#include <test/fuzz/FuzzedDataProvider.h>
 #include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
 #include <util/bip32.h>
+
+#include <cstdint>
+#include <vector>

 void test_one_input(const std::vector<uint8_t>& buffer)
 {
     const std::string keypath_str(buffer.begin(), buffer.end());
     std::vector<uint32_t> keypath;
     (void)ParseHDKeypath(keypath_str, keypath);
+
+    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+    const std::vector<uint32_t> random_keypath = ConsumeRandomLengthIntegralVector<uint32_t>(fuzzed_data_provider);
+    (void)FormatHDKeypath(random_keypath);
+    (void)WriteHDKeypath(random_keypath);
 }

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

#include <test/fuzz/fuzz.h>
#include <util/bip32.h>

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string keypath_str(buffer.begin(), buffer.end());
    std::vector<uint32_t> keypath;
    (void)ParseHDKeypath(keypath_str, keypath);
}

<|edits_diff|>
--- src/test/fuzz/parse_hd_keypath.cpp
+++ src/test/fuzz/parse_hd_keypath.cpp
@@ -2,8 +2,13 @@
 // Distributed under the MIT software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.

+#include <test/fuzz/FuzzedDataProvider.h>
 #include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
 #include <util/bip32.h>
+
+#include <cstdint>
+#include <vector>

 void test_one_input(const std::vector<uint8_t>& buffer)
 {
<|current_version|>
// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <util/bip32.h>

#include <cstdint>
#include <vector>

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string keypath_str(buffer.begin(), buffer.end());
    std::vector<uint32_t> keypath;
    (void)ParseHDKeypath(keypath_str, keypath);
}

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

#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <util/bip32.h>

#include <cstdint>
#include <vector>

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string keypath_str(buffer.begin(), buffer.end());
    std::vector<uint32_t> keypath;
    (void)ParseHDKeypath(keypath_str, keypath);

    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
    const std::vector<uint32_t> random_keypath = ConsumeRandomLengthIntegralVector<uint32_t>(fuzzed_data_provider);
    (void)FormatHDKeypath(random_keypath);
    (void)WriteHDKeypath(random_keypath);
}


Add an error code with sendFail

Add an error code with sendFail

--- src/server/views/helpers.cpp
+++ src/server/views/helpers.cpp
@@ -7,7 +7,9 @@

     JsonBool b = JsonBool(false);
     JsonString s = JsonString(message);
+    JsonInt i = JsonInt(errorcode);
     answer.add("success", &b);
     answer.add("reason", &s);
+    answer.add("code", &i);
     handler->writeToClient(topic, &answer);
 }

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

using namespace std;

void sendFail(UserHandler * handler, int errorcode, string topic, string message){
    JsonDict answer;

    JsonBool b = JsonBool(false);
    JsonString s = JsonString(message);
    answer.add("success", &b);
    answer.add("reason", &s);
    handler->writeToClient(topic, &answer);
}
<|edits_diff|>
--- src/server/views/helpers.cpp
+++ src/server/views/helpers.cpp
@@ -7,6 +7,7 @@

     JsonBool b = JsonBool(false);
     JsonString s = JsonString(message);
+    JsonInt i = JsonInt(errorcode);
     answer.add("success", &b);
     answer.add("reason", &s);
     handler->writeToClient(topic, &answer);
<|current_version|>
#include "helpers.h"

using namespace std;

void sendFail(UserHandler * handler, int errorcode, string topic, string message){
    JsonDict answer;

    JsonBool b = JsonBool(false);
    JsonString s = JsonString(message);
    JsonInt i = JsonInt(errorcode);
    answer.add("success", &b);
    answer.add("reason", &s);
    handler->writeToClient(topic, &answer);
}
<|next_version|>
#include "helpers.h"

using namespace std;

void sendFail(UserHandler * handler, int errorcode, string topic, string message){
    JsonDict answer;

    JsonBool b = JsonBool(false);
    JsonString s = JsonString(message);
    JsonInt i = JsonInt(errorcode);
    answer.add("success", &b);
    answer.add("reason", &s);
    answer.add("code", &i);
    handler->writeToClient(topic, &answer);
}


Add large sbrk support for 32 bit platforms.

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

--- src/allocators/global_sbrk_allocator.cc
+++ src/allocators/global_sbrk_allocator.cc
@@ -11,7 +11,13 @@
 uintptr_t GlobalSbrkAllocator::current_;

 void GlobalSbrkAllocator::InitModule() {
+#ifdef __x86_64__
   size_t size = 1UL << 35;  // 32GiB
+#endif
+#ifdef __i386__
+  size_t size = 1UL << 31;
+#endif
+
   void* p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   if (p == MAP_FAILED) {
     ErrorOut("mmap failed");

<|original_code|>
// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#include "allocators/global_sbrk_allocator.h"

#include <sys/mman.h>  // mmap

#include "log.h"

uintptr_t GlobalSbrkAllocator::current_;

void GlobalSbrkAllocator::InitModule() {
  size_t size = 1UL << 35;  // 32GiB
  void* p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED) {
    ErrorOut("mmap failed");
  }
  current_ = reinterpret_cast<uintptr_t>(p);
}

<|edits_diff|>
--- src/allocators/global_sbrk_allocator.cc
+++ src/allocators/global_sbrk_allocator.cc
@@ -11,6 +11,7 @@
 uintptr_t GlobalSbrkAllocator::current_;

 void GlobalSbrkAllocator::InitModule() {
+#ifdef __x86_64__
   size_t size = 1UL << 35;  // 32GiB
   void* p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   if (p == MAP_FAILED) {
<|current_version|>
// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#include "allocators/global_sbrk_allocator.h"

#include <sys/mman.h>  // mmap

#include "log.h"

uintptr_t GlobalSbrkAllocator::current_;

void GlobalSbrkAllocator::InitModule() {
#ifdef __x86_64__
  size_t size = 1UL << 35;  // 32GiB
  void* p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED) {
    ErrorOut("mmap failed");
  }
  current_ = reinterpret_cast<uintptr_t>(p);
}

<|next_version|>
// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#include "allocators/global_sbrk_allocator.h"

#include <sys/mman.h>  // mmap

#include "log.h"

uintptr_t GlobalSbrkAllocator::current_;

void GlobalSbrkAllocator::InitModule() {
#ifdef __x86_64__
  size_t size = 1UL << 35;  // 32GiB
#endif
#ifdef __i386__
  size_t size = 1UL << 31;
#endif

  void* p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED) {
    ErrorOut("mmap failed");
  }
  current_ = reinterpret_cast<uintptr_t>(p);
}


Test cases print stack trace on sigsegv

Test cases print stack trace on sigsegv

--- test/main.cpp
+++ test/main.cpp
@@ -1,6 +1,8 @@
 #include "google/gtest/gtest.h"
+#include <messmer/cpp-utils/assert/backtrace.h>

 int main(int argc, char **argv) {
+  cpputils::showBacktraceOnSigSegv();
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }

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

int main(int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

<|edits_diff|>
--- test/main.cpp
+++ test/main.cpp
@@ -1,4 +1,5 @@
 #include "google/gtest/gtest.h"
+#include <messmer/cpp-utils/assert/backtrace.h>

 int main(int argc, char **argv) {
   testing::InitGoogleTest(&argc, argv);
<|current_version|>
#include "google/gtest/gtest.h"
#include <messmer/cpp-utils/assert/backtrace.h>

int main(int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

<|next_version|>
#include "google/gtest/gtest.h"
#include <messmer/cpp-utils/assert/backtrace.h>

int main(int argc, char **argv) {
  cpputils::showBacktraceOnSigSegv();
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}


Add example of log channels

[Demo01] Add example of log channels

--- Demo01-WindowManager/DemoWindowManager.cpp
+++ Demo01-WindowManager/DemoWindowManager.cpp
@@ -9,6 +9,10 @@
 {
 	Log::AddDefaultOutputs();

+	Log::Info("Info");
+	Log::Warn("Warning");
+	Log::Error("Error");
+
 	SingletonPointer<CWindowManager> WindowManager;
 	SingletonPointer<CGraphicsAPI> GraphicsAPI;

@@ -17,7 +21,9 @@
 	WindowManager->CreateWindow(vec2i(640, 480), "TestWindowManager", EWindowType::Windowed);

 	while (! WindowManager->ShouldClose())
+	{
 		WindowManager->PollEvents();
+	}

 	return 0;
 }

<|original_code|>

#include <ionWindow.h>
#include <ionGraphicsGL.h>

using namespace ion;

int main()
{
	Log::AddDefaultOutputs();

	SingletonPointer<CWindowManager> WindowManager;
	SingletonPointer<CGraphicsAPI> GraphicsAPI;

	GraphicsAPI->Init(new Graphics::COpenGLImplementation());
	WindowManager->Init(GraphicsAPI);
	WindowManager->CreateWindow(vec2i(640, 480), "TestWindowManager", EWindowType::Windowed);

	while (! WindowManager->ShouldClose())
		WindowManager->PollEvents();

	return 0;
}

<|edits_diff|>
--- Demo01-WindowManager/DemoWindowManager.cpp
+++ Demo01-WindowManager/DemoWindowManager.cpp
@@ -9,6 +9,10 @@
 {
 	Log::AddDefaultOutputs();

+	Log::Info("Info");
+	Log::Warn("Warning");
+	Log::Error("Error");
+
 	SingletonPointer<CWindowManager> WindowManager;
 	SingletonPointer<CGraphicsAPI> GraphicsAPI;

@@ -17,6 +21,7 @@
 	WindowManager->CreateWindow(vec2i(640, 480), "TestWindowManager", EWindowType::Windowed);

 	while (! WindowManager->ShouldClose())
+	{
 		WindowManager->PollEvents();

 	return 0;
<|current_version|>

#include <ionWindow.h>
#include <ionGraphicsGL.h>

using namespace ion;

int main()
{
	Log::AddDefaultOutputs();

	Log::Info("Info");
	Log::Warn("Warning");
	Log::Error("Error");

	SingletonPointer<CWindowManager> WindowManager;
	SingletonPointer<CGraphicsAPI> GraphicsAPI;

	GraphicsAPI->Init(new Graphics::COpenGLImplementation());
	WindowManager->Init(GraphicsAPI);
	WindowManager->CreateWindow(vec2i(640, 480), "TestWindowManager", EWindowType::Windowed);

	while (! WindowManager->ShouldClose())
	{
		WindowManager->PollEvents();

	return 0;
}

<|next_version|>

#include <ionWindow.h>
#include <ionGraphicsGL.h>

using namespace ion;

int main()
{
	Log::AddDefaultOutputs();

	Log::Info("Info");
	Log::Warn("Warning");
	Log::Error("Error");

	SingletonPointer<CWindowManager> WindowManager;
	SingletonPointer<CGraphicsAPI> GraphicsAPI;

	GraphicsAPI->Init(new Graphics::COpenGLImplementation());
	WindowManager->Init(GraphicsAPI);
	WindowManager->CreateWindow(vec2i(640, 480), "TestWindowManager", EWindowType::Windowed);

	while (! WindowManager->ShouldClose())
	{
		WindowManager->PollEvents();
	}

	return 0;
}


Make functions used in tests static

tests: Make functions used in tests static

--- tests/stack.cpp
+++ tests/stack.cpp
@@ -3,14 +3,17 @@
 #include <lua.hpp>
 #include <luwra.hpp>

+static
 int test_function_1(int a, int b) {
 	return a - b;
 }

+static
 int test_function_2(int a, int b, int c) {
 	return a + b * c;
 }

+static
 void test_function_3(int) {

 }

<|original_code|>
#include "catch.hpp"

#include <lua.hpp>
#include <luwra.hpp>

int test_function_1(int a, int b) {
	return a - b;
}

int test_function_2(int a, int b, int c) {
	return a + b * c;
}

void test_function_3(int) {

}

TEST_CASE("stack_interaction") {
	lua_State* state = luaL_newstate();

	luwra::push(state, 1);
	luwra::push(state, 2);
	luwra::push(state, 4);

	// Redundant function
	luwra::apply(state, test_function_3);

	// Absolute index
	REQUIRE(luwra::apply(state, test_function_1) == -1);
	REQUIRE(luwra::apply(state, 1, test_function_1) == -1);
	REQUIRE(luwra::apply(state, test_function_2) == 9);
	REQUIRE(luwra::apply(state, 1, test_function_2) == 9);

	// Relative index
	REQUIRE(luwra::apply(state, -2, test_function_1) == -2);
	REQUIRE(luwra::apply(state, -3, test_function_1) == -1);
	REQUIRE(luwra::apply(state, -3, test_function_2) == 9);

	lua_close(state);
}

<|edits_diff|>
--- tests/stack.cpp
+++ tests/stack.cpp
@@ -3,10 +3,12 @@
 #include <lua.hpp>
 #include <luwra.hpp>

+static
 int test_function_1(int a, int b) {
 	return a - b;
 }

+static
 int test_function_2(int a, int b, int c) {
 	return a + b * c;
 }
<|current_version|>
#include "catch.hpp"

#include <lua.hpp>
#include <luwra.hpp>

static
int test_function_1(int a, int b) {
	return a - b;
}

static
int test_function_2(int a, int b, int c) {
	return a + b * c;
}

void test_function_3(int) {

}

TEST_CASE("stack_interaction") {
	lua_State* state = luaL_newstate();

	luwra::push(state, 1);
	luwra::push(state, 2);
	luwra::push(state, 4);

	// Redundant function
	luwra::apply(state, test_function_3);

	// Absolute index
	REQUIRE(luwra::apply(state, test_function_1) == -1);
	REQUIRE(luwra::apply(state, 1, test_function_1) == -1);
	REQUIRE(luwra::apply(state, test_function_2) == 9);
	REQUIRE(luwra::apply(state, 1, test_function_2) == 9);

	// Relative index
	REQUIRE(luwra::apply(state, -2, test_function_1) == -2);
	REQUIRE(luwra::apply(state, -3, test_function_1) == -1);
	REQUIRE(luwra::apply(state, -3, test_function_2) == 9);

	lua_close(state);
}

<|next_version|>
#include "catch.hpp"

#include <lua.hpp>
#include <luwra.hpp>

static
int test_function_1(int a, int b) {
	return a - b;
}

static
int test_function_2(int a, int b, int c) {
	return a + b * c;
}

static
void test_function_3(int) {

}

TEST_CASE("stack_interaction") {
	lua_State* state = luaL_newstate();

	luwra::push(state, 1);
	luwra::push(state, 2);
	luwra::push(state, 4);

	// Redundant function
	luwra::apply(state, test_function_3);

	// Absolute index
	REQUIRE(luwra::apply(state, test_function_1) == -1);
	REQUIRE(luwra::apply(state, 1, test_function_1) == -1);
	REQUIRE(luwra::apply(state, test_function_2) == 9);
	REQUIRE(luwra::apply(state, 1, test_function_2) == 9);

	// Relative index
	REQUIRE(luwra::apply(state, -2, test_function_1) == -2);
	REQUIRE(luwra::apply(state, -3, test_function_1) == -1);
	REQUIRE(luwra::apply(state, -3, test_function_2) == 9);

	lua_close(state);
}


Quit the application when qml engine wants to.

--- src/mobile/main.cpp
+++ src/mobile/main.cpp
@@ -4,6 +4,7 @@
 #include <QGuiApplication>
 #include <QQuickView>
 #include <QQmlContext>
+#include <QQmlEngine>
 #include <QtQml>
 #include <QUrl>

@@ -17,6 +18,9 @@

     QQuickView view;

+    QQmlEngine* engine = view.engine();
+    QObject::connect(engine, SIGNAL(quit()), &app, SLOT(quit()));
+
     QQmlContext* rootContext = view.rootContext();
     rootContext->setContextProperty("client", Client::instance());

<|original_code|>
#include "client.h"
#include "tests/test.h"

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QtQml>
#include <QUrl>

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

    qmlRegisterUncreatableType<AbstractTest>("mplane", 1, 0, "AbstractTest", "abstract class");
    qmlRegisterUncreatableType<Client>("mplane", 1, 0, "Client", "This is a singleton");
    qmlRegisterUncreatableType<TestScheduler>("mplane", 1, 0, "TestScheduler", "uncreatable type");

    QQuickView view;

    QQmlContext* rootContext = view.rootContext();
    rootContext->setContextProperty("client", Client::instance());

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource( QUrl("qrc:/qml/main.qml") );
    view.show();

    return app.exec();
}

<|edits_diff|>
--- src/mobile/main.cpp
+++ src/mobile/main.cpp
@@ -4,6 +4,7 @@
 #include <QGuiApplication>
 #include <QQuickView>
 #include <QQmlContext>
+#include <QQmlEngine>
 #include <QtQml>
 #include <QUrl>

<|current_version|>
#include "client.h"
#include "tests/test.h"

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QQmlEngine>
#include <QtQml>
#include <QUrl>

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

    qmlRegisterUncreatableType<AbstractTest>("mplane", 1, 0, "AbstractTest", "abstract class");
    qmlRegisterUncreatableType<Client>("mplane", 1, 0, "Client", "This is a singleton");
    qmlRegisterUncreatableType<TestScheduler>("mplane", 1, 0, "TestScheduler", "uncreatable type");

    QQuickView view;

    QQmlContext* rootContext = view.rootContext();
    rootContext->setContextProperty("client", Client::instance());

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource( QUrl("qrc:/qml/main.qml") );
    view.show();

    return app.exec();
}

<|next_version|>
#include "client.h"
#include "tests/test.h"

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QQmlEngine>
#include <QtQml>
#include <QUrl>

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

    qmlRegisterUncreatableType<AbstractTest>("mplane", 1, 0, "AbstractTest", "abstract class");
    qmlRegisterUncreatableType<Client>("mplane", 1, 0, "Client", "This is a singleton");
    qmlRegisterUncreatableType<TestScheduler>("mplane", 1, 0, "TestScheduler", "uncreatable type");

    QQuickView view;

    QQmlEngine* engine = view.engine();
    QObject::connect(engine, SIGNAL(quit()), &app, SLOT(quit()));

    QQmlContext* rootContext = view.rootContext();
    rootContext->setContextProperty("client", Client::instance());

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource( QUrl("qrc:/qml/main.qml") );
    view.show();

    return app.exec();
}


Print a warning if client is not set

Declarative/UserInfo: Print a warning if client is not set

--- imports/TelegramQtQml/DeclarativeUserInfo.cpp
+++ imports/TelegramQtQml/DeclarativeUserInfo.cpp
@@ -2,6 +2,10 @@

 #include "Client.hpp"
 #include "DataStorage.hpp"
+
+#include <QLoggingCategory>
+
+Q_DECLARE_LOGGING_CATEGORY(c_qmlLoggingCategory)

 namespace Telegram {

@@ -35,6 +39,10 @@
 void DeclarativeUserInfo::updateDisplayName()
 {
     UserInfo info;
+    if (!client()) {
+        qCWarning(c_qmlLoggingCategory) << this << "Client not set!";
+        return;
+    }
     client()->dataStorage()->getUserInfo(&info, m_contactId);
     setDisplayName(info.firstName());
 }

<|original_code|>
#include "DeclarativeUserInfo.hpp"

#include "Client.hpp"
#include "DataStorage.hpp"

namespace Telegram {

namespace Client {

DeclarativeUserInfo::DeclarativeUserInfo(QObject *parent) :
    DeclarativeClientOperator(parent)
{
}

void DeclarativeUserInfo::setContactId(quint32 contactId)
{
    if (m_contactId == contactId) {
        return;
    }
    m_contactId = contactId;
    emit contactIdChanged(contactId);

    updateDisplayName();
}

void DeclarativeUserInfo::setDisplayName(const QString &displayName)
{
    if (m_displayName == displayName) {
        return;
    }
    m_displayName = displayName;
    emit displayNameChanged(displayName);
}

void DeclarativeUserInfo::updateDisplayName()
{
    UserInfo info;
    client()->dataStorage()->getUserInfo(&info, m_contactId);
    setDisplayName(info.firstName());
}

} // Client

} // Telegram

<|edits_diff|>
--- imports/TelegramQtQml/DeclarativeUserInfo.cpp
+++ imports/TelegramQtQml/DeclarativeUserInfo.cpp
@@ -2,6 +2,10 @@

 #include "Client.hpp"
 #include "DataStorage.hpp"
+
+#include <QLoggingCategory>
+
+Q_DECLARE_LOGGING_CATEGORY(c_qmlLoggingCategory)

 namespace Telegram {

<|current_version|>
#include "DeclarativeUserInfo.hpp"

#include "Client.hpp"
#include "DataStorage.hpp"

#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(c_qmlLoggingCategory)

namespace Telegram {

namespace Client {

DeclarativeUserInfo::DeclarativeUserInfo(QObject *parent) :
    DeclarativeClientOperator(parent)
{
}

void DeclarativeUserInfo::setContactId(quint32 contactId)
{
    if (m_contactId == contactId) {
        return;
    }
    m_contactId = contactId;
    emit contactIdChanged(contactId);

    updateDisplayName();
}

void DeclarativeUserInfo::setDisplayName(const QString &displayName)
{
    if (m_displayName == displayName) {
        return;
    }
    m_displayName = displayName;
    emit displayNameChanged(displayName);
}

void DeclarativeUserInfo::updateDisplayName()
{
    UserInfo info;
    client()->dataStorage()->getUserInfo(&info, m_contactId);
    setDisplayName(info.firstName());
}

} // Client

} // Telegram

<|next_version|>
#include "DeclarativeUserInfo.hpp"

#include "Client.hpp"
#include "DataStorage.hpp"

#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(c_qmlLoggingCategory)

namespace Telegram {

namespace Client {

DeclarativeUserInfo::DeclarativeUserInfo(QObject *parent) :
    DeclarativeClientOperator(parent)
{
}

void DeclarativeUserInfo::setContactId(quint32 contactId)
{
    if (m_contactId == contactId) {
        return;
    }
    m_contactId = contactId;
    emit contactIdChanged(contactId);

    updateDisplayName();
}

void DeclarativeUserInfo::setDisplayName(const QString &displayName)
{
    if (m_displayName == displayName) {
        return;
    }
    m_displayName = displayName;
    emit displayNameChanged(displayName);
}

void DeclarativeUserInfo::updateDisplayName()
{
    UserInfo info;
    if (!client()) {
        qCWarning(c_qmlLoggingCategory) << this << "Client not set!";
        return;
    }
    client()->dataStorage()->getUserInfo(&info, m_contactId);
    setDisplayName(info.firstName());
}

} // Client

} // Telegram


Fix an issue found by purify with my previous submission.

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

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

Former-commit-id: 9b4d648a30f120aa6158413fbbeaa8442a4c2c0d

--- webkit/glue/resource_loader_bridge.cc
+++ webkit/glue/resource_loader_bridge.cc
@@ -6,6 +6,7 @@
 #include "config.h"

 #include "webkit/glue/resource_loader_bridge.h"
+#include "webkit/glue/webappcachecontext.h"

 #include "net/http/http_response_headers.h"

@@ -13,6 +14,7 @@

 ResourceLoaderBridge::ResponseInfo::ResponseInfo() {
   content_length = -1;
+  app_cache_id = WebAppCacheContext::kNoAppCacheId;
 #if defined(OS_WIN)
   response_data_file = base::kInvalidPlatformFileValue;
 #elif defined(OS_POSIX)

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

#include "config.h"

#include "webkit/glue/resource_loader_bridge.h"

#include "net/http/http_response_headers.h"

namespace webkit_glue {

ResourceLoaderBridge::ResponseInfo::ResponseInfo() {
  content_length = -1;
#if defined(OS_WIN)
  response_data_file = base::kInvalidPlatformFileValue;
#elif defined(OS_POSIX)
  response_data_file.fd = base::kInvalidPlatformFileValue;
  response_data_file.auto_close = false;
#endif
}

ResourceLoaderBridge::ResponseInfo::~ResponseInfo() {
}

ResourceLoaderBridge::SyncLoadResponse::SyncLoadResponse() {
}

ResourceLoaderBridge::SyncLoadResponse::~SyncLoadResponse() {
}

ResourceLoaderBridge::ResourceLoaderBridge() {
}

ResourceLoaderBridge::~ResourceLoaderBridge() {
}

}  // namespace webkit_glue

<|edits_diff|>
--- webkit/glue/resource_loader_bridge.cc
+++ webkit/glue/resource_loader_bridge.cc
@@ -6,6 +6,7 @@
 #include "config.h"

 #include "webkit/glue/resource_loader_bridge.h"
+#include "webkit/glue/webappcachecontext.h"

 #include "net/http/http_response_headers.h"

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

#include "config.h"

#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webappcachecontext.h"

#include "net/http/http_response_headers.h"

namespace webkit_glue {

ResourceLoaderBridge::ResponseInfo::ResponseInfo() {
  content_length = -1;
#if defined(OS_WIN)
  response_data_file = base::kInvalidPlatformFileValue;
#elif defined(OS_POSIX)
  response_data_file.fd = base::kInvalidPlatformFileValue;
  response_data_file.auto_close = false;
#endif
}

ResourceLoaderBridge::ResponseInfo::~ResponseInfo() {
}

ResourceLoaderBridge::SyncLoadResponse::SyncLoadResponse() {
}

ResourceLoaderBridge::SyncLoadResponse::~SyncLoadResponse() {
}

ResourceLoaderBridge::ResourceLoaderBridge() {
}

ResourceLoaderBridge::~ResourceLoaderBridge() {
}

}  // namespace webkit_glue

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

#include "config.h"

#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webappcachecontext.h"

#include "net/http/http_response_headers.h"

namespace webkit_glue {

ResourceLoaderBridge::ResponseInfo::ResponseInfo() {
  content_length = -1;
  app_cache_id = WebAppCacheContext::kNoAppCacheId;
#if defined(OS_WIN)
  response_data_file = base::kInvalidPlatformFileValue;
#elif defined(OS_POSIX)
  response_data_file.fd = base::kInvalidPlatformFileValue;
  response_data_file.auto_close = false;
#endif
}

ResourceLoaderBridge::ResponseInfo::~ResponseInfo() {
}

ResourceLoaderBridge::SyncLoadResponse::SyncLoadResponse() {
}

ResourceLoaderBridge::SyncLoadResponse::~SyncLoadResponse() {
}

ResourceLoaderBridge::ResourceLoaderBridge() {
}

ResourceLoaderBridge::~ResourceLoaderBridge() {
}

}  // namespace webkit_glue


[generator] Optimize EmitterSimple: empty Polygonizer::m_currentNames per feature

--- generator/emitter_simple.cpp
+++ generator/emitter_simple.cpp
@@ -16,7 +16,11 @@

 void EmitterSimple::Process(FeatureBuilder1 & fb)
 {
+  auto & polygonizer = m_regionGenerator->Parent();
+  // Emit each feature independently: clear current country names (see Polygonizer::GetCurrentNames()).
+  polygonizer.Start();
   (*m_regionGenerator)(fb);
+  polygonizer.Finish();
 }

 void EmitterPreserialize::Process(FeatureBuilder1 & fb)

<|original_code|>
#include "generator/emitter_simple.hpp"

#include "generator/feature_builder.hpp"

#include "base/macros.hpp"

namespace generator
{
EmitterSimple::EmitterSimple(feature::GenerateInfo const & info) :
  m_regionGenerator(std::make_unique<SimpleGenerator>(info)) {}

void EmitterSimple::GetNames(std::vector<std::string> & names) const
{
  names = m_regionGenerator->Parent().GetNames();
}

void EmitterSimple::Process(FeatureBuilder1 & fb)
{
  (*m_regionGenerator)(fb);
}

void EmitterPreserialize::Process(FeatureBuilder1 & fb)
{
  UNUSED_VALUE(fb.PreSerialize());
  EmitterSimple::Process(fb);
}
}  // namespace generator

<|edits_diff|>
--- generator/emitter_simple.cpp
+++ generator/emitter_simple.cpp
@@ -16,6 +16,9 @@

 void EmitterSimple::Process(FeatureBuilder1 & fb)
 {
+  auto & polygonizer = m_regionGenerator->Parent();
+  // Emit each feature independently: clear current country names (see Polygonizer::GetCurrentNames()).
+  polygonizer.Start();
   (*m_regionGenerator)(fb);
 }

<|current_version|>
#include "generator/emitter_simple.hpp"

#include "generator/feature_builder.hpp"

#include "base/macros.hpp"

namespace generator
{
EmitterSimple::EmitterSimple(feature::GenerateInfo const & info) :
  m_regionGenerator(std::make_unique<SimpleGenerator>(info)) {}

void EmitterSimple::GetNames(std::vector<std::string> & names) const
{
  names = m_regionGenerator->Parent().GetNames();
}

void EmitterSimple::Process(FeatureBuilder1 & fb)
{
  auto & polygonizer = m_regionGenerator->Parent();
  // Emit each feature independently: clear current country names (see Polygonizer::GetCurrentNames()).
  polygonizer.Start();
  (*m_regionGenerator)(fb);
}

void EmitterPreserialize::Process(FeatureBuilder1 & fb)
{
  UNUSED_VALUE(fb.PreSerialize());
  EmitterSimple::Process(fb);
}
}  // namespace generator

<|next_version|>
#include "generator/emitter_simple.hpp"

#include "generator/feature_builder.hpp"

#include "base/macros.hpp"

namespace generator
{
EmitterSimple::EmitterSimple(feature::GenerateInfo const & info) :
  m_regionGenerator(std::make_unique<SimpleGenerator>(info)) {}

void EmitterSimple::GetNames(std::vector<std::string> & names) const
{
  names = m_regionGenerator->Parent().GetNames();
}

void EmitterSimple::Process(FeatureBuilder1 & fb)
{
  auto & polygonizer = m_regionGenerator->Parent();
  // Emit each feature independently: clear current country names (see Polygonizer::GetCurrentNames()).
  polygonizer.Start();
  (*m_regionGenerator)(fb);
  polygonizer.Finish();
}

void EmitterPreserialize::Process(FeatureBuilder1 & fb)
{
  UNUSED_VALUE(fb.PreSerialize());
  EmitterSimple::Process(fb);
}
}  // namespace generator


Allow to only run some test suites from the test runner

--- tests/src/main.cpp
+++ tests/src/main.cpp
@@ -12,6 +12,10 @@
 		QGuiApplication a(argc, argv);
 	#endif

+	QStringList testSuites;
+	for (int i = 1; i < argc; ++i)
+		testSuites.append(argv[i]);
+
 	QMap<QString,int> results;
 	int failed = 0;

@@ -19,6 +23,9 @@

 	for (QObject *suite : TestSuite::suites)
 	{
+		if (!testSuites.isEmpty() && !testSuites.contains(suite->metaObject()->className()))
+			continue;
+
 		int result = QTest::qExec(suite);
 		results.insert(suite->metaObject()->className(), result);
 		if (result != 0)

<|original_code|>
#include <QTest>
#include "test-suite.h"
#include "custom-network-access-manager.h"
#include <iostream>

int main(int argc, char *argv[])
{
	#ifdef HEADLESS
		QCoreApplication a(argc, argv);
	#else
		QGuiApplication a(argc, argv);
	#endif

	QMap<QString,int> results;
	int failed = 0;

	CustomNetworkAccessManager::TestMode = true;

	for (QObject *suite : TestSuite::suites)
	{
		int result = QTest::qExec(suite);
		results.insert(suite->metaObject()->className(), result);
		if (result != 0)
		{
			failed++;
		}
	}

	for (auto key : results.keys())
	{
		std::cout << '[' << (results.value(key) != 0 ? "FAIL" : "OK") << "] " << key.toStdString() << std::endl;
	}

	return failed;
}

<|edits_diff|>
--- tests/src/main.cpp
+++ tests/src/main.cpp
@@ -11,6 +11,10 @@
 	#else
 		QGuiApplication a(argc, argv);
 	#endif
+
+	QStringList testSuites;
+	for (int i = 1; i < argc; ++i)
+		testSuites.append(argv[i]);

 	QMap<QString,int> results;
 	int failed = 0;
<|current_version|>
#include <QTest>
#include "test-suite.h"
#include "custom-network-access-manager.h"
#include <iostream>

int main(int argc, char *argv[])
{
	#ifdef HEADLESS
		QCoreApplication a(argc, argv);
	#else
		QGuiApplication a(argc, argv);
	#endif

	QStringList testSuites;
	for (int i = 1; i < argc; ++i)
		testSuites.append(argv[i]);

	QMap<QString,int> results;
	int failed = 0;

	CustomNetworkAccessManager::TestMode = true;

	for (QObject *suite : TestSuite::suites)
	{
		int result = QTest::qExec(suite);
		results.insert(suite->metaObject()->className(), result);
		if (result != 0)
		{
			failed++;
		}
	}

	for (auto key : results.keys())
	{
		std::cout << '[' << (results.value(key) != 0 ? "FAIL" : "OK") << "] " << key.toStdString() << std::endl;
	}

	return failed;
}

<|next_version|>
#include <QTest>
#include "test-suite.h"
#include "custom-network-access-manager.h"
#include <iostream>

int main(int argc, char *argv[])
{
	#ifdef HEADLESS
		QCoreApplication a(argc, argv);
	#else
		QGuiApplication a(argc, argv);
	#endif

	QStringList testSuites;
	for (int i = 1; i < argc; ++i)
		testSuites.append(argv[i]);

	QMap<QString,int> results;
	int failed = 0;

	CustomNetworkAccessManager::TestMode = true;

	for (QObject *suite : TestSuite::suites)
	{
		if (!testSuites.isEmpty() && !testSuites.contains(suite->metaObject()->className()))
			continue;

		int result = QTest::qExec(suite);
		results.insert(suite->metaObject()->className(), result);
		if (result != 0)
		{
			failed++;
		}
	}

	for (auto key : results.keys())
	{
		std::cout << '[' << (results.value(key) != 0 ? "FAIL" : "OK") << "] " << key.toStdString() << std::endl;
	}

	return failed;
}


Initialize and enable LEDs in animation to test

--- firmware/main/AnimationTask.cpp
+++ firmware/main/AnimationTask.cpp
@@ -29,8 +29,12 @@
 }

 void AnimationTask::run(void* data) {
+    m_i2c->init(I2C_NUM_1, I2C_MODE_MASTER, GPIO_NUM_18, GPIO_NUM_19, GPIO_PULLUP_DISABLE, GPIO_PULLUP_DISABLE, 100000);
+    m_i2c->i2c_is31_init(I2C_NUM_1);
     while (1) {
         ESP_LOGW(tag, "AnimationTask::run");
+        m_i2c->i2c_is31_pwm(I2C_NUM_1);
+        m_i2c->i2c_is31_en(I2C_NUM_1);
         delay(1000);
     }
 }

<|original_code|>
/*
 * AnimationTask.cpp
 *
 * Copyright (C) 2018 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

#include <esp_log.h>

#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"

#include "AnimationTask.h"
#include "sdkconfig.h"

static char tag[] = "AnimationTask";

AnimationTask::AnimationTask(const char* taskName, I2C* i2c)
        : Esp32RtosTask(taskName),
          m_i2c(i2c) {
}

AnimationTask::~AnimationTask() {
}

void AnimationTask::run(void* data) {
    while (1) {
        ESP_LOGW(tag, "AnimationTask::run");
        delay(1000);
    }
}

<|edits_diff|>
--- firmware/main/AnimationTask.cpp
+++ firmware/main/AnimationTask.cpp
@@ -29,6 +29,8 @@
 }

 void AnimationTask::run(void* data) {
+    m_i2c->init(I2C_NUM_1, I2C_MODE_MASTER, GPIO_NUM_18, GPIO_NUM_19, GPIO_PULLUP_DISABLE, GPIO_PULLUP_DISABLE, 100000);
+    m_i2c->i2c_is31_init(I2C_NUM_1);
     while (1) {
         ESP_LOGW(tag, "AnimationTask::run");
         delay(1000);
<|current_version|>
/*
 * AnimationTask.cpp
 *
 * Copyright (C) 2018 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

#include <esp_log.h>

#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"

#include "AnimationTask.h"
#include "sdkconfig.h"

static char tag[] = "AnimationTask";

AnimationTask::AnimationTask(const char* taskName, I2C* i2c)
        : Esp32RtosTask(taskName),
          m_i2c(i2c) {
}

AnimationTask::~AnimationTask() {
}

void AnimationTask::run(void* data) {
    m_i2c->init(I2C_NUM_1, I2C_MODE_MASTER, GPIO_NUM_18, GPIO_NUM_19, GPIO_PULLUP_DISABLE, GPIO_PULLUP_DISABLE, 100000);
    m_i2c->i2c_is31_init(I2C_NUM_1);
    while (1) {
        ESP_LOGW(tag, "AnimationTask::run");
        delay(1000);
    }
}

<|next_version|>
/*
 * AnimationTask.cpp
 *
 * Copyright (C) 2018 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

#include <esp_log.h>

#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"

#include "AnimationTask.h"
#include "sdkconfig.h"

static char tag[] = "AnimationTask";

AnimationTask::AnimationTask(const char* taskName, I2C* i2c)
        : Esp32RtosTask(taskName),
          m_i2c(i2c) {
}

AnimationTask::~AnimationTask() {
}

void AnimationTask::run(void* data) {
    m_i2c->init(I2C_NUM_1, I2C_MODE_MASTER, GPIO_NUM_18, GPIO_NUM_19, GPIO_PULLUP_DISABLE, GPIO_PULLUP_DISABLE, 100000);
    m_i2c->i2c_is31_init(I2C_NUM_1);
    while (1) {
        ESP_LOGW(tag, "AnimationTask::run");
        m_i2c->i2c_is31_pwm(I2C_NUM_1);
        m_i2c->i2c_is31_en(I2C_NUM_1);
        delay(1000);
    }
}


Add SinogramCreatorMC to manager list

Add SinogramCreatorMC to manager list

--- ImageReconstruction/main.cpp
+++ ImageReconstruction/main.cpp
@@ -16,6 +16,7 @@
 #include "JPetManager/JPetManager.h"
 #include "ImageReco.h"
 #include "SinogramCreator.h"
+#include "SinogramCreatorMC.h"
 using namespace std;

 int main(int argc, const char* argv[])
@@ -24,9 +25,11 @@

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

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

   manager.run(argc, argv);
 }

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

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

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

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

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

  manager.run(argc, argv);
}

<|edits_diff|>
--- ImageReconstruction/main.cpp
+++ ImageReconstruction/main.cpp
@@ -16,6 +16,7 @@
 #include "JPetManager/JPetManager.h"
 #include "ImageReco.h"
 #include "SinogramCreator.h"
+#include "SinogramCreatorMC.h"
 using namespace std;

 int main(int argc, const char* argv[])
@@ -24,6 +25,7 @@

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

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

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

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

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

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

  manager.run(argc, argv);
}

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

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

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

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

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

  manager.run(argc, argv);
}


Set numeric locale to C for proper tesseract-orc-* packages work on linux.

--- main.cpp
+++ main.cpp
@@ -1,3 +1,7 @@
+#ifdef Q_OS_LINUX
+#  include <locale.h>
+#endif
+
 #include <QApplication>
 #include <QTranslator>

@@ -11,6 +15,9 @@
   if (a.sendMessage (QString ())) {
     return 0;
   }
+#ifdef Q_OS_LINUX
+  setlocale (LC_NUMERIC, "C");
+#endif
   a.setQuitOnLastWindowClosed (false);
   a.setApplicationName (settings_values::appName);
   a.setOrganizationName (settings_values::companyName);

<|original_code|>
#include <QApplication>
#include <QTranslator>

#include <qtsingleapplication.h>

#include <Manager.h>
#include <Settings.h>

int main (int argc, char *argv[]) {
  QtSingleApplication a (argc, argv);
  if (a.sendMessage (QString ())) {
    return 0;
  }
  a.setQuitOnLastWindowClosed (false);
  a.setApplicationName (settings_values::appName);
  a.setOrganizationName (settings_values::companyName);

  QTranslator translator;
  // Set default to english.
  if (translator.load (QLocale::system (), "translation", "_", ":/translations") ||
      translator.load (":/translations/translation_en")) {
    a.installTranslator (&translator);
  }

  Manager manager;

  return a.exec ();
}

<|edits_diff|>
--- main.cpp
+++ main.cpp
@@ -1,3 +1,7 @@
+#ifdef Q_OS_LINUX
+#  include <locale.h>
+#endif
+
 #include <QApplication>
 #include <QTranslator>

<|current_version|>
#ifdef Q_OS_LINUX
#  include <locale.h>
#endif

#include <QApplication>
#include <QTranslator>

#include <qtsingleapplication.h>

#include <Manager.h>
#include <Settings.h>

int main (int argc, char *argv[]) {
  QtSingleApplication a (argc, argv);
  if (a.sendMessage (QString ())) {
    return 0;
  }
  a.setQuitOnLastWindowClosed (false);
  a.setApplicationName (settings_values::appName);
  a.setOrganizationName (settings_values::companyName);

  QTranslator translator;
  // Set default to english.
  if (translator.load (QLocale::system (), "translation", "_", ":/translations") ||
      translator.load (":/translations/translation_en")) {
    a.installTranslator (&translator);
  }

  Manager manager;

  return a.exec ();
}

<|next_version|>
#ifdef Q_OS_LINUX
#  include <locale.h>
#endif

#include <QApplication>
#include <QTranslator>

#include <qtsingleapplication.h>

#include <Manager.h>
#include <Settings.h>

int main (int argc, char *argv[]) {
  QtSingleApplication a (argc, argv);
  if (a.sendMessage (QString ())) {
    return 0;
  }
#ifdef Q_OS_LINUX
  setlocale (LC_NUMERIC, "C");
#endif
  a.setQuitOnLastWindowClosed (false);
  a.setApplicationName (settings_values::appName);
  a.setOrganizationName (settings_values::companyName);

  QTranslator translator;
  // Set default to english.
  if (translator.load (QLocale::system (), "translation", "_", ":/translations") ||
      translator.load (":/translations/translation_en")) {
    a.installTranslator (&translator);
  }

  Manager manager;

  return a.exec ();
}


Add exit check for setup call

[DV] Add exit check for setup call

Check the return value and exit program execution.

--- dv/riscv_compliance/ibex_riscv_compliance.cc
+++ dv/riscv_compliance/ibex_riscv_compliance.cc
@@ -20,6 +20,9 @@

   // Setup simctrl
   retcode = simctrl->SetupSimulation(argc, argv);
+  if (retcode != 0) {
+    goto free_return;
+  }

   // Initialize RAM
   simctrl->InitRam("TOP.ibex_riscv_compliance.u_ram");
@@ -27,6 +30,7 @@
   // Run the simulation
   simctrl->RunSimulation();

+free_return:
   delete top;
   delete simctrl;
   return retcode;

<|original_code|>
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#include <signal.h>

#include <iostream>

#include "verilated_toplevel.h"
#include "verilator_sim_ctrl.h"

ibex_riscv_compliance *top;
VerilatorSimCtrl *simctrl;

int main(int argc, char **argv) {
  int retcode;
  top = new ibex_riscv_compliance;
  simctrl = new VerilatorSimCtrl(top, top->IO_CLK, top->IO_RST_N,
                                 VerilatorSimCtrlFlags::ResetPolarityNegative);

  // Setup simctrl
  retcode = simctrl->SetupSimulation(argc, argv);

  // Initialize RAM
  simctrl->InitRam("TOP.ibex_riscv_compliance.u_ram");

  // Run the simulation
  simctrl->RunSimulation();

  delete top;
  delete simctrl;
  return retcode;
}

<|edits_diff|>
--- dv/riscv_compliance/ibex_riscv_compliance.cc
+++ dv/riscv_compliance/ibex_riscv_compliance.cc
@@ -20,6 +20,9 @@

   // Setup simctrl
   retcode = simctrl->SetupSimulation(argc, argv);
+  if (retcode != 0) {
+    goto free_return;
+  }

   // Initialize RAM
   simctrl->InitRam("TOP.ibex_riscv_compliance.u_ram");
<|current_version|>
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#include <signal.h>

#include <iostream>

#include "verilated_toplevel.h"
#include "verilator_sim_ctrl.h"

ibex_riscv_compliance *top;
VerilatorSimCtrl *simctrl;

int main(int argc, char **argv) {
  int retcode;
  top = new ibex_riscv_compliance;
  simctrl = new VerilatorSimCtrl(top, top->IO_CLK, top->IO_RST_N,
                                 VerilatorSimCtrlFlags::ResetPolarityNegative);

  // Setup simctrl
  retcode = simctrl->SetupSimulation(argc, argv);
  if (retcode != 0) {
    goto free_return;
  }

  // Initialize RAM
  simctrl->InitRam("TOP.ibex_riscv_compliance.u_ram");

  // Run the simulation
  simctrl->RunSimulation();

  delete top;
  delete simctrl;
  return retcode;
}

<|next_version|>
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#include <signal.h>

#include <iostream>

#include "verilated_toplevel.h"
#include "verilator_sim_ctrl.h"

ibex_riscv_compliance *top;
VerilatorSimCtrl *simctrl;

int main(int argc, char **argv) {
  int retcode;
  top = new ibex_riscv_compliance;
  simctrl = new VerilatorSimCtrl(top, top->IO_CLK, top->IO_RST_N,
                                 VerilatorSimCtrlFlags::ResetPolarityNegative);

  // Setup simctrl
  retcode = simctrl->SetupSimulation(argc, argv);
  if (retcode != 0) {
    goto free_return;
  }

  // Initialize RAM
  simctrl->InitRam("TOP.ibex_riscv_compliance.u_ram");

  // Run the simulation
  simctrl->RunSimulation();

free_return:
  delete top;
  delete simctrl;
  return retcode;
}