diff options
22 files changed, 63 insertions, 37 deletions
diff --git a/Backport/memory b/Backport/memory new file mode 100644 index 0000000..018113e --- /dev/null +++ b/Backport/memory @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include_next <memory> + + +#if __cplusplus < 201402L && !MSC_VER +namespace std { + +template<typename T, typename ...Args> +std::unique_ptr<T> make_unique( Args&& ...args ) +{ + return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) ); +} + +} +#endif + diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot index f815bbc..4c68076 100644 --- a/BuildTools/SCons/SConscript.boot +++ b/BuildTools/SCons/SConscript.boot @@ -247,6 +247,9 @@ for flags_type in ["ccflags", "cxxflags", "linkflags"] : # where you need it env["OBJCCFLAGS"] = [] +if env["PLATFORM"] != "win32" : + env.AppendUnique(CCFLAGS=['-isystem', Dir('#').abspath + '/Backport/']) + # Compile code as C++11 if env["PLATFORM"] != "win32" : env.Append(CXXFLAGS = ["-std=c++11"]) diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index d10e6d4..ff8efa2 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -112,7 +112,7 @@ MUCController::MUCController ( isInitialJoin_ = true; chatWindowTitle_ = ""; - roster_ = std::unique_ptr<Roster>(new Roster(false, true)); + roster_ = std::make_unique<Roster>(false, true); rosterVCardProvider_ = new RosterVCardProvider(roster_.get(), vcardManager, JID::WithResource); completer_ = new TabComplete(); chatWindow_->setRosterModel(roster_.get()); diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 1502dc9..8f6c3a8 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -160,7 +160,7 @@ class ChatsManagerTest : public CppUnit::TestFixture { public: void setUp() { mocks_ = new MockRepository(); - notifier_ = std::unique_ptr<DummyNotifier>(new DummyNotifier()); + notifier_ = std::make_unique<DummyNotifier>(); jid_ = JID("test@test.com/resource"); stanzaChannel_ = new DummyStanzaChannel(); iqRouter_ = new IQRouter(stanzaChannel_); diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index f6f6ce0..5b7e454 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -23,7 +23,7 @@ namespace Swift { -Roster::Roster(bool sortByStatus, bool fullJIDMapping) : fullJIDMapping_(fullJIDMapping), sortByStatus_(sortByStatus), root_(std::unique_ptr<GroupRosterItem>(new GroupRosterItem("Dummy-Root", nullptr, sortByStatus_))) { +Roster::Roster(bool sortByStatus, bool fullJIDMapping) : fullJIDMapping_(fullJIDMapping), sortByStatus_(sortByStatus), root_(std::make_unique<GroupRosterItem>("Dummy-Root", nullptr, sortByStatus_)) { root_->onChildrenChanged.connect(boost::bind(&Roster::handleChildrenChanged, this, root_.get())); } diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 1d20c4a..f5de801 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -79,7 +79,7 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata subscriptionManager_->onPresenceSubscriptionRequest.connect(boost::bind(&RosterController::handleSubscriptionRequest, this, _1, _2)); uiEventConnection_ = uiEventStream->onUIEvent.connect(boost::bind(&RosterController::handleUIEvent, this, _1)); - featureOracle_ = std::unique_ptr<FeatureOracle>(new FeatureOracle(entityCapsManager_, presenceOracle_)); + featureOracle_ = std::make_unique<FeatureOracle>(entityCapsManager_, presenceOracle_); vcardManager_->onOwnVCardChanged.connect(boost::bind(&RosterController::handleOwnVCardChanged, this, _1)); avatarManager_->onAvatarChanged.connect(boost::bind(&RosterController::handleAvatarChanged, this, _1)); diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp index 2f15fb5..9b64def 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp @@ -72,7 +72,7 @@ class RosterControllerTest : public CppUnit::TestFixture { mainWindowFactory_ = new MockMainWindowFactory(); mucRegistry_ = new MUCRegistry(); crypto_ = PlatformCryptoProvider::create(); - storages_ = std::unique_ptr<MemoryStorages>(new MemoryStorages(crypto_)); + storages_ = std::make_unique<MemoryStorages>(crypto_); nickResolver_ = new NickResolver(jid_.toBare(), xmppRoster_, nullptr, mucRegistry_); channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); @@ -83,7 +83,7 @@ class RosterControllerTest : public CppUnit::TestFixture { uiEventStream_ = new UIEventStream(); settings_ = new DummySettingsProvider(); nickManager_ = new DummyNickManager(); - capsManager_ = std::unique_ptr<CapsManager>(new CapsManager(storages_->getCapsStorage(), stanzaChannel_, router_, crypto_)); + capsManager_ = std::make_unique<CapsManager>(storages_->getCapsStorage(), stanzaChannel_, router_, crypto_); entityCapsManager_ = new EntityCapsManager(capsManager_.get(), stanzaChannel_); jingleSessionManager_ = new JingleSessionManager(router_); @@ -92,7 +92,7 @@ class RosterControllerTest : public CppUnit::TestFixture { vcardManager_ = new VCardManager(jid_, router_, vcardStorage_); rosterController_ = new RosterController(jid_, xmppRoster_, avatarManager_, mainWindowFactory_, nickManager_, nickResolver_, presenceOracle_, subscriptionManager_, eventController_, uiEventStream_, router_, settings_, entityCapsManager_, clientBlockListManager_, vcardManager_); mainWindow_ = mainWindowFactory_->last; - capsInfoGenerator_ = std::unique_ptr<CapsInfoGenerator>(new CapsInfoGenerator("", crypto_)); + capsInfoGenerator_ = std::make_unique<CapsInfoGenerator>("", crypto_); } void tearDown() { diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp index 5f500d4..045a5e4 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp @@ -30,7 +30,7 @@ class RosterTest : public CppUnit::TestFixture { jid1_ = JID("a@b.c"); jid2_ = JID("b@c.d"); jid3_ = JID("c@d.e"); - roster_ = std::unique_ptr<Roster>(new Roster()); + roster_ = std::make_unique<Roster>(); } void testGetGroup() { diff --git a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp index ddc8785..7ebce17 100644 --- a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp @@ -34,8 +34,8 @@ class TableRosterTest : public CppUnit::TestFixture { public: void setUp() { - timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); - roster = std::unique_ptr<Roster>(new Roster()); + timerFactory = std::make_unique<DummyTimerFactory>(); + roster = std::make_unique<Roster>(); jid1 = JID("jid1@example.com"); jid2 = JID("jid2@example.com"); } diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 7051683..e750caa 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -693,7 +693,7 @@ void QtChatWindow::handleEmojisButtonClicked() { emojisLayout->setContentsMargins(style()->pixelMetric(QStyle::PM_MenuHMargin),style()->pixelMetric(QStyle::PM_MenuVMargin), style()->pixelMetric(QStyle::PM_MenuHMargin),style()->pixelMetric(QStyle::PM_MenuVMargin)); emojisLayout->addWidget(emojisGrid_); - emojisMenu_ = std::unique_ptr<QMenu>(new QMenu()); + emojisMenu_ = std::make_unique<QMenu>(); emojisMenu_->setLayout(emojisLayout); emojisMenu_->adjustSize(); diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp index 8aca98e..3e5e9e6 100644 --- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp +++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp @@ -48,8 +48,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { public: void setUp() { - avatarProvider1 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider()); - avatarProvider2 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider()); + avatarProvider1 = std::make_unique<DummyAvatarProvider>(); + avatarProvider2 = std::make_unique<DummyAvatarProvider>(); user1 = JID("user1@bar.com/bla"); user2 = JID("user2@foo.com/baz"); avatarHash1 = "ABCDEFG"; diff --git a/Swiften/Client/ClientXMLTracer.cpp b/Swiften/Client/ClientXMLTracer.cpp index e205f41..e1b9e0c 100644 --- a/Swiften/Client/ClientXMLTracer.cpp +++ b/Swiften/Client/ClientXMLTracer.cpp @@ -16,9 +16,9 @@ namespace Swift { ClientXMLTracer::ClientXMLTracer(CoreClient* client, bool bosh) : bosh_(bosh) { #ifdef SWIFTEN_PLATFORM_WIN32 - beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + beautifier_ = std::make_unique<XMLBeautifier>(true, false); #else - beautifier_ = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, true)); + beautifier_ = std::make_unique<XMLBeautifier>(true, true); #endif onDataReadConnection_ = client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, this, '<', _1)); onDataWrittenConnection_ = client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, this, '>', _1)); diff --git a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp index 0188634..2eac086 100644 --- a/Swiften/Client/UnitTest/XMLBeautifierTest.cpp +++ b/Swiften/Client/UnitTest/XMLBeautifierTest.cpp @@ -15,7 +15,7 @@ namespace { } TEST(XMLBeautifierTest, testBeautify) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); ASSERT_EQ(FULL_FORMATTED_OUTPUT, beautifier->beautify("<list><el>aqq</el><el>bzz</el></list>")); ASSERT_TRUE(beautifier->wasReset()); @@ -26,7 +26,7 @@ TEST(XMLBeautifierTest, testBeautify) { } TEST(XMLBeautifierTest, testBeautifyMultipleChunks) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); auto result = beautifier->beautify("<list><el>aqq</el>"); ASSERT_TRUE(beautifier->wasReset()); @@ -40,7 +40,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunks) { } TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); auto result = beautifier->beautify("<l"); ASSERT_TRUE(beautifier->wasReset()); @@ -54,7 +54,7 @@ TEST(XMLBeautifierTest, testBeautifyMultipleChunksMiddleElement) { } TEST(XMLBeautifierTest, testBeautifyInvalidMultipleChunks) { - auto beautifier = std::unique_ptr<XMLBeautifier>(new XMLBeautifier(true, false)); + auto beautifier = std::make_unique<XMLBeautifier>(true, false); ASSERT_EQ(std::string("<list>\n <el>aqq"), beautifier->beautify("<list><el>aqq<")); ASSERT_TRUE(beautifier->wasReset()); diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp index 153e821..5f1aaf4 100644 --- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp @@ -47,9 +47,9 @@ class CapsManagerTest : public CppUnit::TestFixture { public: void setUp() { crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); - stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); - iqRouter = std::unique_ptr<IQRouter>(new IQRouter(stanzaChannel.get())); - storage = std::unique_ptr<CapsMemoryStorage>(new CapsMemoryStorage()); + stanzaChannel = std::make_unique<DummyStanzaChannel>(); + iqRouter = std::make_unique<IQRouter>(stanzaChannel.get()); + storage = std::make_unique<CapsMemoryStorage>(); user1 = JID("user1@bar.com/bla"); discoInfo1 = std::make_shared<DiscoInfo>(); discoInfo1->addFeature("http://swift.im/feature1"); diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp index 8c59741..6548485 100644 --- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp @@ -37,8 +37,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture { void setUp() { crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); - stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); - capsProvider = std::unique_ptr<DummyCapsProvider>(new DummyCapsProvider()); + stanzaChannel = std::make_unique<DummyStanzaChannel>(); + capsProvider = std::make_unique<DummyCapsProvider>(); user1 = JID("user1@bar.com/bla"); discoInfo1 = std::make_shared<DiscoInfo>(); diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index 290dda5..80667b6 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -59,8 +59,8 @@ public: crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); destination = "092a44d859d19c9eed676b551ee80025903351c2"; randomGen.seed(static_cast<unsigned int>(time(nullptr))); - eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop()); - timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); + eventLoop = std::make_unique<DummyEventLoop>(); + timerFactory = std::make_unique<DummyTimerFactory>(); connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get()); //connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); //stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); diff --git a/Swiften/Parser/PlatformXMLParserFactory.cpp b/Swiften/Parser/PlatformXMLParserFactory.cpp index 97e1c9e..bf66734 100644 --- a/Swiften/Parser/PlatformXMLParserFactory.cpp +++ b/Swiften/Parser/PlatformXMLParserFactory.cpp @@ -22,9 +22,9 @@ PlatformXMLParserFactory::PlatformXMLParserFactory() { std::unique_ptr<XMLParser> PlatformXMLParserFactory::createXMLParser(XMLParserClient* client) { #ifdef HAVE_LIBXML - return std::unique_ptr<XMLParser>(new LibXMLParser(client)); + return std::make_unique<LibXMLParser>(client); #else - return std::unique_ptr<XMLParser>(new ExpatParser(client)); + return std::make_unique<ExpatParser>(client); #endif } diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp index 38e67fb..e313124 100644 --- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp @@ -29,12 +29,12 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { public: void setUp() { - channel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel()); + channel = std::make_unique<DummyStanzaChannel>(); testPresence = std::make_shared<Presence>(); testPresence->setStatus("Foo"); secondTestPresence = std::make_shared<Presence>(); secondTestPresence->setStatus("Bar"); - stanzaChannelPresenceSender = std::unique_ptr<StanzaChannelPresenceSender>(new StanzaChannelPresenceSender(channel.get())); + stanzaChannelPresenceSender = std::make_unique<StanzaChannelPresenceSender>(channel.get()); } void testSendPresence() { diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp index b53cd2f..02ec0f8 100644 --- a/Swiften/QA/TLSTest/CertificateTest.cpp +++ b/Swiften/QA/TLSTest/CertificateTest.cpp @@ -34,7 +34,7 @@ class CertificateTest : public CppUnit::TestFixture { public: void setUp() { - pathProvider = std::unique_ptr<PlatformApplicationPathProvider>(new PlatformApplicationPathProvider("FileReadBytestreamTest")); + pathProvider = std::make_unique<PlatformApplicationPathProvider>("FileReadBytestreamTest"); readByteArrayFromFile(certificateData, (pathProvider->getExecutableDir() / "jabber_org.crt")); certificateFactory = std::unique_ptr<CertificateFactory>(new CERTIFICATE_FACTORY()); } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index 8a4b9fc..ed242f9 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -34,8 +34,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { public: void setUp() { - channel = std::unique_ptr<DummyIQChannel>(new DummyIQChannel()); - router = std::unique_ptr<IQRouter>(new IQRouter(channel.get())); + channel = std::make_unique<DummyIQChannel>(); + router = std::make_unique<IQRouter>(channel.get()); } void tearDown() { diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index 94bfed1..fa5072b 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -32,8 +32,8 @@ class ResponderTest : public CppUnit::TestFixture { public: void setUp() { - channel_ = std::unique_ptr<DummyIQChannel>(new DummyIQChannel()); - router_ = std::unique_ptr<IQRouter>(new IQRouter(channel_.get())); + channel_ = std::make_unique<DummyIQChannel>(); + router_ = std::make_unique<IQRouter>(channel_.get()); payload_ = std::make_shared<SoftwareVersion>("foo"); } diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp index 73e76d3..4137ebf 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp @@ -30,8 +30,8 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { jid1_ = JID("a@b.c"); jid2_ = JID("b@c.d"); jid3_ = JID("c@d.e"); - roster_ = std::unique_ptr<XMPPRosterImpl>(new XMPPRosterImpl()); - handler_ = std::unique_ptr<XMPPRosterSignalHandler>(new XMPPRosterSignalHandler(roster_.get())); + roster_ = std::make_unique<XMPPRosterImpl>(); + handler_ = std::make_unique<XMPPRosterSignalHandler>(roster_.get()); groups1_.push_back("bobs"); groups1_.push_back("berts"); groups2_.push_back("ernies"); |