From a39a55e030f126e862f2caf09b14e6ea182851c1 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Tue, 9 Dec 2014 14:29:44 -0800 Subject: [PATCH 01/57] Suggested modifications to the CoreRunnable interface --- autowiring/CoreRunnable.h | 57 ++++++++++++++++++++++++++------- src/autowiring/CoreRunnable.cpp | 19 ++++++++++- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/autowiring/CoreRunnable.h b/autowiring/CoreRunnable.h index 53cc712b3..71d056959 100644 --- a/autowiring/CoreRunnable.h +++ b/autowiring/CoreRunnable.h @@ -9,15 +9,53 @@ class CoreRunnable { CoreRunnable(void); virtual ~CoreRunnable(void); +private: + // Set to true if this runnable was ever signalled to start + bool m_wasStarted; + + // The outstanding count, held for as long as processing is underway + std::shared_ptr m_outstanding; + + // Set to true if this runnable should terminate processing + bool m_shouldStop; + +protected: + std::mutex m_lock; + std::condition_variable m_cv; + + /// + /// Method invoked from Start when this class is being asked to begin processing + /// + /// True if processing has started, false otherwise + /// + /// This method will be called at most once. + /// + virtual bool DoStart(void) = 0; + + /// + /// Invoked by the base class when a Stop call has been made + /// + /// + /// This method will be called at most once, and may potentially be called even + /// + virtual void OnStop(bool graceful) = 0; + +public: + // Accessor methods: + bool IsRunning(void) const { return (bool)m_outstanding; } + bool WasStarted(void) const { return m_wasStarted; } + bool ShouldStop(void) const { return m_shouldStop; } + /// /// Causes this runnable to begin processing /// + /// True if this call resulted in a successful start the first time, false in all other cases /// /// It is an error to call this routine more than once. The passed outstanding shared pointer /// is used to keep tracking of number of simultaneous runnables outstanding. This routine may /// be called even after Stop has been called; the caller MUST return false in this case. /// - virtual bool Start(std::shared_ptr outstanding) = 0; + void Start(std::shared_ptr outstanding); /// /// Stops this runnable, optionally performing graceful cleanup if requested @@ -26,20 +64,15 @@ class CoreRunnable { /// On return of this method, regardless of the return value, a subsequent call to Wait is /// guaranteed to either return immediately, or once the thread implementation completes. /// - virtual void Stop(bool graceful) = 0; - - /// - /// True if this runnable is currently running - /// - virtual bool IsRunning(void) const = 0; + virtual void Stop(bool graceful); - /// - /// True if this runnable has been told to stop - /// - virtual bool ShouldStop(void) const = 0; + /// + /// Waits for this object to start running, and then stop running + /// + void Wait(void); /// /// Waits for this object to start running, and then stop running /// - virtual void Wait(void) = 0; + void WaitFor(std::chrono::nanoseconds timeout); }; diff --git a/src/autowiring/CoreRunnable.cpp b/src/autowiring/CoreRunnable.cpp index a66c19abf..98d4fa023 100644 --- a/src/autowiring/CoreRunnable.cpp +++ b/src/autowiring/CoreRunnable.cpp @@ -2,6 +2,23 @@ #include "stdafx.h" #include "CoreRunnable.h" -CoreRunnable::CoreRunnable(void){} +CoreRunnable::CoreRunnable(void): +m_wasStarted(false), + m_shouldStop(false) +{} CoreRunnable::~CoreRunnable(void){} + +void CoreRunnable::Start(std::shared_ptr outstanding) { + if(m_outstanding || m_wasStarted) + // We have already been started, end here + return; + + m_wasStarted = true; + if(!DoStart()) { + m_shouldStop = true; + return; + } + + m_outstanding = outstanding; +} \ No newline at end of file From a88d3b79d4bff49095e3b21d40e1b7ffffdd8998 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Tue, 16 Dec 2014 11:09:48 -0800 Subject: [PATCH 02/57] Adding stub unit tests --- autowiring/AutoPacket.h | 5 +++ src/autowiring/AutoPacket.cpp | 5 +++ src/autowiring/test/AutoFilterSequencing.cpp | 32 ++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index ed11e6690..74800409d 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -474,6 +474,11 @@ class AutoPacket: /// True if the indicated type has been requested for use by some consumer bool HasSubscribers(const std::type_info& data) const; + + /// + /// Returns the next packet that will be issued by the packet factory in this context relative to this context + /// + std::shared_ptr Successor(void) const; }; #include "CallExtractor.h" diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index d4a1b2312..a4fffe768 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -370,3 +370,8 @@ bool AutoPacket::HasSubscribers(const std::type_info& data) const { std::lock_guard lk(m_lock); return m_decorations.count(data) != 0; } + +std::shared_ptr AutoPacket::Successor(void) const { + std::shared_ptr retVal; + return retVal; +} \ No newline at end of file diff --git a/src/autowiring/test/AutoFilterSequencing.cpp b/src/autowiring/test/AutoFilterSequencing.cpp index d66fb3d9f..ac8dab10b 100644 --- a/src/autowiring/test/AutoFilterSequencing.cpp +++ b/src/autowiring/test/AutoFilterSequencing.cpp @@ -62,3 +62,35 @@ class FilterOutDeferred: return Deferred(this); } }; + +TEST_F(AutoFilterSequencing, SuccessorAliasRules) { + AutoRequired factory; + auto packet1 = factory->NewPacket(); + auto packet2 = packet1->Successor(); + ASSERT_TRUE(!!packet2) << "Returned successor packet was null"; + + auto expected = factory->NewPacket(); + + ASSERT_EQ(expected, packet2) << "Expected that the successor packet would match the next packet returned by the factory"; +} + +TEST_F(AutoFilterSequencing, SuccessorHoldViolationCheck) { + AutoRequired factory; + auto packet1 = factory->NewPacket(); + auto packet2 = packet1->Successor(); + + ASSERT_TRUE(packet1.unique()) << "Expected that the first issued packet shared pointer not to be aliased anywhere"; + + packet1.reset(); + + ASSERT_TRUE(packet2.unique()) << "Expected that a successor packet would be unique when the principal was destroyed"; +} + +TEST_F(AutoFilterSequencing, PacketReverseSuccessor) { + AutoRequired factory; + + auto packet1 = factory->NewPacket(); + auto packet2 = factory->NewPacket(); + + ASSERT_EQ(packet2, packet1->Successor()) << "Successor packet obtained after generation from the factory did not match as expected"; +} \ No newline at end of file From 138f308061a1ccac8957344e722d1673bcdaeb96 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Tue, 16 Dec 2014 12:01:46 -0800 Subject: [PATCH 03/57] Make AutoPacketInternal.h a private header --- src/autowiring/AutoPacketFactory.cpp | 4 +--- src/autowiring/AutoPacketInternal.cpp | 2 +- .../autowiring/AutoPacketInternal.hpp | 0 src/autowiring/CMakeLists.txt | 2 +- src/autowiring/test/AutoFilterSequencing.cpp | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) rename autowiring/AutoPacketInternal.h => src/autowiring/AutoPacketInternal.hpp (100%) diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 1cc56337d..f0997fbd0 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -1,13 +1,11 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #include "stdafx.h" #include "AutoPacketFactory.h" -#include "AutoPacketInternal.h" +#include "AutoPacketInternal.hpp" #include "fast_pointer_cast.h" #include "thread_specific_ptr.h" #include -template class ObjectPool; - AutoPacketFactory::AutoPacketFactory(void): ContextMember("AutoPacketFactory"), m_parent(GetContext()->GetParentContext()), diff --git a/src/autowiring/AutoPacketInternal.cpp b/src/autowiring/AutoPacketInternal.cpp index e0c1be75f..b7c794bd4 100644 --- a/src/autowiring/AutoPacketInternal.cpp +++ b/src/autowiring/AutoPacketInternal.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #include "stdafx.h" -#include "AutoPacketInternal.h" +#include "AutoPacketInternal.hpp" #include "AutoPacketFactory.h" #include "SatCounter.h" diff --git a/autowiring/AutoPacketInternal.h b/src/autowiring/AutoPacketInternal.hpp similarity index 100% rename from autowiring/AutoPacketInternal.h rename to src/autowiring/AutoPacketInternal.hpp diff --git a/src/autowiring/CMakeLists.txt b/src/autowiring/CMakeLists.txt index fc47dab52..625477b6f 100644 --- a/src/autowiring/CMakeLists.txt +++ b/src/autowiring/CMakeLists.txt @@ -29,7 +29,7 @@ set(Autowiring_SRCS AutoPacket.cpp AutoPacket.h AutoPacketInternal.cpp - AutoPacketInternal.h + AutoPacketInternal.hpp AutoPacketFactory.cpp AutoPacketFactory.h AutoPacketProfiler.cpp diff --git a/src/autowiring/test/AutoFilterSequencing.cpp b/src/autowiring/test/AutoFilterSequencing.cpp index ac8dab10b..6705252bb 100644 --- a/src/autowiring/test/AutoFilterSequencing.cpp +++ b/src/autowiring/test/AutoFilterSequencing.cpp @@ -93,4 +93,4 @@ TEST_F(AutoFilterSequencing, PacketReverseSuccessor) { auto packet2 = factory->NewPacket(); ASSERT_EQ(packet2, packet1->Successor()) << "Successor packet obtained after generation from the factory did not match as expected"; -} \ No newline at end of file +} From f3ba412633a64c998b51534b2b6810b98925bf6b Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 17:13:57 -0800 Subject: [PATCH 04/57] First implementation of the AutoPacketGraph (capable of exporting a .gv file) --- autowiring/AutoPacketGraph.h | 59 +++++++++++ src/autowiring/AutoPacket.cpp | 18 ++++ src/autowiring/AutoPacketGraph.cpp | 53 ++++++++++ src/autowiring/CMakeLists.txt | 2 + src/autowiring/test/AutoPacketGraphTest.cpp | 111 ++++++++++++++++++++ src/autowiring/test/CMakeLists.txt | 1 + 6 files changed, 244 insertions(+) create mode 100644 autowiring/AutoPacketGraph.h create mode 100644 src/autowiring/AutoPacketGraph.cpp create mode 100644 src/autowiring/test/AutoPacketGraphTest.cpp diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h new file mode 100644 index 000000000..3130621f3 --- /dev/null +++ b/autowiring/AutoPacketGraph.h @@ -0,0 +1,59 @@ +// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. +#pragma once +#include "AutoFilterDescriptor.h" +#include "SatCounter.h" +#include STL_UNORDERED_MAP + + + +/// +/// TODO +/// +struct DeliveryEdge +{ + // The type info + const std::type_info* type_info; + + // + AutoFilterDescriptor descriptor; + + // Specifies if the argument is an + bool input; + + bool operator==(const DeliveryEdge& rhs) const { + // AutoFilter methods are the same for all instances of a class, + // and classes may have more than one AutoFilter method, + // so both comparisons are required. + return + type_info == rhs.type_info && + descriptor == rhs.descriptor && + input == rhs.input; + } +}; + +namespace std { + template<> + struct hash + { + size_t operator()(const DeliveryEdge& edge) const { + return (size_t) edge.descriptor.GetAutoFilter()->ptr(); + } + }; +} + +/// +/// TODO +/// +class AutoPacketGraph +{ +public: + AutoPacketGraph(); + + bool ExportGV(const std::string& filename) const; + + void RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + +protected: + // A mapping + std::unordered_map> m_deliveryGraph; +}; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index d4a1b2312..54c83e8c8 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -3,6 +3,7 @@ #include "AutoPacket.h" #include "Autowired.h" #include "AutoPacketFactory.h" +#include "AutoPacketGraph.h" #include "AutoPacketProfiler.h" #include "AutoFilterDescriptor.h" #include "ContextEnumerator.h" @@ -47,6 +48,23 @@ AutoPacket::~AutoPacket(void) { std::chrono::high_resolution_clock::now() - m_initTime ) ); + + Autowired apg; + if (apg) { + for (auto& itr : m_decorations) { + DecorationDisposition& decoration = itr.second; + + if (decoration.m_publisher) { + apg->RecordDelivery(decoration.m_type, *decoration.m_publisher, false); + } + + for (auto& subscriber : decoration.m_subscribers) { + if (subscriber->called) { + apg->RecordDelivery(decoration.m_type, *subscriber, true); + } + } + } + } } DecorationDisposition& AutoPacket::CheckoutImmediateUnsafe(const std::type_info& ti, const void* pvImmed) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp new file mode 100644 index 000000000..c647216f8 --- /dev/null +++ b/src/autowiring/AutoPacketGraph.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. +#include "stdafx.h" +#include "AutoPacketGraph.h" +#include "AutoPacketProfiler.h" +#include "demangle.h" +#include + +AutoPacketGraph::AutoPacketGraph() +{ +} + +bool AutoPacketGraph::ExportGV(const std::string& filename) const +{ + std::ofstream file(filename); + if (!file && !file.good()) { + return false; + } + + file << "digraph AutoPacketGraph {\n"; + + for (auto& itr : m_deliveryGraph) { + const DeliveryEdge& edge = itr.first; + // TODO: use counts and labels +// size_t count = itr.second; + + // string format: "type" -> "AutoFilter" (or vice versa) + std::stringstream ss; + ss << " \""; + if (edge.input) { + ss << autowiring::demangle(edge.type_info) << "\" -> \"" << autowiring::demangle(edge.descriptor.GetType()); + } else { + ss << autowiring::demangle(edge.descriptor.GetType()) << "\" -> \"" << autowiring::demangle(edge.type_info); + } + ss << "\"" << std::endl; + + file << ss.str(); + } + + file << "}\n"; + + return true; +} + +void AutoPacketGraph::RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { + DeliveryEdge edge { ti, descriptor, input }; + + auto itr = m_deliveryGraph.find(edge); + if (itr == m_deliveryGraph.end()) { + m_deliveryGraph[edge] = 1; + } else { + itr->second++; + } +} diff --git a/src/autowiring/CMakeLists.txt b/src/autowiring/CMakeLists.txt index fc47dab52..bc447c766 100644 --- a/src/autowiring/CMakeLists.txt +++ b/src/autowiring/CMakeLists.txt @@ -32,6 +32,8 @@ set(Autowiring_SRCS AutoPacketInternal.h AutoPacketFactory.cpp AutoPacketFactory.h + AutoPacketGraph.cpp + AutoPacketGraph.h AutoPacketProfiler.cpp AutoPacketProfiler.h AutoParameter.h diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp new file mode 100644 index 000000000..29f1a06e7 --- /dev/null +++ b/src/autowiring/test/AutoPacketGraphTest.cpp @@ -0,0 +1,111 @@ +// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. +#include "stdafx.h" +#include "TestFixtures/Decoration.hpp" +#include +#include +#include CHRONO_HEADER +#include THREAD_HEADER + +class AutoPacketGraphTest: + public testing::Test +{}; + +class APReceiver1 { +public: + APReceiver1(void) {} + + void AutoFilter(Decoration<0> d0) { + m_int0 = d0.i; + } + + int m_int0; +}; + +class APReceiver2 { +public: + APReceiver2(void) {} + + void AutoFilter(Decoration<0> d0, Decoration<1>& d1) { + m_int0 = d0.i; + + d1.i = m_int1; + } + + int m_int0; + int m_int1; +}; + +class APReceiver3 { +public: + APReceiver3(void) {} + + void AutoFilter(Decoration<0> d0, Decoration<1> d1) { + m_int0 = d0.i; + m_int1 = d1.i; + } + + int m_int0; + int m_int1; +}; + +class APReceiver4 { +public: + APReceiver4(void) {} + + void AutoFilter(Decoration<0> d0, Decoration<2> d2) { + m_int0 = d0.i; + m_int2 = d2.i; + } + + int m_int0; + int m_int2; +}; + +TEST_F(AutoPacketGraphTest, SimpleAutoGraph) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); + + AutoRequired factory(ctxt); + AutoRequired graph; + + AutoRequired receiver1; + AutoRequired receiver2; + AutoRequired receiver3; + AutoRequired receiver4; + + ctxt->Initiate(); + + int int0 = 12; + int int1 = 34; + int int2 = 56; + + receiver2->m_int1 = int1; + + { + // decorate 1 + auto packet = factory->NewPacket(); + packet->Decorate(Decoration<0>(int0)); + + // TODO: add some real test cases +// ASSERT_EQ(int0, receiver1->m_int0); +// +// ASSERT_EQ(int0, receiver2->m_int0); +// +// ASSERT_EQ(int0, receiver3->m_int0); +// ASSERT_EQ(int1, receiver3->m_int1); + + // decorate 2 + packet->Decorate(Decoration<2>(int2)); + + // TODO: add some real test cases +// ASSERT_EQ(int0, receiver4->m_int0); +// ASSERT_EQ(int2, receiver4->m_int2); + } + + graph->ExportGV("/Users/jnguyen/Desktop/graph.gv"); + + // Shutdown our context, and rundown our factory + ctxt->SignalShutdown(); + factory->Wait(); + +} \ No newline at end of file diff --git a/src/autowiring/test/CMakeLists.txt b/src/autowiring/test/CMakeLists.txt index d355b1f88..a1e1fbd8a 100644 --- a/src/autowiring/test/CMakeLists.txt +++ b/src/autowiring/test/CMakeLists.txt @@ -6,6 +6,7 @@ set(AutowiringTest_SRCS AutoFilterCollapseRulesTest.cpp AutoInjectableTest.cpp AutoPacketFactoryTest.cpp + AutoPacketGraphTest.cpp AutoParameterTest.cpp AutoRestarterTest.cpp AutowiringTest.cpp From 742e81aba9b903ee776fa164f9ac768d8d061fd0 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 17:26:59 -0800 Subject: [PATCH 05/57] protecting the transactions in a lock --- autowiring/AutoPacketGraph.h | 3 +++ src/autowiring/AutoPacketGraph.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 3130621f3..d86dce2ec 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -56,4 +56,7 @@ class AutoPacketGraph protected: // A mapping std::unordered_map> m_deliveryGraph; + + // A lock for this type + mutable std::mutex m_lock; }; diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index c647216f8..83aabfadd 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -18,6 +18,7 @@ bool AutoPacketGraph::ExportGV(const std::string& filename) const file << "digraph AutoPacketGraph {\n"; + std::lock_guard lk(m_lock); for (auto& itr : m_deliveryGraph) { const DeliveryEdge& edge = itr.first; // TODO: use counts and labels @@ -44,6 +45,7 @@ bool AutoPacketGraph::ExportGV(const std::string& filename) const void AutoPacketGraph::RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { DeliveryEdge edge { ti, descriptor, input }; + std::lock_guard lk(m_lock); auto itr = m_deliveryGraph.find(edge); if (itr == m_deliveryGraph.end()) { m_deliveryGraph[edge] = 1; From 4836c598979ab8337b142569ee54d9623c23fdcb Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 17:30:12 -0800 Subject: [PATCH 06/57] =?UTF-8?q?Adding=20the=20packet=20=E2=80=9Ccount?= =?UTF-8?q?=E2=80=9D=20to=20the=20graph?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/autowiring/AutoPacketGraph.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 83aabfadd..ff9f1d1ef 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -21,8 +21,7 @@ bool AutoPacketGraph::ExportGV(const std::string& filename) const std::lock_guard lk(m_lock); for (auto& itr : m_deliveryGraph) { const DeliveryEdge& edge = itr.first; - // TODO: use counts and labels -// size_t count = itr.second; + size_t count = itr.second; // string format: "type" -> "AutoFilter" (or vice versa) std::stringstream ss; @@ -32,7 +31,9 @@ bool AutoPacketGraph::ExportGV(const std::string& filename) const } else { ss << autowiring::demangle(edge.descriptor.GetType()) << "\" -> \"" << autowiring::demangle(edge.type_info); } - ss << "\"" << std::endl; + + // TODO: count should probably be optional + ss << "\" [label=\"" << count << "\"];" << std::endl; file << ss.str(); } From 47a0ddc3e963f0b93b550113b566ce684355486a Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 17:36:08 -0800 Subject: [PATCH 07/57] Renaming the function API names and adding some comments --- autowiring/AutoPacketGraph.h | 10 ++++++-- src/autowiring/AutoPacket.cpp | 4 +-- src/autowiring/AutoPacketGraph.cpp | 27 +++++++++++---------- src/autowiring/test/AutoPacketGraphTest.cpp | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index d86dce2ec..59d21fee4 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -49,9 +49,15 @@ class AutoPacketGraph public: AutoPacketGraph(); - bool ExportGV(const std::string& filename) const; + /// + /// Add an edge to the graph given the following parameters + /// + void AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); - void RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + /// + /// Write the graph to a file in graphviz format + /// + bool WriteGV(const std::string& filename) const; protected: // A mapping diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index 54c83e8c8..7c84608a8 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -55,12 +55,12 @@ AutoPacket::~AutoPacket(void) { DecorationDisposition& decoration = itr.second; if (decoration.m_publisher) { - apg->RecordDelivery(decoration.m_type, *decoration.m_publisher, false); + apg->AddEdge(decoration.m_type, *decoration.m_publisher, false); } for (auto& subscriber : decoration.m_subscribers) { if (subscriber->called) { - apg->RecordDelivery(decoration.m_type, *subscriber, true); + apg->AddEdge(decoration.m_type, *subscriber, true); } } } diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index ff9f1d1ef..ed7989777 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -9,7 +9,20 @@ AutoPacketGraph::AutoPacketGraph() { } -bool AutoPacketGraph::ExportGV(const std::string& filename) const + +void AutoPacketGraph::AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { + DeliveryEdge edge { ti, descriptor, input }; + + std::lock_guard lk(m_lock); + auto itr = m_deliveryGraph.find(edge); + if (itr == m_deliveryGraph.end()) { + m_deliveryGraph[edge] = 1; + } else { + itr->second++; + } +} + +bool AutoPacketGraph::WriteGV(const std::string& filename) const { std::ofstream file(filename); if (!file && !file.good()) { @@ -42,15 +55,3 @@ bool AutoPacketGraph::ExportGV(const std::string& filename) const return true; } - -void AutoPacketGraph::RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { - DeliveryEdge edge { ti, descriptor, input }; - - std::lock_guard lk(m_lock); - auto itr = m_deliveryGraph.find(edge); - if (itr == m_deliveryGraph.end()) { - m_deliveryGraph[edge] = 1; - } else { - itr->second++; - } -} diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp index 29f1a06e7..bb9dfb19f 100644 --- a/src/autowiring/test/AutoPacketGraphTest.cpp +++ b/src/autowiring/test/AutoPacketGraphTest.cpp @@ -102,7 +102,7 @@ TEST_F(AutoPacketGraphTest, SimpleAutoGraph) { // ASSERT_EQ(int2, receiver4->m_int2); } - graph->ExportGV("/Users/jnguyen/Desktop/graph.gv"); + graph->WriteGV("/Users/jnguyen/Desktop/graph.gv"); // Shutdown our context, and rundown our factory ctxt->SignalShutdown(); From de0ac19559409e083912fe17e66058fa3dfaa1c0 Mon Sep 17 00:00:00 2001 From: Ted Nitz Date: Tue, 16 Dec 2014 17:43:41 -0800 Subject: [PATCH 08/57] Add unit tests regarding behavior of is_base_of and dynamic_cast when private base classes are involved. --- src/autowiring/test/AutowiringTest.cpp | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/autowiring/test/AutowiringTest.cpp b/src/autowiring/test/AutowiringTest.cpp index 02df626ea..5d5b1e47a 100644 --- a/src/autowiring/test/AutowiringTest.cpp +++ b/src/autowiring/test/AutowiringTest.cpp @@ -106,4 +106,29 @@ TEST_F(AutowiringTest, AUTOTHROW_CanSeeThrownAutoDesiredExceptions) { AutoRequired cfe; AutoDesired(); ASSERT_TRUE(cfe->m_called) << "Exception was not caught by exception filter in Autowiring context"; -} \ No newline at end of file +} + +class PublicBase { +public: + PublicBase(void) {} + virtual ~PublicBase(void) {} +}; + +class PrivateBase { +public: + PrivateBase(void) {} + virtual ~PrivateBase(void) {} +}; + +class Derived : public PublicBase, private PrivateBase { +public: + Derived(void) {} + ~Derived(void) {} +}; + +TEST_F(AutowiringTest, TestFailureOfDynamicCast) { + Derived d; + PublicBase *pub = static_cast(&d); + ASSERT_EQ(dynamic_cast(pub), nullptr) << "Dynamic cast failed to give nullptr when cross casting to a private base class"; + static_assert(!std::is_base_of::value, "is_base_of said a private base was a base"); +} From 51423fc7a65eefe2f389b25acbe3e347f15a45f3 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 18:35:26 -0800 Subject: [PATCH 09/57] Refactoring the AutoPacketGraph to use AutoFilter with the AutoPacket& backdoor. This required adding a AutoPacket::GetDispositions() function and copying the subscribers list to the DecorationDisposition copy constructor --- autowiring/AutoPacket.h | 6 ++++++ autowiring/AutoPacketGraph.h | 5 ++++- autowiring/DecorationDisposition.h | 2 ++ src/autowiring/AutoPacket.cpp | 27 ++++++++++----------------- src/autowiring/AutoPacketGraph.cpp | 16 ++++++++++++++++ 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index ed11e6690..00b05fd2f 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -465,6 +465,12 @@ class AutoPacket: /// All subscribers to the specified data std::list GetSubscribers(const std::type_info& data) const; + /// All decoration dispositions + /// + /// This method is useful for getting a picture of the entire disposition graph + /// + std::list GetDispositions() const; + /// All decoration dispositions associated with the data type /// /// This method is useful for determining whether flow conditions (broadcast, pipes diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 59d21fee4..5ac596a8b 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -1,11 +1,12 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #pragma once #include "AutoFilterDescriptor.h" +#include "AutoPacket.h" +#include "DecorationDisposition.h" #include "SatCounter.h" #include STL_UNORDERED_MAP - /// /// TODO /// @@ -54,6 +55,8 @@ class AutoPacketGraph /// void AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + void AutoFilter(AutoPacket& packet); + /// /// Write the graph to a file in graphviz format /// diff --git a/autowiring/DecorationDisposition.h b/autowiring/DecorationDisposition.h index 0eb2c3c37..7c10d45a3 100644 --- a/autowiring/DecorationDisposition.h +++ b/autowiring/DecorationDisposition.h @@ -46,6 +46,7 @@ struct DecorationDisposition m_type(source.m_type), m_pImmediate(source.m_pImmediate), m_publisher(source.m_publisher), + m_subscribers(source.m_subscribers), isCheckedOut(source.isCheckedOut), satisfied(source.satisfied) {} @@ -54,6 +55,7 @@ struct DecorationDisposition m_type = source.m_type; m_pImmediate = source.m_pImmediate; m_publisher = source.m_publisher; + m_subscribers = source.m_subscribers; isCheckedOut = source.isCheckedOut; satisfied = source.satisfied; return *this; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index 7c84608a8..f8ad93866 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -3,7 +3,6 @@ #include "AutoPacket.h" #include "Autowired.h" #include "AutoPacketFactory.h" -#include "AutoPacketGraph.h" #include "AutoPacketProfiler.h" #include "AutoFilterDescriptor.h" #include "ContextEnumerator.h" @@ -49,22 +48,8 @@ AutoPacket::~AutoPacket(void) { ) ); - Autowired apg; - if (apg) { - for (auto& itr : m_decorations) { - DecorationDisposition& decoration = itr.second; - - if (decoration.m_publisher) { - apg->AddEdge(decoration.m_type, *decoration.m_publisher, false); - } - - for (auto& subscriber : decoration.m_subscribers) { - if (subscriber->called) { - apg->AddEdge(decoration.m_type, *subscriber, true); - } - } - } - } + // Needed for the AutoPacketGraph + NotifyTeardownListeners(); } DecorationDisposition& AutoPacket::CheckoutImmediateUnsafe(const std::type_info& ti, const void* pvImmed) @@ -375,6 +360,14 @@ std::list AutoPacket::GetSubscribers(const std::type_info& data) con return subscribers; } +std::list AutoPacket::GetDispositions() const { + std::lock_guard lk(m_lock); + std::list dispositions; + for (auto& disposition : m_decorations) + dispositions.push_back(disposition.second); + return dispositions; +} + std::list AutoPacket::GetDispositions(const std::type_info& data) const { std::lock_guard lk(m_lock); std::list dispositions; diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index ed7989777..71a00fa85 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -22,6 +22,22 @@ void AutoPacketGraph::AddEdge(const std::type_info* ti, const AutoFilterDescript } } +void AutoPacketGraph::AutoFilter(AutoPacket& packet) { + packet.AddTeardownListener([this, &packet] () { + for (auto& decoration : packet.GetDispositions()) { + if (decoration.m_publisher) { + AddEdge(decoration.m_type, *decoration.m_publisher, false); + } + + for (auto& subscriber : decoration.m_subscribers) { + if (subscriber->called) { + AddEdge(decoration.m_type, *subscriber, true); + } + } + } + }); +} + bool AutoPacketGraph::WriteGV(const std::string& filename) const { std::ofstream file(filename); From 5a05517de1f51d07b42d85deeab1aaa0b087b36e Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 18:57:28 -0800 Subject: [PATCH 10/57] Drawing the shapes for graphviz (types are rectangles, AutoFilters are ellipses) --- src/autowiring/AutoPacketGraph.cpp | 32 ++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 71a00fa85..9e2f807c0 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -48,17 +48,33 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const file << "digraph AutoPacketGraph {\n"; std::lock_guard lk(m_lock); + + // Containers for the unique types and descriptors + std::unordered_set types; + std::unordered_set> descriptors; + + // draw the edges for (auto& itr : m_deliveryGraph) { - const DeliveryEdge& edge = itr.first; - size_t count = itr.second; + auto& edge = itr.first; + auto type = edge.type_info; + auto& descriptor = edge.descriptor; + auto count = itr.second; + + if (types.find(type) == types.end()) { + types.insert(type); + } + + if (descriptors.find(descriptor) == descriptors.end()) { + descriptors.insert(descriptor); + } // string format: "type" -> "AutoFilter" (or vice versa) std::stringstream ss; ss << " \""; if (edge.input) { - ss << autowiring::demangle(edge.type_info) << "\" -> \"" << autowiring::demangle(edge.descriptor.GetType()); + ss << autowiring::demangle(type) << "\" -> \"" << autowiring::demangle(descriptor.GetType()); } else { - ss << autowiring::demangle(edge.descriptor.GetType()) << "\" -> \"" << autowiring::demangle(edge.type_info); + ss << autowiring::demangle(descriptor.GetType()) << "\" -> \"" << autowiring::demangle(type); } // TODO: count should probably be optional @@ -66,6 +82,14 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const file << ss.str(); } + file << std::endl; + + // Setup the shapes for the types and descriptors + for (auto& type : types) + file << " \"" << autowiring::demangle(type) << "\" [shape=box];" << std::endl; + + for (auto& descriptor : descriptors) + file << " \"" << autowiring::demangle(descriptor.GetType()) << "\" [shape=ellipse];" << std::endl; file << "}\n"; From b2e5bb2febb857afdd3c139aad1d9dec4ba66f53 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 19:38:40 -0800 Subject: [PATCH 11/57] Adding some comments --- autowiring/AutoPacketGraph.h | 20 ++++++++++++-------- src/autowiring/AutoPacketGraph.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 5ac596a8b..8b5085752 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -8,23 +8,21 @@ /// -/// TODO +/// Represents an edge in the graph from a type to an AutoFilter /// struct DeliveryEdge { // The type info const std::type_info* type_info; - // + // The AutoFilterDescriptor AutoFilterDescriptor descriptor; - // Specifies if the argument is an + // Specifies if the argument is an input (type -> descriptor) or output (descriptor -> type) bool input; + // For the unordered map/hash comparison bool operator==(const DeliveryEdge& rhs) const { - // AutoFilter methods are the same for all instances of a class, - // and classes may have more than one AutoFilter method, - // so both comparisons are required. return type_info == rhs.type_info && descriptor == rhs.descriptor && @@ -32,6 +30,9 @@ struct DeliveryEdge } }; +/// +/// Using the same hash function as the AutoFilterDescriptor +/// namespace std { template<> struct hash @@ -43,7 +44,7 @@ namespace std { } /// -/// TODO +/// Graphical visualization of AutoPackets /// class AutoPacketGraph { @@ -55,6 +56,9 @@ class AutoPacketGraph /// void AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + /// + /// Get a copy of the packet via AutoFilter + /// void AutoFilter(AutoPacket& packet); /// @@ -63,7 +67,7 @@ class AutoPacketGraph bool WriteGV(const std::string& filename) const; protected: - // A mapping + // A mapping of an edge to the number of times it was delivered std::unordered_map> m_deliveryGraph; // A lock for this type diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 9e2f807c0..fc46b4551 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -53,20 +53,20 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const std::unordered_set types; std::unordered_set> descriptors; - // draw the edges for (auto& itr : m_deliveryGraph) { auto& edge = itr.first; auto type = edge.type_info; auto& descriptor = edge.descriptor; auto count = itr.second; - if (types.find(type) == types.end()) { + // TODO: skip if type == AutoPacketGraph + + // Get a unique set of types/descriptors + if (types.find(type) == types.end()) types.insert(type); - } - if (descriptors.find(descriptor) == descriptors.end()) { + if (descriptors.find(descriptor) == descriptors.end()) descriptors.insert(descriptor); - } // string format: "type" -> "AutoFilter" (or vice versa) std::stringstream ss; From ad6e6bbf3257850027eecdd664465ac7275127bd Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 19:42:35 -0800 Subject: [PATCH 12/57] Slight optimization to store the string names instead to avoid repeated demangling --- src/autowiring/AutoPacketGraph.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index fc46b4551..7563cf728 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -4,6 +4,7 @@ #include "AutoPacketProfiler.h" #include "demangle.h" #include +#include AutoPacketGraph::AutoPacketGraph() { @@ -50,8 +51,8 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const std::lock_guard lk(m_lock); // Containers for the unique types and descriptors - std::unordered_set types; - std::unordered_set> descriptors; + std::unordered_set typeNames; + std::unordered_set descriptorNames; for (auto& itr : m_deliveryGraph) { auto& edge = itr.first; @@ -61,20 +62,23 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const // TODO: skip if type == AutoPacketGraph + std::string typeName = autowiring::demangle(type); + std::string descriptorName = autowiring::demangle(descriptor.GetType()); + // Get a unique set of types/descriptors - if (types.find(type) == types.end()) - types.insert(type); + if (typeNames.find(typeName) == typeNames.end()) + typeNames.insert(typeName); - if (descriptors.find(descriptor) == descriptors.end()) - descriptors.insert(descriptor); + if (descriptorNames.find(descriptorName) == descriptorNames.end()) + descriptorNames.insert(descriptorName); // string format: "type" -> "AutoFilter" (or vice versa) std::stringstream ss; ss << " \""; if (edge.input) { - ss << autowiring::demangle(type) << "\" -> \"" << autowiring::demangle(descriptor.GetType()); + ss << typeName << "\" -> \"" << descriptorName; } else { - ss << autowiring::demangle(descriptor.GetType()) << "\" -> \"" << autowiring::demangle(type); + ss << descriptorName << "\" -> \"" << typeName; } // TODO: count should probably be optional @@ -85,11 +89,11 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const file << std::endl; // Setup the shapes for the types and descriptors - for (auto& type : types) - file << " \"" << autowiring::demangle(type) << "\" [shape=box];" << std::endl; + for (auto& typeName : typeNames) + file << " \"" << typeName << "\" [shape=box];" << std::endl; - for (auto& descriptor : descriptors) - file << " \"" << autowiring::demangle(descriptor.GetType()) << "\" [shape=ellipse];" << std::endl; + for (auto& descriptorName : descriptorNames) + file << " \"" << descriptorName << "\" [shape=ellipse];" << std::endl; file << "}\n"; From eb1cedd49198ff6b1d88955665198f407d285ce5 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 16 Dec 2014 20:00:07 -0800 Subject: [PATCH 13/57] Titling the graph with the context name --- src/autowiring/AutoPacketGraph.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 7563cf728..7c8c4f18f 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -2,6 +2,7 @@ #include "stdafx.h" #include "AutoPacketGraph.h" #include "AutoPacketProfiler.h" +#include "CoreContext.h" #include "demangle.h" #include #include @@ -46,7 +47,7 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const return false; } - file << "digraph AutoPacketGraph {\n"; + file << "digraph \"" << autowiring::demangle(CoreContext::CurrentContext()->GetSigilType()) << " context\" {\n"; std::lock_guard lk(m_lock); From facf477bb7c6f86109bbc8e2cd0be7da983a5cfa Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Wed, 17 Dec 2014 10:31:15 -0800 Subject: [PATCH 14/57] Fixed small bug where publisher needs to check if it has been called --- src/autowiring/AutoPacketGraph.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 7c8c4f18f..504df0b48 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -27,13 +27,16 @@ void AutoPacketGraph::AddEdge(const std::type_info* ti, const AutoFilterDescript void AutoPacketGraph::AutoFilter(AutoPacket& packet) { packet.AddTeardownListener([this, &packet] () { for (auto& decoration : packet.GetDispositions()) { - if (decoration.m_publisher) { - AddEdge(decoration.m_type, *decoration.m_publisher, false); + auto publisher = decoration.m_publisher; + auto type = decoration.m_type; + + if (publisher && publisher->called) { + AddEdge(type, *publisher, false); } for (auto& subscriber : decoration.m_subscribers) { if (subscriber->called) { - AddEdge(decoration.m_type, *subscriber, true); + AddEdge(type, *subscriber, true); } } } From f934d34770b17109007a51a4738061fb9d048d99 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Wed, 17 Dec 2014 10:31:56 -0800 Subject: [PATCH 15/57] Moving includes to cpp --- autowiring/AutoPacketGraph.h | 2 -- src/autowiring/AutoPacketGraph.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 8b5085752..a9e155594 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -2,8 +2,6 @@ #pragma once #include "AutoFilterDescriptor.h" #include "AutoPacket.h" -#include "DecorationDisposition.h" -#include "SatCounter.h" #include STL_UNORDERED_MAP diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 504df0b48..25699cb6b 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -3,7 +3,9 @@ #include "AutoPacketGraph.h" #include "AutoPacketProfiler.h" #include "CoreContext.h" +#include "DecorationDisposition.h" #include "demangle.h" +#include "SatCounter.h" #include #include From cba9b3a5af5745ccfcb8f58d85beb9ad44f6a5c2 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Wed, 17 Dec 2014 10:40:13 -0800 Subject: [PATCH 16/57] minor style cleanup --- autowiring/AutoPacketGraph.h | 16 +++++++++------- src/autowiring/AutoPacketGraph.cpp | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index a9e155594..1dc6d97c3 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -49,11 +49,20 @@ class AutoPacketGraph public: AutoPacketGraph(); +protected: + // A mapping of an edge to the number of times it was delivered + typedef std::unordered_map> t_deliveryGraph; + t_deliveryGraph m_deliveryGraph; + + // A lock for this type + mutable std::mutex m_lock; + /// /// Add an edge to the graph given the following parameters /// void AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); +public: /// /// Get a copy of the packet via AutoFilter /// @@ -63,11 +72,4 @@ class AutoPacketGraph /// Write the graph to a file in graphviz format /// bool WriteGV(const std::string& filename) const; - -protected: - // A mapping of an edge to the number of times it was delivered - std::unordered_map> m_deliveryGraph; - - // A lock for this type - mutable std::mutex m_lock; }; diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 25699cb6b..36c03187e 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -9,11 +9,11 @@ #include #include + AutoPacketGraph::AutoPacketGraph() { } - void AutoPacketGraph::AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { DeliveryEdge edge { ti, descriptor, input }; @@ -52,7 +52,7 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const return false; } - file << "digraph \"" << autowiring::demangle(CoreContext::CurrentContext()->GetSigilType()) << " context\" {\n"; + file << "digraph \"" << autowiring::demangle(CoreContext::CurrentContext()->GetSigilType()) << " context\" {" << std::endl; std::lock_guard lk(m_lock); From 1136eadd0bea1c5d4d55ed5c3f9fa60f6db54d67 Mon Sep 17 00:00:00 2001 From: Ted Nitz Date: Fri, 12 Dec 2014 18:20:44 -0800 Subject: [PATCH 17/57] Implement the new interface across the code base. All tests are passing, I think this may be ready to merge. --- autowiring/AutoPacketFactory.h | 14 +--- autowiring/AutoRestarter.h | 21 ++--- autowiring/BasicThread.h | 52 ++---------- autowiring/CoreJob.h | 17 +--- autowiring/CoreRunnable.h | 29 +++++-- autowiring/CoreThread.h | 4 +- src/autonet/AutoNetServerImpl.cpp | 2 +- src/autonet/AutoNetServerImpl.hpp | 2 +- src/autowiring/AutoPacket.cpp | 4 +- src/autowiring/AutoPacketFactory.cpp | 39 +++------ src/autowiring/BasicThread.cpp | 81 +++---------------- src/autowiring/CoreJob.cpp | 59 +++----------- src/autowiring/CoreRunnable.cpp | 66 +++++++++++++-- src/autowiring/CoreThread.cpp | 4 +- src/autowiring/test/CoreRunnableTest.cpp | 9 +-- .../test/TestFixtures/SimpleReceiver.hpp | 4 +- 16 files changed, 147 insertions(+), 260 deletions(-) diff --git a/autowiring/AutoPacketFactory.h b/autowiring/AutoPacketFactory.h index 85b95af78..2e33bf2cd 100644 --- a/autowiring/AutoPacketFactory.h +++ b/autowiring/AutoPacketFactory.h @@ -40,12 +40,6 @@ class AutoPacketFactory: // State change notification std::condition_variable m_stateCondition; - - // Have we been signaled to stop - bool m_wasStopped; - - // Outstanding reference if this factory is currently running: - std::shared_ptr m_outstanding; // Internal outstanding reference for issued packet: std::weak_ptr m_outstandingInternal; @@ -79,11 +73,9 @@ class AutoPacketFactory: } // CoreRunnable overrides: - bool Start(std::shared_ptr outstanding) override; - void Stop(bool graceful = false) override; - void Wait(void) override; - bool IsRunning(void) const override { return m_outstanding && !m_wasStopped; }; - bool ShouldStop(void) const override { return m_wasStopped; }; + bool DoStart(void) override; + void OnStop(bool graceful) override; + void DoAdditionalWait(void) override; /// /// Causes this AutoPacketFactory to release all of its packet subscribers diff --git a/autowiring/AutoRestarter.h b/autowiring/AutoRestarter.h index 61cfd26a8..418af1083 100644 --- a/autowiring/AutoRestarter.h +++ b/autowiring/AutoRestarter.h @@ -52,21 +52,18 @@ class AutoRestarter: const AutoRestarterConfig config; // CoreRunnable overrides: - bool Start(std::shared_ptr outstanding) override { + bool DoStart() override { // Start the enclosed context, do nothing else auto ctxt = GetContext(); if(ctxt && config.startWhenCreated) ctxt->Initiate(); - return true; + return false; } - void Stop(bool graceful) override { + void OnStop(bool graceful) override { std::lock_guard lk(m_lock); m_context.reset(); } - bool IsRunning(void) const override { return false; } - bool ShouldStop(void) const override { return true; } - void Wait(void) override {} private: mutable std::mutex m_lock; @@ -84,21 +81,13 @@ class AutoRestarter: // Parent restarter, we hand control here when we're stopped AutoRestarter& ar; - bool Start(std::shared_ptr outstanding) override { - m_outstanding = outstanding; + bool DoStart(void) override { return true; } - void Stop(bool graceful) override { + void OnStop(bool graceful) override { ar.OnContextStopped(*this); - m_outstanding.reset(); } - - std::shared_ptr m_outstanding; - - bool IsRunning(void) const override { return false; } - bool ShouldStop(void) const override { return false; } - void Wait(void) {} }; protected: diff --git a/autowiring/BasicThread.h b/autowiring/BasicThread.h index dca27dcdc..37233c6ec 100644 --- a/autowiring/BasicThread.h +++ b/autowiring/BasicThread.h @@ -167,11 +167,6 @@ class BasicThread: /// bool ThreadSleep(std::chrono::nanoseconds timeout); -public: - // Accessor methods: - bool ShouldStop(void) const override; - bool IsRunning(void) const override; - /// /// Causes a new thread to be created in which the Run method will be invoked /// @@ -181,8 +176,13 @@ class BasicThread: /// Start will not be called from more than one place on the same object. The thread /// will be invoked from the context which was active at the time the thread was created. /// - virtual bool Start(std::shared_ptr outstanding); + bool DoStart() override; + + void OnStop(bool graceful) override; + + void DoAdditionalWait() override; +public: /// /// Begins the core thread /// @@ -193,46 +193,6 @@ class BasicThread: /// virtual void Run() = 0; - /// - /// Waits until the core thread is launched and then terminates - /// - /// - /// Unlike Join, this method may be invoked even if the CoreThread isn't running - /// - void Wait(void) override; - - /// - /// Timed version of Wait - /// - /// False if the timeout elapsed, true otherwise - bool WaitFor(std::chrono::nanoseconds duration); - - /// - /// Timed version of Wait - /// - /// False if the timeout elapsed, true otherwise - template - bool WaitUntil(TimeType timepoint); - - /// - /// Event which may be used to perform custom handling when the thread is told to stop - /// - /// Set to true to rundown the dispatch queue before quitting - /// - /// This method is called when the thread should stop. When invoked, the value of - /// CoreThread::ShouldStop is guaranteed to be true. - /// - /// Callers are not required to call CoreThread::OnStop. This method is guaranteed to do - /// nothing by default. - /// - virtual void OnStop(void) {} - - /// - /// This is an override method that will cause ShouldStop to return true, - /// regardless of what the global stop setting is. - /// - virtual void Stop(bool graceful = false); - /// /// Forces all Autowiring threads to reidentify themselves /// diff --git a/autowiring/CoreJob.h b/autowiring/CoreJob.h index 774ef6b34..860d2405e 100644 --- a/autowiring/CoreJob.h +++ b/autowiring/CoreJob.h @@ -17,15 +17,9 @@ class CoreJob: virtual ~CoreJob(){}; private: - // Hold on to this so CoreContext knows we still exist - std::shared_ptr m_outstanding; - // Flag, set to true when it's time to start dispatching bool m_running; - // Flag, set to stop when we should stop running - bool m_shouldStop; - // The current outstanding async in the thread pool, if one exists: std::future m_curEvent; @@ -46,13 +40,8 @@ class CoreJob: void Abort(void); public: - // Accessor methods: - bool ShouldStop(void) const override { return m_shouldStop; } - // "CoreRunnable" overrides - bool Start(std::shared_ptr outstanding) override; - void Stop(bool graceful) override; - bool IsRunning(void) const override { return m_running; } - void Wait(void) override; - bool WaitFor(std::chrono::nanoseconds duration); + bool DoStart(void) override; + void OnStop(bool graceful) override; + void DoAdditionalWait(void) override; }; diff --git a/autowiring/CoreRunnable.h b/autowiring/CoreRunnable.h index 71d056959..86321430e 100644 --- a/autowiring/CoreRunnable.h +++ b/autowiring/CoreRunnable.h @@ -1,6 +1,7 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #pragma once #include MEMORY_HEADER +#include MUTEX_HEADER class Object; @@ -13,13 +14,13 @@ class CoreRunnable { // Set to true if this runnable was ever signalled to start bool m_wasStarted; - // The outstanding count, held for as long as processing is underway - std::shared_ptr m_outstanding; - // Set to true if this runnable should terminate processing bool m_shouldStop; protected: + // The outstanding count, held for as long as processing is underway + std::shared_ptr m_outstanding; + std::mutex m_lock; std::condition_variable m_cv; @@ -30,7 +31,7 @@ class CoreRunnable { /// /// This method will be called at most once. /// - virtual bool DoStart(void) = 0; + virtual bool DoStart(void) { return false; }; /// /// Invoked by the base class when a Stop call has been made @@ -38,7 +39,15 @@ class CoreRunnable { /// /// This method will be called at most once, and may potentially be called even /// - virtual void OnStop(bool graceful) = 0; + virtual void OnStop(bool graceful) {}; + + /// + /// Invoked by the base class when a Wait call has been made, to ensure all cleanups have happened after the Stop call + /// + /// + /// This call should not block for extended periods of time. + /// + virtual void DoAdditionalWait() {}; public: // Accessor methods: @@ -64,7 +73,7 @@ class CoreRunnable { /// On return of this method, regardless of the return value, a subsequent call to Wait is /// guaranteed to either return immediately, or once the thread implementation completes. /// - virtual void Stop(bool graceful); + void Stop(bool graceful = true); /// /// Waits for this object to start running, and then stop running @@ -74,5 +83,11 @@ class CoreRunnable { /// /// Waits for this object to start running, and then stop running /// - void WaitFor(std::chrono::nanoseconds timeout); + bool WaitFor(std::chrono::nanoseconds timeout); + + /// + /// Waits for this object to start running, and then stop running + /// + template + bool WaitUntil(TimeType timepoint); }; diff --git a/autowiring/CoreThread.h b/autowiring/CoreThread.h index c98969505..2458612c8 100644 --- a/autowiring/CoreThread.h +++ b/autowiring/CoreThread.h @@ -64,7 +64,7 @@ class CoreThread: /// The default implementation of Run will simply call WaitForEvent in a loop until it's /// told to quit. /// - virtual void Run() override; + void Run() override; /// /// Event which may be used to perform custom handling when the thread is told to stop @@ -77,5 +77,5 @@ class CoreThread: /// Callers are not required to call CoreThread::OnStop. This method is guaranteed to do /// nothing by default. /// - virtual void Stop(bool graceful = false) override; + void OnStop(bool graceful = false) override; }; diff --git a/src/autonet/AutoNetServerImpl.cpp b/src/autonet/AutoNetServerImpl.cpp index 82cf7e7e0..a1bc0b751 100644 --- a/src/autonet/AutoNetServerImpl.cpp +++ b/src/autonet/AutoNetServerImpl.cpp @@ -65,7 +65,7 @@ void AutoNetServerImpl::Run(void){ CoreThread::Run(); } -void AutoNetServerImpl::OnStop(void) { +void AutoNetServerImpl::OnStop(bool graceful) { if (m_Server.is_listening()) m_Server.stop_listening(); diff --git a/src/autonet/AutoNetServerImpl.hpp b/src/autonet/AutoNetServerImpl.hpp index 108309263..d126836bb 100644 --- a/src/autonet/AutoNetServerImpl.hpp +++ b/src/autonet/AutoNetServerImpl.hpp @@ -31,7 +31,7 @@ class AutoNetServerImpl: // Functions from BasicThread virtual void Run(void) override; - virtual void OnStop(void) override; + virtual void OnStop(bool graceful) override; // Server Handler functions void OnOpen(websocketpp::connection_hdl hdl); diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index c89e88ef7..88b6be1e8 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -13,8 +13,8 @@ using namespace autowiring; AutoPacket::AutoPacket(AutoPacketFactory& factory, std::shared_ptr&& outstanding): m_parentFactory(std::static_pointer_cast(factory.shared_from_this())), - m_outstanding(std::move(outstanding)), - m_initTime(std::chrono::high_resolution_clock::now()) + m_initTime(std::chrono::high_resolution_clock::now()), + m_outstanding(std::move(outstanding)) { // Traverse all contexts, adding their packet subscriber vectors one at a time: for(const auto& curContext : ContextEnumerator(factory.GetContext())) { diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 1cc56337d..79362179c 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -11,8 +11,6 @@ template class ObjectPool; AutoPacketFactory::AutoPacketFactory(void): ContextMember("AutoPacketFactory"), m_parent(GetContext()->GetParentContext()), - m_wasStopped(false), - m_outstanding(0), m_packetCount(0), m_packetDurationSum(0), m_packetDurationSqSum(0) @@ -45,17 +43,6 @@ bool AutoPacketFactory::IsAutoPacketType(const std::type_info& dataType) { dataType == typeid(auto_arg::id_type); } -bool AutoPacketFactory::Start(std::shared_ptr outstanding) { - std::lock_guard lk(m_lock); - if(m_wasStopped) - // Cannot start if already stopped - return false; - - m_outstanding = outstanding; - m_stateCondition.notify_all(); - return true; -} - std::shared_ptr AutoPacketFactory::GetInternalOutstanding(void) { auto retVal = m_outstandingInternal.lock(); if (retVal) @@ -77,38 +64,29 @@ std::shared_ptr AutoPacketFactory::GetInternalOutstanding(void) { return retVal; } -void AutoPacketFactory::Stop(bool graceful) { - // Return optimization - if(m_wasStopped) - return; +bool AutoPacketFactory::DoStart(void) { + m_stateCondition.notify_all(); + return true; +} +void AutoPacketFactory::OnStop(bool graceful) { // Kill the object pool Invalidate(); // Queue of local variables to be destroyed when leaving scope - std::shared_ptr outstanding; t_autoFilterSet autoFilters; // Lock destruction precedes local variables std::lock_guard lk(m_lock); - // Swap outstanding count into a local var, so we can reset outside of a lock - outstanding.swap(m_outstanding); - // Same story with the AutoFilters autoFilters.swap(m_autoFilters); // Now we can lock, update state, and notify any listeners - m_wasStopped = true; m_stateCondition.notify_all(); } -void AutoPacketFactory::Clear(void) { - // Simple handoff to Stop is sufficient - Stop(false); -} - -void AutoPacketFactory::Wait(void) { +void AutoPacketFactory::DoAdditionalWait(void) { std::unique_lock lk(m_lock); m_stateCondition.wait( lk, @@ -118,6 +96,11 @@ void AutoPacketFactory::Wait(void) { ); } +void AutoPacketFactory::Clear(void) { + // Simple handoff to Stop is sufficient + Stop(false); +} + void AutoPacketFactory::Invalidate(void) { if(m_parent) m_parent->Invalidate(); diff --git a/src/autowiring/BasicThread.cpp b/src/autowiring/BasicThread.cpp index 13b79caee..228b8d797 100644 --- a/src/autowiring/BasicThread.cpp +++ b/src/autowiring/BasicThread.cpp @@ -6,10 +6,6 @@ #include "ContextEnumerator.h" #include "fast_pointer_cast.h" -// Explicit instantiation of supported time point types: -template<> bool BasicThread::WaitUntil(std::chrono::steady_clock::time_point); -template<> bool BasicThread::WaitUntil(std::chrono::system_clock::time_point); - BasicThread::BasicThread(const char* pName): ContextMember(pName), m_state(std::make_shared()), @@ -79,6 +75,9 @@ void BasicThread::DoRunLoopCleanup(std::shared_ptr&& ctxt, std::sha // No longer running, we MUST release the thread pointer to ensure proper teardown order state->m_thisThread.detach(); + // Tell our CoreRunnable parent that we're done to ensure that our reference count will be cleared. + Stop(false); + // Release our hold on the context. After this point, we have to be VERY CAREFUL that we // don't try to refer to any of our own member variables, because our own object may have // already gone out of scope. [this] is potentially dangling. @@ -111,43 +110,22 @@ void BasicThread::PerformStatusUpdate(const std::function& fn) { m_state->m_stateCondition.notify_all(); } -bool BasicThread::ShouldStop(void) const { - auto context = ContextMember::GetContext(); - return m_stop || !context || context->IsShutdown(); -} - -bool BasicThread::IsRunning(void) const { - std::lock_guard lk(m_state->m_lock); - return m_running; -} - bool BasicThread::ThreadSleep(std::chrono::nanoseconds timeout) { std::unique_lock lk(m_state->m_lock); return m_state->m_stateCondition.wait_for(lk, timeout, [this] { return ShouldStop(); }); } -bool BasicThread::Start(std::shared_ptr outstanding) { +bool BasicThread::DoStart() { std::shared_ptr context = m_context.lock(); if(!context) return false; - { - std::lock_guard lk(m_state->m_lock); - if(m_running) - // Already running, short-circuit - return true; - - if(m_completed) - // Already completed (perhaps cancelled), short-circuit - return false; - - // Currently running: - m_running = true; - m_state->m_stateCondition.notify_all(); - } + // Currently running: + m_running = true; // Place the new thread entity directly in the space where it goes to avoid // any kind of races arising from asynchronous access to this space + auto outstanding = m_outstanding; m_state->m_thisThread.~thread(); new (&m_state->m_thisThread) std::thread( [this, outstanding] () mutable { @@ -157,53 +135,20 @@ bool BasicThread::Start(std::shared_ptr outstanding) { return true; } -void BasicThread::Wait(void) { - std::unique_lock lk(m_state->m_lock); - m_state->m_stateCondition.wait( - lk, - [this] {return this->m_completed; } - ); -} - -bool BasicThread::WaitFor(std::chrono::nanoseconds duration) { - std::unique_lock lk(m_state->m_lock); - return m_state->m_stateCondition.wait_for( - lk, - duration, - [this] {return this->m_completed; } - ); +void BasicThread::OnStop(bool graceful) { + if (!m_running) { + m_completed = true; + } } -template -bool BasicThread::WaitUntil(TimeType timepoint) { +void BasicThread::DoAdditionalWait(void) { std::unique_lock lk(m_state->m_lock); - return m_state->m_stateCondition.wait_until( + m_state->m_stateCondition.wait( lk, - timepoint, [this] {return this->m_completed; } ); } -void BasicThread::Stop(bool graceful) { - { - std::lock_guard lk(m_state->m_lock); - - // Trivial return check: - if(m_stop) - return; - - // If we're not running, mark ourselves complete - if(!m_running) - m_completed = true; - - // Now we send the appropriate trigger: - m_stop = true; - m_state->m_stateCondition.notify_all(); - } - - // Event notification takes place outside of the context of a lock - OnStop(); -} void BasicThread::ForceCoreThreadReidentify(void) { for(const auto& ctxt : ContextEnumerator(AutoGlobalContext())) { diff --git a/src/autowiring/CoreJob.cpp b/src/autowiring/CoreJob.cpp index 327760691..3d8d0e464 100644 --- a/src/autowiring/CoreJob.cpp +++ b/src/autowiring/CoreJob.cpp @@ -6,31 +6,32 @@ CoreJob::CoreJob(const char* name) : ContextMember(name), m_running(false), - m_shouldStop(false), m_curEventInTeardown(true) {} void CoreJob::OnPended(std::unique_lock&& lk){ - if(!m_curEventInTeardown) + if(!m_curEventInTeardown) { // Something is already outstanding, it will handle dispatching for us. return; + } - if(!m_running) + if(!m_running) { // Nothing to do, we aren't running yet--just hold on to this entry until we are // ready to initiate it. return; + } // Increment outstanding count because we now have an entry out in a thread pool auto outstanding = m_outstanding; - if(!outstanding) + if(!outstanding) { // We're currently signalled to stop, we must empty the queue and then // return here--we can't accept dispatch delivery on a stopped queue. while(!m_dispatchQueue.empty()) { delete m_dispatchQueue.front(); m_dispatchQueue.pop_front(); } - else { + } else { // Need to ask the thread pool to handle our events again: m_curEventInTeardown = false; m_curEvent = std::async( @@ -65,12 +66,12 @@ void CoreJob::DispatchAllAndClearCurrent(void) { } } -bool CoreJob::Start(std::shared_ptr outstanding) { +bool CoreJob::DoStart() { std::shared_ptr context = m_context.lock(); - if(!context) + if(!context) { return false; + } - m_outstanding = outstanding; m_running = true; std::unique_lock lk; @@ -86,7 +87,7 @@ void CoreJob::Abort(void) { m_running = false; } -void CoreJob::Stop(bool graceful) { +void CoreJob::OnStop(bool graceful) { if(graceful) // Pend a call which will invoke Abort once the dispatch queue is done: DispatchQueue::Pend( @@ -95,47 +96,9 @@ void CoreJob::Stop(bool graceful) { else // Abort the dispatch queue so anyone waiting will wake up Abort(); - - // Reset the outstanding pointer, we don't intend to hold it anymore: - m_outstanding.reset(); - - // Hit our condition variable to wake up any listeners: - std::lock_guard lk(m_dispatchLock); - m_shouldStop = true; - m_queueUpdated.notify_all(); } -void CoreJob::Wait() { - { - std::unique_lock lk(m_dispatchLock); - m_queueUpdated.wait( - lk, - [this] { - return ShouldStop() && m_curEventInTeardown; - } - ); - } - - // If the current event is valid, we can block on it until it becomes valid: +void CoreJob::DoAdditionalWait() { if(m_curEvent.valid()) m_curEvent.wait(); } - -bool CoreJob::WaitFor(std::chrono::nanoseconds duration) { - { - std::unique_lock lk(m_dispatchLock); - if(!m_queueUpdated.wait_for( - lk, - duration, - [this] { - return ShouldStop() && m_curEventInTeardown; - } - )) - return false; - } - - // If the current event is valid, we can block on it until it becomes valid: - if(m_curEvent.valid()) - m_curEvent.wait(); - return true; -} \ No newline at end of file diff --git a/src/autowiring/CoreRunnable.cpp b/src/autowiring/CoreRunnable.cpp index 98d4fa023..cfccccb72 100644 --- a/src/autowiring/CoreRunnable.cpp +++ b/src/autowiring/CoreRunnable.cpp @@ -2,23 +2,77 @@ #include "stdafx.h" #include "CoreRunnable.h" +#include + +// Explicit instantiation of supported time point types: +template<> bool CoreRunnable::WaitUntil(std::chrono::steady_clock::time_point); +template<> bool CoreRunnable::WaitUntil(std::chrono::system_clock::time_point); + CoreRunnable::CoreRunnable(void): -m_wasStarted(false), + m_wasStarted(false), m_shouldStop(false) {} -CoreRunnable::~CoreRunnable(void){} +CoreRunnable::~CoreRunnable(void) {} void CoreRunnable::Start(std::shared_ptr outstanding) { - if(m_outstanding || m_wasStarted) - // We have already been started, end here + std::lock_guard lk(m_lock); + if(m_wasStarted || m_outstanding || m_shouldStop) + // We have already been started or stopped, end here return; m_wasStarted = true; + m_outstanding = outstanding; if(!DoStart()) { m_shouldStop = true; + m_outstanding.reset(); return; } +} + +void CoreRunnable::Stop(bool graceful) { + if(m_shouldStop) { + // We were never started or have already stopped, end here + return; + } else if (!m_wasStarted) { + // We were never started, and now we never will be. + m_shouldStop = true; + OnStop(graceful); + return; + } + + std::shared_ptr outstanding; + + m_shouldStop = true; + OnStop(graceful); + + std::lock_guard lk(m_lock); + outstanding.swap(m_outstanding); + m_cv.notify_all(); +} + +void CoreRunnable::Wait(void) { + std::unique_lock lk(m_lock); + m_cv.wait(lk, [this](){ return ShouldStop() && !IsRunning(); }); + DoAdditionalWait(); +} + +bool CoreRunnable::WaitFor(std::chrono::nanoseconds timeout) { + std::unique_lock lk(m_lock); + if (m_cv.wait_for(lk, timeout, [this](){ return ShouldStop() && !IsRunning(); })) { + DoAdditionalWait(); + return true; + } + return false; +} + +template +bool CoreRunnable::WaitUntil(TimeType timepoint) { + std::unique_lock lk(m_lock); + if (m_cv.wait_until(lk, timepoint, [this](){ return ShouldStop() && !IsRunning(); })) { + DoAdditionalWait(); + return true; + } + return false; +} - m_outstanding = outstanding; -} \ No newline at end of file diff --git a/src/autowiring/CoreThread.cpp b/src/autowiring/CoreThread.cpp index 3ccb54529..4bdaf13ac 100644 --- a/src/autowiring/CoreThread.cpp +++ b/src/autowiring/CoreThread.cpp @@ -103,7 +103,7 @@ void CoreThread::Run() { WaitForEvent(); } -void CoreThread::Stop(bool graceful) { +void CoreThread::OnStop(bool graceful) { if(graceful) { // Pend a call which will invoke Abort once the dispatch queue is done: DispatchQueue::Pend([this] { @@ -117,5 +117,5 @@ void CoreThread::Stop(bool graceful) { DispatchQueue::Abort(); // Pass off to base class handling: - BasicThread::Stop(graceful); + BasicThread::OnStop(graceful); } diff --git a/src/autowiring/test/CoreRunnableTest.cpp b/src/autowiring/test/CoreRunnableTest.cpp index dea9650cf..c27a0c1df 100644 --- a/src/autowiring/test/CoreRunnableTest.cpp +++ b/src/autowiring/test/CoreRunnableTest.cpp @@ -13,15 +13,10 @@ class StartsSubcontextWhileStarting: public: AutoCreateContext m_myContext; - bool Start(std::shared_ptr outstanding) override { + bool DoStart() override { m_myContext->Initiate(); - return true; + return false; } - - void Stop(bool graceful) override {} - bool IsRunning(void) const override { return false; } - bool ShouldStop(void) const override { return true; } - void Wait(void) override {} }; TEST_F(CoreRunnableTest, CanStartSubcontextWhileInitiating) { diff --git a/src/autowiring/test/TestFixtures/SimpleReceiver.hpp b/src/autowiring/test/TestFixtures/SimpleReceiver.hpp index a482b2e10..689a5fa47 100644 --- a/src/autowiring/test/TestFixtures/SimpleReceiver.hpp +++ b/src/autowiring/test/TestFixtures/SimpleReceiver.hpp @@ -193,8 +193,10 @@ class SimpleReceiver: } // Overridden here so we can hit the barrier if we're still waiting on it - void OnStop() override { + void OnStop(bool graceful) override { Proceed(); + // Allow our parent to handle the stop as well + CoreThread::OnStop(graceful); } /// From 369daa523605886019fe0de27683c49549dca5e4 Mon Sep 17 00:00:00 2001 From: Ted Nitz Date: Wed, 17 Dec 2014 11:12:16 -0800 Subject: [PATCH 18/57] Minor cleanup in preparation for merge. --- autowiring/CoreJob.h | 2 +- autowiring/CoreRunnable.h | 2 +- autowiring/CoreThread.h | 4 ++-- src/autowiring/BasicThread.cpp | 6 +++--- src/autowiring/CoreJob.cpp | 12 +++++++----- src/autowiring/CoreRunnable.cpp | 6 ++---- src/autowiring/CoreThread.cpp | 8 +++++--- src/autowiring/test/CoreRunnableTest.cpp | 2 +- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/autowiring/CoreJob.h b/autowiring/CoreJob.h index 860d2405e..d04508daf 100644 --- a/autowiring/CoreJob.h +++ b/autowiring/CoreJob.h @@ -14,7 +14,7 @@ class CoreJob: { public: CoreJob(const char* name = nullptr); - virtual ~CoreJob(){}; + virtual ~CoreJob(void) {}; private: // Flag, set to true when it's time to start dispatching diff --git a/autowiring/CoreRunnable.h b/autowiring/CoreRunnable.h index 86321430e..0d7932066 100644 --- a/autowiring/CoreRunnable.h +++ b/autowiring/CoreRunnable.h @@ -37,7 +37,7 @@ class CoreRunnable { /// Invoked by the base class when a Stop call has been made /// /// - /// This method will be called at most once, and may potentially be called even + /// This method will be called at most once. /// virtual void OnStop(bool graceful) {}; diff --git a/autowiring/CoreThread.h b/autowiring/CoreThread.h index 2458612c8..8938296e1 100644 --- a/autowiring/CoreThread.h +++ b/autowiring/CoreThread.h @@ -64,7 +64,7 @@ class CoreThread: /// The default implementation of Run will simply call WaitForEvent in a loop until it's /// told to quit. /// - void Run() override; + void Run(void) override; /// /// Event which may be used to perform custom handling when the thread is told to stop @@ -77,5 +77,5 @@ class CoreThread: /// Callers are not required to call CoreThread::OnStop. This method is guaranteed to do /// nothing by default. /// - void OnStop(bool graceful = false) override; + void OnStop(bool graceful) override; }; diff --git a/src/autowiring/BasicThread.cpp b/src/autowiring/BasicThread.cpp index 228b8d797..30c4818e7 100644 --- a/src/autowiring/BasicThread.cpp +++ b/src/autowiring/BasicThread.cpp @@ -71,7 +71,6 @@ void BasicThread::DoRunLoopCleanup(std::shared_ptr&& ctxt, std::sha m_completed = true; m_running = false; - // No longer running, we MUST release the thread pointer to ensure proper teardown order state->m_thisThread.detach(); @@ -115,7 +114,7 @@ bool BasicThread::ThreadSleep(std::chrono::nanoseconds timeout) { return m_state->m_stateCondition.wait_for(lk, timeout, [this] { return ShouldStop(); }); } -bool BasicThread::DoStart() { +bool BasicThread::DoStart(void) { std::shared_ptr context = m_context.lock(); if(!context) return false; @@ -136,12 +135,14 @@ bool BasicThread::DoStart() { } void BasicThread::OnStop(bool graceful) { + // If we were never started, we need to set our completed flag to true if (!m_running) { m_completed = true; } } void BasicThread::DoAdditionalWait(void) { + // Wait for the run loop cleanup to happen in DoRunLoopCleanup std::unique_lock lk(m_state->m_lock); m_state->m_stateCondition.wait( lk, @@ -149,7 +150,6 @@ void BasicThread::DoAdditionalWait(void) { ); } - void BasicThread::ForceCoreThreadReidentify(void) { for(const auto& ctxt : ContextEnumerator(AutoGlobalContext())) { for(const auto& thread : ctxt->CopyBasicThreadList()) diff --git a/src/autowiring/CoreJob.cpp b/src/autowiring/CoreJob.cpp index 3d8d0e464..d987ffaef 100644 --- a/src/autowiring/CoreJob.cpp +++ b/src/autowiring/CoreJob.cpp @@ -66,7 +66,7 @@ void CoreJob::DispatchAllAndClearCurrent(void) { } } -bool CoreJob::DoStart() { +bool CoreJob::DoStart(void) { std::shared_ptr context = m_context.lock(); if(!context) { return false; @@ -75,9 +75,10 @@ bool CoreJob::DoStart() { m_running = true; std::unique_lock lk; - if(!m_dispatchQueue.empty()) + if(!m_dispatchQueue.empty()) { // Simulate a pending event, because we need to set up our async: OnPended(std::move(lk)); + } return true; } @@ -88,17 +89,18 @@ void CoreJob::Abort(void) { } void CoreJob::OnStop(bool graceful) { - if(graceful) + if(graceful) { // Pend a call which will invoke Abort once the dispatch queue is done: DispatchQueue::Pend( [this] {this->Abort();} ); - else + } else { // Abort the dispatch queue so anyone waiting will wake up Abort(); + } } -void CoreJob::DoAdditionalWait() { +void CoreJob::DoAdditionalWait(void) { if(m_curEvent.valid()) m_curEvent.wait(); } diff --git a/src/autowiring/CoreRunnable.cpp b/src/autowiring/CoreRunnable.cpp index cfccccb72..adfb9354a 100644 --- a/src/autowiring/CoreRunnable.cpp +++ b/src/autowiring/CoreRunnable.cpp @@ -2,8 +2,6 @@ #include "stdafx.h" #include "CoreRunnable.h" -#include - // Explicit instantiation of supported time point types: template<> bool CoreRunnable::WaitUntil(std::chrono::steady_clock::time_point); template<> bool CoreRunnable::WaitUntil(std::chrono::system_clock::time_point); @@ -17,9 +15,10 @@ CoreRunnable::~CoreRunnable(void) {} void CoreRunnable::Start(std::shared_ptr outstanding) { std::lock_guard lk(m_lock); - if(m_wasStarted || m_outstanding || m_shouldStop) + if(m_wasStarted || m_outstanding || m_shouldStop) { // We have already been started or stopped, end here return; + } m_wasStarted = true; m_outstanding = outstanding; @@ -75,4 +74,3 @@ bool CoreRunnable::WaitUntil(TimeType timepoint) { } return false; } - diff --git a/src/autowiring/CoreThread.cpp b/src/autowiring/CoreThread.cpp index 4bdaf13ac..5e94a66e7 100644 --- a/src/autowiring/CoreThread.cpp +++ b/src/autowiring/CoreThread.cpp @@ -44,13 +44,14 @@ void CoreThread::WaitForEvent(void) { !this->m_dispatchQueue.empty(); }); - if(m_dispatchQueue.empty()) + if(m_dispatchQueue.empty()) { // The delay queue has items but the dispatch queue does not, we need to switch // to the suggested sleep timeout variant: WaitForEventUnsafe(lk, m_delayedQueue.top().GetReadyTime()); - else + } else { // We have an event, we can just hop over to this variant: DispatchEventUnsafe(lk); + } } bool CoreThread::WaitForEvent(std::chrono::milliseconds milliseconds) { @@ -58,9 +59,10 @@ bool CoreThread::WaitForEvent(std::chrono::milliseconds milliseconds) { } bool CoreThread::WaitForEvent(std::chrono::steady_clock::time_point wakeTime) { - if(wakeTime == std::chrono::steady_clock::time_point::max()) + if(wakeTime == std::chrono::steady_clock::time_point::max()) { // Maximal wait--we can optimize by using the zero-arguments version return WaitForEvent(), true; + } std::unique_lock lk(m_dispatchLock); return WaitForEventUnsafe(lk, wakeTime); diff --git a/src/autowiring/test/CoreRunnableTest.cpp b/src/autowiring/test/CoreRunnableTest.cpp index c27a0c1df..ee66b750e 100644 --- a/src/autowiring/test/CoreRunnableTest.cpp +++ b/src/autowiring/test/CoreRunnableTest.cpp @@ -13,7 +13,7 @@ class StartsSubcontextWhileStarting: public: AutoCreateContext m_myContext; - bool DoStart() override { + bool DoStart(void) override { m_myContext->Initiate(); return false; } From 79a3bf4650ff07997cd3803e86388476508f211b Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Wed, 17 Dec 2014 14:36:58 -0800 Subject: [PATCH 19/57] Basic Successor functionality works. Still not thread safe --- autowiring/AutoPacket.h | 5 ++++- autowiring/AutoPacketFactory.h | 5 +++++ src/autowiring/AutoPacket.cpp | 14 +++++++++++--- src/autowiring/AutoPacketFactory.cpp | 24 +++++++++++++++++++----- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index 74800409d..229057811 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -57,6 +57,9 @@ class AutoPacket: protected: // A pointer back to the factory that created us. Used for recording lifetime statistics. const std::shared_ptr m_parentFactory; + + // The successor to this packet + std::weak_ptr m_successor; // Hold the time point at which this packet was last initalized. const std::chrono::high_resolution_clock::time_point m_initTime; @@ -478,7 +481,7 @@ class AutoPacket: /// /// Returns the next packet that will be issued by the packet factory in this context relative to this context /// - std::shared_ptr Successor(void) const; + std::shared_ptr Successor(void); }; #include "CallExtractor.h" diff --git a/autowiring/AutoPacketFactory.h b/autowiring/AutoPacketFactory.h index 85b95af78..2d315afb7 100644 --- a/autowiring/AutoPacketFactory.h +++ b/autowiring/AutoPacketFactory.h @@ -49,6 +49,9 @@ class AutoPacketFactory: // Internal outstanding reference for issued packet: std::weak_ptr m_outstandingInternal; + + // The last packet issued from this factory + std::weak_ptr m_prevPacket; // Collection of known subscribers typedef std::unordered_set> t_autoFilterSet; @@ -134,6 +137,8 @@ class AutoPacketFactory: /// std::shared_ptr NewPacket(void); + std::shared_ptr ConstructPacket(void); + /// the number of outstanding AutoPackets size_t GetOutstanding(void) const; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index a4fffe768..aec461cd2 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -371,7 +371,15 @@ bool AutoPacket::HasSubscribers(const std::type_info& data) const { return m_decorations.count(data) != 0; } -std::shared_ptr AutoPacket::Successor(void) const { - std::shared_ptr retVal; +std::shared_ptr AutoPacket::Successor(void) { + std::lock_guard lk(m_lock); + + // If successor already exists, construct it + if (!m_successor.expired()){ + return m_successor.lock(); + } + + std::shared_ptr retVal = m_parentFactory->ConstructPacket(); + m_successor = retVal; return retVal; -} \ No newline at end of file +} diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index f0997fbd0..9081e563b 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -27,11 +27,25 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { if(!IsRunning()) throw autowiring_error("Cannot create a packet until the AutoPacketFactory is started"); - // Obtain a packet, initialize it, return it - auto retVal = std::make_shared( - *this, - GetInternalOutstanding() - ); + // Hack, this currently can't be called while holding a lock + std::shared_ptr retVal; + + // Obtain a packet from previous packet if it still exists + if (auto prev = m_prevPacket.lock()) { + retVal = prev->Successor(); + } else { + retVal = ConstructPacket(); + } + + // Store new packet as previous packet + std::lock_guard lk(m_lock); + m_prevPacket = retVal; + return retVal; +} + +std::shared_ptr AutoPacketFactory::ConstructPacket(void) { + // Hack, this currently can't be called while holding a lock + std::shared_ptr retVal = std::make_shared(*this, GetInternalOutstanding()); retVal->Initialize(); return retVal; } From 7ff150110b316a84fa453d873c636a36751f1ff5 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Wed, 17 Dec 2014 15:23:24 -0800 Subject: [PATCH 20/57] Make NewPacket thread safe --- autowiring/AutoPacket.h | 1 + autowiring/AutoPacketFactory.h | 4 ++++ src/autowiring/AutoPacket.cpp | 9 ++++++--- src/autowiring/AutoPacketFactory.cpp | 6 ++---- src/autowiring/AutoPacketInternal.cpp | 7 ++----- src/autowiring/AutoPacketInternal.hpp | 1 + 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index 229057811..3aeba8f9b 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -46,6 +46,7 @@ class AutoPacket: AutoPacket(AutoPacket&&) = delete; public: + // Must hold the lock to 'factory' when calling this constructor AutoPacket(AutoPacketFactory& factory, std::shared_ptr&& outstanding); ~AutoPacket(); diff --git a/autowiring/AutoPacketFactory.h b/autowiring/AutoPacketFactory.h index 2d315afb7..5ae4bffd2 100644 --- a/autowiring/AutoPacketFactory.h +++ b/autowiring/AutoPacketFactory.h @@ -78,6 +78,10 @@ class AutoPacketFactory: template void AppendAutoFiltersTo(T& container) const { std::lock_guard lk(m_lock); + AppendAutoFiltersToUnsafe(container); + } + template + void AppendAutoFiltersToUnsafe(T& container) const { container.insert(container.end(), m_autoFilters.begin(), m_autoFilters.end()); } diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index aec461cd2..83fddaa44 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -16,8 +16,11 @@ AutoPacket::AutoPacket(AutoPacketFactory& factory, std::shared_ptr&& outst m_initTime(std::chrono::high_resolution_clock::now()), m_outstanding(std::move(outstanding)) { - // Traverse all contexts, adding their packet subscriber vectors one at a time: - for(const auto& curContext : ContextEnumerator(factory.GetContext())) { + // Add filters from our factory. We're holding the lock for this factory, so use unsafe + factory.AppendAutoFiltersToUnsafe(m_satCounters); + + // Traverse all descendant contexts, adding their packet subscriber vectors one at a time: + for(const auto& curContext : ContextEnumerator(factory.GetContext()->FirstChild())) { AutowiredFast curFactory(curContext); if(curFactory) // Only insert if this context actually has a packet factory @@ -374,7 +377,7 @@ bool AutoPacket::HasSubscribers(const std::type_info& data) const { std::shared_ptr AutoPacket::Successor(void) { std::lock_guard lk(m_lock); - // If successor already exists, construct it + // If successor already exists, use it if (!m_successor.expired()){ return m_successor.lock(); } diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 9081e563b..36c88ae15 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -27,10 +27,10 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { if(!IsRunning()) throw autowiring_error("Cannot create a packet until the AutoPacketFactory is started"); - // Hack, this currently can't be called while holding a lock std::shared_ptr retVal; // Obtain a packet from previous packet if it still exists + std::lock_guard lk(m_lock); if (auto prev = m_prevPacket.lock()) { retVal = prev->Successor(); } else { @@ -38,14 +38,12 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { } // Store new packet as previous packet - std::lock_guard lk(m_lock); m_prevPacket = retVal; return retVal; } std::shared_ptr AutoPacketFactory::ConstructPacket(void) { - // Hack, this currently can't be called while holding a lock - std::shared_ptr retVal = std::make_shared(*this, GetInternalOutstanding()); + auto retVal = std::make_shared(*this, GetInternalOutstanding()); retVal->Initialize(); return retVal; } diff --git a/src/autowiring/AutoPacketInternal.cpp b/src/autowiring/AutoPacketInternal.cpp index b7c794bd4..737f6053e 100644 --- a/src/autowiring/AutoPacketInternal.cpp +++ b/src/autowiring/AutoPacketInternal.cpp @@ -6,12 +6,9 @@ AutoPacketInternal::AutoPacketInternal(AutoPacketFactory& factory, std::shared_ptr&& outstanding) : AutoPacket(factory, std::move(outstanding)) -{ -} +{} -AutoPacketInternal::~AutoPacketInternal(void) -{ -} +AutoPacketInternal::~AutoPacketInternal(void) {} void AutoPacketInternal::Initialize(void) { // Find all subscribers with no required or optional arguments: diff --git a/src/autowiring/AutoPacketInternal.hpp b/src/autowiring/AutoPacketInternal.hpp index dd3807e1d..d9302b1e4 100644 --- a/src/autowiring/AutoPacketInternal.hpp +++ b/src/autowiring/AutoPacketInternal.hpp @@ -9,6 +9,7 @@ class AutoPacketInternal: public AutoPacket { public: + // Must hold the lock to 'factory' when calling this constructor AutoPacketInternal(AutoPacketFactory& factory, std::shared_ptr&& outstanding); ~AutoPacketInternal(void); From 45a1c8499ec2ed9eebe14c22a9e75d109226c184 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Wed, 17 Dec 2014 16:32:13 -0800 Subject: [PATCH 21/57] Update outdated test Packets are now guaranteed to be destroyed in the order they are issued --- autowiring/AutoPacket.h | 2 +- src/autowiring/AutoPacket.cpp | 4 ++-- src/autowiring/test/AutoFilterSequencing.cpp | 14 ++++++++++++++ src/autowiring/test/AutoFilterTest.cpp | 5 ----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index 3aeba8f9b..c440e891f 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -60,7 +60,7 @@ class AutoPacket: const std::shared_ptr m_parentFactory; // The successor to this packet - std::weak_ptr m_successor; + std::shared_ptr m_successor; // Hold the time point at which this packet was last initalized. const std::chrono::high_resolution_clock::time_point m_initTime; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index 83fddaa44..d03d3d22c 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -378,8 +378,8 @@ std::shared_ptr AutoPacket::Successor(void) { std::lock_guard lk(m_lock); // If successor already exists, use it - if (!m_successor.expired()){ - return m_successor.lock(); + if (m_successor){ + return m_successor; } std::shared_ptr retVal = m_parentFactory->ConstructPacket(); diff --git a/src/autowiring/test/AutoFilterSequencing.cpp b/src/autowiring/test/AutoFilterSequencing.cpp index 6705252bb..f9ae39f66 100644 --- a/src/autowiring/test/AutoFilterSequencing.cpp +++ b/src/autowiring/test/AutoFilterSequencing.cpp @@ -94,3 +94,17 @@ TEST_F(AutoFilterSequencing, PacketReverseSuccessor) { ASSERT_EQ(packet2, packet1->Successor()) << "Successor packet obtained after generation from the factory did not match as expected"; } + +TEST_F(AutoFilterSequencing, ManySuccessors) { + AutoRequired factory; + + auto packetA = factory->NewPacket(); + auto packet5 = packetA->Successor()->Successor()->Successor()->Successor(); + + auto packetB = factory->NewPacket(); + auto packetC = factory->NewPacket(); + auto packetD = factory->NewPacket(); + auto packetE = factory->NewPacket(); + + ASSERT_EQ(packet5, packetE) << "Successor packet obtained after generation from the factory did not match as expected"; +} diff --git a/src/autowiring/test/AutoFilterTest.cpp b/src/autowiring/test/AutoFilterTest.cpp index c5f23baaf..417a297ec 100644 --- a/src/autowiring/test/AutoFilterTest.cpp +++ b/src/autowiring/test/AutoFilterTest.cpp @@ -63,7 +63,6 @@ TEST_F(AutoFilterTest, VerifyDescendentAwareness) { EXPECT_TRUE(strongPacket->HasSubscribers(typeid(Decoration<0>))) << "Packet lacked expected subscription from subcontext"; EXPECT_TRUE(weakPacket.lock()->HasSubscribers(typeid(Decoration<0>))) << "Packet lacked expected subscription from subcontext"; } - EXPECT_TRUE(weakPacket.expired()) << "Packet was not destroyed when it's subscribers were removed"; EXPECT_FALSE(filterChecker.expired()) << "Packet keeping subcontext member alive"; // Verify the second packet will no longer have subscriptions - @@ -83,10 +82,6 @@ TEST_F(AutoFilterTest, VerifyDescendentAwareness) { // Create a packet after the subcontext has been destroyed auto lastPacket = parentFactory->NewPacket(); EXPECT_FALSE(lastPacket->HasSubscribers(typeid(Decoration<0>))) << "Subscription was incorrectly, retroactively added to a packet"; - - // Verify that strongPacket was responsible for keeping subFilter alive - strongPacket.reset(); - EXPECT_TRUE(filterChecker.expired()) << "Subscriber from destroyed subcontext didn't expire after packet was reset."; } TEST_F(AutoFilterTest, VerifySimpleFilter) { From 197bad5cd92e0f18f3d3340805ddb38ab8176927 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Wed, 17 Dec 2014 16:44:27 -0800 Subject: [PATCH 22/57] Simplify logic --- src/autowiring/AutoPacket.cpp | 10 ++++------ src/autowiring/AutoPacketFactory.cpp | 10 +++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index d03d3d22c..6f0db26c7 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -377,12 +377,10 @@ bool AutoPacket::HasSubscribers(const std::type_info& data) const { std::shared_ptr AutoPacket::Successor(void) { std::lock_guard lk(m_lock); - // If successor already exists, use it - if (m_successor){ - return m_successor; + // If successor doesn't already exists, create it + if (!m_successor){ + m_successor = m_parentFactory->ConstructPacket(); } - std::shared_ptr retVal = m_parentFactory->ConstructPacket(); - m_successor = retVal; - return retVal; + return m_successor; } diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 36c88ae15..c1264e735 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -27,15 +27,11 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { if(!IsRunning()) throw autowiring_error("Cannot create a packet until the AutoPacketFactory is started"); - std::shared_ptr retVal; + std::lock_guard lk(m_lock); // Obtain a packet from previous packet if it still exists - std::lock_guard lk(m_lock); - if (auto prev = m_prevPacket.lock()) { - retVal = prev->Successor(); - } else { - retVal = ConstructPacket(); - } + auto prev = m_prevPacket.lock(); + auto retVal = prev ? prev->Successor() : ConstructPacket(); // Store new packet as previous packet m_prevPacket = retVal; From 1226995e639ca84bbd8285fce3ad1c06e8490bde Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:11:53 -0800 Subject: [PATCH 23/57] MORE DEATH TO AUTOLINK --- .../autoboost/boost/archive/basic_archive.hpp | 1 - .../boost/archive/basic_binary_iprimitive.hpp | 1 - .../boost/archive/basic_binary_oprimitive.hpp | 1 - .../boost/archive/basic_xml_archive.hpp | 1 - .../autoboost/boost/archive/codecvt_null.hpp | 1 - .../archive/detail/archive_serializer_map.hpp | 1 - .../archive/detail/auto_link_archive.hpp | 48 ------------------- .../archive/detail/auto_link_warchive.hpp | 47 ------------------ .../archive/detail/basic_iserializer.hpp | 1 - .../archive/detail/basic_oserializer.hpp | 1 - .../detail/basic_pointer_iserializer.hpp | 1 - .../detail/basic_pointer_oserializer.hpp | 1 - .../archive/detail/basic_serializer_map.hpp | 1 - .../archive/detail/interface_iarchive.hpp | 1 - .../archive/detail/interface_oarchive.hpp | 1 - .../autoboost/boost/archive/text_iarchive.hpp | 1 - .../autoboost/boost/archive/text_oarchive.hpp | 1 - .../boost/archive/text_wiarchive.hpp | 1 - .../boost/archive/text_woarchive.hpp | 1 - .../autoboost/boost/archive/xml_iarchive.hpp | 1 - .../autoboost/boost/archive/xml_oarchive.hpp | 1 - .../autoboost/boost/archive/xml_wiarchive.hpp | 1 - .../autoboost/boost/archive/xml_woarchive.hpp | 1 - .../autoboost/boost/atomic/detail/link.hpp | 16 ------- contrib/autoboost/boost/chrono/config.hpp | 20 -------- .../autoboost/boost/context/detail/config.hpp | 8 ---- .../boost/coroutine/detail/config.hpp | 8 ---- .../autoboost/boost/serialization/config.hpp | 23 --------- contrib/autoboost/boost/test/unit_test.hpp | 18 ------- .../autoboost/boost/thread/detail/config.hpp | 32 +------------ contrib/autoboost/boost/version.hpp | 1 - .../libs/serialization/src/basic_iarchive.cpp | 2 - .../src/basic_text_iprimitive.cpp | 1 - .../src/basic_text_oprimitive.cpp | 1 - .../src/basic_text_wiprimitive.cpp | 1 - .../src/basic_text_woprimitive.cpp | 1 - 36 files changed, 2 insertions(+), 246 deletions(-) delete mode 100644 contrib/autoboost/boost/archive/detail/auto_link_archive.hpp delete mode 100644 contrib/autoboost/boost/archive/detail/auto_link_warchive.hpp diff --git a/contrib/autoboost/boost/archive/basic_archive.hpp b/contrib/autoboost/boost/archive/basic_archive.hpp index a1779fbf9..2d6d45616 100644 --- a/contrib/autoboost/boost/archive/basic_archive.hpp +++ b/contrib/autoboost/boost/archive/basic_archive.hpp @@ -22,7 +22,6 @@ #include #include -#include #include // must be the last header namespace autoboost { diff --git a/contrib/autoboost/boost/archive/basic_binary_iprimitive.hpp b/contrib/autoboost/boost/archive/basic_binary_iprimitive.hpp index 62300fa8e..d3060bc7d 100644 --- a/contrib/autoboost/boost/archive/basic_binary_iprimitive.hpp +++ b/contrib/autoboost/boost/archive/basic_binary_iprimitive.hpp @@ -54,7 +54,6 @@ namespace std{ #include #include #include -#include #include // must be the last header namespace autoboost { diff --git a/contrib/autoboost/boost/archive/basic_binary_oprimitive.hpp b/contrib/autoboost/boost/archive/basic_binary_oprimitive.hpp index 7ec2d389f..bc782ea26 100644 --- a/contrib/autoboost/boost/archive/basic_binary_oprimitive.hpp +++ b/contrib/autoboost/boost/archive/basic_binary_oprimitive.hpp @@ -48,7 +48,6 @@ namespace std{ #include #include #include -#include #include // must be the last header namespace autoboost { diff --git a/contrib/autoboost/boost/archive/basic_xml_archive.hpp b/contrib/autoboost/boost/archive/basic_xml_archive.hpp index d5ddbd68d..20dff5b17 100644 --- a/contrib/autoboost/boost/archive/basic_xml_archive.hpp +++ b/contrib/autoboost/boost/archive/basic_xml_archive.hpp @@ -18,7 +18,6 @@ #include -#include #include // must be the last header namespace autoboost { diff --git a/contrib/autoboost/boost/archive/codecvt_null.hpp b/contrib/autoboost/boost/archive/codecvt_null.hpp index 022e1031f..ca6e90a8f 100644 --- a/contrib/autoboost/boost/archive/codecvt_null.hpp +++ b/contrib/autoboost/boost/archive/codecvt_null.hpp @@ -20,7 +20,6 @@ #include // NULL, size_t #include // for mbstate_t #include -#include #include // must be the last header #if defined(BOOST_NO_STDC_NAMESPACE) diff --git a/contrib/autoboost/boost/archive/detail/archive_serializer_map.hpp b/contrib/autoboost/boost/archive/detail/archive_serializer_map.hpp index 0b25cf88c..338be8b9c 100644 --- a/contrib/autoboost/boost/archive/detail/archive_serializer_map.hpp +++ b/contrib/autoboost/boost/archive/detail/archive_serializer_map.hpp @@ -21,7 +21,6 @@ // basic_serializer_map so we can have a one map / archive type. #include -#include #include // must be the last header namespace autoboost { diff --git a/contrib/autoboost/boost/archive/detail/auto_link_archive.hpp b/contrib/autoboost/boost/archive/detail/auto_link_archive.hpp deleted file mode 100644 index 35e1acf45..000000000 --- a/contrib/autoboost/boost/archive/detail/auto_link_archive.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP -#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// auto_link_archive.hpp -// -// (c) Copyright Robert Ramey 2004 -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/serialization - -//----------------------------------------------------------------------------// - -// This header implements separate compilation features as described in -// http://www.boost.org/more/separate_compilation.html - -// enable automatic library variant selection ------------------------------// - -#include - -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) \ -&& !defined(BOOST_ARCHIVE_SOURCE) && !defined(BOOST_WARCHIVE_SOURCE) \ -&& !defined(BOOST_SERIALIZATION_SOURCE) - - // Set the name of our library, this will get undef'ed by auto_link.hpp - // once it's done with it: - // - #define BOOST_LIB_NAME autoboost_serialization - // - // If we're importing code from a dll, then tell auto_link.hpp about it: - // - #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK) - # define BOOST_DYN_LINK - #endif - // - // And include the header that does the work: - // - #include -#endif // auto-linking disabled - -#endif // BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP diff --git a/contrib/autoboost/boost/archive/detail/auto_link_warchive.hpp b/contrib/autoboost/boost/archive/detail/auto_link_warchive.hpp deleted file mode 100644 index 4bcaa3142..000000000 --- a/contrib/autoboost/boost/archive/detail/auto_link_warchive.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP -#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// auto_link_warchive.hpp -// -// (c) Copyright Robert Ramey 2004 -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/serialization - -//----------------------------------------------------------------------------// - -// This header implements separate compilation features as described in -// http://www.boost.org/more/separate_compilation.html - -// enable automatic library variant selection ------------------------------// - -#include - -#if !defined(BOOST_WARCHIVE_SOURCE) \ -&& !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) - -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#define BOOST_LIB_NAME autoboost_wserialization -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK) -# define BOOST_DYN_LINK -#endif -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled - -#endif // ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP diff --git a/contrib/autoboost/boost/archive/detail/basic_iserializer.hpp b/contrib/autoboost/boost/archive/detail/basic_iserializer.hpp index 380a22680..758f0e800 100644 --- a/contrib/autoboost/boost/archive/detail/basic_iserializer.hpp +++ b/contrib/autoboost/boost/archive/detail/basic_iserializer.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include // must be the last header #ifdef BOOST_MSVC diff --git a/contrib/autoboost/boost/archive/detail/basic_oserializer.hpp b/contrib/autoboost/boost/archive/detail/basic_oserializer.hpp index 4eacf5d0d..4b344dfaa 100644 --- a/contrib/autoboost/boost/archive/detail/basic_oserializer.hpp +++ b/contrib/autoboost/boost/archive/detail/basic_oserializer.hpp @@ -21,7 +21,6 @@ #include #include -#include #include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/detail/basic_pointer_iserializer.hpp b/contrib/autoboost/boost/archive/detail/basic_pointer_iserializer.hpp index 1cb313db4..d532758d9 100644 --- a/contrib/autoboost/boost/archive/detail/basic_pointer_iserializer.hpp +++ b/contrib/autoboost/boost/archive/detail/basic_pointer_iserializer.hpp @@ -18,7 +18,6 @@ // See http://www.boost.org for updates, documentation, and revision history. #include #include -#include #include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/detail/basic_pointer_oserializer.hpp b/contrib/autoboost/boost/archive/detail/basic_pointer_oserializer.hpp index 4f1089b63..dcb6a0319 100644 --- a/contrib/autoboost/boost/archive/detail/basic_pointer_oserializer.hpp +++ b/contrib/autoboost/boost/archive/detail/basic_pointer_oserializer.hpp @@ -18,7 +18,6 @@ // See http://www.boost.org for updates, documentation, and revision history. #include #include -#include #include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/detail/basic_serializer_map.hpp b/contrib/autoboost/boost/archive/detail/basic_serializer_map.hpp index 025633146..3c3eff54f 100644 --- a/contrib/autoboost/boost/archive/detail/basic_serializer_map.hpp +++ b/contrib/autoboost/boost/archive/detail/basic_serializer_map.hpp @@ -20,7 +20,6 @@ #include #include -#include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/detail/interface_iarchive.hpp b/contrib/autoboost/boost/archive/detail/interface_iarchive.hpp index e3a3007c7..b7d41163c 100644 --- a/contrib/autoboost/boost/archive/detail/interface_iarchive.hpp +++ b/contrib/autoboost/boost/archive/detail/interface_iarchive.hpp @@ -18,7 +18,6 @@ #include // NULL #include #include -#include #include #include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/detail/interface_oarchive.hpp b/contrib/autoboost/boost/archive/detail/interface_oarchive.hpp index 9689b4a34..50d180eea 100644 --- a/contrib/autoboost/boost/archive/detail/interface_oarchive.hpp +++ b/contrib/autoboost/boost/archive/detail/interface_oarchive.hpp @@ -19,7 +19,6 @@ #include #include -#include #include #include // must be the last header diff --git a/contrib/autoboost/boost/archive/text_iarchive.hpp b/contrib/autoboost/boost/archive/text_iarchive.hpp index e9afce651..bc04625bc 100644 --- a/contrib/autoboost/boost/archive/text_iarchive.hpp +++ b/contrib/autoboost/boost/archive/text_iarchive.hpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/text_oarchive.hpp b/contrib/autoboost/boost/archive/text_oarchive.hpp index 3d862ab08..8c331dda9 100644 --- a/contrib/autoboost/boost/archive/text_oarchive.hpp +++ b/contrib/autoboost/boost/archive/text_oarchive.hpp @@ -26,7 +26,6 @@ namespace std{ } // namespace std #endif -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/text_wiarchive.hpp b/contrib/autoboost/boost/archive/text_wiarchive.hpp index ad7bd3f92..fb6bde0c0 100644 --- a/contrib/autoboost/boost/archive/text_wiarchive.hpp +++ b/contrib/autoboost/boost/archive/text_wiarchive.hpp @@ -23,7 +23,6 @@ #include -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/text_woarchive.hpp b/contrib/autoboost/boost/archive/text_woarchive.hpp index 1dd58c9ea..cab13ec7f 100644 --- a/contrib/autoboost/boost/archive/text_woarchive.hpp +++ b/contrib/autoboost/boost/archive/text_woarchive.hpp @@ -31,7 +31,6 @@ namespace std{ } // namespace std #endif -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/xml_iarchive.hpp b/contrib/autoboost/boost/archive/xml_iarchive.hpp index 725de403a..bb084ca79 100644 --- a/contrib/autoboost/boost/archive/xml_iarchive.hpp +++ b/contrib/autoboost/boost/archive/xml_iarchive.hpp @@ -19,7 +19,6 @@ #include //#include -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/xml_oarchive.hpp b/contrib/autoboost/boost/archive/xml_oarchive.hpp index 073ed2a22..693efa54e 100644 --- a/contrib/autoboost/boost/archive/xml_oarchive.hpp +++ b/contrib/autoboost/boost/archive/xml_oarchive.hpp @@ -26,7 +26,6 @@ namespace std{ } // namespace std #endif -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/xml_wiarchive.hpp b/contrib/autoboost/boost/archive/xml_wiarchive.hpp index d8ff50ed0..7bc0239ff 100644 --- a/contrib/autoboost/boost/archive/xml_wiarchive.hpp +++ b/contrib/autoboost/boost/archive/xml_wiarchive.hpp @@ -24,7 +24,6 @@ #include //#include -#include #include #include #include diff --git a/contrib/autoboost/boost/archive/xml_woarchive.hpp b/contrib/autoboost/boost/archive/xml_woarchive.hpp index f62540450..d8406ef53 100644 --- a/contrib/autoboost/boost/archive/xml_woarchive.hpp +++ b/contrib/autoboost/boost/archive/xml_woarchive.hpp @@ -30,7 +30,6 @@ namespace std{ #include -#include #include #include #include diff --git a/contrib/autoboost/boost/atomic/detail/link.hpp b/contrib/autoboost/boost/atomic/detail/link.hpp index 29c9e7f6e..747972df9 100644 --- a/contrib/autoboost/boost/atomic/detail/link.hpp +++ b/contrib/autoboost/boost/atomic/detail/link.hpp @@ -39,20 +39,4 @@ #define BOOST_ATOMIC_DECL #endif -/////////////////////////////////////////////////////////////////////////////// -// Auto library naming -#if !defined(BOOST_ATOMIC_SOURCE) && !defined(BOOST_ALL_NO_LIB) && \ - !defined(BOOST_ATOMIC_NO_LIB) - -#define BOOST_LIB_NAME autoboost_atomic - -// tell the auto-link code to select a dll when required: -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ATOMIC_DYN_LINK) -#define BOOST_DYN_LINK -#endif - -#include - -#endif // auto-linking disabled - #endif diff --git a/contrib/autoboost/boost/chrono/config.hpp b/contrib/autoboost/boost/chrono/config.hpp index 751b68644..4461cb3f4 100644 --- a/contrib/autoboost/boost/chrono/config.hpp +++ b/contrib/autoboost/boost/chrono/config.hpp @@ -191,26 +191,6 @@ #endif - -// enable automatic library variant selection ------------------------------// - -#if !defined(BOOST_CHRONO_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_CHRONO_NO_LIB) -// -// Set the name of our library; this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#define BOOST_LIB_NAME autoboost_chrono -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK) -# define BOOST_DYN_LINK -#endif -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled #endif // BOOST_CHRONO_HEADER_ONLY #endif // BOOST_CHRONO_CONFIG_HPP diff --git a/contrib/autoboost/boost/context/detail/config.hpp b/contrib/autoboost/boost/context/detail/config.hpp index 5c5957632..e9228612e 100644 --- a/contrib/autoboost/boost/context/detail/config.hpp +++ b/contrib/autoboost/boost/context/detail/config.hpp @@ -27,14 +27,6 @@ # define BOOST_CONTEXT_DECL #endif -#if ! defined(BOOST_CONTEXT_SOURCE) && ! defined(BOOST_ALL_NO_LIB) && ! defined(BOOST_CONTEXT_NO_LIB) -# define BOOST_LIB_NAME autoboost_context -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTEXT_DYN_LINK) -# define BOOST_DYN_LINK -# endif -# include -#endif - #undef BOOST_CONTEXT_CALLDECL #if (defined(i386) || defined(__i386__) || defined(__i386) \ || defined(__i486__) || defined(__i586__) || defined(__i686__) \ diff --git a/contrib/autoboost/boost/coroutine/detail/config.hpp b/contrib/autoboost/boost/coroutine/detail/config.hpp index 7a88561ee..9e2556fd9 100644 --- a/contrib/autoboost/boost/coroutine/detail/config.hpp +++ b/contrib/autoboost/boost/coroutine/detail/config.hpp @@ -27,14 +27,6 @@ # define BOOST_COROUTINES_DECL #endif -#if ! defined(BOOST_COROUTINES_SOURCE) && ! defined(BOOST_ALL_NO_LIB) && ! defined(BOOST_COROUTINES_NO_LIB) -# define BOOST_LIB_NAME autoboost_coroutine -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_COROUTINES_DYN_LINK) -# define BOOST_DYN_LINK -# endif -# include -#endif - #if defined(BOOST_USE_SEGMENTED_STACKS) # if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) diff --git a/contrib/autoboost/boost/serialization/config.hpp b/contrib/autoboost/boost/serialization/config.hpp index bf025a0b8..0d596d403 100644 --- a/contrib/autoboost/boost/serialization/config.hpp +++ b/contrib/autoboost/boost/serialization/config.hpp @@ -59,27 +59,4 @@ #define BOOST_SERIALIZATION_DECL(T) T #endif -// enable automatic library variant selection ------------------------------// - -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) \ -&& !defined(BOOST_ARCHIVE_SOURCE) && !defined(BOOST_WARCHIVE_SOURCE) \ -&& !defined(BOOST_SERIALIZATION_SOURCE) - // - // Set the name of our library, this will get undef'ed by auto_link.hpp - // once it's done with it: - // - #define BOOST_LIB_NAME autoboost_serialization - // - // If we're importing code from a dll, then tell auto_link.hpp about it: - // - #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK) - # define BOOST_DYN_LINK - #endif - // - // And include the header that does the work: - // - #include - -#endif - #endif // BOOST_SERIALIZATION_CONFIG_HPP diff --git a/contrib/autoboost/boost/test/unit_test.hpp b/contrib/autoboost/boost/test/unit_test.hpp index b3b487137..851e518c0 100644 --- a/contrib/autoboost/boost/test/unit_test.hpp +++ b/contrib/autoboost/boost/test/unit_test.hpp @@ -19,24 +19,6 @@ #include #include -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** Auto Linking ************** // -// ************************************************************************** // - -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TEST_NO_LIB) && \ - !defined(BOOST_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED) -# define BOOST_LIB_NAME autoboost_unit_test_framework - -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEST_DYN_LINK) -# define BOOST_DYN_LINK -# endif - -# include - -#endif // auto-linking disabled - // ************************************************************************** // // ************** unit_test_main ************** // // ************************************************************************** // diff --git a/contrib/autoboost/boost/thread/detail/config.hpp b/contrib/autoboost/boost/thread/detail/config.hpp index ebc7a0a76..993cbcec5 100644 --- a/contrib/autoboost/boost/thread/detail/config.hpp +++ b/contrib/autoboost/boost/thread/detail/config.hpp @@ -428,38 +428,10 @@ # define BOOST_THREAD_DECL #endif // BOOST_HAS_DECLSPEC -// -// Automatically link to the correct build variant where possible. -// -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL) && !defined(BOOST_THREAD_BUILD_LIB) -// -// Tell the autolink to link dynamically, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#if defined(BOOST_THREAD_USE_DLL) -# define BOOST_DYN_LINK -#endif -// -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#if defined(BOOST_THREAD_LIB_NAME) -# define BOOST_LIB_NAME BOOST_THREAD_LIB_NAME -#else -# define BOOST_LIB_NAME autoboost_thread -#endif -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled - -#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP - // Change Log: // 22 Jan 05 Roland Schwarz (speedsnail) // Usage of BOOST_HAS_DECLSPEC macro. // Default again is static lib usage. // BOOST_DYN_LINK only defined when autolink included. + +#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP \ No newline at end of file diff --git a/contrib/autoboost/boost/version.hpp b/contrib/autoboost/boost/version.hpp index c156fd791..c13720d48 100644 --- a/contrib/autoboost/boost/version.hpp +++ b/contrib/autoboost/boost/version.hpp @@ -25,7 +25,6 @@ // BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION // but as a *string* in the form "x_y[_z]" where x is the major version // number, y is the minor version number, and z is the patch level if not 0. -// This is used by to select which library version to link to. #define BOOST_LIB_VERSION "1_57" diff --git a/contrib/autoboost/libs/serialization/src/basic_iarchive.cpp b/contrib/autoboost/libs/serialization/src/basic_iarchive.cpp index 3d853bb06..79f98c962 100644 --- a/contrib/autoboost/libs/serialization/src/basic_iarchive.cpp +++ b/contrib/autoboost/libs/serialization/src/basic_iarchive.cpp @@ -41,8 +41,6 @@ namespace std{ #include #include -#include - using namespace autoboost::serialization; namespace autoboost { diff --git a/contrib/autoboost/libs/serialization/src/basic_text_iprimitive.cpp b/contrib/autoboost/libs/serialization/src/basic_text_iprimitive.cpp index 43dd66978..31ee4e92c 100644 --- a/contrib/autoboost/libs/serialization/src/basic_text_iprimitive.cpp +++ b/contrib/autoboost/libs/serialization/src/basic_text_iprimitive.cpp @@ -15,7 +15,6 @@ #include #define BOOST_ARCHIVE_SOURCE -#include #include namespace autoboost { diff --git a/contrib/autoboost/libs/serialization/src/basic_text_oprimitive.cpp b/contrib/autoboost/libs/serialization/src/basic_text_oprimitive.cpp index 51fbb0177..6ea4ad03b 100644 --- a/contrib/autoboost/libs/serialization/src/basic_text_oprimitive.cpp +++ b/contrib/autoboost/libs/serialization/src/basic_text_oprimitive.cpp @@ -15,7 +15,6 @@ #include #define BOOST_ARCHIVE_SOURCE -#include #include namespace autoboost { diff --git a/contrib/autoboost/libs/serialization/src/basic_text_wiprimitive.cpp b/contrib/autoboost/libs/serialization/src/basic_text_wiprimitive.cpp index 15ccd13e0..d41c4ba53 100644 --- a/contrib/autoboost/libs/serialization/src/basic_text_wiprimitive.cpp +++ b/contrib/autoboost/libs/serialization/src/basic_text_wiprimitive.cpp @@ -21,7 +21,6 @@ #include #define BOOST_WARCHIVE_SOURCE -#include #include namespace autoboost { diff --git a/contrib/autoboost/libs/serialization/src/basic_text_woprimitive.cpp b/contrib/autoboost/libs/serialization/src/basic_text_woprimitive.cpp index cc04b6110..306376f68 100644 --- a/contrib/autoboost/libs/serialization/src/basic_text_woprimitive.cpp +++ b/contrib/autoboost/libs/serialization/src/basic_text_woprimitive.cpp @@ -21,7 +21,6 @@ #include #define BOOST_WARCHIVE_SOURCE -#include #include namespace autoboost { From b1aa63283988fee455dc15596b8f5ca6514f3087 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:16:15 -0800 Subject: [PATCH 24/57] Eliminating Spirit This is a C++ lexer/parser implementation based on templates that we will never use. --- .../boost/spirit/home/classic/core/assert.hpp | 38 - .../home/classic/core/composite/actions.hpp | 136 ---- .../classic/core/composite/alternative.hpp | 147 ---- .../home/classic/core/composite/composite.hpp | 151 ---- .../classic/core/composite/difference.hpp | 150 ---- .../classic/core/composite/directives.hpp | 607 ---------------- .../classic/core/composite/exclusive_or.hpp | 142 ---- .../core/composite/impl/alternative.ipp | 90 --- .../core/composite/impl/difference.ipp | 90 --- .../core/composite/impl/directives.ipp | 210 ------ .../core/composite/impl/exclusive_or.ipp | 90 --- .../core/composite/impl/intersection.ipp | 90 --- .../core/composite/impl/kleene_star.ipp | 34 - .../home/classic/core/composite/impl/list.ipp | 93 --- .../classic/core/composite/impl/optional.ipp | 34 - .../classic/core/composite/impl/positive.ipp | 34 - .../classic/core/composite/impl/sequence.ipp | 90 --- .../core/composite/impl/sequential_and.ipp | 90 --- .../core/composite/impl/sequential_or.ipp | 90 --- .../classic/core/composite/intersection.hpp | 142 ---- .../classic/core/composite/kleene_star.hpp | 109 --- .../home/classic/core/composite/list.hpp | 73 -- .../home/classic/core/composite/operators.hpp | 25 - .../home/classic/core/composite/optional.hpp | 94 --- .../home/classic/core/composite/positive.hpp | 112 --- .../home/classic/core/composite/sequence.hpp | 142 ---- .../classic/core/composite/sequential_and.hpp | 76 -- .../classic/core/composite/sequential_or.hpp | 154 ----- .../boost/spirit/home/classic/core/config.hpp | 62 -- .../spirit/home/classic/core/impl/match.ipp | 113 --- .../classic/core/impl/match_attr_traits.ipp | 102 --- .../spirit/home/classic/core/impl/parser.ipp | 55 -- .../boost/spirit/home/classic/core/match.hpp | 185 ----- .../boost/spirit/home/classic/core/nil.hpp | 25 - .../classic/core/non_terminal/impl/rule.ipp | 420 ----------- .../core/non_terminal/parser_context.hpp | 150 ---- .../classic/core/non_terminal/parser_id.hpp | 122 ---- .../home/classic/core/non_terminal/rule.hpp | 175 ----- .../boost/spirit/home/classic/core/parser.hpp | 223 ------ .../classic/core/primitives/impl/numerics.ipp | 478 ------------- .../core/primitives/impl/primitives.ipp | 390 ----------- .../home/classic/core/primitives/numerics.hpp | 289 -------- .../classic/core/primitives/numerics_fwd.hpp | 88 --- .../classic/core/primitives/primitives.hpp | 654 ------------------ .../spirit/home/classic/core/safe_bool.hpp | 64 -- .../classic/core/scanner/impl/skipper.ipp | 181 ----- .../home/classic/core/scanner/scanner.hpp | 329 --------- .../home/classic/core/scanner/scanner_fwd.hpp | 52 -- .../home/classic/core/scanner/skipper.hpp | 197 ------ .../home/classic/core/scanner/skipper_fwd.hpp | 32 - .../boost/spirit/home/classic/debug.hpp | 154 ----- .../spirit/home/classic/debug/debug_node.hpp | 319 --------- .../spirit/home/classic/debug/minimal.hpp | 81 --- .../spirit/home/classic/meta/as_parser.hpp | 113 --- .../boost/spirit/home/classic/namespace.hpp | 35 - .../spirit/home/classic/utility/chset.hpp | 187 ----- .../home/classic/utility/chset_operators.hpp | 402 ----------- .../home/classic/utility/impl/chset.ipp | 322 --------- .../utility/impl/chset/basic_chset.hpp | 107 --- .../utility/impl/chset/basic_chset.ipp | 246 ------- .../classic/utility/impl/chset/range_run.hpp | 127 ---- .../classic/utility/impl/chset/range_run.ipp | 218 ------ .../classic/utility/impl/chset_operators.ipp | 592 ---------------- .../boost/spirit/home/classic/version.hpp | 30 - .../boost/spirit/include/classic_actions.hpp | 12 - .../boost/spirit/include/classic_chset.hpp | 12 - .../boost/spirit/include/classic_numerics.hpp | 12 - .../spirit/include/classic_operators.hpp | 12 - .../boost/spirit/include/classic_rule.hpp | 12 - 69 files changed, 10712 deletions(-) delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/assert.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/actions.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/alternative.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/composite.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/difference.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/directives.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/exclusive_or.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/alternative.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/difference.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/directives.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/exclusive_or.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/intersection.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/kleene_star.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/list.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/optional.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/positive.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequence.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_and.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_or.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/intersection.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/kleene_star.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/list.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/operators.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/optional.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/positive.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/sequence.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_and.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_or.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/config.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/impl/match.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/impl/match_attr_traits.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/impl/parser.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/match.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/nil.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_context.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_id.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/non_terminal/rule.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/parser.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/primitives.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/primitives/primitives.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/safe_bool.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/scanner/impl/skipper.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/debug.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/debug/debug_node.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/debug/minimal.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/meta/as_parser.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/namespace.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/chset.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/chset_operators.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.hpp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/utility/impl/chset_operators.ipp delete mode 100644 contrib/autoboost/boost/spirit/home/classic/version.hpp delete mode 100644 contrib/autoboost/boost/spirit/include/classic_actions.hpp delete mode 100644 contrib/autoboost/boost/spirit/include/classic_chset.hpp delete mode 100644 contrib/autoboost/boost/spirit/include/classic_numerics.hpp delete mode 100644 contrib/autoboost/boost/spirit/include/classic_operators.hpp delete mode 100644 contrib/autoboost/boost/spirit/include/classic_rule.hpp diff --git a/contrib/autoboost/boost/spirit/home/classic/core/assert.hpp b/contrib/autoboost/boost/spirit/home/classic/core/assert.hpp deleted file mode 100644 index ac57f5813..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/assert.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_ASSERT_HPP) -#define BOOST_SPIRIT_ASSERT_HPP - -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -// -// BOOST_SPIRIT_ASSERT is used throughout the framework. It can be -// overridden by the user. If BOOST_SPIRIT_ASSERT_EXCEPTION is defined, -// then that will be thrown, otherwise, BOOST_SPIRIT_ASSERT simply turns -// into a plain BOOST_ASSERT() -// -/////////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_SPIRIT_ASSERT) -#if defined(NDEBUG) - #define BOOST_SPIRIT_ASSERT(x) -#elif defined (BOOST_SPIRIT_ASSERT_EXCEPTION) - #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) BOOST_SPIRIT_ASSERT_AUX2(f, l, x) - #define BOOST_SPIRIT_ASSERT_AUX2(f, l, x) \ - do{ if (!(x)) autoboost::throw_exception( \ - BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0) - #define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x) -#else - #include - #define BOOST_SPIRIT_ASSERT(x) BOOST_ASSERT(x) -#endif -#endif // !defined(BOOST_SPIRIT_ASSERT) - -#endif // BOOST_SPIRIT_ASSERT_HPP diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/actions.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/actions.hpp deleted file mode 100644 index 9d091e8bd..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/actions.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_ACTIONS_HPP -#define BOOST_SPIRIT_ACTIONS_HPP - -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - /////////////////////////////////////////////////////////////////////////// - // - // action class - // - // The action class binds a parser with a user defined semantic - // action. Instances of action are never created manually. Instead, - // action objects are typically created indirectly through - // expression templates of the form: - // - // p[f] - // - // where p is a parser and f is a function or functor. The semantic - // action may be a function or a functor. When the parser is - // successful, the actor calls the scanner's action_policy policy - // (see scanner.hpp): - // - // scan.do_action(actor, attribute, first, last); - // - // passing in these information: - // - // actor: The action's function or functor - // attribute: The match (returned by the parser) object's - // attribute (see match.hpp) - // first: Iterator pointing to the start of the matching - // portion of the input - // last: Iterator pointing to one past the end of the - // matching portion of the input - // - // It is the responsibility of the scanner's action_policy policy to - // dispatch the function or functor as it sees fit. The expected - // function or functor signature depends on the parser being - // wrapped. In general, if the attribute type of the parser being - // wrapped is a nil_t, the function or functor expect the signature: - // - // void func(Iterator first, Iterator last); // functions - // - // struct ftor // functors - // { - // void func(Iterator first, Iterator last) const; - // }; - // - // where Iterator is the type of the iterator that is being used and - // first and last are the iterators pointing to the matching portion - // of the input. - // - // If the attribute type of the parser being wrapped is not a nil_t, - // the function or functor usually expect the signature: - // - // void func(T val); // functions - // - // struct ftor // functors - // { - // void func(T val) const; - // }; - // - // where T is the attribute type and val is the attribute value - // returned by the parser being wrapped. - // - /////////////////////////////////////////////////////////////////////////// - template - class action : public unary > > - { - public: - - typedef action self_t; - typedef action_parser_category parser_category_t; - typedef unary > base_t; - typedef ActionT predicate_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - action(ParserT const& p, ActionT const& a) - : base_t(p) - , actor(a) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename ScannerT::iterator_t iterator_t; - typedef typename parser_result::type result_t; - - scan.at_end(); // allow skipper to take effect - iterator_t save = scan.first; - result_t hit = this->subject().parse(scan); - if (hit) - { - typename result_t::return_t val = hit.value(); - scan.do_action(actor, val, save, scan.first); - } - return hit; - } - - ActionT const& predicate() const { return actor; } - - private: - - ActionT actor; - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/alternative.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/alternative.hpp deleted file mode 100644 index 174a8dd13..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/alternative.hpp +++ /dev/null @@ -1,147 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_ALTERNATIVE_HPP) -#define BOOST_SPIRIT_ALTERNATIVE_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // alternative class - // - // Handles expressions of the form: - // - // a | b - // - // where a and b are parsers. The expression returns a composite - // parser that matches a or b. One (not both) of the operands may - // be a literal char, wchar_t or a primitive string char const*, - // wchar_t const*. - // - // The expression is short circuit evaluated. b is never touched - // when a is returns a successful match. - // - /////////////////////////////////////////////////////////////////////////// - struct alternative_parser_gen; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct alternative - : public binary > > - { - typedef alternative self_t; - typedef binary_parser_category parser_category_t; - typedef alternative_parser_gen parser_generator_t; - typedef binary > base_t; - - alternative(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - { // scope for save - iterator_t save = scan.first; - if (result_t hit = this->left().parse(scan)) - return hit; - scan.first = save; - } - return this->right().parse(scan); - } - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - - struct alternative_parser_gen - { - template - struct result - { - typedef - alternative< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static alternative< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return alternative::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - alternative - operator|(parser const& a, parser const& b); - - template - alternative > - operator|(parser const& a, char b); - - template - alternative, B> - operator|(char a, parser const& b); - - template - alternative > - operator|(parser const& a, char const* b); - - template - alternative, B> - operator|(char const* a, parser const& b); - - template - alternative > - operator|(parser const& a, wchar_t b); - - template - alternative, B> - operator|(wchar_t a, parser const& b); - - template - alternative > - operator|(parser const& a, wchar_t const* b); - - template - alternative, B> - operator|(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/composite.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/composite.hpp deleted file mode 100644 index e5bee9a3a..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/composite.hpp +++ /dev/null @@ -1,151 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_COMPOSITE_HPP) -#define BOOST_SPIRIT_COMPOSITE_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - /////////////////////////////////////////////////////////////////////////// - // - // unary class. - // - // Composite class composed of a single subject. This template class - // is parameterized by the subject type S and a base class to - // inherit from, BaseT. The unary class is meant to be a base class - // to inherit from. The inheritance structure, given the BaseT - // template parameter places the unary class in the middle of a - // linear, single parent hierarchy. For instance, given a class S - // and a base class B, a class D can derive from unary: - // - // struct D : public unary {...}; - // - // The inheritance structure is thus: - // - // B - // | - // unary (has S) - // | - // D - // - // The subject can be accessed from the derived class D as: - // this->subject(); - // - // Typically, the subject S is specified as typename S::embed_t. - // embed_t specifies how the subject is embedded in the composite - // (See parser.hpp for details). - // - /////////////////////////////////////////////////////////////////////////// - template - class unary : public BaseT - { - public: - - typedef BaseT base_t; - typedef typename autoboost::call_traits::param_type param_t; - typedef typename autoboost::call_traits::const_reference return_t; - typedef S subject_t; - typedef typename S::embed_t subject_embed_t; - - unary(param_t subj_) - : base_t(), subj(subj_) {} - - unary(BaseT const& base, param_t subj_) - : base_t(base), subj(subj_) {} - - return_t - subject() const - { return subj; } - - private: - - subject_embed_t subj; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // binary class. - // - // Composite class composed of a pair (left and right). This - // template class is parameterized by the left and right subject - // types A and B and a base class to inherit from, BaseT. The binary - // class is meant to be a base class to inherit from. The - // inheritance structure, given the BaseT template parameter places - // the binary class in the middle of a linear, single parent - // hierarchy. For instance, given classes X and Y and a base class - // B, a class D can derive from binary: - // - // struct D : public binary {...}; - // - // The inheritance structure is thus: - // - // B - // | - // binary (has X and Y) - // | - // D - // - // The left and right subjects can be accessed from the derived - // class D as: this->left(); and this->right(); - // - // Typically, the pairs X and Y are specified as typename X::embed_t - // and typename Y::embed_t. embed_t specifies how the subject is - // embedded in the composite (See parser.hpp for details). - // - /////////////////////////////////////////////////////////////////////////////// - template - class binary : public BaseT - { - public: - - typedef BaseT base_t; - typedef typename autoboost::call_traits::param_type left_param_t; - typedef typename autoboost::call_traits::const_reference left_return_t; - typedef typename autoboost::call_traits::param_type right_param_t; - typedef typename autoboost::call_traits::const_reference right_return_t; - typedef A left_t; - typedef typename A::embed_t left_embed_t; - typedef B right_t; - typedef typename B::embed_t right_embed_t; - - binary(left_param_t a, right_param_t b) - : base_t(), subj(a, b) {} - - left_return_t - left() const - { return subj.first(); } - - right_return_t - right() const - { return subj.second(); } - - private: - - autoboost::compressed_pair subj; - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/difference.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/difference.hpp deleted file mode 100644 index 4e986717a..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/difference.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DIFFERENCE_HPP) -#define BOOST_SPIRIT_DIFFERENCE_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // difference: a - b; Matches a but not b - // - // Handles expressions of the form: - // - // a - b - // - // where a and b are parsers. The expression returns a composite - // parser that matches a but not b. One (not both) of the operands - // may be a literal char, wchar_t or a primitive string char const*, - // wchar_t const*. - // - /////////////////////////////////////////////////////////////////////////// - struct difference_parser_gen; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct difference - : public binary > > - { - typedef difference self_t; - typedef binary_parser_category parser_category_t; - typedef difference_parser_gen parser_generator_t; - typedef binary > base_t; - - difference(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - iterator_t save = scan.first; - if (result_t hl = this->left().parse(scan)) - { - std::swap(save, scan.first); - result_t hr = this->right().parse(scan); - if (!hr || (hr.length() < hl.length())) - { - scan.first = save; - return hl; - } - } - - return scan.no_match(); - } - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - - struct difference_parser_gen - { - template - struct result - { - typedef - difference< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static difference< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return difference::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - difference - operator-(parser const& a, parser const& b); - - template - difference > - operator-(parser const& a, char b); - - template - difference, B> - operator-(char a, parser const& b); - - template - difference > - operator-(parser const& a, char const* b); - - template - difference, B> - operator-(char const* a, parser const& b); - - template - difference > - operator-(parser const& a, wchar_t b); - - template - difference, B> - operator-(wchar_t a, parser const& b); - - template - difference > - operator-(parser const& a, wchar_t const* b); - - template - difference, B> - operator-(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/directives.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/directives.hpp deleted file mode 100644 index a8fcedc38..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/directives.hpp +++ /dev/null @@ -1,607 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DIRECTIVES_HPP) -#define BOOST_SPIRIT_DIRECTIVES_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include - -#include -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // contiguous class - // - /////////////////////////////////////////////////////////////////////////// - struct lexeme_parser_gen; - - template - struct contiguous - : public unary > > - { - typedef contiguous self_t; - typedef unary_parser_category parser_category_t; - typedef lexeme_parser_gen parser_generator_t; - typedef unary > base_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - contiguous(ParserT const& p) - : base_t(p) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - return impl::contiguous_parser_parse - (this->subject(), scan, scan); - } - }; - - struct lexeme_parser_gen - { - template - struct result { - - typedef contiguous type; - }; - - template - static contiguous - generate(parser const& subject) - { - return contiguous(subject.derived()); - } - - template - contiguous - operator[](parser const& subject) const - { - return contiguous(subject.derived()); - } - }; - - ////////////////////////////////// - const lexeme_parser_gen lexeme_d = lexeme_parser_gen(); - - /////////////////////////////////////////////////////////////////////////// - // - // lexeme_scanner - // - // Given a Scanner, return the correct scanner type that - // the lexeme_d uses. Scanner is assumed to be a phrase - // level scanner (see skipper.hpp) - // - /////////////////////////////////////////////////////////////////////////// - template - struct lexeme_scanner - { - typedef scanner_policies< - no_skipper_iteration_policy< - typename ScannerT::iteration_policy_t>, - typename ScannerT::match_policy_t, - typename ScannerT::action_policy_t - > policies_t; - - typedef typename - rebind_scanner_policies::type type; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // inhibit_case_iteration_policy class - // - /////////////////////////////////////////////////////////////////////////// - template - struct inhibit_case_iteration_policy : public BaseT - { - typedef BaseT base_t; - - inhibit_case_iteration_policy() - : BaseT() {} - - template - inhibit_case_iteration_policy(PolicyT const& other) - : BaseT(other) {} - - template - CharT filter(CharT ch) const - { return impl::tolower_(ch); } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // inhibit_case class - // - /////////////////////////////////////////////////////////////////////////// - struct inhibit_case_parser_gen; - - template - struct inhibit_case - : public unary > > - { - typedef inhibit_case self_t; - typedef unary_parser_category parser_category_t; - typedef inhibit_case_parser_gen parser_generator_t; - typedef unary > base_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - inhibit_case(ParserT const& p) - : base_t(p) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - return impl::inhibit_case_parser_parse - (this->subject(), scan, scan); - } - }; - - template - struct inhibit_case_parser_gen_base - { - // This hack is needed to make borland happy. - // If these member operators were defined in the - // inhibit_case_parser_gen class, or if this class - // is non-templated, borland ICEs. - - static inhibit_case > - generate(char const* str) - { return inhibit_case >(str); } - - static inhibit_case > - generate(wchar_t const* str) - { return inhibit_case >(str); } - - static inhibit_case > - generate(char ch) - { return inhibit_case >(ch); } - - static inhibit_case > - generate(wchar_t ch) - { return inhibit_case >(ch); } - - template - static inhibit_case - generate(parser const& subject) - { return inhibit_case(subject.derived()); } - - inhibit_case > - operator[](char const* str) const - { return inhibit_case >(str); } - - inhibit_case > - operator[](wchar_t const* str) const - { return inhibit_case >(str); } - - inhibit_case > - operator[](char ch) const - { return inhibit_case >(ch); } - - inhibit_case > - operator[](wchar_t ch) const - { return inhibit_case >(ch); } - - template - inhibit_case - operator[](parser const& subject) const - { return inhibit_case(subject.derived()); } - }; - - ////////////////////////////////// - struct inhibit_case_parser_gen : public inhibit_case_parser_gen_base<0> - { - inhibit_case_parser_gen() {} - }; - - ////////////////////////////////// - // Depracated - const inhibit_case_parser_gen nocase_d = inhibit_case_parser_gen(); - - // Preferred syntax - const inhibit_case_parser_gen as_lower_d = inhibit_case_parser_gen(); - - /////////////////////////////////////////////////////////////////////////// - // - // as_lower_scanner - // - // Given a Scanner, return the correct scanner type that - // the as_lower_d uses. Scanner is assumed to be a scanner - // with an inhibit_case_iteration_policy. - // - /////////////////////////////////////////////////////////////////////////// - template - struct as_lower_scanner - { - typedef scanner_policies< - inhibit_case_iteration_policy< - typename ScannerT::iteration_policy_t>, - typename ScannerT::match_policy_t, - typename ScannerT::action_policy_t - > policies_t; - - typedef typename - rebind_scanner_policies::type type; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // longest_alternative class - // - /////////////////////////////////////////////////////////////////////////// - struct longest_parser_gen; - - template - struct longest_alternative - : public binary > > - { - typedef longest_alternative self_t; - typedef binary_parser_category parser_category_t; - typedef longest_parser_gen parser_generator_t; - typedef binary > base_t; - - longest_alternative(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typename ScannerT::iterator_t save = scan.first; - result_t l = this->left().parse(scan); - std::swap(scan.first, save); - result_t r = this->right().parse(scan); - - if (l || r) - { - if (l.length() > r.length()) - { - scan.first = save; - return l; - } - return r; - } - - return scan.no_match(); - } - }; - - struct longest_parser_gen - { - template - struct result { - - typedef typename - impl::to_longest_alternative >::result_t - type; - }; - - template - static typename - impl::to_longest_alternative >::result_t - generate(alternative const& alt) - { - return impl::to_longest_alternative >:: - convert(alt); - } - - //'generate' for binary composite - template - static - longest_alternative - generate(A const &left, B const &right) - { - return longest_alternative(left, right); - } - - template - typename impl::to_longest_alternative >::result_t - operator[](alternative const& alt) const - { - return impl::to_longest_alternative >:: - convert(alt); - } - }; - - const longest_parser_gen longest_d = longest_parser_gen(); - - /////////////////////////////////////////////////////////////////////////// - // - // shortest_alternative class - // - /////////////////////////////////////////////////////////////////////////// - struct shortest_parser_gen; - - template - struct shortest_alternative - : public binary > > - { - typedef shortest_alternative self_t; - typedef binary_parser_category parser_category_t; - typedef shortest_parser_gen parser_generator_t; - typedef binary > base_t; - - shortest_alternative(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typename ScannerT::iterator_t save = scan.first; - result_t l = this->left().parse(scan); - std::swap(scan.first, save); - result_t r = this->right().parse(scan); - - if (l || r) - { - if ((l.length() < r.length() && l) || !r) - { - scan.first = save; - return l; - } - return r; - } - - return scan.no_match(); - } - }; - - struct shortest_parser_gen - { - template - struct result { - - typedef typename - impl::to_shortest_alternative >::result_t - type; - }; - - template - static typename - impl::to_shortest_alternative >::result_t - generate(alternative const& alt) - { - return impl::to_shortest_alternative >:: - convert(alt); - } - - //'generate' for binary composite - template - static - shortest_alternative - generate(A const &left, B const &right) - { - return shortest_alternative(left, right); - } - - template - typename impl::to_shortest_alternative >::result_t - operator[](alternative const& alt) const - { - return impl::to_shortest_alternative >:: - convert(alt); - } - }; - - const shortest_parser_gen shortest_d = shortest_parser_gen(); - - /////////////////////////////////////////////////////////////////////////// - // - // min_bounded class - // - /////////////////////////////////////////////////////////////////////////// - template - struct min_bounded_gen; - - template - struct min_bounded - : public unary > > - { - typedef min_bounded self_t; - typedef unary_parser_category parser_category_t; - typedef min_bounded_gen parser_generator_t; - typedef unary > base_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - min_bounded(ParserT const& p, BoundsT const& min__) - : base_t(p) - , min_(min__) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - result_t hit = this->subject().parse(scan); - if (hit.has_valid_attribute() && hit.value() < min_) - return scan.no_match(); - return hit; - } - - BoundsT min_; - }; - - template - struct min_bounded_gen - { - min_bounded_gen(BoundsT const& min__) - : min_(min__) {} - - template - min_bounded - operator[](parser const& p) const - { return min_bounded(p.derived(), min_); } - - BoundsT min_; - }; - - template - inline min_bounded_gen - min_limit_d(BoundsT const& min_) - { return min_bounded_gen(min_); } - - /////////////////////////////////////////////////////////////////////////// - // - // max_bounded class - // - /////////////////////////////////////////////////////////////////////////// - template - struct max_bounded_gen; - - template - struct max_bounded - : public unary > > - { - typedef max_bounded self_t; - typedef unary_parser_category parser_category_t; - typedef max_bounded_gen parser_generator_t; - typedef unary > base_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - max_bounded(ParserT const& p, BoundsT const& max__) - : base_t(p) - , max_(max__) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - result_t hit = this->subject().parse(scan); - if (hit.has_valid_attribute() && hit.value() > max_) - return scan.no_match(); - return hit; - } - - BoundsT max_; - }; - - template - struct max_bounded_gen - { - max_bounded_gen(BoundsT const& max__) - : max_(max__) {} - - template - max_bounded - operator[](parser const& p) const - { return max_bounded(p.derived(), max_); } - - BoundsT max_; - }; - - ////////////////////////////////// - template - inline max_bounded_gen - max_limit_d(BoundsT const& max_) - { return max_bounded_gen(max_); } - - /////////////////////////////////////////////////////////////////////////// - // - // bounded class - // - /////////////////////////////////////////////////////////////////////////// - template - struct bounded_gen; - - template - struct bounded - : public unary > > - { - typedef bounded self_t; - typedef unary_parser_category parser_category_t; - typedef bounded_gen parser_generator_t; - typedef unary > base_t; - - template - struct result - { - typedef typename parser_result::type type; - }; - - bounded(ParserT const& p, BoundsT const& min__, BoundsT const& max__) - : base_t(p) - , min_(min__) - , max_(max__) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - result_t hit = this->subject().parse(scan); - if (hit.has_valid_attribute() && - (hit.value() < min_ || hit.value() > max_)) - return scan.no_match(); - return hit; - } - - BoundsT min_, max_; - }; - - template - struct bounded_gen - { - bounded_gen(BoundsT const& min__, BoundsT const& max__) - : min_(min__) - , max_(max__) {} - - template - bounded - operator[](parser const& p) const - { return bounded(p.derived(), min_, max_); } - - BoundsT min_, max_; - }; - - template - inline bounded_gen - limit_d(BoundsT const& min_, BoundsT const& max_) - { return bounded_gen(min_, max_); } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/exclusive_or.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/exclusive_or.hpp deleted file mode 100644 index 8810d12c4..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/exclusive_or.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_EXCLUSIVE_OR_HPP) -#define BOOST_SPIRIT_EXCLUSIVE_OR_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // exclusive_or class - // - // Handles expressions of the form: - // - // a ^ b - // - // where a and b are parsers. The expression returns a composite - // parser that matches a or b but not both. One (not both) of the - // operands may be a literal char, wchar_t or a primitive string - // char const*, wchar_t const*. - // - /////////////////////////////////////////////////////////////////////////// - struct exclusive_or_parser_gen; - - template - struct exclusive_or - : public binary > > - { - typedef exclusive_or self_t; - typedef binary_parser_category parser_category_t; - typedef exclusive_or_parser_gen parser_generator_t; - typedef binary > base_t; - - exclusive_or(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - - iterator_t save = scan.first; - result_t l = this->left().parse(scan); - std::swap(save, scan.first); - result_t r = this->right().parse(scan); - - if (l ? !bool(r) : bool(r)) - { - if (l) - scan.first = save; - return l ? l : r; - } - - return scan.no_match(); - } - }; - - struct exclusive_or_parser_gen - { - template - struct result - { - typedef - exclusive_or< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static exclusive_or< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return exclusive_or::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - exclusive_or - operator^(parser const& a, parser const& b); - - template - exclusive_or > - operator^(parser const& a, char b); - - template - exclusive_or, B> - operator^(char a, parser const& b); - - template - exclusive_or > - operator^(parser const& a, char const* b); - - template - exclusive_or, B> - operator^(char const* a, parser const& b); - - template - exclusive_or > - operator^(parser const& a, wchar_t b); - - template - exclusive_or, B> - operator^(wchar_t a, parser const& b); - - template - exclusive_or > - operator^(parser const& a, wchar_t const* b); - - template - exclusive_or, B> - operator^(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/alternative.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/alternative.ipp deleted file mode 100644 index cffa46c4f..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/alternative.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_ALTERNATIVE_IPP) -#define BOOST_SPIRIT_ALTERNATIVE_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // alternative class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline alternative - operator|(parser const& a, parser const& b) - { - return alternative(a.derived(), b.derived()); - } - - template - inline alternative > - operator|(parser const& a, char b) - { - return alternative >(a.derived(), b); - } - - template - inline alternative, B> - operator|(char a, parser const& b) - { - return alternative, B>(a, b.derived()); - } - - template - inline alternative > - operator|(parser const& a, char const* b) - { - return alternative >(a.derived(), b); - } - - template - inline alternative, B> - operator|(char const* a, parser const& b) - { - return alternative, B>(a, b.derived()); - } - - template - inline alternative > - operator|(parser const& a, wchar_t b) - { - return alternative >(a.derived(), b); - } - - template - inline alternative, B> - operator|(wchar_t a, parser const& b) - { - return alternative, B>(a, b.derived()); - } - - template - inline alternative > - operator|(parser const& a, wchar_t const* b) - { - return alternative >(a.derived(), b); - } - - template - inline alternative, B> - operator|(wchar_t const* a, parser const& b) - { - return alternative, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/difference.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/difference.ipp deleted file mode 100644 index f37c912d4..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/difference.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DIFFERENCE_IPP) -#define BOOST_SPIRIT_DIFFERENCE_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // difference class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline difference - operator-(parser const& a, parser const& b) - { - return difference(a.derived(), b.derived()); - } - - template - inline difference > - operator-(parser const& a, char b) - { - return difference >(a.derived(), b); - } - - template - inline difference, B> - operator-(char a, parser const& b) - { - return difference, B>(a, b.derived()); - } - - template - inline difference > - operator-(parser const& a, char const* b) - { - return difference >(a.derived(), b); - } - - template - inline difference, B> - operator-(char const* a, parser const& b) - { - return difference, B>(a, b.derived()); - } - - template - inline difference > - operator-(parser const& a, wchar_t b) - { - return difference >(a.derived(), b); - } - - template - inline difference, B> - operator-(wchar_t a, parser const& b) - { - return difference, B>(a, b.derived()); - } - - template - inline difference > - operator-(parser const& a, wchar_t const* b) - { - return difference >(a.derived(), b); - } - - template - inline difference, B> - operator-(wchar_t const* a, parser const& b) - { - return difference, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/directives.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/directives.ipp deleted file mode 100644 index 64af4389e..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/directives.ipp +++ /dev/null @@ -1,210 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2001 Bruce Florman - Copyright (c) 2002 Raghavendra Satish - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DIRECTIVES_IPP) -#define BOOST_SPIRIT_DIRECTIVES_IPP - -/////////////////////////////////////////////////////////////////////////////// -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - template - struct no_skipper_iteration_policy; - - template - struct inhibit_case_iteration_policy; - - template - struct alternative; - - template - struct longest_alternative; - - template - struct shortest_alternative; - - namespace impl - { - template - inline RT - contiguous_parser_parse( - ST const& s, - ScannerT const& scan, - skipper_iteration_policy const&) - { - typedef scanner_policies< - no_skipper_iteration_policy< - BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>, - BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t, - BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t - > policies_t; - - scan.skip(scan); - RT hit = s.parse(scan.change_policies(policies_t(scan))); - // We will not do a post skip!!! - return hit; - } - - template - inline RT - contiguous_parser_parse( - ST const& s, - ScannerT const& scan, - no_skipper_iteration_policy const&) - { - return s.parse(scan); - } - - template - inline RT - contiguous_parser_parse( - ST const& s, - ScannerT const& scan, - iteration_policy const&) - { - return s.parse(scan); - } - - template < - typename RT, - typename ParserT, - typename ScannerT, - typename BaseT> - inline RT - implicit_lexeme_parse( - ParserT const& p, - ScannerT const& scan, - skipper_iteration_policy const&) - { - typedef scanner_policies< - no_skipper_iteration_policy< - BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>, - BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t, - BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t - > policies_t; - - scan.skip(scan); - RT hit = p.parse_main(scan.change_policies(policies_t(scan))); - // We will not do a post skip!!! - return hit; - } - - template < - typename RT, - typename ParserT, - typename ScannerT, - typename BaseT> - inline RT - implicit_lexeme_parse( - ParserT const& p, - ScannerT const& scan, - no_skipper_iteration_policy const&) - { - return p.parse_main(scan); - } - - template - inline RT - implicit_lexeme_parse( - ParserT const& p, - ScannerT const& scan, - iteration_policy const&) - { - return p.parse_main(scan); - } - - template - inline RT - inhibit_case_parser_parse( - ST const& s, - ScannerT const& scan, - iteration_policy const&) - { - typedef scanner_policies< - inhibit_case_iteration_policy< - BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>, - BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t, - BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t - > policies_t; - - return s.parse(scan.change_policies(policies_t(scan))); - } - - template - inline RT - inhibit_case_parser_parse( - ST const& s, - ScannerT const& scan, - inhibit_case_iteration_policy const&) - { - return s.parse(scan); - } - - template - struct to_longest_alternative - { - typedef T result_t; - static result_t const& - convert(T const& a) // Special (end) case - { return a; } - }; - - template - struct to_longest_alternative > - { - typedef typename to_longest_alternative::result_t a_t; - typedef typename to_longest_alternative::result_t b_t; - typedef longest_alternative result_t; - - static result_t - convert(alternative const& alt) // Recursive case - { - return result_t( - to_longest_alternative::convert(alt.left()), - to_longest_alternative::convert(alt.right())); - } - }; - - template - struct to_shortest_alternative - { - typedef T result_t; - static result_t const& - convert(T const& a) // Special (end) case - { return a; } - }; - - template - struct to_shortest_alternative > - { - typedef typename to_shortest_alternative::result_t a_t; - typedef typename to_shortest_alternative::result_t b_t; - typedef shortest_alternative result_t; - - static result_t - convert(alternative const& alt) // Recursive case - { - return result_t( - to_shortest_alternative::convert(alt.left()), - to_shortest_alternative::convert(alt.right())); - } - }; - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/exclusive_or.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/exclusive_or.ipp deleted file mode 100644 index 1abe2b561..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/exclusive_or.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_EXCLUSIVE_OR_IPP) -#define BOOST_SPIRIT_EXCLUSIVE_OR_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // exclusive_or class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline exclusive_or - operator^(parser const& a, parser const& b) - { - return exclusive_or(a.derived(), b.derived()); - } - - template - inline exclusive_or > - operator^(parser const& a, char b) - { - return exclusive_or >(a.derived(), b); - } - - template - inline exclusive_or, B> - operator^(char a, parser const& b) - { - return exclusive_or, B>(a, b.derived()); - } - - template - inline exclusive_or > - operator^(parser const& a, char const* b) - { - return exclusive_or >(a.derived(), b); - } - - template - inline exclusive_or, B> - operator^(char const* a, parser const& b) - { - return exclusive_or, B>(a, b.derived()); - } - - template - inline exclusive_or > - operator^(parser const& a, wchar_t b) - { - return exclusive_or >(a.derived(), b); - } - - template - inline exclusive_or, B> - operator^(wchar_t a, parser const& b) - { - return exclusive_or, B>(a, b.derived()); - } - - template - inline exclusive_or > - operator^(parser const& a, wchar_t const* b) - { - return exclusive_or >(a.derived(), b); - } - - template - inline exclusive_or, B> - operator^(wchar_t const* a, parser const& b) - { - return exclusive_or, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/intersection.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/intersection.ipp deleted file mode 100644 index c51f57379..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/intersection.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_INTERSECTION_IPP) -#define BOOST_SPIRIT_INTERSECTION_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // intersection class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline intersection - operator&(parser const& a, parser const& b) - { - return intersection(a.derived(), b.derived()); - } - - template - inline intersection > - operator&(parser const& a, char b) - { - return intersection >(a.derived(), b); - } - - template - inline intersection, B> - operator&(char a, parser const& b) - { - return intersection, B>(a, b.derived()); - } - - template - inline intersection > - operator&(parser const& a, char const* b) - { - return intersection >(a.derived(), b); - } - - template - inline intersection, B> - operator&(char const* a, parser const& b) - { - return intersection, B>(a, b.derived()); - } - - template - inline intersection > - operator&(parser const& a, wchar_t b) - { - return intersection >(a.derived(), b); - } - - template - inline intersection, B> - operator&(wchar_t a, parser const& b) - { - return intersection, B>(a, b.derived()); - } - - template - inline intersection > - operator&(parser const& a, wchar_t const* b) - { - return intersection >(a.derived(), b); - } - - template - inline intersection, B> - operator&(wchar_t const* a, parser const& b) - { - return intersection, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/kleene_star.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/kleene_star.ipp deleted file mode 100644 index 421abe936..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/kleene_star.ipp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_KLEENE_STAR_IPP) -#define BOOST_SPIRIT_KLEENE_STAR_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // kleene_star class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline kleene_star - operator*(parser const& a) - { - return kleene_star(a.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/list.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/list.ipp deleted file mode 100644 index 72467aa84..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/list.ipp +++ /dev/null @@ -1,93 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_LIST_IPP) -#define BOOST_SPIRIT_LIST_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // operator% is defined as: - // a % b ---> a >> *(b >> a) - // - /////////////////////////////////////////////////////////////////////////// - template - inline sequence > > - operator%(parser const& a, parser const& b) - { - return a.derived() >> *(b.derived() >> a.derived()); - } - - template - inline sequence, A> > > - operator%(parser const& a, char b) - { - return a.derived() >> *(b >> a.derived()); - } - - template - inline sequence, kleene_star > > > - operator%(char a, parser const& b) - { - return a >> *(b.derived() >> a); - } - - template - inline sequence, A> > > - operator%(parser const& a, char const* b) - { - return a.derived() >> *(b >> a.derived()); - } - - template - inline sequence, - kleene_star > > > - operator%(char const* a, parser const& b) - { - return a >> *(b.derived() >> a); - } - - template - inline sequence, A> > > - operator%(parser const& a, wchar_t b) - { - return a.derived() >> *(b >> a.derived()); - } - - template - inline sequence, kleene_star > > > - operator%(wchar_t a, parser const& b) - { - return a >> *(b.derived() >> a); - } - - template - inline sequence, A> > > - operator%(parser const& a, wchar_t const* b) - { - return a.derived() >> *(b >> a.derived()); - } - - template - inline sequence, - kleene_star > > > - operator%(wchar_t const* a, parser const& b) - { - return a >> *(b.derived() >> a); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/optional.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/optional.ipp deleted file mode 100644 index cf235ec1a..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/optional.ipp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_OPTIONAL_IPP) -#define BOOST_SPIRIT_OPTIONAL_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // optional class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - optional - operator!(parser const& a) - { - return optional(a.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/positive.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/positive.ipp deleted file mode 100644 index bcef0905b..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/positive.ipp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_POSITIVE_IPP) -#define BOOST_SPIRIT_POSITIVE_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // positive class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline positive - operator+(parser const& a) - { - return positive(a.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequence.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequence.ipp deleted file mode 100644 index 5cc8fe1f0..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequence.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENCE_IPP) -#define BOOST_SPIRIT_SEQUENCE_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequence class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline sequence - operator>>(parser const& a, parser const& b) - { - return sequence(a.derived(), b.derived()); - } - - template - inline sequence > - operator>>(parser const& a, char b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator>>(char a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator>>(parser const& a, char const* b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator>>(char const* a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator>>(parser const& a, wchar_t b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator>>(wchar_t a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator>>(parser const& a, wchar_t const* b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator>>(wchar_t const* a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_and.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_and.ipp deleted file mode 100644 index 2cdcac8de..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_and.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENTIAL_AND_IPP) -#define BOOST_SPIRIT_SEQUENTIAL_AND_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequential-and operators implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline sequence - operator&&(parser const& a, parser const& b) - { - return sequence(a.derived(), b.derived()); - } - - template - inline sequence > - operator&&(parser const& a, char b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator&&(char a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator&&(parser const& a, char const* b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator&&(char const* a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator&&(parser const& a, wchar_t b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator&&(wchar_t a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - - template - inline sequence > - operator&&(parser const& a, wchar_t const* b) - { - return sequence >(a.derived(), b); - } - - template - inline sequence, B> - operator&&(wchar_t const* a, parser const& b) - { - return sequence, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_or.ipp b/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_or.ipp deleted file mode 100644 index 156db467b..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/impl/sequential_or.ipp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENTIAL_OR_IPP) -#define BOOST_SPIRIT_SEQUENTIAL_OR_IPP - -namespace autoboost { namespace spirit { - - BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequential-or class implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline sequential_or - operator||(parser const& a, parser const& b) - { - return sequential_or(a.derived(), b.derived()); - } - - template - inline sequential_or > - operator||(parser const& a, char b) - { - return sequential_or >(a.derived(), b); - } - - template - inline sequential_or, B> - operator||(char a, parser const& b) - { - return sequential_or, B>(a, b.derived()); - } - - template - inline sequential_or > - operator||(parser const& a, char const* b) - { - return sequential_or >(a.derived(), b); - } - - template - inline sequential_or, B> - operator||(char const* a, parser const& b) - { - return sequential_or, B>(a, b.derived()); - } - - template - inline sequential_or > - operator||(parser const& a, wchar_t b) - { - return sequential_or >(a.derived(), b); - } - - template - inline sequential_or, B> - operator||(wchar_t a, parser const& b) - { - return sequential_or, B>(a, b.derived()); - } - - template - inline sequential_or > - operator||(parser const& a, wchar_t const* b) - { - return sequential_or >(a.derived(), b); - } - - template - inline sequential_or, B> - operator||(wchar_t const* a, parser const& b) - { - return sequential_or, B>(a, b.derived()); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/intersection.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/intersection.hpp deleted file mode 100644 index b912d87e2..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/intersection.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_INTERSECTION_HPP) -#define BOOST_SPIRIT_INTERSECTION_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // intersection class - // - // Handles expressions of the form: - // - // a & b - // - // where a and b are parsers. The expression returns a composite - // parser that matches a and b. One (not both) of the operands may - // be a literal char, wchar_t or a primitive string char const*, - // wchar_t const*. - // - // The expression is short circuit evaluated. b is never touched - // when a is returns a no-match. - // - /////////////////////////////////////////////////////////////////////////// - struct intersection_parser_gen; - - template - struct intersection - : public binary > > - { - typedef intersection self_t; - typedef binary_parser_category parser_category_t; - typedef intersection_parser_gen parser_generator_t; - typedef binary > base_t; - - intersection(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - iterator_t save = scan.first; - if (result_t hl = this->left().parse(scan)) - { - ScannerT bscan(scan.first, scan.first, scan); - scan.first = save; - result_t hr = this->right().parse(bscan); - if (hl.length() == hr.length()) - return hl; - } - - return scan.no_match(); - } - }; - - struct intersection_parser_gen - { - template - struct result - { - typedef - intersection< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static intersection< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return intersection::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - intersection - operator&(parser const& a, parser const& b); - - template - intersection > - operator&(parser const& a, char b); - - template - intersection, B> - operator&(char a, parser const& b); - - template - intersection > - operator&(parser const& a, char const* b); - - template - intersection, B> - operator&(char const* a, parser const& b); - - template - intersection > - operator&(parser const& a, wchar_t b); - - template - intersection, B> - operator&(wchar_t a, parser const& b); - - template - intersection > - operator&(parser const& a, wchar_t const* b); - - template - intersection, B> - operator&(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/kleene_star.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/kleene_star.hpp deleted file mode 100644 index 85cc0fb3d..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/kleene_star.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_KLEENE_STAR_HPP) -#define BOOST_SPIRIT_KLEENE_STAR_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // kleene_star class - // - // Handles expressions of the form: - // - // *a - // - // where a is a parser. The expression returns a composite - // parser that matches its subject zero (0) or more times. - // - /////////////////////////////////////////////////////////////////////////// - struct kleene_star_parser_gen; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct kleene_star - : public unary > > - { - typedef kleene_star self_t; - typedef unary_parser_category parser_category_t; - typedef kleene_star_parser_gen parser_generator_t; - typedef unary > base_t; - - kleene_star(S const& a) - : base_t(a) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - result_t hit = scan.empty_match(); - - for (;;) - { - iterator_t save = scan.first; - if (result_t next = this->subject().parse(scan)) - { - scan.concat_match(hit, next); - } - else - { - scan.first = save; - return hit; - } - } - } - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - - struct kleene_star_parser_gen - { - template - struct result - { - typedef kleene_star type; - }; - - template - static kleene_star - generate(parser const& a) - { - return kleene_star(a.derived()); - } - }; - - ////////////////////////////////// - template - kleene_star - operator*(parser const& a); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/list.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/list.hpp deleted file mode 100644 index b1b9cc0a6..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/list.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_LIST_HPP) -#define BOOST_SPIRIT_LIST_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // operator% is defined as: - // a % b ---> a >> *(b >> a) - // - /////////////////////////////////////////////////////////////////////////// - template - sequence > > - operator%(parser const& a, parser const& b); - - template - sequence, A> > > - operator%(parser const& a, char b); - - template - sequence, kleene_star > > > - operator%(char a, parser const& b); - - template - sequence, A> > > - operator%(parser const& a, char const* b); - - template - sequence, - kleene_star > > > - operator%(char const* a, parser const& b); - - template - sequence, A> > > - operator%(parser const& a, wchar_t b); - - template - sequence, kleene_star > > > - operator%(wchar_t a, parser const& b); - - template - sequence, A> > > - operator%(parser const& a, wchar_t const* b); - - template - sequence, - kleene_star > > > - operator%(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/operators.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/operators.hpp deleted file mode 100644 index 5732ef9ae..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/operators.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_OPERATORS_HPP) -#define BOOST_SPIRIT_OPERATORS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/optional.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/optional.hpp deleted file mode 100644 index ef6c7f4fb..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/optional.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_OPTIONAL_HPP) -#define BOOST_SPIRIT_OPTIONAL_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // optional class - // - // Handles expressions of the form: - // - // !a - // - // where a is a parser. The expression returns a composite - // parser that matches its subject zero (0) or one (1) time. - // - /////////////////////////////////////////////////////////////////////////// - struct optional_parser_gen; - - template - struct optional - : public unary > > - { - typedef optional self_t; - typedef unary_parser_category parser_category_t; - typedef optional_parser_gen parser_generator_t; - typedef unary > base_t; - - optional(S const& a) - : base_t(a) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - iterator_t save = scan.first; - if (result_t r = this->subject().parse(scan)) - { - return r; - } - else - { - scan.first = save; - return scan.empty_match(); - } - } - }; - - struct optional_parser_gen - { - template - struct result - { - typedef optional type; - }; - - template - static optional - generate(parser const& a) - { - return optional(a.derived()); - } - }; - - template - optional - operator!(parser const& a); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/positive.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/positive.hpp deleted file mode 100644 index 0b478bab6..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/positive.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_POSITIVE_HPP) -#define BOOST_SPIRIT_POSITIVE_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // positive class - // - // Handles expressions of the form: - // - // +a - // - // where a is a parser. The expression returns a composite - // parser that matches its subject one (1) or more times. - // - /////////////////////////////////////////////////////////////////////////// - struct positive_parser_gen; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct positive - : public unary > > - { - typedef positive self_t; - typedef unary_parser_category parser_category_t; - typedef positive_parser_gen parser_generator_t; - typedef unary > base_t; - - positive(S const& a) - : base_t(a) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - result_t hit = this->subject().parse(scan); - - if (hit) - { - for (;;) - { - iterator_t save = scan.first; - if (result_t next = this->subject().parse(scan)) - { - scan.concat_match(hit, next); - } - else - { - scan.first = save; - break; - } - } - } - return hit; - } - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - - struct positive_parser_gen - { - template - struct result - { - typedef positive type; - }; - - template - static positive - generate(parser const& a) - { - return positive(a.derived()); - } - }; - - template - inline positive - operator+(parser const& a); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequence.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/sequence.hpp deleted file mode 100644 index 13069381d..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequence.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENCE_HPP) -#define BOOST_SPIRIT_SEQUENCE_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequence class - // - // Handles expressions of the form: - // - // a >> b - // - // where a and b are parsers. The expression returns a composite - // parser that matches a and b in sequence. One (not both) of the - // operands may be a literal char, wchar_t or a primitive string - // char const*, wchar_t const*. - // - ////////////////////////////////////////////////////////////////////////// - struct sequence_parser_gen; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct sequence : public binary > > - { - typedef sequence self_t; - typedef binary_parser_category parser_category_t; - typedef sequence_parser_gen parser_generator_t; - typedef binary > base_t; - - sequence(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - if (result_t ma = this->left().parse(scan)) - if (result_t mb = this->right().parse(scan)) - { - scan.concat_match(ma, mb); - return ma; - } - return scan.no_match(); - } - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - - struct sequence_parser_gen - { - template - struct result - { - typedef - sequence< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static sequence< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return sequence::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - sequence - operator>>(parser const& a, parser const& b); - - template - sequence > - operator>>(parser const& a, char b); - - template - sequence, B> - operator>>(char a, parser const& b); - - template - sequence > - operator>>(parser const& a, char const* b); - - template - sequence, B> - operator>>(char const* a, parser const& b); - - template - sequence > - operator>>(parser const& a, wchar_t b); - - template - sequence, B> - operator>>(wchar_t a, parser const& b); - - template - sequence > - operator>>(parser const& a, wchar_t const* b); - - template - sequence, B> - operator>>(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_and.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_and.hpp deleted file mode 100644 index da9b80319..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_and.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENTIAL_AND_HPP) -#define BOOST_SPIRIT_SEQUENTIAL_AND_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequential-and operators - // - // Handles expressions of the form: - // - // a && b - // - // Same as a >> b. - // - /////////////////////////////////////////////////////////////////////////// - template - sequence - operator&&(parser const& a, parser const& b); - - template - sequence > - operator&&(parser const& a, char b); - - template - sequence, B> - operator&&(char a, parser const& b); - - template - sequence > - operator&&(parser const& a, char const* b); - - template - sequence, B> - operator&&(char const* a, parser const& b); - - template - sequence > - operator&&(parser const& a, wchar_t b); - - template - sequence, B> - operator&&(wchar_t a, parser const& b); - - template - sequence > - operator&&(parser const& a, wchar_t const* b); - - template - sequence, B> - operator&&(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_or.hpp b/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_or.hpp deleted file mode 100644 index e04afcf6c..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/composite/sequential_or.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - Copyright (c) 2002 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SEQUENTIAL_OR_HPP) -#define BOOST_SPIRIT_SEQUENTIAL_OR_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // sequential-or class - // - // Handles expressions of the form: - // - // a || b - // - // Equivalent to - // - // a | b | a >> b; - // - // where a and b are parsers. The expression returns a composite - // parser that matches matches a or b in sequence. One (not both) of - // the operands may be a literal char, wchar_t or a primitive string - // char const*, wchar_t const*. - // - /////////////////////////////////////////////////////////////////////////// - struct sequential_or_parser_gen; - - template - struct sequential_or : public binary > > - { - typedef sequential_or self_t; - typedef binary_parser_category parser_category_t; - typedef sequential_or_parser_gen parser_generator_t; - typedef binary > base_t; - - sequential_or(A const& a, B const& b) - : base_t(a, b) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::iterator_t iterator_t; - { // scope for save - iterator_t save = scan.first; - if (result_t ma = this->left().parse(scan)) - { - save = scan.first; - if (result_t mb = this->right().parse(scan)) - { - // matched a b - scan.concat_match(ma, mb); - return ma; - } - else - { - // matched a - scan.first = save; - return ma; - } - } - scan.first = save; - } - - // matched b - return this->right().parse(scan); - } - }; - - struct sequential_or_parser_gen - { - template - struct result - { - typedef - sequential_or< - typename as_parser::type - , typename as_parser::type - > - type; - }; - - template - static sequential_or< - typename as_parser::type - , typename as_parser::type - > - generate(A const& a, B const& b) - { - return sequential_or::type, - BOOST_DEDUCED_TYPENAME as_parser::type> - (as_parser::convert(a), as_parser::convert(b)); - } - }; - - template - sequential_or - operator||(parser const& a, parser const& b); - - template - sequential_or > - operator||(parser const& a, char b); - - template - sequential_or, B> - operator||(char a, parser const& b); - - template - sequential_or > - operator||(parser const& a, char const* b); - - template - sequential_or, B> - operator||(char const* a, parser const& b); - - template - sequential_or > - operator||(parser const& a, wchar_t b); - - template - sequential_or, B> - operator||(wchar_t a, parser const& b); - - template - sequential_or > - operator||(parser const& a, wchar_t const* b); - - template - sequential_or, B> - operator||(wchar_t const* a, parser const& b); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/config.hpp b/contrib/autoboost/boost/spirit/home/classic/core/config.hpp deleted file mode 100644 index 57eca7f03..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/config.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_CONFIG_HPP) -#define BOOST_SPIRIT_CONFIG_HPP - -#include - -/////////////////////////////////////////////////////////////////////////////// -// -// Compiler check: -// -// Historically, Spirit supported a lot of compilers, including (to some -// extent) poorly conforming compilers such as VC6. Spirit v1.6.x will be -// the last release that will support older poorly conforming compilers. -// Starting from Spirit v1.8.0, ill conforming compilers will not be -// supported. If you are still using one of these older compilers, you can -// still use Spirit v1.6.x. -// -// The reason why Spirit v1.6.x worked on old non-conforming compilers is -// that the authors laboriously took the trouble of searching for -// workarounds to make these compilers happy. The process takes a lot of -// time and energy, especially when one encounters the dreaded ICE or -// "Internal Compiler Error". Sometimes searching for a single workaround -// takes days or even weeks. Sometimes, there are no known workarounds. This -// stifles progress a lot. And, as the library gets more progressive and -// takes on more advanced C++ techniques, the difficulty is escalated to -// even new heights. -// -// Spirit v1.6.x will still be supported. Maintenance and bug fixes will -// still be applied. There will still be active development for the back- -// porting of new features introduced in Spirit v1.8.0 (and Spirit 1.9.0) -// to lesser able compilers; hopefully, fueled by contributions from the -// community. For instance, there is already a working AST tree back-port -// for VC6 and VC7 by Peder Holt. -// -// If you got here somehow, your compiler is known to be poorly conforming -// WRT ANSI/ISO C++ standard. Library implementers get a bad reputation when -// someone attempts to compile the code on a non-conforming compiler. She'll -// be confronted with tons of compiler errors when she tries to compile the -// library. Such errors will somehow make less informed users conclude that -// the code is poorly written. It's better for the user to see a message -// "sorry, this code has not been ported to your compiler yet", than to see -// pages and pages of compiler error messages. -// -///////////////////////////////////////////////////////////////////////////////// -#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1310)) \ - || (defined(__BORLANDC__) && (__BORLANDC__ <= 0x570)) \ - || (defined(__GNUC__) && (__GNUC__ < 3)) \ - || (defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) -# error "Compiler not supported. See note in " -#else -// Pass... Compiler supported. -#endif - -#endif - - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/impl/match.ipp b/contrib/autoboost/boost/spirit/home/classic/core/impl/match.ipp deleted file mode 100644 index dcd32ff4d..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/impl/match.ipp +++ /dev/null @@ -1,113 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_MATCH_IPP) -#define BOOST_SPIRIT_MATCH_IPP -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - template - inline match::match() - : len(-1), val() {} - - template - inline match::match(std::size_t length_) - : len(length_), val() {} - - template - inline match::match(std::size_t length_, ctor_param_t val_) - : len(length_), val(val_) {} - - template - inline bool - match::operator!() const - { - return len < 0; - } - - template - inline std::ptrdiff_t - match::length() const - { - return len; - } - - template - inline bool - match::has_valid_attribute() const - { - return val.is_initialized(); - } - - template - inline typename match::return_t - match::value() const - { - BOOST_SPIRIT_ASSERT(val.is_initialized()); - return *val; - } - - template - inline void - match::swap(match& other) - { - std::swap(len, other.len); - std::swap(val, other.val); - } - - inline match::match() - : len(-1) {} - - inline match::match(std::size_t length_) - : len(length_) {} - - inline match::match(std::size_t length_, nil_t) - : len(length_) {} - - inline bool - match::operator!() const - { - return len < 0; - } - - inline bool - match::has_valid_attribute() const - { - return false; - } - - inline std::ptrdiff_t - match::length() const - { - return len; - } - - inline nil_t - match::value() const - { - return nil_t(); - } - - inline void - match::value(nil_t) {} - - inline void - match::swap(match& other) - { - std::swap(len, other.len); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/impl/match_attr_traits.ipp b/contrib/autoboost/boost/spirit/home/classic/core/impl/match_attr_traits.ipp deleted file mode 100644 index 6e9b6c67c..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/impl/match_attr_traits.ipp +++ /dev/null @@ -1,102 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_MATCH_ATTR_TRAITS_IPP) -#define BOOST_SPIRIT_MATCH_ATTR_TRAITS_IPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -namespace impl -{ - template - struct match_attr_traits - { - typedef typename - autoboost::optional::reference_const_type - const_reference; - - // case where src *IS* convertible to T (dest) - template - static void - convert(autoboost::optional& dest, T2 const& src, mpl::true_) - { - dest.reset(src); - } - - // case where src *IS NOT* convertible to T (dest) - template - static void - convert(autoboost::optional& dest, T2 const& /*src*/, mpl::false_) - { - dest.reset(); - } - - static void - convert(autoboost::optional& dest, nil_t/*src*/) - { - dest.reset(); - } - - template - static void - convert(autoboost::optional& dest, T2 const& src) - { - convert(dest, src, is_convertible()); - } - - template - static void - copy(autoboost::optional& dest, OtherMatchT const& src) - { - if (src.has_valid_attribute()) - convert(dest, src.value()); - } - - template - static void - assign(autoboost::optional& dest, OtherMatchT const& src) - { - if (src.has_valid_attribute()) - convert(dest, src.value()); - else - dest.reset(); - } - - // T is not reference - template - static void - set_value(autoboost::optional& dest, ValueT const& val, mpl::false_) - { - dest.reset(val); - } - - // T is a reference - template - static void - set_value(autoboost::optional& dest, ValueT const& val, mpl::true_) - { - dest.get() = val; - } - }; - -} - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit::impl - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/impl/parser.ipp b/contrib/autoboost/boost/spirit/home/classic/core/impl/parser.ipp deleted file mode 100644 index 30a94c9a0..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/impl/parser.ipp +++ /dev/null @@ -1,55 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PARSER_IPP) -#define BOOST_SPIRIT_PARSER_IPP - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // Generic parse function implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline parse_info - parse( - IteratorT const& first_ - , IteratorT const& last - , parser const& p) - { - IteratorT first = first_; - scanner > scan(first, last); - match hit = p.derived().parse(scan); - return parse_info( - first, hit, hit && (first == last), hit.length()); - } - - /////////////////////////////////////////////////////////////////////////// - // - // Parse function for null terminated strings implementation - // - /////////////////////////////////////////////////////////////////////////// - template - inline parse_info - parse(CharT const* str, parser const& p) - { - CharT const* last = str; - while (*last) - last++; - return parse(str, last, p); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/match.hpp b/contrib/autoboost/boost/spirit/home/classic/core/match.hpp deleted file mode 100644 index 32136bd55..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/match.hpp +++ /dev/null @@ -1,185 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_MATCH_HPP) -#define BOOST_SPIRIT_MATCH_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // match class - // - // The match holds the result of a parser. A match object evaluates - // to true when a successful match is found, otherwise false. The - // length of the match is the number of characters (or tokens) that - // is successfully matched. This can be queried through its length() - // member function. A negative value means that the match is - // unsucessful. - // - // Each parser may have an associated attribute. This attribute is - // also returned back to the client on a successful parse through - // the match object. The match's value() member function returns the - // match's attribute. - // - // A match attribute is valid: - // - // * on a successful match - // * when its value is set through the value(val) member function - // * if it is assigned or copied from a compatible match object - // (e.g. match from match) with a valid attribute. - // - // The match attribute is undefined: - // - // * on an unsuccessful match - // * when an attempt to copy or assign from another match object - // with an incompatible attribute type (e.g. match - // from match). - // - // The member function has_valid_attribute() can be queried to know if - // it is safe to get the match's attribute. The attribute may be set - // through the member function value(v) where v is the new attribute - // value. - // - /////////////////////////////////////////////////////////////////////////// - template - class match : public safe_bool > - { - - public: - - typedef typename autoboost::optional optional_type; - typedef typename optional_type::argument_type ctor_param_t; - typedef typename optional_type::reference_const_type return_t; - typedef T attr_t; - - match(); - explicit match(std::size_t length); - match(std::size_t length, ctor_param_t val); - - bool operator!() const; - std::ptrdiff_t length() const; - bool has_valid_attribute() const; - return_t value() const; - void swap(match& other); - - template - match(match const& other) - : len(other.length()), val() - { - impl::match_attr_traits::copy(val, other); - } - - template - match& - operator=(match const& other) - { - impl::match_attr_traits::assign(val, other); - len = other.length(); - return *this; - } - - template - void - concat(MatchT const& other) - { - BOOST_SPIRIT_ASSERT(*this && other); - len += other.length(); - } - - template - void - value(ValueT const& val_) - { - impl::match_attr_traits::set_value(val, val_, is_reference()); - } - - bool operator_bool() const - { - return len >= 0; - } - - private: - - std::ptrdiff_t len; - optional_type val; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // match class specialization for nil_t values - // - /////////////////////////////////////////////////////////////////////////// - template <> - class match : public safe_bool > - { - public: - - typedef nil_t attr_t; - typedef nil_t return_t; - - match(); - explicit match(std::size_t length); - match(std::size_t length, nil_t); - - bool operator!() const; - bool has_valid_attribute() const; - std::ptrdiff_t length() const; - nil_t value() const; - void value(nil_t); - void swap(match& other); - - template - match(match const& other) - : len(other.length()) {} - - template - match<>& - operator=(match const& other) - { - len = other.length(); - return *this; - } - - template - void - concat(match const& other) - { - BOOST_SPIRIT_ASSERT(*this && other); - len += other.length(); - } - - bool operator_bool() const - { - return len >= 0; - } - - private: - - std::ptrdiff_t len; - }; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif -#include - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/nil.hpp b/contrib/autoboost/boost/spirit/home/classic/core/nil.hpp deleted file mode 100644 index b0d171c6e..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/nil.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_NIL_HPP) -#define BOOST_SPIRIT_NIL_HPP - -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - struct nil_t {}; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} - -#endif - - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp b/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp deleted file mode 100644 index 9db5531cf..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp +++ /dev/null @@ -1,420 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_RULE_IPP) -#define BOOST_SPIRIT_RULE_IPP - -#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 -#include -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 - - template < - BOOST_PP_ENUM_BINARY_PARAMS( - BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT, - typename ScannerT, = mpl::void_ BOOST_PP_INTERCEPT - ) - > - struct scanner_list; - -#endif // BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 - - /////////////////////////////////////////////////////////////////////////// - namespace impl - { - template - struct get_param - { - typedef typename mpl::if_< - is_base_and_derived - , T0 - , typename mpl::if_< - is_base_and_derived - , T1 - , typename mpl::if_< - is_base_and_derived - , T2 - , DefaultT - >::type - >::type - >::type type; - }; - - template - struct get_context - { - typedef typename get_param< - parser_context_base, parser_context<>, T0, T1, T2>::type - type; - }; - - template - struct get_tag - { - typedef typename get_param< - parser_tag_base, parser_address_tag, T0, T1, T2>::type - type; - }; - - template - struct get_scanner - { - typedef typename get_param< - scanner_base, scanner<>, T0, T1, T2>::type - type; - }; - - /////////////////////////////////////////////////////////////////////// - // - // rule_base class - // - // The rule_base class implements the basic plumbing for rules - // minus the storage mechanism. It is up to the derived class - // to actually store the definition somewhere. The rule_base - // class assumes that the derived class provides a get() function - // that will return a pointer to a parser. The get() function - // may return NULL. See rule below for details. - // - // <<< For framework use only. Not for public consumption. >>> - // - /////////////////////////////////////////////////////////////////////// - template < - typename DerivedT // derived class - , typename EmbedT // how derived class is embedded - , typename T0 = nil_t // see rule class - , typename T1 = nil_t // see rule class - , typename T2 = nil_t // see rule class - > - class rule_base; // forward declaration - - class rule_base_access - { -#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - public: // YUCK! -#else - template < - typename DerivedT - , typename EmbedT - , typename T0 - , typename T1 - , typename T2 - > - friend class rule_base; -#endif - template - static typename RuleT::abstract_parser_t* - get(RuleT const& r) - { - return r.get(); - } - }; - - template < - typename DerivedT // derived class - , typename EmbedT // how derived class is embedded - , typename T0 // see rule class - , typename T1 // see rule class - , typename T2 // see rule class - > - class rule_base - : public parser - , public impl::get_context::type::base_t - , public context_aux< - typename impl::get_context::type, DerivedT> - , public impl::get_tag::type - { - public: - - typedef typename impl::get_scanner::type scanner_t; - typedef typename impl::get_context::type context_t; - typedef typename impl::get_tag::type tag_t; - - typedef EmbedT embed_t; - typedef typename context_t::context_linker_t linked_context_t; - typedef typename linked_context_t::attr_t attr_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef parser_scanner_linker linked_scanner_t; - typedef typename parser_result::type result_t; - BOOST_SPIRIT_CONTEXT_PARSE( - scan, *this, linked_scanner_t, linked_context_t, result_t); - } - - template - typename parser_result::type - parse_main(ScannerT const& scan) const - { - typename parser_result::type hit; - - // MWCW 8.3 needs this cast to be done through a pointer, - // not a reference. Otherwise, it will silently construct - // a temporary, causing an infinite runtime recursion. - DerivedT const* derived_this = static_cast(this); - - if (rule_base_access::get(*derived_this)) - { - typename ScannerT::iterator_t s(scan.first); - hit = rule_base_access::get(*derived_this) - ->do_parse_virtual(scan); - scan.group_match(hit, this->id(), s, scan.first); - } - else - { - hit = scan.no_match(); - } - return hit; - } - }; - - /////////////////////////////////////////////////////////////////////// - // - // abstract_parser class - // - /////////////////////////////////////////////////////////////////////// - template - struct abstract_parser - { - abstract_parser() {} - virtual ~abstract_parser() {} - - virtual typename match_result::type - do_parse_virtual(ScannerT const& scan) const = 0; - - virtual abstract_parser* - clone() const = 0; - }; - - /////////////////////////////////////////////////////////////////////// - // - // concrete_parser class - // - /////////////////////////////////////////////////////////////////////// -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(push) -#pragma warning(disable:4512) //assignment operator could not be generated -#endif - - template - struct concrete_parser : abstract_parser - { - concrete_parser(ParserT const& p_) : p(p_) {} - virtual ~concrete_parser() {} - - virtual typename match_result::type - do_parse_virtual(ScannerT const& scan) const - { - return p.parse(scan); - } - - virtual abstract_parser* - clone() const - { - return new concrete_parser(p); - } - - typename ParserT::embed_t p; - }; - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -#pragma warning(pop) -#endif - -#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 - - /////////////////////////////////////////////////////////////////////// - // - // This generates partial specializations for the class - // - // abstract_parser - // - // with an increasing number of different ScannerT template parameters - // and corresponding do_parse_virtual function declarations for each - // of the different required scanner types: - // - // template - // struct abstract_parser, AttrT> - // { - // abstract_parser() {} - // virtual ~abstract_parser() {} - // - // virtual typename match_result::type - // do_parse_virtual(ScannerT0 const &scan) const = 0; - // - // virtual abstract_parser* - // clone() const = 0; - // - // ... - // }; - // - /////////////////////////////////////////////////////////////////////// - #define BOOST_SPIRIT_RULE_ENUM_DOPARSE_A(z, N, _) \ - virtual typename match_result< \ - BOOST_PP_CAT(ScannerT, N), AttrT \ - >::type \ - do_parse_virtual( \ - BOOST_PP_CAT(ScannerT, N) const& scan) const = 0; \ - - #define BOOST_SPIRIT_ENUM_ABSTRACT_PARSERS(z, N, _) \ - template < \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), typename ScannerT), \ - typename AttrT \ - > \ - struct abstract_parser< \ - scanner_list< \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), ScannerT) \ - >, \ - AttrT \ - > \ - { \ - abstract_parser() {} \ - virtual ~abstract_parser() {} \ - \ - BOOST_PP_REPEAT_ ## z( \ - BOOST_PP_INC(N), BOOST_SPIRIT_RULE_ENUM_DOPARSE_A, _) \ - \ - virtual abstract_parser* \ - clone() const = 0; \ - }; \ - - BOOST_PP_REPEAT_FROM_TO(1, BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT, - BOOST_SPIRIT_ENUM_ABSTRACT_PARSERS, _) - - #undef BOOST_SPIRIT_RULE_ENUM_DOPARSE_A - #undef BOOST_SPIRIT_ENUM_ABSTRACT_PARSERS - /////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////// - // - // This generates partial specializations for the class - // - // concrete_parser - // - // with an increasing number of different ScannerT template parameters - // and corresponding do_parse_virtual function declarations for each - // of the different required scanner types: - // - // template < - // typename ParserT, typename ScannerT0, ..., typename AttrT - // > - // struct concrete_parser< - // ParserT, scanner_list, AttrT - // > - // : public abstract_parser, AttrT> - // { - // concrete_parser(ParserT const& p_) : p(p_) {} - // virtual ~concrete_parser() {} - // - // virtual typename match_result::type - // do_parse_virtual(ScannerT0 const &scan) const - // { return p.parse(scan); } - // - // virtual abstract_parser, AttrT>* - // clone() const - // { - // return new concrete_parser(p); - // } - // - // ... - // - // typename ParserT::embed_t p; - // }; - // - /////////////////////////////////////////////////////////////////////// - #define BOOST_SPIRIT_RULE_ENUM_DOPARSE_C(z, N, _) \ - virtual typename match_result< \ - BOOST_PP_CAT(ScannerT, N), AttrT \ - >::type \ - do_parse_virtual( \ - BOOST_PP_CAT(ScannerT, N) const& scan) const \ - { return p.parse(scan); } \ - - #define BOOST_SPIRIT_ENUM_CONCRETE_PARSERS(z, N, _) \ - template < \ - typename ParserT, \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), typename ScannerT), \ - typename AttrT \ - > \ - struct concrete_parser< \ - ParserT, \ - scanner_list< \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), ScannerT) \ - >, \ - AttrT \ - > \ - : abstract_parser< \ - scanner_list< \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), ScannerT) \ - >, \ - AttrT \ - > \ - { \ - concrete_parser(ParserT const& p_) : p(p_) {} \ - virtual ~concrete_parser() {} \ - \ - BOOST_PP_REPEAT_ ## z( \ - BOOST_PP_INC(N), BOOST_SPIRIT_RULE_ENUM_DOPARSE_C, _) \ - \ - virtual abstract_parser< \ - scanner_list< \ - BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(N), ScannerT) \ - >, \ - AttrT \ - >* \ - clone() const \ - { \ - return new concrete_parser(p); \ - } \ - \ - typename ParserT::embed_t p; \ - }; \ - - BOOST_PP_REPEAT_FROM_TO(1, BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT, - BOOST_SPIRIT_ENUM_CONCRETE_PARSERS, _) - - #undef BOOST_SPIRIT_ENUM_CONCRETE_PARSERS - #undef BOOST_SPIRIT_RULE_ENUM_DOPARSE_C - /////////////////////////////////////////////////////////////////////// - -#endif // BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 - - } // namespace impl - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_context.hpp b/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_context.hpp deleted file mode 100644 index 3d6759055..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_context.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================= - Copyright (c) 2002-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PARSER_CONTEXT_HPP) -#define BOOST_SPIRIT_PARSER_CONTEXT_HPP - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost -{ - namespace spirit - { - BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - - /////////////////////////////////////////////////////////////////////////// - // - // default_parser_context_base class { default context base } - // - /////////////////////////////////////////////////////////////////////////// - struct default_parser_context_base - { - template - struct aux {}; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_context_base class { base class of all context classes } - // - /////////////////////////////////////////////////////////////////////////// - struct parser_context_base {}; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_context class { default context } - // - /////////////////////////////////////////////////////////////////////////// - struct nil_t; - template struct parser_context_linker; - - template - struct parser_context : parser_context_base - { - typedef AttrT attr_t; - typedef default_parser_context_base base_t; - typedef parser_context_linker > context_linker_t; - - template - parser_context(ParserT const&) {} - - template - void - pre_parse(ParserT const&, ScannerT const&) {} - - template - ResultT& - post_parse(ResultT& hit, ParserT const&, ScannerT const&) - { return hit; } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // context_aux class - // - // context_aux is a class derived from the - // ContextT's nested base_t::base template class. (see - // default_parser_context_base::aux for an example). - // - // Basically, this class provides ContextT dependent optional - // functionality to the derived class DerivedT through the CRTP - // idiom (Curiously recurring template pattern). - // - /////////////////////////////////////////////////////////////////////////// - template - struct context_aux : public ContextT::base_t::template aux {}; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_scanner_linker and parser_scanner_linker classes - // { helper templates for the rule extensibility } - // - // This classes can be 'overloaded' (defined elsewhere), to plug - // in additional functionality into the non-terminal parsing process. - // - /////////////////////////////////////////////////////////////////////////// - #if !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) - #define BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED - - template - struct parser_scanner_linker : public ScannerT - { - parser_scanner_linker(ScannerT const scan_) : ScannerT(scan_) {} - }; - - #endif // !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) - - ////////////////////////////////// - #if !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) - #define BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED - - template - struct parser_context_linker : public ContextT - { - template - parser_context_linker(ParserT const& p) - : ContextT(p) {} - - template - void pre_parse(ParserT const& p, ScannerT const& scan) - { ContextT::pre_parse(p, scan); } - - template - ResultT& - post_parse(ResultT& hit, ParserT const& p, ScannerT const& scan) - { return ContextT::post_parse(hit, p, scan); } - }; - - #endif // !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) - - /////////////////////////////////////////////////////////////////////////// - // - // BOOST_SPIRIT_CONTEXT_PARSE helper macro - // - // The original implementation uses a template class. However, we - // need to lessen the template instantiation depth to help inferior - // compilers that sometimes choke on deep template instantiations. - // The objective is to avoid code redundancy. A macro, in this case - // is an obvious solution. Sigh! - // - // WARNING: INTERNAL USE ONLY. NOT FOR PUBLIC CONSUMPTION. - // - /////////////////////////////////////////////////////////////////////////// - #define BOOST_SPIRIT_CONTEXT_PARSE(scan, this_, scanner_t, context_t, result_t) \ - scanner_t scan_wrap(scan); \ - context_t context_wrap(this_); \ - context_wrap.pre_parse(this_, scan_wrap); \ - result_t hit = parse_main(scan); \ - return context_wrap.post_parse(hit, this_, scan_wrap); - - BOOST_SPIRIT_CLASSIC_NAMESPACE_END - - } // namespace spirit -} // namespace autoboost - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_id.hpp b/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_id.hpp deleted file mode 100644 index 87c1d60f1..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/parser_id.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001 Daniel Nuffer - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PARSER_ID_HPP) -#define BOOST_SPIRIT_PARSER_ID_HPP - -#if defined(BOOST_SPIRIT_DEBUG) -# include -#endif -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // parser_id class - // - /////////////////////////////////////////////////////////////////////////// - class parser_id - { - public: - parser_id() : p(0) {} - explicit parser_id(void const* prule) : p(prule) {} - parser_id(std::size_t l_) : l(l_) {} - - bool operator==(parser_id const& x) const { return p == x.p; } - bool operator!=(parser_id const& x) const { return !(*this == x); } - bool operator<(parser_id const& x) const { return p < x.p; } - std::size_t to_long() const { return l; } - - private: - - union - { - void const* p; - std::size_t l; - }; - }; - - #if defined(BOOST_SPIRIT_DEBUG) - inline std::ostream& - operator<<(std::ostream& out, parser_id const& rid) - { - out << (unsigned int)rid.to_long(); - return out; - } - #endif - - /////////////////////////////////////////////////////////////////////////// - // - // parser_tag_base class: base class of all parser tags - // - /////////////////////////////////////////////////////////////////////////// - struct parser_tag_base {}; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_address_tag class: tags a parser with its address - // - /////////////////////////////////////////////////////////////////////////// - struct parser_address_tag : parser_tag_base - { - parser_id id() const - { return parser_id(reinterpret_cast(this)); } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_tag class: tags a parser with an integer ID - // - /////////////////////////////////////////////////////////////////////////// - template - struct parser_tag : parser_tag_base - { - static parser_id id() - { return parser_id(std::size_t(N)); } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // dynamic_parser_tag class: tags a parser with a dynamically changeable - // integer ID - // - /////////////////////////////////////////////////////////////////////////// - class dynamic_parser_tag : public parser_tag_base - { - public: - - dynamic_parser_tag() - : tag(std::size_t(0)) {} - - parser_id - id() const - { - return - tag.to_long() - ? tag - : parser_id(reinterpret_cast(this)); - } - - void set_id(parser_id id_) { tag = id_; } - - private: - - parser_id tag; - }; - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/rule.hpp b/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/rule.hpp deleted file mode 100644 index 638452952..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/non_terminal/rule.hpp +++ /dev/null @@ -1,175 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_RULE_HPP) -#define BOOST_SPIRIT_RULE_HPP - -#include - -/////////////////////////////////////////////////////////////////////////////// -// -// Spirit predefined maximum number of simultaneously usable different -// scanner types. -// -// This limit defines the maximum number of possible different scanner -// types for which a specific rule<> may be used. If this isn't defined, a -// rule<> may be used with one scanner type only (multiple scanner support -// is disabled). -// -/////////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT) -# define BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT 1 -#endif - -// Ensure a meaningful maximum number of simultaneously usable scanner types -BOOST_STATIC_ASSERT(BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 0); - -#include -#include -#include - -#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 -# include -#endif - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1 - - /////////////////////////////////////////////////////////////////////////// - // - // scanner_list (a fake scanner) - // - // Typically, rules are tied to a specific scanner type and - // a particular rule cannot be used with anything else. Sometimes - // there's a need for rules that can accept more than one scanner - // type. The scanner_list can be used as a template - // parameter to the rule class to specify up to the number of - // scanner types defined by the BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT - // constant. Example: - // - // rule > r; - // - // *** This feature is available only to compilers that support - // partial template specialization. *** - // - /////////////////////////////////////////////////////////////////////////// - template < - BOOST_PP_ENUM_PARAMS( - BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT, - typename ScannerT - ) - > - struct scanner_list : scanner_base {}; - -#endif - - /////////////////////////////////////////////////////////////////////////// - // - // rule class - // - // The rule is a polymorphic parser that acts as a named place- - // holder capturing the behavior of an EBNF expression assigned to - // it. - // - // The rule is a template class parameterized by: - // - // 1) scanner (scanner_t, see scanner.hpp), - // 2) the rule's context (context_t, see parser_context.hpp) - // 3) an arbitrary tag (tag_t, see parser_id.hpp) that allows - // a rule to be tagged for identification. - // - // These template parameters may be specified in any order. The - // scanner will default to scanner<> when it is not specified. - // The context will default to parser_context when not specified. - // The tag will default to parser_address_tag when not specified. - // - // The definition of the rule (its right hand side, RHS) held by - // the rule through a scoped_ptr. When a rule is seen in the RHS - // of an assignment or copy construction EBNF expression, the rule - // is held by the LHS rule by reference. - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T0 = nil_t - , typename T1 = nil_t - , typename T2 = nil_t - > - class rule - : public impl::rule_base< - rule - , rule const& - , T0, T1, T2> - { - public: - - typedef rule self_t; - typedef impl::rule_base< - self_t - , self_t const& - , T0, T1, T2> - base_t; - - typedef typename base_t::scanner_t scanner_t; - typedef typename base_t::attr_t attr_t; - typedef impl::abstract_parser abstract_parser_t; - - rule() : ptr() {} - ~rule() {} - - rule(rule const& r) - : ptr(new impl::concrete_parser(r)) {} - - template - rule(ParserT const& p) - : ptr(new impl::concrete_parser(p)) {} - - template - rule& operator=(ParserT const& p) - { - ptr.reset(new impl::concrete_parser(p)); - return *this; - } - - rule& operator=(rule const& r) - { - ptr.reset(new impl::concrete_parser(r)); - return *this; - } - - rule - copy() const - { - return rule(ptr.get() ? ptr->clone() : 0); - } - - private: - friend class impl::rule_base_access; - - abstract_parser_t* - get() const - { - return ptr.get(); - } - - rule(abstract_parser_t* ptr_) - : ptr(ptr_) {} - - rule(abstract_parser_t const* ptr_) - : ptr(ptr_) {} - - scoped_ptr ptr; - }; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/parser.hpp b/contrib/autoboost/boost/spirit/home/classic/core/parser.hpp deleted file mode 100644 index 121baa8c1..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/parser.hpp +++ /dev/null @@ -1,223 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PARSER_HPP) -#define BOOST_SPIRIT_PARSER_HPP - -#include -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - template - class action; // forward declaration - - /////////////////////////////////////////////////////////////////////////// - // - // Parser categories - // - // Helper template classes to distinguish different types of - // parsers. The following categories are the most generic. More - // specific types may inherit from these. Each parser has a typedef - // parser_category_t that defines its category. By default, if one - // is not specified, it will inherit from the base parser class - // which typedefs its parser_category_t as plain_parser_category. - // - // - plain parser has nothing special - // - binary parser has subject a and b (e.g. alternative) - // - unary parser has single subject (e.g. kleene star) - // - action parser has an attached action parser - // - /////////////////////////////////////////////////////////////////////////// - struct plain_parser_category {}; - struct binary_parser_category : plain_parser_category {}; - struct unary_parser_category : plain_parser_category {}; - struct action_parser_category : unary_parser_category {}; - - /////////////////////////////////////////////////////////////////////////// - // - // parser_result metafunction - // - // Given a scanner type ScannerT and a parser type ParserT, the - // parser_result metafunction provides the actual result of the - // parser. - // - // Usage: - // - // typename parser_result::type - // - /////////////////////////////////////////////////////////////////////////// - template - struct parser_result - { - typedef typename autoboost::remove_reference::type parser_type; - typedef typename parser_type::template result::type type; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // parser class - // - // This class is a protocol base class for all parsers. This is - // essentially an interface contract. The parser class does not - // really know how to parse anything but instead relies on the - // template parameter DerivedT (which obviously is assumed to be a - // subclass) to do the actual parsing. - // - // Concrete sub-classes inheriting from parser must have a - // corresponding member function parse(...) compatible with the - // conceptual Interface: - // - // template - // RT parse(ScannerT const& scan) const; - // - // where RT is the desired return type of the parser and ScannerT - // scan is the scanner (see scanner.hpp). - // - // Concrete sub-classes inheriting from parser in most cases need to - // have a nested meta-function result that returns the result type - // of the parser's parse member function, given a scanner type. The - // meta-function has the form: - // - // template - // struct result - // { - // typedef RT type; - // }; - // - // where RT is the desired return type of the parser. This is - // usually, but not always, dependent on the template parameter - // ScannerT. If a parser does not supply a result metafunction, a - // default is provided by the base parser class. - // - // The parser's derived() member function returns a reference to the - // parser as its derived object. - // - // An operator[] is provided. The operator returns a semantic action - // handler (see actions.hpp). - // - // Each parser has a typedef embed_t. This typedef specifies how a - // parser is embedded in a composite (see composite.hpp). By - // default, if one is not specified, the parser will be embedded by - // value. That is, a copy of the parser is placed as a member - // variable of the composite. Most parsers are embedded by value. In - // certain situations however, this is not desirable or possible. - // - /////////////////////////////////////////////////////////////////////////// - template - struct parser - { - typedef DerivedT embed_t; - typedef DerivedT derived_t; - typedef plain_parser_category parser_category_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - DerivedT& derived() - { - return *static_cast(this); - } - - DerivedT const& derived() const - { - return *static_cast(this); - } - - template - action - operator[](ActionT const& actor) const - { - return action(derived(), actor); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // parse_info - // - // Results returned by the free parse functions: - // - // stop: points to the final parse position (i.e parsing - // processed the input up to this point). - // - // hit: true if parsing is successful. This may be full: - // the parser consumed all the input, or partial: - // the parser consumed only a portion of the input. - // - // full: true when we have a full hit (i.e the parser - // consumed all the input. - // - // length: The number of characters consumed by the parser. - // This is valid only if we have a successful hit - // (either partial or full). - // - /////////////////////////////////////////////////////////////////////////// - template - struct parse_info - { - IteratorT stop; - bool hit; - bool full; - std::size_t length; - - parse_info( - IteratorT const& stop_ = IteratorT(), - bool hit_ = false, - bool full_ = false, - std::size_t length_ = 0) - : stop(stop_) - , hit(hit_) - , full(full_) - , length(length_) {} - - template - parse_info(ParseInfoT const& pi) - : stop(pi.stop) - , hit(pi.hit) - , full(pi.full) - , length(pi.length) {} - }; - - /////////////////////////////////////////////////////////////////////////// - // - // Generic parse function - // - /////////////////////////////////////////////////////////////////////////// - template - parse_info - parse( - IteratorT const& first, - IteratorT const& last, - parser const& p); - - /////////////////////////////////////////////////////////////////////////// - // - // Parse function for null terminated strings - // - /////////////////////////////////////////////////////////////////////////// - template - parse_info - parse( - CharT const* str, - parser const& p); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp b/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp deleted file mode 100644 index 25d7a137b..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp +++ /dev/null @@ -1,478 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_NUMERICS_IPP -#define BOOST_SPIRIT_NUMERICS_IPP - -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - struct sign_parser; // forward declaration only - - namespace impl - { - /////////////////////////////////////////////////////////////////////// - // - // Extract the prefix sign (- or +) - // - /////////////////////////////////////////////////////////////////////// - template - bool - extract_sign(ScannerT const& scan, std::size_t& count) - { - // Extract the sign - count = 0; - bool neg = *scan == '-'; - if (neg || (*scan == '+')) - { - ++scan; - ++count; - return neg; - } - - return false; - } - - /////////////////////////////////////////////////////////////////////// - // - // Traits class for radix specific number conversion - // - // Convert a digit from character representation, ch, to binary - // representation, returned in val. - // Returns whether the conversion was successful. - // - // template static bool digit(CharT ch, T& val); - // - /////////////////////////////////////////////////////////////////////// - template - struct radix_traits; - - ////////////////////////////////// Binary - template<> - struct radix_traits<2> - { - template - static bool digit(CharT ch, T& val) - { - val = ch - '0'; - return ('0' == ch || '1' == ch); - } - }; - - ////////////////////////////////// Octal - template<> - struct radix_traits<8> - { - template - static bool digit(CharT ch, T& val) - { - val = ch - '0'; - return ('0' <= ch && ch <= '7'); - } - }; - - ////////////////////////////////// Decimal - template<> - struct radix_traits<10> - { - template - static bool digit(CharT ch, T& val) - { - val = ch - '0'; - return impl::isdigit_(ch); - } - }; - - ////////////////////////////////// Hexadecimal - template<> - struct radix_traits<16> - { - template - static bool digit(CharT ch, T& val) - { - if (radix_traits<10>::digit(ch, val)) - return true; - - CharT lc = impl::tolower_(ch); - if ('a' <= lc && lc <= 'f') - { - val = lc - 'a' + 10; - return true; - } - return false; - } - }; - - /////////////////////////////////////////////////////////////////////// - // - // Helper templates for encapsulation of radix specific - // conversion of an input string to an integral value. - // - // main entry point: - // - // extract_int - // ::f(first, last, n, count); - // - // The template parameter Radix represents the radix of the - // number contained in the parsed string. The template - // parameter MinDigits specifies the minimum digits to - // accept. The template parameter MaxDigits specifies the - // maximum digits to parse. A -1 value for MaxDigits will - // make it parse an arbitrarilly large number as long as the - // numeric type can hold it. Accumulate is either - // positive_accumulate (default) for parsing positive - // numbers or negative_accumulate otherwise. - // Checking is only performed when std::numeric_limits:: - // is_specialized is true. Otherwise, there's no way to - // do the check. - // - // scan.first and scan.last are iterators as usual (i.e. - // first is mutable and is moved forward when a match is - // found), n is a variable that holds the number (passed by - // reference). The number of parsed characters is added to - // count (also passed by reference) - // - // NOTE: - // Returns a non-match, if the number to parse - // overflows (or underflows) the used type. - // - // BEWARE: - // the parameters 'n' and 'count' should be properly - // initialized before calling this function. - // - /////////////////////////////////////////////////////////////////////// -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4127) //conditional expression is constant -#endif - - template - struct positive_accumulate - { - // Use this accumulator if number is positive - static bool add(T& n, T digit) - { - if (std::numeric_limits::is_specialized) - { - static T const max = (std::numeric_limits::max)(); - static T const max_div_radix = max/Radix; - - if (n > max_div_radix) - return false; - n *= Radix; - - if (n > max - digit) - return false; - n += digit; - - return true; - } - else - { - n *= Radix; - n += digit; - return true; - } - } - }; - - template - struct negative_accumulate - { - // Use this accumulator if number is negative - static bool add(T& n, T digit) - { - if (std::numeric_limits::is_specialized) - { - typedef std::numeric_limits num_limits; - static T const min = - (!num_limits::is_integer && num_limits::is_signed && num_limits::has_denorm) ? - -(num_limits::max)() : (num_limits::min)(); - static T const min_div_radix = min/Radix; - - if (n < min_div_radix) - return false; - n *= Radix; - - if (n < min + digit) - return false; - n -= digit; - - return true; - } - else - { - n *= Radix; - n -= digit; - return true; - } - } - }; - - template - inline bool allow_more_digits(std::size_t i) - { - return i < MaxDigits; - } - - template <> - inline bool allow_more_digits<-1>(std::size_t) - { - return true; - } - - ////////////////////////////////// - template < - int Radix, unsigned MinDigits, int MaxDigits, - typename Accumulate - > - struct extract_int - { - template - static bool - f(ScannerT& scan, T& n, std::size_t& count) - { - std::size_t i = 0; - T digit; - while( allow_more_digits(i) && !scan.at_end() && - radix_traits::digit(*scan, digit) ) - { - if (!Accumulate::add(n, digit)) - return false; // Overflow - ++i, ++scan, ++count; - } - return i >= MinDigits; - } - }; - - /////////////////////////////////////////////////////////////////////// - // - // uint_parser_impl class - // - /////////////////////////////////////////////////////////////////////// - template < - typename T = unsigned, - int Radix = 10, - unsigned MinDigits = 1, - int MaxDigits = -1 - > - struct uint_parser_impl - : parser > - { - typedef uint_parser_impl self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - if (!scan.at_end()) - { - T n = 0; - std::size_t count = 0; - typename ScannerT::iterator_t save = scan.first; - if (extract_int >::f(scan, n, count)) - { - return scan.create_match(count, n, save, scan.first); - } - // return no-match if number overflows - } - return scan.no_match(); - } - }; - - /////////////////////////////////////////////////////////////////////// - // - // int_parser_impl class - // - /////////////////////////////////////////////////////////////////////// - template < - typename T = unsigned, - int Radix = 10, - unsigned MinDigits = 1, - int MaxDigits = -1 - > - struct int_parser_impl - : parser > - { - typedef int_parser_impl self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef extract_int > extract_int_neg_t; - typedef extract_int > extract_int_pos_t; - - if (!scan.at_end()) - { - T n = 0; - std::size_t count = 0; - typename ScannerT::iterator_t save = scan.first; - - bool hit = impl::extract_sign(scan, count); - - if (hit) - hit = extract_int_neg_t::f(scan, n, count); - else - hit = extract_int_pos_t::f(scan, n, count); - - if (hit) - return scan.create_match(count, n, save, scan.first); - else - scan.first = save; - // return no-match if number overflows or underflows - } - return scan.no_match(); - } - }; - - /////////////////////////////////////////////////////////////////////// - // - // real_parser_impl class - // - /////////////////////////////////////////////////////////////////////// - template - struct real_parser_impl - { - typedef real_parser_impl self_t; - - template - RT parse_main(ScannerT const& scan) const - { - if (scan.at_end()) - return scan.no_match(); - typename ScannerT::iterator_t save = scan.first; - - typedef typename parser_result::type - sign_match_t; - typedef typename parser_result, ScannerT>::type - exp_match_t; - - sign_match_t sign_match = RealPoliciesT::parse_sign(scan); - std::size_t count = sign_match ? sign_match.length() : 0; - bool neg = sign_match.has_valid_attribute() ? - sign_match.value() : false; - - RT n_match = RealPoliciesT::parse_n(scan); - T n = n_match.has_valid_attribute() ? - n_match.value() : T(0); - bool got_a_number = n_match; - exp_match_t e_hit; - - if (!got_a_number && !RealPoliciesT::allow_leading_dot) - return scan.no_match(); - else - count += n_match.length(); - - if (neg) - n = -n; - - if (RealPoliciesT::parse_dot(scan)) - { - // We got the decimal point. Now we will try to parse - // the fraction if it is there. If not, it defaults - // to zero (0) only if we already got a number. - - if (RT hit = RealPoliciesT::parse_frac_n(scan)) - { -#if !defined(BOOST_NO_STDC_NAMESPACE) - using namespace std; // allow for ADL to find pow() -#endif - hit.value(hit.value() - * pow(T(10), T(-hit.length()))); - if (neg) - n -= hit.value(); - else - n += hit.value(); - count += hit.length() + 1; - - } - - else if (!got_a_number || - !RealPoliciesT::allow_trailing_dot) - return scan.no_match(); - - e_hit = RealPoliciesT::parse_exp(scan); - } - else - { - // We have reached a point where we - // still haven't seen a number at all. - // We return early with a no-match. - if (!got_a_number) - return scan.no_match(); - - // If we must expect a dot and we didn't see - // an exponent, return early with a no-match. - e_hit = RealPoliciesT::parse_exp(scan); - if (RealPoliciesT::expect_dot && !e_hit) - return scan.no_match(); - } - - if (e_hit) - { - // We got the exponent prefix. Now we will try to parse the - // actual exponent. It is an error if it is not there. - if (RT e_n_hit = RealPoliciesT::parse_exp_n(scan)) - { -#if !defined(BOOST_NO_STDC_NAMESPACE) - using namespace std; // allow for ADL to find pow() -#endif - n *= pow(T(10), T(e_n_hit.value())); - count += e_n_hit.length() + e_hit.length(); - } - else - { - // Oops, no exponent, return a no-match - return scan.no_match(); - } - } - - return scan.create_match(count, n, save, scan.first); - } - - template - static RT parse(ScannerT const& scan) - { - static self_t this_; - return impl::implicit_lexeme_parse(this_, scan, scan); - } - }; - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - - } // namespace impl - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/primitives.ipp b/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/primitives.ipp deleted file mode 100644 index 97b8ed4b2..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/primitives/impl/primitives.ipp +++ /dev/null @@ -1,390 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2003 Martin Wille - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PRIMITIVES_IPP) -#define BOOST_SPIRIT_PRIMITIVES_IPP - -#include -#if !defined(BOOST_NO_CWCTYPE) -#include -#endif - -#include // char_traits - -#if defined(BOOST_MSVC) -# pragma warning (push) -# pragma warning(disable:4800) -#endif - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - template struct char_parser; - - namespace impl - { - template - inline IteratorT - get_last(IteratorT first) - { - while (*first) - first++; - return first; - } - - template< - typename RT, - typename IteratorT, - typename ScannerT> - inline RT - string_parser_parse( - IteratorT str_first, - IteratorT str_last, - ScannerT& scan) - { - typedef typename ScannerT::iterator_t iterator_t; - iterator_t saved = scan.first; - std::size_t slen = str_last - str_first; - - while (str_first != str_last) - { - if (scan.at_end() || (*str_first != *scan)) - return scan.no_match(); - ++str_first; - ++scan; - } - - return scan.create_match(slen, nil_t(), saved, scan.first); - } - - /////////////////////////////////////////////////////////////////////////// - // - // Conversion from char_type to int_type - // - /////////////////////////////////////////////////////////////////////////// - - // Use char_traits for char and wchar_t only, as these are the only - // specializations provided in the standard. Other types are on their - // own. - // - // For UDT, one may override: - // - // isalnum - // isalpha - // iscntrl - // isdigit - // isgraph - // islower - // isprint - // ispunct - // isspace - // isupper - // isxdigit - // isblank - // isupper - // tolower - // toupper - // - // in a namespace suitable for Argument Dependent lookup or in - // namespace std (disallowed by the standard). - - template - struct char_type_char_traits_helper - { - typedef CharT char_type; - typedef typename std::char_traits::int_type int_type; - - static int_type to_int_type(CharT c) - { - return std::char_traits::to_int_type(c); - } - - static char_type to_char_type(int_type i) - { - return std::char_traits::to_char_type(i); - } - }; - - template - struct char_traits_helper - { - typedef CharT char_type; - typedef CharT int_type; - - static CharT & to_int_type(CharT & c) - { - return c; - } - - static CharT & to_char_type(CharT & c) - { - return c; - } - }; - - template <> - struct char_traits_helper - : char_type_char_traits_helper - { - }; - -#if !defined(BOOST_NO_CWCTYPE) - - template <> - struct char_traits_helper - : char_type_char_traits_helper - { - }; - -#endif - - template - inline typename char_traits_helper::int_type - to_int_type(CharT c) - { - return char_traits_helper::to_int_type(c); - } - - template - inline CharT - to_char_type(typename char_traits_helper::int_type c) - { - return char_traits_helper::to_char_type(c); - } - - /////////////////////////////////////////////////////////////////////// - // - // Convenience functions - // - /////////////////////////////////////////////////////////////////////// - - template - inline bool - isalnum_(CharT c) - { - using namespace std; - return isalnum(to_int_type(c)) ? true : false; - } - - template - inline bool - isalpha_(CharT c) - { - using namespace std; - return isalpha(to_int_type(c)) ? true : false; - } - - template - inline bool - iscntrl_(CharT c) - { - using namespace std; - return iscntrl(to_int_type(c)) ? true : false; - } - - template - inline bool - isdigit_(CharT c) - { - using namespace std; - return isdigit(to_int_type(c)) ? true : false; - } - - template - inline bool - isgraph_(CharT c) - { - using namespace std; - return isgraph(to_int_type(c)) ? true : false; - } - - template - inline bool - islower_(CharT c) - { - using namespace std; - return islower(to_int_type(c)) ? true : false; - } - - template - inline bool - isprint_(CharT c) - { - using namespace std; - return isprint(to_int_type(c)) ? true : false; - } - - template - inline bool - ispunct_(CharT c) - { - using namespace std; - return ispunct(to_int_type(c)) ? true : false; - } - - template - inline bool - isspace_(CharT c) - { - using namespace std; - return isspace(to_int_type(c)) ? true : false; - } - - template - inline bool - isupper_(CharT c) - { - using namespace std; - return isupper(to_int_type(c)) ? true : false; - } - - template - inline bool - isxdigit_(CharT c) - { - using namespace std; - return isxdigit(to_int_type(c)) ? true : false; - } - - template - inline bool - isblank_(CharT c) - { - return (c == ' ' || c == '\t'); - } - - template - inline CharT - tolower_(CharT c) - { - using namespace std; - return to_char_type(tolower(to_int_type(c))); - } - - template - inline CharT - toupper_(CharT c) - { - using namespace std; - return to_char_type(toupper(to_int_type(c))); - } - -#if !defined(BOOST_NO_CWCTYPE) - - inline bool - isalnum_(wchar_t c) - { - using namespace std; - return iswalnum(to_int_type(c)) ? true : false; - } - - inline bool - isalpha_(wchar_t c) - { - using namespace std; - return iswalpha(to_int_type(c)) ? true : false; - } - - inline bool - iscntrl_(wchar_t c) - { - using namespace std; - return iswcntrl(to_int_type(c)) ? true : false; - } - - inline bool - isdigit_(wchar_t c) - { - using namespace std; - return iswdigit(to_int_type(c)) ? true : false; - } - - inline bool - isgraph_(wchar_t c) - { - using namespace std; - return iswgraph(to_int_type(c)) ? true : false; - } - - inline bool - islower_(wchar_t c) - { - using namespace std; - return iswlower(to_int_type(c)) ? true : false; - } - - inline bool - isprint_(wchar_t c) - { - using namespace std; - return iswprint(to_int_type(c)) ? true : false; - } - - inline bool - ispunct_(wchar_t c) - { - using namespace std; - return iswpunct(to_int_type(c)) ? true : false; - } - - inline bool - isspace_(wchar_t c) - { - using namespace std; - return iswspace(to_int_type(c)) ? true : false; - } - - inline bool - isupper_(wchar_t c) - { - using namespace std; - return iswupper(to_int_type(c)) ? true : false; - } - - inline bool - isxdigit_(wchar_t c) - { - using namespace std; - return iswxdigit(to_int_type(c)) ? true : false; - } - - inline bool - isblank_(wchar_t c) - { - return (c == L' ' || c == L'\t'); - } - - inline wchar_t - tolower_(wchar_t c) - { - using namespace std; - return to_char_type(towlower(to_int_type(c))); - } - - inline wchar_t - toupper_(wchar_t c) - { - using namespace std; - return to_char_type(towupper(to_int_type(c))); - } - -#endif // !defined(BOOST_NO_CWCTYPE) - -} - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit::impl - -#ifdef BOOST_MSVC -#pragma warning (pop) -#endif - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics.hpp b/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics.hpp deleted file mode 100644 index 72c8c0ebf..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2001-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_NUMERICS_HPP -#define BOOST_SPIRIT_NUMERICS_HPP - -#include -#include -#include -#include - -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // uint_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T, - int Radix, - unsigned MinDigits, - int MaxDigits - > - struct uint_parser : parser > - { - typedef uint_parser self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef impl::uint_parser_impl impl_t; - typedef typename parser_result::type result_t; - return impl::contiguous_parser_parse(impl_t(), scan, scan); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // int_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T, - int Radix, - unsigned MinDigits, - int MaxDigits - > - struct int_parser : parser > - { - typedef int_parser self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef impl::int_parser_impl impl_t; - typedef typename parser_result::type result_t; - return impl::contiguous_parser_parse(impl_t(), scan, scan); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // uint_parser/int_parser instantiations - // - /////////////////////////////////////////////////////////////////////////// - int_parser const - int_p = int_parser(); - - uint_parser const - uint_p = uint_parser(); - - uint_parser const - bin_p = uint_parser(); - - uint_parser const - oct_p = uint_parser(); - - uint_parser const - hex_p = uint_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // sign_parser class - // - /////////////////////////////////////////////////////////////////////////// - namespace impl - { - // Utility to extract the prefix sign ('-' | '+') - template - bool extract_sign(ScannerT const& scan, std::size_t& count); - } - - struct sign_parser : public parser - { - typedef sign_parser self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - sign_parser() {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - if (!scan.at_end()) - { - std::size_t length; - typename ScannerT::iterator_t save(scan.first); - bool neg = impl::extract_sign(scan, length); - if (length) - return scan.create_match(1, neg, save, scan.first); - } - return scan.no_match(); - } - }; - - sign_parser const sign_p = sign_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // default real number policies - // - /////////////////////////////////////////////////////////////////////////// - template - struct ureal_parser_policies - { - // trailing dot policy suggested suggested by Gustavo Guerra - BOOST_STATIC_CONSTANT(bool, allow_leading_dot = true); - BOOST_STATIC_CONSTANT(bool, allow_trailing_dot = true); - BOOST_STATIC_CONSTANT(bool, expect_dot = false); - - typedef uint_parser uint_parser_t; - typedef int_parser int_parser_t; - - template - static typename match_result::type - parse_sign(ScannerT& scan) - { - return scan.no_match(); - } - - template - static typename parser_result::type - parse_n(ScannerT& scan) - { - return uint_parser_t().parse(scan); - } - - template - static typename parser_result, ScannerT>::type - parse_dot(ScannerT& scan) - { - return ch_p('.').parse(scan); - } - - template - static typename parser_result::type - parse_frac_n(ScannerT& scan) - { - return uint_parser_t().parse(scan); - } - - template - static typename parser_result, ScannerT>::type - parse_exp(ScannerT& scan) - { - return as_lower_d['e'].parse(scan); - } - - template - static typename parser_result::type - parse_exp_n(ScannerT& scan) - { - return int_parser_t().parse(scan); - } - }; - - template - struct real_parser_policies : public ureal_parser_policies - { - template - static typename parser_result::type - parse_sign(ScannerT& scan) - { - return sign_p.parse(scan); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // real_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T, - typename RealPoliciesT - > - struct real_parser - : public parser > - { - typedef real_parser self_t; - - template - struct result - { - typedef typename match_result::type type; - }; - - real_parser() {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - return impl::real_parser_impl::parse(scan); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // real_parser instantiations - // - /////////////////////////////////////////////////////////////////////////// - real_parser > const - ureal_p = real_parser >(); - - real_parser > const - real_p = real_parser >(); - - /////////////////////////////////////////////////////////////////////////// - // - // strict reals (do not allow plain integers (no decimal point)) - // - /////////////////////////////////////////////////////////////////////////// - template - struct strict_ureal_parser_policies : public ureal_parser_policies - { - BOOST_STATIC_CONSTANT(bool, expect_dot = true); - }; - - template - struct strict_real_parser_policies : public real_parser_policies - { - BOOST_STATIC_CONSTANT(bool, expect_dot = true); - }; - - real_parser > const - strict_ureal_p - = real_parser >(); - - real_parser > const - strict_real_p - = real_parser >(); - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp b/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp deleted file mode 100644 index f05bfe589..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/*============================================================================= - Copyright (C) 2006 Tobias Schwinger - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_NUMERICS_FWD_HPP) -# define BOOST_SPIRIT_NUMERICS_FWD_HPP - -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // uint_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T = unsigned, - int Radix = 10, - unsigned MinDigits = 1, - int MaxDigits = -1 - > - struct uint_parser; - - /////////////////////////////////////////////////////////////////////////// - // - // int_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T = unsigned, - int Radix = 10, - unsigned MinDigits = 1, - int MaxDigits = -1 - > - struct int_parser; - - /////////////////////////////////////////////////////////////////////////// - // - // sign_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct sign_parser; - - /////////////////////////////////////////////////////////////////////////// - // - // default real number policies - // - /////////////////////////////////////////////////////////////////////////// - template - struct ureal_parser_policies; - - template - struct real_parser_policies; - - /////////////////////////////////////////////////////////////////////////// - // - // real_parser class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename T = double, - typename RealPoliciesT = ureal_parser_policies - > - struct real_parser; - - /////////////////////////////////////////////////////////////////////////// - // - // strict reals (do not allow plain integers (no decimal point)) - // - /////////////////////////////////////////////////////////////////////////// - template - struct strict_ureal_parser_policies; - - template - struct strict_real_parser_policies; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/primitives/primitives.hpp b/contrib/autoboost/boost/spirit/home/classic/core/primitives/primitives.hpp deleted file mode 100644 index 53e7794b6..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/primitives/primitives.hpp +++ /dev/null @@ -1,654 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - Copyright (c) 2003 Martin Wille - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_PRIMITIVES_HPP) -#define BOOST_SPIRIT_PRIMITIVES_HPP - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_MSVC -#pragma warning (push) -#pragma warning(disable : 4512) -#endif - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // char_parser class - // - /////////////////////////////////////////////////////////////////////////// - template - struct char_parser : public parser - { - typedef DerivedT self_t; - template - struct result - { - typedef typename match_result< - ScannerT, - typename ScannerT::value_t - >::type type; - }; - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - typedef typename ScannerT::value_t value_t; - typedef typename ScannerT::iterator_t iterator_t; - - if (!scan.at_end()) - { - value_t ch = *scan; - if (this->derived().test(ch)) - { - iterator_t save(scan.first); - ++scan.first; - return scan.create_match(1, ch, save, scan.first); - } - } - return scan.no_match(); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // negation of char_parsers - // - /////////////////////////////////////////////////////////////////////////// - template - struct negated_char_parser - : public char_parser > - { - typedef negated_char_parser self_t; - typedef PositiveT positive_t; - - negated_char_parser(positive_t const& p) - : positive(p.derived()) {} - - template - bool test(T ch) const - { - return !positive.test(ch); - } - - positive_t const positive; - }; - - template - inline negated_char_parser - operator~(char_parser const& p) - { - return negated_char_parser(p.derived()); - } - - template - inline ParserT - operator~(negated_char_parser const& n) - { - return n.positive; - } - - /////////////////////////////////////////////////////////////////////////// - // - // chlit class - // - /////////////////////////////////////////////////////////////////////////// - template - struct chlit : public char_parser > - { - chlit(CharT ch_) - : ch(ch_) {} - - template - bool test(T ch_) const - { - return ch_ == ch; - } - - CharT ch; - }; - - template - inline chlit - ch_p(CharT ch) - { - return chlit(ch); - } - - // This should take care of ch_p("a") "bugs" - template - inline chlit - ch_p(CharT const (& str)[N]) - { - // ch_p's argument should be a single character or a null-terminated - // string with a single character - BOOST_STATIC_ASSERT(N < 3); - return chlit(str[0]); - } - - /////////////////////////////////////////////////////////////////////////// - // - // range class - // - /////////////////////////////////////////////////////////////////////////// - template - struct range : public char_parser > - { - range(CharT first_, CharT last_) - : first(first_), last(last_) - { - BOOST_SPIRIT_ASSERT(!(last < first)); - } - - template - bool test(T ch) const - { - return !(CharT(ch) < first) && !(last < CharT(ch)); - } - - CharT first; - CharT last; - }; - - template - inline range - range_p(CharT first, CharT last) - { - return range(first, last); - } - - /////////////////////////////////////////////////////////////////////////// - // - // chseq class - // - /////////////////////////////////////////////////////////////////////////// - template - class chseq : public parser > - { - public: - - typedef chseq self_t; - - chseq(IteratorT first_, IteratorT last_) - : first(first_), last(last_) {} - - chseq(IteratorT first_) - : first(first_), last(impl::get_last(first_)) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename autoboost::unwrap_reference::type striter_t; - typedef typename parser_result::type result_t; - return impl::string_parser_parse( - striter_t(first), - striter_t(last), - scan); - } - - private: - - IteratorT first; - IteratorT last; - }; - - template - inline chseq - chseq_p(CharT const* str) - { - return chseq(str); - } - - template - inline chseq - chseq_p(IteratorT first, IteratorT last) - { - return chseq(first, last); - } - - /////////////////////////////////////////////////////////////////////////// - // - // strlit class - // - /////////////////////////////////////////////////////////////////////////// - template - class strlit : public parser > - { - public: - - typedef strlit self_t; - - strlit(IteratorT first, IteratorT last) - : seq(first, last) {} - - strlit(IteratorT first) - : seq(first) {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typedef typename parser_result::type result_t; - return impl::contiguous_parser_parse - (seq, scan, scan); - } - - private: - - chseq seq; - }; - - template - inline strlit - str_p(CharT const* str) - { - return strlit(str); - } - - template - inline strlit - str_p(CharT * str) - { - return strlit(str); - } - - template - inline strlit - str_p(IteratorT first, IteratorT last) - { - return strlit(first, last); - } - - // This should take care of str_p('a') "bugs" - template - inline chlit - str_p(CharT ch) - { - return chlit(ch); - } - - /////////////////////////////////////////////////////////////////////////// - // - // nothing_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct nothing_parser : public parser - { - typedef nothing_parser self_t; - - nothing_parser() {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - return scan.no_match(); - } - }; - - nothing_parser const nothing_p = nothing_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // anychar_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct anychar_parser : public char_parser - { - typedef anychar_parser self_t; - - anychar_parser() {} - - template - bool test(CharT) const - { - return true; - } - }; - - anychar_parser const anychar_p = anychar_parser(); - - inline nothing_parser - operator~(anychar_parser) - { - return nothing_p; - } - - /////////////////////////////////////////////////////////////////////////// - // - // alnum_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct alnum_parser : public char_parser - { - typedef alnum_parser self_t; - - alnum_parser() {} - - template - bool test(CharT ch) const - { - return impl::isalnum_(ch); - } - }; - - alnum_parser const alnum_p = alnum_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // alpha_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct alpha_parser : public char_parser - { - typedef alpha_parser self_t; - - alpha_parser() {} - - template - bool test(CharT ch) const - { - return impl::isalpha_(ch); - } - }; - - alpha_parser const alpha_p = alpha_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // cntrl_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct cntrl_parser : public char_parser - { - typedef cntrl_parser self_t; - - cntrl_parser() {} - - template - bool test(CharT ch) const - { - return impl::iscntrl_(ch); - } - }; - - cntrl_parser const cntrl_p = cntrl_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // digit_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct digit_parser : public char_parser - { - typedef digit_parser self_t; - - digit_parser() {} - - template - bool test(CharT ch) const - { - return impl::isdigit_(ch); - } - }; - - digit_parser const digit_p = digit_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // graph_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct graph_parser : public char_parser - { - typedef graph_parser self_t; - - graph_parser() {} - - template - bool test(CharT ch) const - { - return impl::isgraph_(ch); - } - }; - - graph_parser const graph_p = graph_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // lower_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct lower_parser : public char_parser - { - typedef lower_parser self_t; - - lower_parser() {} - - template - bool test(CharT ch) const - { - return impl::islower_(ch); - } - }; - - lower_parser const lower_p = lower_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // print_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct print_parser : public char_parser - { - typedef print_parser self_t; - - print_parser() {} - - template - bool test(CharT ch) const - { - return impl::isprint_(ch); - } - }; - - print_parser const print_p = print_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // punct_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct punct_parser : public char_parser - { - typedef punct_parser self_t; - - punct_parser() {} - - template - bool test(CharT ch) const - { - return impl::ispunct_(ch); - } - }; - - punct_parser const punct_p = punct_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // blank_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct blank_parser : public char_parser - { - typedef blank_parser self_t; - - blank_parser() {} - - template - bool test(CharT ch) const - { - return impl::isblank_(ch); - } - }; - - blank_parser const blank_p = blank_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // space_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct space_parser : public char_parser - { - typedef space_parser self_t; - - space_parser() {} - - template - bool test(CharT ch) const - { - return impl::isspace_(ch); - } - }; - - space_parser const space_p = space_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // upper_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct upper_parser : public char_parser - { - typedef upper_parser self_t; - - upper_parser() {} - - template - bool test(CharT ch) const - { - return impl::isupper_(ch); - } - }; - - upper_parser const upper_p = upper_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // xdigit_parser class - // - /////////////////////////////////////////////////////////////////////////// - struct xdigit_parser : public char_parser - { - typedef xdigit_parser self_t; - - xdigit_parser() {} - - template - bool test(CharT ch) const - { - return impl::isxdigit_(ch); - } - }; - - xdigit_parser const xdigit_p = xdigit_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // eol_parser class (contributed by Martin Wille) - // - /////////////////////////////////////////////////////////////////////////// - struct eol_parser : public parser - { - typedef eol_parser self_t; - - eol_parser() {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - typename ScannerT::iterator_t save = scan.first; - std::size_t len = 0; - - if (!scan.at_end() && *scan == '\r') // CR - { - ++scan.first; - ++len; - } - - // Don't call skipper here - if (scan.first != scan.last && *scan == '\n') // LF - { - ++scan.first; - ++len; - } - - if (len) - return scan.create_match(len, nil_t(), save, scan.first); - return scan.no_match(); - } - }; - - eol_parser const eol_p = eol_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // end_parser class (suggested by Markus Schoepflin) - // - /////////////////////////////////////////////////////////////////////////// - struct end_parser : public parser - { - typedef end_parser self_t; - - end_parser() {} - - template - typename parser_result::type - parse(ScannerT const& scan) const - { - if (scan.at_end()) - return scan.empty_match(); - return scan.no_match(); - } - }; - - end_parser const end_p = end_parser(); - - /////////////////////////////////////////////////////////////////////////// - // - // the pizza_p parser :-) - // - /////////////////////////////////////////////////////////////////////////// - inline strlit const - pizza_p(char const* your_favorite_pizza) - { - return your_favorite_pizza; - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#ifdef BOOST_MSVC -#pragma warning (pop) -#endif - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/safe_bool.hpp b/contrib/autoboost/boost/spirit/home/classic/core/safe_bool.hpp deleted file mode 100644 index ab8e51de9..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/safe_bool.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*============================================================================= - Copyright (c) 2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SAFE_BOOL_HPP) -#define BOOST_SPIRIT_SAFE_BOOL_HPP - -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - namespace impl - { - template - struct no_base {}; - - template - struct safe_bool_impl - { -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) - void stub(T*) {}; - typedef void (safe_bool_impl::*type)(T*); -#else - typedef T* TP; // workaround to make parsing easier - TP stub; - typedef TP safe_bool_impl::*type; -#endif - }; - } - - template > - struct safe_bool : BaseT - { - private: - typedef impl::safe_bool_impl impl_t; - typedef typename impl_t::type bool_type; - - public: - operator bool_type() const - { - return static_cast(this)->operator_bool() ? - &impl_t::stub : 0; - } - - operator bool_type() - { - return static_cast(this)->operator_bool() ? - &impl_t::stub : 0; - } - }; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/scanner/impl/skipper.ipp b/contrib/autoboost/boost/spirit/home/classic/core/scanner/impl/skipper.ipp deleted file mode 100644 index 5db89a77e..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/scanner/impl/skipper.ipp +++ /dev/null @@ -1,181 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -============================================================================*/ -#if !defined(BOOST_SPIRIT_SKIPPER_IPP) -#define BOOST_SPIRIT_SKIPPER_IPP - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - struct space_parser; - template - struct no_skipper_iteration_policy; - - namespace impl - { - template - inline void - skipper_skip( - ST const& s, - ScannerT const& scan, - skipper_iteration_policy const&) - { - typedef scanner_policies< - no_skipper_iteration_policy< - BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>, - BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t, - BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t - > policies_t; - - scanner - scan2(scan.first, scan.last, policies_t(scan)); - typedef typename ScannerT::iterator_t iterator_t; - - for (;;) - { - iterator_t save = scan.first; - if (!s.parse(scan2)) - { - scan.first = save; - break; - } - } - } - - template - inline void - skipper_skip( - ST const& s, - ScannerT const& scan, - no_skipper_iteration_policy const&) - { - for (;;) - { - typedef typename ScannerT::iterator_t iterator_t; - iterator_t save = scan.first; - if (!s.parse(scan)) - { - scan.first = save; - break; - } - } - } - - template - inline void - skipper_skip( - ST const& s, - ScannerT const& scan, - iteration_policy const&) - { - for (;;) - { - typedef typename ScannerT::iterator_t iterator_t; - iterator_t save = scan.first; - if (!s.parse(scan)) - { - scan.first = save; - break; - } - } - } - - template - struct phrase_parser - { - template - static parse_info - parse( - IteratorT const& first_, - IteratorT const& last, - ParserT const& p, - SkipT const& skip) - { - typedef skip_parser_iteration_policy iter_policy_t; - typedef scanner_policies scanner_policies_t; - typedef scanner scanner_t; - - iter_policy_t iter_policy(skip); - scanner_policies_t policies(iter_policy); - IteratorT first = first_; - scanner_t scan(first, last, policies); - match hit = p.parse(scan); - return parse_info( - first, hit, hit && (first == last), - hit.length()); - } - }; - - template <> - struct phrase_parser - { - template - static parse_info - parse( - IteratorT const& first_, - IteratorT const& last, - ParserT const& p, - space_parser const&) - { - typedef skipper_iteration_policy<> iter_policy_t; - typedef scanner_policies scanner_policies_t; - typedef scanner scanner_t; - - IteratorT first = first_; - scanner_t scan(first, last); - match hit = p.parse(scan); - return parse_info( - first, hit, hit && (first == last), - hit.length()); - } - }; - } - - /////////////////////////////////////////////////////////////////////////// - // - // Free parse functions using the skippers - // - /////////////////////////////////////////////////////////////////////////// - template - inline parse_info - parse( - IteratorT const& first, - IteratorT const& last, - parser const& p, - parser const& skip) - { - return impl::phrase_parser:: - parse(first, last, p.derived(), skip.derived()); - } - - /////////////////////////////////////////////////////////////////////////// - // - // Parse function for null terminated strings using the skippers - // - /////////////////////////////////////////////////////////////////////////// - template - inline parse_info - parse( - CharT const* str, - parser const& p, - parser const& skip) - { - CharT const* last = str; - while (*last) - last++; - return parse(str, last, p, skip); - } - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner.hpp b/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner.hpp deleted file mode 100644 index a00f96504..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner.hpp +++ /dev/null @@ -1,329 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2002 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SCANNER_HPP) -#define BOOST_SPIRIT_SCANNER_HPP - -#include -#include -#include -#include -#include -#include // for autoboost::detail::iterator_traits - -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // iteration_policy class - // - /////////////////////////////////////////////////////////////////////////// - struct iteration_policy - { - template - void - advance(ScannerT const& scan) const - { - ++scan.first; - } - - template - bool at_end(ScannerT const& scan) const - { - return scan.first == scan.last; - } - - template - T filter(T ch) const - { - return ch; - } - - template - typename ScannerT::ref_t - get(ScannerT const& scan) const - { - return *scan.first; - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // match_policy class - // - /////////////////////////////////////////////////////////////////////////// - struct match_policy - { - template - struct result { typedef match type; }; - - const match - no_match() const - { - return match(); - } - - const match - empty_match() const - { - return match(0, nil_t()); - } - - template - match - create_match( - std::size_t length, - AttrT const& val, - IteratorT const& /*first*/, - IteratorT const& /*last*/) const - { - return match(length, val); - } - - template - void group_match( - MatchT& /*m*/, - parser_id const& /*id*/, - IteratorT const& /*first*/, - IteratorT const& /*last*/) const {} - - template - void concat_match(Match1T& l, Match2T const& r) const - { - l.concat(r); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // match_result class - // - /////////////////////////////////////////////////////////////////////////// - template - struct match_result - { - typedef typename MatchPolicyT::template result::type type; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // action_policy class - // - /////////////////////////////////////////////////////////////////////////// - template - struct attributed_action_policy - { - template - static void - call( - ActorT const& actor, - AttrT& val, - IteratorT const&, - IteratorT const&) - { - actor(val); - } - }; - - ////////////////////////////////// - template <> - struct attributed_action_policy - { - template - static void - call( - ActorT const& actor, - nil_t, - IteratorT const& first, - IteratorT const& last) - { - actor(first, last); - } - }; - - ////////////////////////////////// - struct action_policy - { - template - void - do_action( - ActorT const& actor, - AttrT& val, - IteratorT const& first, - IteratorT const& last) const - { - attributed_action_policy::call(actor, val, first, last); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // scanner_policies class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename IterationPolicyT, - typename MatchPolicyT, - typename ActionPolicyT> - struct scanner_policies : - public IterationPolicyT, - public MatchPolicyT, - public ActionPolicyT - { - typedef IterationPolicyT iteration_policy_t; - typedef MatchPolicyT match_policy_t; - typedef ActionPolicyT action_policy_t; - - scanner_policies( - IterationPolicyT const& i_policy = IterationPolicyT(), - MatchPolicyT const& m_policy = MatchPolicyT(), - ActionPolicyT const& a_policy = ActionPolicyT()) - : IterationPolicyT(i_policy) - , MatchPolicyT(m_policy) - , ActionPolicyT(a_policy) {} - - template - scanner_policies(ScannerPoliciesT const& policies) - : IterationPolicyT(policies) - , MatchPolicyT(policies) - , ActionPolicyT(policies) {} - }; - - /////////////////////////////////////////////////////////////////////////// - // - // scanner_policies_base class: the base class of all scanners - // - /////////////////////////////////////////////////////////////////////////// - struct scanner_base {}; - - /////////////////////////////////////////////////////////////////////////// - // - // scanner class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename IteratorT, - typename PoliciesT> - class scanner : public PoliciesT, public scanner_base - { - public: - - typedef IteratorT iterator_t; - typedef PoliciesT policies_t; - - typedef typename autoboost::detail:: - iterator_traits::value_type value_t; - typedef typename autoboost::detail:: - iterator_traits::reference ref_t; - typedef typename autoboost:: - call_traits::param_type iter_param_t; - - scanner( - IteratorT& first_, - iter_param_t last_, - PoliciesT const& policies = PoliciesT()) - : PoliciesT(policies), first(first_), last(last_) - { - at_end(); - } - - scanner(scanner const& other) - : PoliciesT(other), first(other.first), last(other.last) {} - - scanner(scanner const& other, IteratorT& first_) - : PoliciesT(other), first(first_), last(other.last) {} - - template - scanner(scanner const& other) - : PoliciesT(other), first(other.first), last(other.last) {} - - bool - at_end() const - { - typedef typename PoliciesT::iteration_policy_t iteration_policy_type; - return iteration_policy_type::at_end(*this); - } - - value_t - operator*() const - { - typedef typename PoliciesT::iteration_policy_t iteration_policy_type; - return iteration_policy_type::filter(iteration_policy_type::get(*this)); - } - - scanner const& - operator++() const - { - typedef typename PoliciesT::iteration_policy_t iteration_policy_type; - iteration_policy_type::advance(*this); - return *this; - } - - template - struct rebind_policies - { - typedef scanner type; - }; - - template - scanner - change_policies(PoliciesT2 const& policies) const - { - return scanner(first, last, policies); - } - - template - struct rebind_iterator - { - typedef scanner type; - }; - - template - scanner - change_iterator(IteratorT2 const& first_, IteratorT2 const &last_) const - { - return scanner(first_, last_, *this); - } - - IteratorT& first; - IteratorT const last; - - private: - - scanner& - operator=(scanner const& other); - }; - - /////////////////////////////////////////////////////////////////////////// - // - // rebind_scanner_policies class - // - /////////////////////////////////////////////////////////////////////////// - template - struct rebind_scanner_policies - { - typedef typename ScannerT::template - rebind_policies::type type; - }; - - ////////////////////////////////// - template - struct rebind_scanner_iterator - { - typedef typename ScannerT::template - rebind_iterator::type type; - }; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp b/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp deleted file mode 100644 index c9f293004..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/*============================================================================= - Copyright (c) 2006 Tobias Schwinger - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SCANNER_FWD_HPP) -#define BOOST_SPIRIT_SCANNER_FWD_HPP - -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // policy classes - // - /////////////////////////////////////////////////////////////////////////// - struct iteration_policy; - struct action_policy; - struct match_policy; - - /////////////////////////////////////////////////////////////////////////// - // - // scanner_policies class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename IterationPolicyT = iteration_policy, - typename MatchPolicyT = match_policy, - typename ActionPolicyT = action_policy> - struct scanner_policies; - - /////////////////////////////////////////////////////////////////////////// - // - // scanner class - // - /////////////////////////////////////////////////////////////////////////// - template < - typename IteratorT = char const*, - typename PoliciesT = scanner_policies<> > - class scanner; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper.hpp b/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper.hpp deleted file mode 100644 index f5b3a5837..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/*============================================================================= - Copyright (c) 1998-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SKIPPER_HPP) -#define BOOST_SPIRIT_SKIPPER_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include - -#include -#include -#include - -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // skipper_iteration_policy class - // - /////////////////////////////////////////////////////////////////////////// - template - struct skipper_iteration_policy : public BaseT - { - typedef BaseT base_t; - - skipper_iteration_policy() - : BaseT() {} - - template - skipper_iteration_policy(PolicyT const& other) - : BaseT(other) {} - - template - void - advance(ScannerT const& scan) const - { - BaseT::advance(scan); - scan.skip(scan); - } - - template - bool - at_end(ScannerT const& scan) const - { - scan.skip(scan); - return BaseT::at_end(scan); - } - - template - void - skip(ScannerT const& scan) const - { - while (!BaseT::at_end(scan) && impl::isspace_(BaseT::get(scan))) - BaseT::advance(scan); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // no_skipper_iteration_policy class - // - /////////////////////////////////////////////////////////////////////////// - template - struct no_skipper_iteration_policy : public BaseT - { - typedef BaseT base_t; - - no_skipper_iteration_policy() - : BaseT() {} - - template - no_skipper_iteration_policy(PolicyT const& other) - : BaseT(other) {} - - template - void - skip(ScannerT const& /*scan*/) const {} - }; - - /////////////////////////////////////////////////////////////////////////// - // - // skip_parser_iteration_policy class - // - /////////////////////////////////////////////////////////////////////////// - namespace impl - { - template - void - skipper_skip( - ST const& s, - ScannerT const& scan, - skipper_iteration_policy const&); - - template - void - skipper_skip( - ST const& s, - ScannerT const& scan, - no_skipper_iteration_policy const&); - - template - void - skipper_skip( - ST const& s, - ScannerT const& scan, - iteration_policy const&); - } - - template - class skip_parser_iteration_policy : public skipper_iteration_policy - { - public: - - typedef skipper_iteration_policy base_t; - - skip_parser_iteration_policy( - ParserT const& skip_parser, - base_t const& base = base_t()) - : base_t(base), subject(skip_parser) {} - - template - skip_parser_iteration_policy(PolicyT const& other) - : base_t(other), subject(other.skipper()) {} - - template - void - skip(ScannerT const& scan) const - { - impl::skipper_skip(subject, scan, scan); - } - - ParserT const& - skipper() const - { - return subject; - } - - private: - - ParserT const& subject; - }; - - /////////////////////////////////////////////////////////////////////////////// - // - // Free parse functions using the skippers - // - /////////////////////////////////////////////////////////////////////////////// - template - parse_info - parse( - IteratorT const& first, - IteratorT const& last, - parser const& p, - parser const& skip); - - /////////////////////////////////////////////////////////////////////////////// - // - // Parse function for null terminated strings using the skippers - // - /////////////////////////////////////////////////////////////////////////////// - template - parse_info - parse( - CharT const* str, - parser const& p, - parser const& skip); - - /////////////////////////////////////////////////////////////////////////////// - // - // phrase_scanner_t and wide_phrase_scanner_t - // - // The most common scanners. Use these typedefs when you need - // a scanner that skips white spaces. - // - /////////////////////////////////////////////////////////////////////////////// - typedef skipper_iteration_policy<> iter_policy_t; - typedef scanner_policies scanner_policies_t; - typedef scanner phrase_scanner_t; - typedef scanner wide_phrase_scanner_t; - - /////////////////////////////////////////////////////////////////////////////// - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#include -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp b/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp deleted file mode 100644 index d7c1da39b..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/*============================================================================= - Copyright (c) 2006 Tobias Schwinger - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_SKIPPER_FWD_HPP) -#define BOOST_SPIRIT_SKIPPER_FWD_HPP - -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - template - struct skipper_iteration_policy; - - template - struct no_skipper_iteration_policy; - - template - class skip_parser_iteration_policy; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/debug.hpp b/contrib/autoboost/boost/spirit/home/classic/debug.hpp deleted file mode 100644 index 9737b35be..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/debug.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) -#define BOOST_SPIRIT_DEBUG_MAIN_HPP - -/////////////////////////////////////////////////////////////////////////// -#if defined(BOOST_SPIRIT_DEBUG) - -#include - -/////////////////////////////////////////////////////////////////////////////// -// -// Spirit.Debug includes and defines -// -/////////////////////////////////////////////////////////////////////////////// - - #include - - /////////////////////////////////////////////////////////////////////////// - // - // The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used - // for debug diagnostics. This defaults to std::cout. - // - /////////////////////////////////////////////////////////////////////////// - #if !defined(BOOST_SPIRIT_DEBUG_OUT) - #define BOOST_SPIRIT_DEBUG_OUT std::cout - #endif - - /////////////////////////////////////////////////////////////////////////// - // - // The BOOST_SPIRIT_DEBUG_PRINT_SOME constant defines the number of characters - // from the stream to be printed for diagnosis. This defaults to the first - // 20 characters. - // - /////////////////////////////////////////////////////////////////////////// - #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME) - #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20 - #endif - - /////////////////////////////////////////////////////////////////////////// - // - // Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed - // Basic constants are defined in debug/minimal.hpp. - // - /////////////////////////////////////////////////////////////////////////// - #define BOOST_SPIRIT_DEBUG_FLAGS_NODES 0x0001 // node diagnostics - #define BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR 0x0002 // escape_char_parse diagnostics - #define BOOST_SPIRIT_DEBUG_FLAGS_TREES 0x0004 // parse tree/ast diagnostics - #define BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES 0x0008 // closure diagnostics - #define BOOST_SPIRIT_DEBUG_FLAGS_SLEX 0x8000 // slex diagnostics - - #define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics - - #if !defined(BOOST_SPIRIT_DEBUG_FLAGS) - #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX - #endif - - /////////////////////////////////////////////////////////////////////////// - // - // By default all nodes are traced (even those, not registered with - // BOOST_SPIRIT_DEBUG_RULE et.al. - see below). The following constant may be - // used to redefine this default. - // - /////////////////////////////////////////////////////////////////////////// - #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE) - #define BOOST_SPIRIT_DEBUG_TRACENODE (true) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE) - - /////////////////////////////////////////////////////////////////////////// - // - // Helper macros for giving rules and subrules a name accessible through - // parser_name() functions (see parser_names.hpp). - // - // Additionally, the macros BOOST_SPIRIT_DEBUG_RULE, SPIRIT_DEBUG_NODE and - // BOOST_SPIRIT_DEBUG_GRAMMAR enable/disable the tracing of the - // correspondingnode accordingly to the PP constant - // BOOST_SPIRIT_DEBUG_TRACENODE. - // - // The macros BOOST_SPIRIT_DEBUG_TRACE_RULE, BOOST_SPIRIT_DEBUG_TRACE_NODE - // and BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR allow to specify a flag to define, - // whether the corresponding node is to be traced or not. - // - /////////////////////////////////////////////////////////////////////////// - #if !defined(BOOST_SPIRIT_DEBUG_RULE) - #define BOOST_SPIRIT_DEBUG_RULE(r) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) - #endif // !defined(BOOST_SPIRIT_DEBUG_RULE) - - #if !defined(BOOST_SPIRIT_DEBUG_NODE) - #define BOOST_SPIRIT_DEBUG_NODE(r) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) - #endif // !defined(BOOST_SPIRIT_DEBUG_NODE) - - #if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) - #define BOOST_SPIRIT_DEBUG_GRAMMAR(r) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) - #endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) - #define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, (t)) - #endif // !defined(BOOST_SPIRIT_TRACE_RULE) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) - #define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, (t)) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) - #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, #r, (t)) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) - #define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, (n), (t)) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) - #define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, (n), (t)) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) - - #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) - #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) \ - ::BOOST_SPIRIT_CLASSIC_NS::impl::get_node_registry(). \ - register_node(&r, (n), (t)) - #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) - - ////////////////////////////////// - #include - -#else - ////////////////////////////////// - #include - -#endif // BOOST_SPIRIT_DEBUG - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/debug/debug_node.hpp b/contrib/autoboost/boost/spirit/home/classic/debug/debug_node.hpp deleted file mode 100644 index d70b28923..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/debug/debug_node.hpp +++ /dev/null @@ -1,319 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - Copyright (c) 2003 Gustavo Guerra - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_DEBUG_NODE_HPP) -#define BOOST_SPIRIT_DEBUG_NODE_HPP - -#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) -#error "You must include boost/spirit/debug.hpp, not boost/spirit/debug/debug_node.hpp" -#endif - -#if defined(BOOST_SPIRIT_DEBUG) - -#include - -#include -#include -#include -#include -#include // for iscntrl_ - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// -// Debug helper classes for rules, which ensure maximum non-intrusiveness of -// the Spirit debug support -// -/////////////////////////////////////////////////////////////////////////////// - -namespace impl { - - struct token_printer_aux_for_chars - { - template - static void print(std::ostream& o, CharT c) - { - if (c == static_cast('\a')) - o << "\\a"; - - else if (c == static_cast('\b')) - o << "\\b"; - - else if (c == static_cast('\f')) - o << "\\f"; - - else if (c == static_cast('\n')) - o << "\\n"; - - else if (c == static_cast('\r')) - o << "\\r"; - - else if (c == static_cast('\t')) - o << "\\t"; - - else if (c == static_cast('\v')) - o << "\\v"; - - else if (iscntrl_(c)) - o << "\\" << static_cast(c); - - else - o << static_cast(c); - } - }; - - // for token types where the comparison with char constants wouldn't work - struct token_printer_aux_for_other_types - { - template - static void print(std::ostream& o, CharT c) - { - o << c; - } - }; - - template - struct token_printer_aux - : mpl::if_< - mpl::and_< - is_convertible, - is_convertible >, - token_printer_aux_for_chars, - token_printer_aux_for_other_types - >::type - { - }; - - template - inline void token_printer(std::ostream& o, CharT c) - { - #if !defined(BOOST_SPIRIT_DEBUG_TOKEN_PRINTER) - - token_printer_aux::print(o, c); - - #else - - BOOST_SPIRIT_DEBUG_TOKEN_PRINTER(o, c); - - #endif - } - -/////////////////////////////////////////////////////////////////////////////// -// -// Dump infos about the parsing state of a rule -// -/////////////////////////////////////////////////////////////////////////////// - -#if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - template - inline void - print_node_info(bool hit, int level, bool close, std::string const& name, - IteratorT first, IteratorT last) - { - if (!name.empty()) - { - for (int i = 0; i < level; ++i) - BOOST_SPIRIT_DEBUG_OUT << " "; - if (close) - { - if (hit) - BOOST_SPIRIT_DEBUG_OUT << "/"; - else - BOOST_SPIRIT_DEBUG_OUT << "#"; - } - BOOST_SPIRIT_DEBUG_OUT << name << ":\t\""; - IteratorT iter = first; - IteratorT ilast = last; - for (int j = 0; j < BOOST_SPIRIT_DEBUG_PRINT_SOME; ++j) - { - if (iter == ilast) - break; - - token_printer(BOOST_SPIRIT_DEBUG_OUT, *iter); - ++iter; - } - BOOST_SPIRIT_DEBUG_OUT << "\"\n"; - } - } -#endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - -#if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES - template - inline ResultT & - print_closure_info(ResultT &hit, int level, std::string const& name) - { - if (!name.empty()) - { - for (int i = 0; i < level-1; ++i) - BOOST_SPIRIT_DEBUG_OUT << " "; - - // for now, print out the return value only - BOOST_SPIRIT_DEBUG_OUT << "^" << name << ":\t"; - if (hit.has_valid_attribute()) - BOOST_SPIRIT_DEBUG_OUT << hit.value(); - else - BOOST_SPIRIT_DEBUG_OUT << "undefined attribute"; - BOOST_SPIRIT_DEBUG_OUT << "\n"; - } - return hit; - } -#endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES - -} - -/////////////////////////////////////////////////////////////////////////////// -// -// Implementation note: The parser_context_linker, parser_scanner_linker and -// closure_context_linker classes are wrapped by a PP constant to allow -// redefinition of this classes outside of Spirit -// -/////////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) -#define BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED - - /////////////////////////////////////////////////////////////////////////// - // - // parser_context_linker is a debug wrapper for the ContextT template - // parameter of the rule<>, subrule<> and the grammar<> classes - // - /////////////////////////////////////////////////////////////////////////// - template - struct parser_context_linker : public ContextT - { - typedef ContextT base_t; - - template - parser_context_linker(ParserT const& p) - : ContextT(p) {} - - template - void pre_parse(ParserT const& p, ScannerT &scan) - { - this->base_t::pre_parse(p, scan); - -#if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - if (trace_parser(p.derived())) { - impl::print_node_info( - false, - scan.get_level(), - false, - parser_name(p.derived()), - scan.first, - scan.last); - } - scan.get_level()++; -#endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - } - - template - ResultT& post_parse(ResultT& hit, ParserT const& p, ScannerT &scan) - { -#if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - --scan.get_level(); - if (trace_parser(p.derived())) { - impl::print_node_info( - hit, - scan.get_level(), - true, - parser_name(p.derived()), - scan.first, - scan.last); - } -#endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES - - return this->base_t::post_parse(hit, p, scan); - } - }; - -#endif // !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) - -#if !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) -#define BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED - -/////////////////////////////////////////////////////////////////////////////// -// This class is to avoid linker problems and to ensure a real singleton -// 'level' variable - struct debug_support - { - int& get_level() - { - static int level = 0; - return level; - } - }; - - template - struct parser_scanner_linker : public ScannerT - { - parser_scanner_linker(ScannerT const &scan_) : ScannerT(scan_) - {} - - int &get_level() - { return debug.get_level(); } - - private: debug_support debug; - }; - -#endif // !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) - -#if !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) -#define BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED - - /////////////////////////////////////////////////////////////////////////// - // - // closure_context_linker is a debug wrapper for the closure template - // parameter of the rule<>, subrule<> and grammar classes - // - /////////////////////////////////////////////////////////////////////////// - - template - struct closure_context_linker : public parser_context_linker - { - typedef parser_context_linker base_t; - - template - closure_context_linker(ParserT const& p) - : parser_context_linker(p) {} - - template - void pre_parse(ParserT const& p, ScannerT &scan) - { this->base_t::pre_parse(p, scan); } - - template - ResultT& - post_parse(ResultT& hit, ParserT const& p, ScannerT &scan) - { -#if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES - if (hit && trace_parser(p.derived())) { - // for now, print out the return value only - return impl::print_closure_info( - this->base_t::post_parse(hit, p, scan), - scan.get_level(), - parser_name(p.derived()) - ); - } -#endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES - - return this->base_t::post_parse(hit, p, scan); - } - }; - -#endif // !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif // defined(BOOST_SPIRIT_DEBUG) - -#endif // !defined(BOOST_SPIRIT_DEBUG_NODE_HPP) - diff --git a/contrib/autoboost/boost/spirit/home/classic/debug/minimal.hpp b/contrib/autoboost/boost/spirit/home/classic/debug/minimal.hpp deleted file mode 100644 index 0cb42644a..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/debug/minimal.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_MINIMAL_DEBUG_HPP) -#define BOOST_SPIRIT_MINIMAL_DEBUG_HPP - -#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) -#error "You must include boost/spirit/debug.hpp, not boost/spirit/debug/minimal.hpp" -#endif -/////////////////////////////////////////////////////////////////////////////// -// -// Minimum debugging tools support -// -/////////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_SPIRIT_DEBUG_OUT) -#define BOOST_SPIRIT_DEBUG_OUT std::cout -#endif - -/////////////////////////////////////////////////////////////////////////// -// -// BOOST_SPIRIT_DEBUG_FLAGS controls the level of diagnostics printed -// -/////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_SPIRIT_DEBUG_FLAGS_NONE) -#define BOOST_SPIRIT_DEBUG_FLAGS_NONE 0x0000 // no diagnostics at all -#endif - -#if !defined(BOOST_SPIRIT_DEBUG_FLAGS_MAX) -#define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics -#endif - -#if !defined(BOOST_SPIRIT_DEBUG_FLAGS) -#define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX -#endif - -#if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME) -#define BOOST_SPIRIT_DEBUG_PRINT_SOME 20 -#endif - -#if !defined(BOOST_SPIRIT_DEBUG_RULE) -#define BOOST_SPIRIT_DEBUG_RULE(r) -#endif // !defined(BOOST_SPIRIT_DEBUG_RULE) - -#if !defined(BOOST_SPIRIT_DEBUG_NODE) -#define BOOST_SPIRIT_DEBUG_NODE(r) -#endif // !defined(BOOST_SPIRIT_DEBUG_NODE) - -#if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) -#define BOOST_SPIRIT_DEBUG_GRAMMAR(r) -#endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) -#define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) -#define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) -#define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) -#define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) -#define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) - -#if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) -#define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) -#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) - -#endif // !defined(BOOST_SPIRIT_MINIMAL_DEBUG_HPP) diff --git a/contrib/autoboost/boost/spirit/home/classic/meta/as_parser.hpp b/contrib/autoboost/boost/spirit/home/classic/meta/as_parser.hpp deleted file mode 100644 index 8cffcb7f5..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/meta/as_parser.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/*============================================================================= - Copyright (c) 2002-2003 Joel de Guzman - Copyright (c) 2002-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_AS_PARSER_HPP) -#define BOOST_SPIRIT_AS_PARSER_HPP - -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // Helper templates to derive the parser type from an auxilliary type - // and to generate an object of the required parser type given an - // auxilliary object. Supported types to convert are parsers, - // single characters and character strings. - // - /////////////////////////////////////////////////////////////////////////// - namespace impl - { - template - struct default_as_parser - { - typedef T type; - static type const& convert(type const& p) - { - return p; - } - }; - - struct char_as_parser - { - typedef chlit type; - static type convert(char ch) - { - return type(ch); - } - }; - - struct wchar_as_parser - { - typedef chlit type; - static type convert(wchar_t ch) - { - return type(ch); - } - }; - - struct string_as_parser - { - typedef strlit type; - static type convert(char const* str) - { - return type(str); - } - }; - - struct wstring_as_parser - { - typedef strlit type; - static type convert(wchar_t const* str) - { - return type(str); - } - }; - } - - template - struct as_parser : impl::default_as_parser {}; - - template<> - struct as_parser : impl::char_as_parser {}; - - template<> - struct as_parser : impl::wchar_as_parser {}; - - template<> - struct as_parser : impl::string_as_parser {}; - - template<> - struct as_parser : impl::string_as_parser {}; - - template<> - struct as_parser : impl::wstring_as_parser {}; - - template<> - struct as_parser : impl::wstring_as_parser {}; - - template - struct as_parser : impl::string_as_parser {}; - - template - struct as_parser : impl::wstring_as_parser {}; - - template - struct as_parser : impl::string_as_parser {}; - - template - struct as_parser : impl::wstring_as_parser {}; - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/namespace.hpp b/contrib/autoboost/boost/spirit/home/classic/namespace.hpp deleted file mode 100644 index ed9031f2d..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/namespace.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(SPIRIT_CLASSIC_NAMESPACE_HPP) -#define SPIRIT_CLASSIC_NAMESPACE_HPP - -#if defined(BOOST_SPIRIT_USE_OLD_NAMESPACE) - -// Use the old namespace for Spirit.Classic, everything is located in the -// namespace autoboost::spirit. -// This is in place for backwards compatibility with Spirit V1.8.x. Don't use -// it when combining Spirit.Classic with other parts of the library - -#define BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN /*namespace classic {*/ -#define BOOST_SPIRIT_CLASSIC_NS autoboost::spirit/*::classic*/ -#define BOOST_SPIRIT_CLASSIC_NAMESPACE_END /*}*/ - -#else - -// This is the normal (and suggested) mode of operation when using -// Spirit.Classic. Everything will be located in the namespace -// autoboost::spirit::classic, avoiding name clashes with other parts of Spirit. - -#define BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN namespace classic { -#define BOOST_SPIRIT_CLASSIC_NS autoboost::spirit::classic -#define BOOST_SPIRIT_CLASSIC_NAMESPACE_END } - -#endif - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/chset.hpp b/contrib/autoboost/boost/spirit/home/classic/utility/chset.hpp deleted file mode 100644 index 7dff20eae..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/chset.hpp +++ /dev/null @@ -1,187 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001-2003 Daniel Nuffer - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_CHSET_HPP -#define BOOST_SPIRIT_CHSET_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -namespace utility { namespace impl { - - // This is here because some compilers choke on out-of-line member - // template functions. And we don't want to put the whole algorithm - // in the chset constructor in the class definition. - template - void construct_chset(autoboost::shared_ptr >& ptr, - CharT2 const* definition); - -}} // namespace utility::impl - -/////////////////////////////////////////////////////////////////////////////// -// -// chset class -// -/////////////////////////////////////////////////////////////////////////////// -template -class chset: public char_parser > { - -public: - chset(); - chset(chset const& arg_); - explicit chset(CharT arg_); - explicit chset(anychar_parser arg_); - explicit chset(nothing_parser arg_); - explicit chset(chlit const& arg_); - explicit chset(range const& arg_); - explicit chset(negated_char_parser > const& arg_); - explicit chset(negated_char_parser > const& arg_); - - template - explicit chset(CharT2 const* definition) - : ptr(new basic_chset()) - { - utility::impl::construct_chset(ptr, definition); - } - ~chset(); - - chset& operator=(chset const& rhs); - chset& operator=(CharT rhs); - chset& operator=(anychar_parser rhs); - chset& operator=(nothing_parser rhs); - chset& operator=(chlit const& rhs); - chset& operator=(range const& rhs); - chset& operator=(negated_char_parser > const& rhs); - chset& operator=(negated_char_parser > const& rhs); - - void set(range const& arg_); - void set(negated_char_parser > const& arg_); - void set(negated_char_parser > const& arg_); - - void clear(range const& arg_); - void clear(negated_char_parser > const& arg_); - bool test(CharT ch) const; - chset& inverse(); - void swap(chset& x); - - chset& operator|=(chset const& x); - chset& operator&=(chset const& x); - chset& operator-=(chset const& x); - chset& operator^=(chset const& x); - -private: - - autoboost::shared_ptr > ptr; -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// Generator functions -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -chset_p(chlit const& arg_) -{ return chset(arg_); } - -////////////////////////////////// -template -inline chset -chset_p(range const& arg_) -{ return chset(arg_); } - -template -inline chset -chset_p(negated_char_parser > const& arg_) -{ return chset(arg_); } - -template -inline chset -chset_p(negated_char_parser > const& arg_) -{ return chset(arg_); } - -////////////////////////////////// -inline chset -chset_p(char const* init) -{ return chset(init); } - -////////////////////////////////// -inline chset -chset_p(wchar_t const* init) -{ return chset(init); } - -////////////////////////////////// -inline chset -chset_p(char ch) -{ return chset(ch); } - -////////////////////////////////// -inline chset -chset_p(wchar_t ch) -{ return chset(ch); } - -////////////////////////////////// -inline chset -chset_p(int ch) -{ return chset(ch); } - -////////////////////////////////// -inline chset -chset_p(unsigned int ch) -{ return chset(ch); } - -////////////////////////////////// -inline chset -chset_p(short ch) -{ return chset(ch); } - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) -////////////////////////////////// -inline chset -chset_p(unsigned short ch) -{ return chset(ch); } -#endif -////////////////////////////////// -inline chset -chset_p(long ch) -{ return chset(ch); } - -////////////////////////////////// -inline chset -chset_p(unsigned long ch) -{ return chset(ch); } - -#ifdef BOOST_HAS_LONG_LONG -////////////////////////////////// -inline chset< ::autoboost::long_long_type> -chset_p( ::autoboost::long_long_type ch) -{ return chset< ::autoboost::long_long_type>(ch); } - -////////////////////////////////// -inline chset< ::autoboost::ulong_long_type> -chset_p( ::autoboost::ulong_long_type ch) -{ return chset< ::autoboost::ulong_long_type>(ch); } -#endif - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/chset_operators.hpp b/contrib/autoboost/boost/spirit/home/classic/utility/chset_operators.hpp deleted file mode 100644 index 6b1f44503..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/chset_operators.hpp +++ /dev/null @@ -1,402 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001-2003 Daniel Nuffer - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_CHSET_OPERATORS_HPP -#define BOOST_SPIRIT_CHSET_OPERATORS_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// -// chset free operators -// -// Where a and b are both chsets, implements: -// -// a | b, a & b, a - b, a ^ b -// -// Where a is a chset, implements: -// -// ~a -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator~(chset const& a); - -////////////////////////////////// -template -chset -operator|(chset const& a, chset const& b); - -////////////////////////////////// -template -chset -operator&(chset const& a, chset const& b); - -////////////////////////////////// -template -chset -operator-(chset const& a, chset const& b); - -////////////////////////////////// -template -chset -operator^(chset const& a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// range <--> chset free operators -// -// Where a is a chset and b is a range, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, range const& b); - -////////////////////////////////// -template -chset -operator&(chset const& a, range const& b); - -////////////////////////////////// -template -chset -operator-(chset const& a, range const& b); - -////////////////////////////////// -template -chset -operator^(chset const& a, range const& b); - -////////////////////////////////// -template -chset -operator|(range const& a, chset const& b); - -////////////////////////////////// -template -chset -operator&(range const& a, chset const& b); - -////////////////////////////////// -template -chset -operator-(range const& a, chset const& b); - -////////////////////////////////// -template -chset -operator^(range const& a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// chlit <--> chset free operators -// -// Where a is a chset and b is a chlit, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, chlit const& b); - -////////////////////////////////// -template -chset -operator&(chset const& a, chlit const& b); - -////////////////////////////////// -template -chset -operator-(chset const& a, chlit const& b); - -////////////////////////////////// -template -chset -operator^(chset const& a, chlit const& b); - -////////////////////////////////// -template -chset -operator|(chlit const& a, chset const& b); - -////////////////////////////////// -template -chset -operator&(chlit const& a, chset const& b); - -////////////////////////////////// -template -chset -operator-(chlit const& a, chset const& b); - -////////////////////////////////// -template -chset -operator^(chlit const& a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// negated_char_parser <--> chset free operators -// -// Where a is a chset and b is a range, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator&(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator-(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator^(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator|(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator&(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator-(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator^(negated_char_parser > const& a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// negated_char_parser <--> chset free operators -// -// Where a is a chset and b is a chlit, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator&(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator-(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator^(chset const& a, negated_char_parser > const& b); - -////////////////////////////////// -template -chset -operator|(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator&(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator-(negated_char_parser > const& a, chset const& b); - -////////////////////////////////// -template -chset -operator^(negated_char_parser > const& a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// literal primitives <--> chset free operators -// -// Where a is a chset and b is a literal primitive, -// and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, CharT b); - -////////////////////////////////// -template -chset -operator&(chset const& a, CharT b); - -////////////////////////////////// -template -chset -operator-(chset const& a, CharT b); - -////////////////////////////////// -template -chset -operator^(chset const& a, CharT b); - -////////////////////////////////// -template -chset -operator|(CharT a, chset const& b); - -////////////////////////////////// -template -chset -operator&(CharT a, chset const& b); - -////////////////////////////////// -template -chset -operator-(CharT a, chset const& b); - -////////////////////////////////// -template -chset -operator^(CharT a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// anychar_parser <--> chset free operators -// -// Where a is chset and b is a anychar_parser, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, anychar_parser b); - -////////////////////////////////// -template -chset -operator&(chset const& a, anychar_parser b); - -////////////////////////////////// -template -chset -operator-(chset const& a, anychar_parser b); - -////////////////////////////////// -template -chset -operator^(chset const& a, anychar_parser b); - -////////////////////////////////// -template -chset -operator|(anychar_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator&(anychar_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator-(anychar_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator^(anychar_parser a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -// -// nothing_parser <--> chset free operators -// -// Where a is chset and b is nothing_parser, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -template -chset -operator|(chset const& a, nothing_parser b); - -////////////////////////////////// -template -chset -operator&(chset const& a, nothing_parser b); - -////////////////////////////////// -template -chset -operator-(chset const& a, nothing_parser b); - -////////////////////////////////// -template -chset -operator^(chset const& a, nothing_parser b); - -////////////////////////////////// -template -chset -operator|(nothing_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator&(nothing_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator-(nothing_parser a, chset const& b); - -////////////////////////////////// -template -chset -operator^(nothing_parser a, chset const& b); - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset.ipp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset.ipp deleted file mode 100644 index 60a6c7f7f..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset.ipp +++ /dev/null @@ -1,322 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001-2003 Daniel Nuffer - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_CHSET_IPP -#define BOOST_SPIRIT_CHSET_IPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// -// chset class -// -/////////////////////////////////////////////////////////////////////////////// -namespace utility { namespace impl { - template - inline void - detach(autoboost::shared_ptr >& ptr) - { - if (!ptr.unique()) - ptr = autoboost::shared_ptr > - (new basic_chset(*ptr)); - } - - template - inline void - detach_clear(autoboost::shared_ptr >& ptr) - { - if (ptr.unique()) - ptr->clear(); - else - ptr.reset(new basic_chset()); - } - - template - void construct_chset(autoboost::shared_ptr >& ptr, - CharT2 const* definition) - { - CharT2 ch = *definition++; - while (ch) - { - CharT2 next = *definition++; - if (next == '-') - { - next = *definition++; - if (next == 0) - { - ptr->set(ch); - ptr->set('-'); - break; - } - ptr->set(ch, next); - } - else - { - ptr->set(ch); - } - ch = next; - } - } - -}} // namespace utility::impl - -template -inline chset::chset() -: ptr(new basic_chset()) {} - -template -inline chset::chset(chset const& arg_) -: ptr(new basic_chset(*arg_.ptr)) {} - -template -inline chset::chset(CharT arg_) -: ptr(new basic_chset()) -{ ptr->set(arg_); } - -template -inline chset::chset(anychar_parser /*arg*/) -: ptr(new basic_chset()) -{ - ptr->set( - (std::numeric_limits::min)(), - (std::numeric_limits::max)() - ); -} - -template -inline chset::chset(nothing_parser arg_) -: ptr(new basic_chset()) {} - -template -inline chset::chset(chlit const& arg_) -: ptr(new basic_chset()) -{ ptr->set(arg_.ch); } - -template -inline chset::chset(range const& arg_) -: ptr(new basic_chset()) -{ ptr->set(arg_.first, arg_.last); } - -template -inline chset::chset(negated_char_parser > const& arg_) -: ptr(new basic_chset()) -{ - set(arg_); -} - -template -inline chset::chset(negated_char_parser > const& arg_) -: ptr(new basic_chset()) -{ - set(arg_); -} - -template -inline chset::~chset() {} - -template -inline chset& -chset::operator=(chset const& rhs) -{ - ptr = rhs.ptr; - return *this; -} - -template -inline chset& -chset::operator=(CharT rhs) -{ - utility::impl::detach_clear(ptr); - ptr->set(rhs); - return *this; -} - -template -inline chset& -chset::operator=(anychar_parser rhs) -{ - utility::impl::detach_clear(ptr); - ptr->set( - (std::numeric_limits::min)(), - (std::numeric_limits::max)() - ); - return *this; -} - -template -inline chset& -chset::operator=(nothing_parser rhs) -{ - utility::impl::detach_clear(ptr); - return *this; -} - -template -inline chset& -chset::operator=(chlit const& rhs) -{ - utility::impl::detach_clear(ptr); - ptr->set(rhs.ch); - return *this; -} - -template -inline chset& -chset::operator=(range const& rhs) -{ - utility::impl::detach_clear(ptr); - ptr->set(rhs.first, rhs.last); - return *this; -} - -template -inline chset& -chset::operator=(negated_char_parser > const& rhs) -{ - utility::impl::detach_clear(ptr); - set(rhs); - return *this; -} - -template -inline chset& -chset::operator=(negated_char_parser > const& rhs) -{ - utility::impl::detach_clear(ptr); - set(rhs); - return *this; -} - -template -inline void -chset::set(range const& arg_) -{ - utility::impl::detach(ptr); - ptr->set(arg_.first, arg_.last); -} - -template -inline void -chset::set(negated_char_parser > const& arg_) -{ - utility::impl::detach(ptr); - - if(arg_.positive.ch != (std::numeric_limits::min)()) { - ptr->set((std::numeric_limits::min)(), arg_.positive.ch - 1); - } - if(arg_.positive.ch != (std::numeric_limits::max)()) { - ptr->set(arg_.positive.ch + 1, (std::numeric_limits::max)()); - } -} - -template -inline void -chset::set(negated_char_parser > const& arg_) -{ - utility::impl::detach(ptr); - - if(arg_.positive.first != (std::numeric_limits::min)()) { - ptr->set((std::numeric_limits::min)(), arg_.positive.first - 1); - } - if(arg_.positive.last != (std::numeric_limits::max)()) { - ptr->set(arg_.positive.last + 1, (std::numeric_limits::max)()); - } -} - -template -inline void -chset::clear(range const& arg_) -{ - utility::impl::detach(ptr); - ptr->clear(arg_.first, arg_.last); -} - -template -inline void -chset::clear(negated_char_parser > const& arg_) -{ - utility::impl::detach(ptr); - - if(arg_.positive.first != (std::numeric_limits::min)()) { - ptr->clear((std::numeric_limits::min)(), arg_.positive.first - 1); - } - if(arg_.positive.last != (std::numeric_limits::max)()) { - ptr->clear(arg_.positive.last + 1, (std::numeric_limits::max)()); - } -} - -template -inline bool -chset::test(CharT ch) const -{ return ptr->test(ch); } - -template -inline chset& -chset::inverse() -{ - utility::impl::detach(ptr); - ptr->inverse(); - return *this; -} - -template -inline void -chset::swap(chset& x) -{ ptr.swap(x.ptr); } - -template -inline chset& -chset::operator|=(chset const& x) -{ - utility::impl::detach(ptr); - *ptr |= *x.ptr; - return *this; -} - -template -inline chset& -chset::operator&=(chset const& x) -{ - utility::impl::detach(ptr); - *ptr &= *x.ptr; - return *this; -} - -template -inline chset& -chset::operator-=(chset const& x) -{ - utility::impl::detach(ptr); - *ptr -= *x.ptr; - return *this; -} - -template -inline chset& -chset::operator^=(chset const& x) -{ - utility::impl::detach(ptr); - *ptr ^= *x.ptr; - return *this; -} - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp deleted file mode 100644 index f37e48b56..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001-2003 Daniel Nuffer - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_BASIC_CHSET_HPP -#define BOOST_SPIRIT_BASIC_CHSET_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include - -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - /////////////////////////////////////////////////////////////////////////// - // - // basic_chset: basic character set implementation using range_run - // - /////////////////////////////////////////////////////////////////////////// - template - class basic_chset - { - public: - basic_chset(); - basic_chset(basic_chset const& arg_); - - bool test(CharT v) const; - void set(CharT from, CharT to); - void set(CharT c); - void clear(CharT from, CharT to); - void clear(CharT c); - void clear(); - - void inverse(); - void swap(basic_chset& x); - - basic_chset& operator|=(basic_chset const& x); - basic_chset& operator&=(basic_chset const& x); - basic_chset& operator-=(basic_chset const& x); - basic_chset& operator^=(basic_chset const& x); - - private: utility::impl::range_run rr; - }; - - #if (CHAR_BIT == 8) - - /////////////////////////////////////////////////////////////////////////// - // - // basic_chset: specializations for 8 bit chars using std::bitset - // - /////////////////////////////////////////////////////////////////////////// - template - class basic_chset_8bit { - - public: - basic_chset_8bit(); - basic_chset_8bit(basic_chset_8bit const& arg_); - - bool test(CharT v) const; - void set(CharT from, CharT to); - void set(CharT c); - void clear(CharT from, CharT to); - void clear(CharT c); - void clear(); - - void inverse(); - void swap(basic_chset_8bit& x); - - basic_chset_8bit& operator|=(basic_chset_8bit const& x); - basic_chset_8bit& operator&=(basic_chset_8bit const& x); - basic_chset_8bit& operator-=(basic_chset_8bit const& x); - basic_chset_8bit& operator^=(basic_chset_8bit const& x); - - private: std::bitset<256> bset; - }; - - ///////////////////////////////// - template <> - class basic_chset - : public basic_chset_8bit {}; - - ///////////////////////////////// - template <> - class basic_chset - : public basic_chset_8bit {}; - - ///////////////////////////////// - template <> - class basic_chset - : public basic_chset_8bit {}; - -#endif - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp deleted file mode 100644 index 212bff02d..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp +++ /dev/null @@ -1,246 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - Copyright (c) 2001-2003 Daniel Nuffer - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_BASIC_CHSET_IPP -#define BOOST_SPIRIT_BASIC_CHSET_IPP - -/////////////////////////////////////////////////////////////////////////////// -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// -// basic_chset: character set implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline basic_chset::basic_chset() {} - -////////////////////////////////// -template -inline basic_chset::basic_chset(basic_chset const& arg_) -: rr(arg_.rr) {} - -////////////////////////////////// -template -inline bool -basic_chset::test(CharT v) const -{ return rr.test(v); } - -////////////////////////////////// -template -inline void -basic_chset::set(CharT from, CharT to) -{ rr.set(utility::impl::range(from, to)); } - -////////////////////////////////// -template -inline void -basic_chset::set(CharT c) -{ rr.set(utility::impl::range(c, c)); } - -////////////////////////////////// -template -inline void -basic_chset::clear(CharT from, CharT to) -{ rr.clear(utility::impl::range(from, to)); } - -////////////////////////////////// -template -inline void -basic_chset::clear() -{ rr.clear(); } - -///////////////////////////////// -template -inline void -basic_chset::inverse() -{ - basic_chset inv; - inv.set( - (std::numeric_limits::min)(), - (std::numeric_limits::max)() - ); - inv -= *this; - swap(inv); -} - -///////////////////////////////// -template -inline void -basic_chset::swap(basic_chset& x) -{ rr.swap(x.rr); } - -///////////////////////////////// -template -inline basic_chset& -basic_chset::operator|=(basic_chset const& x) -{ - typedef typename utility::impl::range_run::const_iterator const_iterator; - for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) - rr.set(*iter); - return *this; -} - -///////////////////////////////// -template -inline basic_chset& -basic_chset::operator&=(basic_chset const& x) -{ - basic_chset inv; - inv.set( - (std::numeric_limits::min)(), - (std::numeric_limits::max)() - ); - inv -= x; - *this -= inv; - return *this; -} - -///////////////////////////////// -template -inline basic_chset& -basic_chset::operator-=(basic_chset const& x) -{ - typedef typename utility::impl::range_run::const_iterator const_iterator; - for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) - rr.clear(*iter); - return *this; -} - -///////////////////////////////// -template -inline basic_chset& -basic_chset::operator^=(basic_chset const& x) -{ - basic_chset bma = x; - bma -= *this; - *this -= x; - *this |= bma; - return *this; -} - -#if (CHAR_BIT == 8) - -/////////////////////////////////////////////////////////////////////////////// -// -// basic_chset: specializations for 8 bit chars using std::bitset -// -/////////////////////////////////////////////////////////////////////////////// -template -inline basic_chset_8bit::basic_chset_8bit() {} - -///////////////////////////////// -template -inline basic_chset_8bit::basic_chset_8bit(basic_chset_8bit const& arg_) -: bset(arg_.bset) {} - -///////////////////////////////// -template -inline bool -basic_chset_8bit::test(CharT v) const -{ return bset.test((unsigned char)v); } - -///////////////////////////////// -template -inline void -basic_chset_8bit::set(CharT from, CharT to) -{ - for (int i = from; i <= to; ++i) - bset.set((unsigned char)i); -} - -///////////////////////////////// -template -inline void -basic_chset_8bit::set(CharT c) -{ bset.set((unsigned char)c); } - -///////////////////////////////// -template -inline void -basic_chset_8bit::clear(CharT from, CharT to) -{ - for (int i = from; i <= to; ++i) - bset.reset((unsigned char)i); -} - -///////////////////////////////// -template -inline void -basic_chset_8bit::clear(CharT c) -{ bset.reset((unsigned char)c); } - -///////////////////////////////// -template -inline void -basic_chset_8bit::clear() -{ bset.reset(); } - -///////////////////////////////// -template -inline void -basic_chset_8bit::inverse() -{ bset.flip(); } - -///////////////////////////////// -template -inline void -basic_chset_8bit::swap(basic_chset_8bit& x) -{ std::swap(bset, x.bset); } - -///////////////////////////////// -template -inline basic_chset_8bit& -basic_chset_8bit::operator|=(basic_chset_8bit const& x) -{ - bset |= x.bset; - return *this; -} - -///////////////////////////////// -template -inline basic_chset_8bit& -basic_chset_8bit::operator&=(basic_chset_8bit const& x) -{ - bset &= x.bset; - return *this; -} - -///////////////////////////////// -template -inline basic_chset_8bit& -basic_chset_8bit::operator-=(basic_chset_8bit const& x) -{ - bset &= ~x.bset; - return *this; -} - -///////////////////////////////// -template -inline basic_chset_8bit& -basic_chset_8bit::operator^=(basic_chset_8bit const& x) -{ - bset ^= x.bset; - return *this; -} - -#endif - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.hpp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.hpp deleted file mode 100644 index 5c0073a44..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_RANGE_RUN_HPP -#define BOOST_SPIRIT_RANGE_RUN_HPP - -/////////////////////////////////////////////////////////////////////////////// -#include - -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -namespace utility { namespace impl { - - /////////////////////////////////////////////////////////////////////////// - // - // range class - // - // Implements a closed range of values. This class is used in - // the implementation of the range_run class. - // - // { Low level implementation detail } - // { Not to be confused with BOOST_SPIRIT_CLASSIC_NS::range } - // - /////////////////////////////////////////////////////////////////////////// - template - struct range { - - range(CharT first, CharT last); - - bool is_valid() const; - bool includes(CharT v) const; - bool includes(range const& r) const; - bool overlaps(range const& r) const; - void merge(range const& r); - - CharT first; - CharT last; - }; - - ////////////////////////////////// - template - struct range_char_compare { - - bool operator()(range const& x, const CharT y) const - { return x.first < y; } - - bool operator()(const CharT x, range const& y) const - { return x < y.first; } - - // This additional operator is required for the checked STL shipped - // with VC8 testing the ordering of the iterators passed to the - // std::lower_bound algo this range_char_compare<> predicate is passed - // to. - bool operator()(range const& x, range const& y) const - { return x.first < y.first; } - }; - - ////////////////////////////////// - template - struct range_compare { - - bool operator()(range const& x, range const& y) const - { return x.first < y.first; } - }; - - /////////////////////////////////////////////////////////////////////////// - // - // range_run - // - // An implementation of a sparse bit (boolean) set. The set uses - // a sorted vector of disjoint ranges. This class implements the - // bare minimum essentials from which the full range of set - // operators can be implemented. The set is constructed from - // ranges. Internally, adjacent or overlapping ranges are - // coalesced. - // - // range_runs are very space-economical in situations where there - // are lots of ranges and a few individual disjoint values. - // Searching is O(log n) where n is the number of ranges. - // - // { Low level implementation detail } - // - /////////////////////////////////////////////////////////////////////////// - template - class range_run { - - public: - - typedef range range_t; - typedef std::vector run_t; - typedef typename run_t::iterator iterator; - typedef typename run_t::const_iterator const_iterator; - - void swap(range_run& rr); - bool test(CharT v) const; - void set(range_t const& r); - void clear(range_t const& r); - void clear(); - - const_iterator begin() const; - const_iterator end() const; - - private: - - void merge(iterator iter, range_t const& r); - - run_t run; - }; - -}} - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace BOOST_SPIRIT_CLASSIC_NS::utility::impl - -#endif - -#include diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.ipp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.ipp deleted file mode 100644 index 16bbc3350..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset/range_run.ipp +++ /dev/null @@ -1,218 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_RANGE_RUN_IPP -#define BOOST_SPIRIT_RANGE_RUN_IPP - -/////////////////////////////////////////////////////////////////////////////// -#include // for std::lower_bound -#include // for BOOST_SPIRIT_ASSERT -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - - namespace utility { namespace impl { - - /////////////////////////////////////////////////////////////////////// - // - // range class implementation - // - /////////////////////////////////////////////////////////////////////// - template - inline range::range(CharT first_, CharT last_) - : first(first_), last(last_) {} - - ////////////////////////////////// - template - inline bool - range::is_valid() const - { return first <= last; } - - ////////////////////////////////// - template - inline bool - range::includes(range const& r) const - { return (first <= r.first) && (last >= r.last); } - - ////////////////////////////////// - template - inline bool - range::includes(CharT v) const - { return (first <= v) && (last >= v); } - - ////////////////////////////////// - template - inline bool - range::overlaps(range const& r) const - { - CharT decr_first = - first == (std::numeric_limits::min)() ? first : first-1; - CharT incr_last = - last == (std::numeric_limits::max)() ? last : last+1; - - return (decr_first <= r.last) && (incr_last >= r.first); - } - - ////////////////////////////////// - template - inline void - range::merge(range const& r) - { - first = (std::min)(first, r.first); - last = (std::max)(last, r.last); - } - - /////////////////////////////////////////////////////////////////////// - // - // range_run class implementation - // - /////////////////////////////////////////////////////////////////////// - template - inline bool - range_run::test(CharT v) const - { - if (!run.empty()) - { - const_iterator iter = - std::lower_bound( - run.begin(), run.end(), v, - range_char_compare() - ); - - if (iter != run.end() && iter->includes(v)) - return true; - if (iter != run.begin()) - return (--iter)->includes(v); - } - return false; - } - - ////////////////////////////////// - template - inline void - range_run::swap(range_run& rr) - { run.swap(rr.run); } - - ////////////////////////////////// - template - void - range_run::merge(iterator iter, range const& r) - { - iter->merge(r); - iterator i = iter + 1; - - while (i != run.end() && iter->overlaps(*i)) - iter->merge(*i++); - - run.erase(iter+1, i); - } - - ////////////////////////////////// - template - void - range_run::set(range const& r) - { - BOOST_SPIRIT_ASSERT(r.is_valid()); - if (!run.empty()) - { - iterator iter = - std::lower_bound( - run.begin(), run.end(), r, - range_compare() - ); - - if ((iter != run.end() && iter->includes(r)) || - ((iter != run.begin()) && (iter - 1)->includes(r))) - return; - - if (iter != run.begin() && (iter - 1)->overlaps(r)) - merge(--iter, r); - - else if (iter != run.end() && iter->overlaps(r)) - merge(iter, r); - - else - run.insert(iter, r); - } - else - { - run.push_back(r); - } - } - - ////////////////////////////////// - template - void - range_run::clear(range const& r) - { - BOOST_SPIRIT_ASSERT(r.is_valid()); - if (!run.empty()) - { - iterator iter = - std::lower_bound( - run.begin(), run.end(), r, - range_compare() - ); - - iterator left_iter; - - if ((iter != run.begin()) && - (left_iter = (iter - 1))->includes(r.first)) - { - if (left_iter->last > r.last) - { - CharT save_last = left_iter->last; - left_iter->last = r.first-1; - run.insert(iter, range(r.last+1, save_last)); - return; - } - else - { - left_iter->last = r.first-1; - } - } - - iterator i = iter; - while (i != run.end() && r.includes(*i)) - i++; - if (i != run.end() && i->includes(r.last)) - i->first = r.last+1; - run.erase(iter, i); - } - } - - ////////////////////////////////// - template - inline void - range_run::clear() - { run.clear(); } - - ////////////////////////////////// - template - inline typename range_run::const_iterator - range_run::begin() const - { return run.begin(); } - - ////////////////////////////////// - template - inline typename range_run::const_iterator - range_run::end() const - { return run.end(); } - - }} // namespace utility::impl - -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif diff --git a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset_operators.ipp b/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset_operators.ipp deleted file mode 100644 index 682621dce..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/utility/impl/chset_operators.ipp +++ /dev/null @@ -1,592 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Joel de Guzman - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_CHSET_OPERATORS_IPP -#define BOOST_SPIRIT_CHSET_OPERATORS_IPP - -/////////////////////////////////////////////////////////////////////////////// -#include - -/////////////////////////////////////////////////////////////////////////////// -namespace autoboost { namespace spirit { - -BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN - -/////////////////////////////////////////////////////////////////////////////// -// -// chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, chset const& b) -{ - return chset(a) |= b; -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, chset const& b) -{ - return chset(a) -= b; -} - -////////////////////////////////// -template -inline chset -operator~(chset const& a) -{ - return chset(a).inverse(); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, chset const& b) -{ - return chset(a) &= b; -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, chset const& b) -{ - return chset(a) ^= b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// range <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, range const& b) -{ - chset a_(a); - a_.set(b); - return a_; -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, range const& b) -{ - chset a_(a); - if(b.first != (std::numeric_limits::min)()) { - a_.clear(range((std::numeric_limits::min)(), b.first - 1)); - } - if(b.last != (std::numeric_limits::max)()) { - a_.clear(range(b.last + 1, (std::numeric_limits::max)())); - } - return a_; -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, range const& b) -{ - chset a_(a); - a_.clear(b); - return a_; -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, range const& b) -{ - return a ^ chset(b); -} - -////////////////////////////////// -template -inline chset -operator|(range const& a, chset const& b) -{ - chset b_(b); - b_.set(a); - return b_; -} - -////////////////////////////////// -template -inline chset -operator&(range const& a, chset const& b) -{ - chset b_(b); - if(a.first != (std::numeric_limits::min)()) { - b_.clear(range((std::numeric_limits::min)(), a.first - 1)); - } - if(a.last != (std::numeric_limits::max)()) { - b_.clear(range(a.last + 1, (std::numeric_limits::max)())); - } - return b_; -} - -////////////////////////////////// -template -inline chset -operator-(range const& a, chset const& b) -{ - return chset(a) - b; -} - -////////////////////////////////// -template -inline chset -operator^(range const& a, chset const& b) -{ - return chset(a) ^ b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// literal primitives <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, CharT b) -{ - return a | chset(b); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, CharT b) -{ - return a & chset(b); -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, CharT b) -{ - return a - chset(b); -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, CharT b) -{ - return a ^ chset(b); -} - -////////////////////////////////// -template -inline chset -operator|(CharT a, chset const& b) -{ - return chset(a) | b; -} - -////////////////////////////////// -template -inline chset -operator&(CharT a, chset const& b) -{ - return chset(a) & b; -} - -////////////////////////////////// -template -inline chset -operator-(CharT a, chset const& b) -{ - return chset(a) - b; -} - -////////////////////////////////// -template -inline chset -operator^(CharT a, chset const& b) -{ - return chset(a) ^ b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// chlit <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, chlit const& b) -{ - return a | chset(b.ch); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, chlit const& b) -{ - return a & chset(b.ch); -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, chlit const& b) -{ - return a - chset(b.ch); -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, chlit const& b) -{ - return a ^ chset(b.ch); -} - -////////////////////////////////// -template -inline chset -operator|(chlit const& a, chset const& b) -{ - return chset(a.ch) | b; -} - -////////////////////////////////// -template -inline chset -operator&(chlit const& a, chset const& b) -{ - return chset(a.ch) & b; -} - -////////////////////////////////// -template -inline chset -operator-(chlit const& a, chset const& b) -{ - return chset(a.ch) - b; -} - -////////////////////////////////// -template -inline chset -operator^(chlit const& a, chset const& b) -{ - return chset(a.ch) ^ b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// negated_char_parser <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, negated_char_parser > const& b) -{ - return a | chset(b); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, negated_char_parser > const& b) -{ - return a & chset(b); -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, negated_char_parser > const& b) -{ - return a - chset(b); -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, negated_char_parser > const& b) -{ - return a ^ chset(b); -} - -////////////////////////////////// -template -inline chset -operator|(negated_char_parser > const& a, chset const& b) -{ - return chset(a) | b; -} - -////////////////////////////////// -template -inline chset -operator&(negated_char_parser > const& a, chset const& b) -{ - return chset(a) & b; -} - -////////////////////////////////// -template -inline chset -operator-(negated_char_parser > const& a, chset const& b) -{ - return chset(a) - b; -} - -////////////////////////////////// -template -inline chset -operator^(negated_char_parser > const& a, chset const& b) -{ - return chset(a) ^ b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// negated_char_parser <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, negated_char_parser > const& b) -{ - return a | chset(b); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, negated_char_parser > const& b) -{ - return a & chset(b); -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, negated_char_parser > const& b) -{ - return a - chset(b); -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, negated_char_parser > const& b) -{ - return a ^ chset(b); -} - -////////////////////////////////// -template -inline chset -operator|(negated_char_parser > const& a, chset const& b) -{ - return chset(a) | b; -} - -////////////////////////////////// -template -inline chset -operator&(negated_char_parser > const& a, chset const& b) -{ - return chset(a) & b; -} - -////////////////////////////////// -template -inline chset -operator-(negated_char_parser > const& a, chset const& b) -{ - return chset(a) - b; -} - -////////////////////////////////// -template -inline chset -operator^(negated_char_parser > const& a, chset const& b) -{ - return chset(a) ^ b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// anychar_parser <--> chset free operators -// -// Where a is chset and b is a anychar_parser, and vice-versa, implements: -// -// a | b, a & b, a - b, a ^ b -// -/////////////////////////////////////////////////////////////////////////////// -namespace impl { - - template - inline BOOST_SPIRIT_CLASSIC_NS::range const& - full() - { - static BOOST_SPIRIT_CLASSIC_NS::range full_( - (std::numeric_limits::min)(), - (std::numeric_limits::max)()); - return full_; - } - - template - inline BOOST_SPIRIT_CLASSIC_NS::range const& - empty() - { - static BOOST_SPIRIT_CLASSIC_NS::range empty_; - return empty_; - } -} - -////////////////////////////////// -template -inline chset -operator|(chset const&, anychar_parser) -{ - return chset(impl::full()); -} - -////////////////////////////////// -template -inline chset -operator&(chset const& a, anychar_parser) -{ - return a; -} - -////////////////////////////////// -template -inline chset -operator-(chset const&, anychar_parser) -{ - return chset(); -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, anychar_parser) -{ - return ~a; -} - -////////////////////////////////// -template -inline chset -operator|(anychar_parser, chset const& /*b*/) -{ - return chset(impl::full()); -} - -////////////////////////////////// -template -inline chset -operator&(anychar_parser, chset const& b) -{ - return b; -} - -////////////////////////////////// -template -inline chset -operator-(anychar_parser, chset const& b) -{ - return ~b; -} - -////////////////////////////////// -template -inline chset -operator^(anychar_parser, chset const& b) -{ - return ~b; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// nothing_parser <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template -inline chset -operator|(chset const& a, nothing_parser) -{ - return a; -} - -////////////////////////////////// -template -inline chset -operator&(chset const& /*a*/, nothing_parser) -{ - return impl::empty(); -} - -////////////////////////////////// -template -inline chset -operator-(chset const& a, nothing_parser) -{ - return a; -} - -////////////////////////////////// -template -inline chset -operator^(chset const& a, nothing_parser) -{ - return a; -} - -////////////////////////////////// -template -inline chset -operator|(nothing_parser, chset const& b) -{ - return b; -} - -////////////////////////////////// -template -inline chset -operator&(nothing_parser, chset const& /*b*/) -{ - return impl::empty(); -} - -////////////////////////////////// -template -inline chset -operator-(nothing_parser, chset const& /*b*/) -{ - return impl::empty(); -} - -////////////////////////////////// -template -inline chset -operator^(nothing_parser, chset const& b) -{ - return b; -} - -/////////////////////////////////////////////////////////////////////////////// -BOOST_SPIRIT_CLASSIC_NAMESPACE_END - -}} // namespace autoboost::spirit - -#endif - diff --git a/contrib/autoboost/boost/spirit/home/classic/version.hpp b/contrib/autoboost/boost/spirit/home/classic/version.hpp deleted file mode 100644 index 77371ed37..000000000 --- a/contrib/autoboost/boost/spirit/home/classic/version.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2003 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(SPIRIT_CLASSIC_VERSION_HPP) -#define SPIRIT_CLASSIC_VERSION_HPP - -/////////////////////////////////////////////////////////////////////////////// -// -// This checks, whether the used Boost library is at least V1.32.0 -// -/////////////////////////////////////////////////////////////////////////////// -#include - -#if BOOST_VERSION < 103200 -#error "Spirit v1.8.x needs at least Boost V1.32.0 to compile successfully." -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// This is the version of the current Spirit distribution -// -/////////////////////////////////////////////////////////////////////////////// -#define SPIRIT_VERSION 0x1806 -#define SPIRIT_PIZZA_VERSION SPIRIT_MEGA_VEGGI // :-) - -#endif // defined(SPIRIT_VERSION_HPP) diff --git a/contrib/autoboost/boost/spirit/include/classic_actions.hpp b/contrib/autoboost/boost/spirit/include/classic_actions.hpp deleted file mode 100644 index a37d631b5..000000000 --- a/contrib/autoboost/boost/spirit/include/classic_actions.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_INCLUDE_CLASSIC_CLASSIC_ACTIONS -#define BOOST_SPIRIT_INCLUDE_CLASSIC_CLASSIC_ACTIONS -#include -#endif diff --git a/contrib/autoboost/boost/spirit/include/classic_chset.hpp b/contrib/autoboost/boost/spirit/include/classic_chset.hpp deleted file mode 100644 index 2f8df490d..000000000 --- a/contrib/autoboost/boost/spirit/include/classic_chset.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_INCLUDE_CLASSIC_CHSET -#define BOOST_SPIRIT_INCLUDE_CLASSIC_CHSET -#include -#endif diff --git a/contrib/autoboost/boost/spirit/include/classic_numerics.hpp b/contrib/autoboost/boost/spirit/include/classic_numerics.hpp deleted file mode 100644 index 75f7c053b..000000000 --- a/contrib/autoboost/boost/spirit/include/classic_numerics.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_INCLUDE_CLASSIC_NUMERICS -#define BOOST_SPIRIT_INCLUDE_CLASSIC_NUMERICS -#include -#endif diff --git a/contrib/autoboost/boost/spirit/include/classic_operators.hpp b/contrib/autoboost/boost/spirit/include/classic_operators.hpp deleted file mode 100644 index c05d94779..000000000 --- a/contrib/autoboost/boost/spirit/include/classic_operators.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_INCLUDE_CLASSIC_OPERATORS -#define BOOST_SPIRIT_INCLUDE_CLASSIC_OPERATORS -#include -#endif diff --git a/contrib/autoboost/boost/spirit/include/classic_rule.hpp b/contrib/autoboost/boost/spirit/include/classic_rule.hpp deleted file mode 100644 index c2e0df1d3..000000000 --- a/contrib/autoboost/boost/spirit/include/classic_rule.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 Joel de Guzman - Copyright (c) 2001-2008 Hartmut Kaiser - http://spirit.sourceforge.net/ - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#ifndef BOOST_SPIRIT_INCLUDE_CLASSIC_RULE -#define BOOST_SPIRIT_INCLUDE_CLASSIC_RULE -#include -#endif From 29aa83cd01db9aea2d6eadcbe0a6e393167eac2e Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:17:58 -0800 Subject: [PATCH 25/57] Eliminating Concept Boost::Concept is a library for template concept checking; it's a nice idea, but Autowiring already has a lot of this functionality built in now, and we do not want to create a dependency here --- contrib/autoboost/boost/concept/assert.hpp | 45 ------- .../concept/detail/backward_compatibility.hpp | 16 --- .../boost/concept/detail/borland.hpp | 30 ----- .../boost/concept/detail/concept_def.hpp | 34 ----- .../boost/concept/detail/concept_undef.hpp | 5 - .../boost/concept/detail/general.hpp | 84 ------------ .../boost/concept/detail/has_constraints.hpp | 50 ------- .../autoboost/boost/concept/detail/msvc.hpp | 123 ------------------ contrib/autoboost/boost/concept/usage.hpp | 36 ----- 9 files changed, 423 deletions(-) delete mode 100644 contrib/autoboost/boost/concept/assert.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/backward_compatibility.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/borland.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/concept_def.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/concept_undef.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/general.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/has_constraints.hpp delete mode 100644 contrib/autoboost/boost/concept/detail/msvc.hpp delete mode 100644 contrib/autoboost/boost/concept/usage.hpp diff --git a/contrib/autoboost/boost/concept/assert.hpp b/contrib/autoboost/boost/concept/assert.hpp deleted file mode 100644 index cf9817952..000000000 --- a/contrib/autoboost/boost/concept/assert.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_ASSERT_DWA2006430_HPP -# define BOOST_CONCEPT_ASSERT_DWA2006430_HPP - -# include -# include - -// The old protocol used a constraints() member function in concept -// checking classes. If the compiler supports SFINAE, we can detect -// that function and seamlessly support the old concept checking -// classes. In this release, backward compatibility with the old -// concept checking classes is enabled by default, where available. -// The old protocol is deprecated, though, and backward compatibility -// will no longer be the default in the next release. - -# if !defined(BOOST_NO_OLD_CONCEPT_SUPPORT) \ - && !defined(BOOST_NO_SFINAE) \ - \ - && !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4)) - -// Note: gcc-2.96 through 3.3.x have some SFINAE, but no ability to -// check for the presence of particularmember functions. - -# define BOOST_OLD_CONCEPT_SUPPORT - -# endif - -# ifdef BOOST_MSVC -# include -# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# include -# else -# include -# endif - - // Usage, in class or function context: - // - // BOOST_CONCEPT_ASSERT((UnaryFunctionConcept)); - // -# define BOOST_CONCEPT_ASSERT(ModelInParens) \ - BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) - -#endif // BOOST_CONCEPT_ASSERT_DWA2006430_HPP diff --git a/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp b/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp deleted file mode 100644 index cbb2aed09..000000000 --- a/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright David Abrahams 2009. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP -# define BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP - -namespace autoboost -{ - namespace concepts {} - -# if defined(BOOST_HAS_CONCEPTS) && !defined(BOOST_CONCEPT_NO_BACKWARD_KEYWORD) - namespace concept = concepts; -# endif -} // namespace autoboost::concept - -#endif // BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP diff --git a/contrib/autoboost/boost/concept/detail/borland.hpp b/contrib/autoboost/boost/concept/detail/borland.hpp deleted file mode 100644 index 05e86cbec..000000000 --- a/contrib/autoboost/boost/concept/detail/borland.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP -# define BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP - -# include -# include - -namespace autoboost { namespace concepts { - -template -struct require; - -template -struct require -{ - enum { instantiate = sizeof((((Model*)0)->~Model()), 3) }; -}; - -# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ - enum \ - { \ - BOOST_PP_CAT(boost_concept_check,__LINE__) = \ - autoboost::concepts::require::instantiate \ - } - -}} // namespace autoboost::concept - -#endif // BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/concept_def.hpp b/contrib/autoboost/boost/concept/detail/concept_def.hpp deleted file mode 100644 index 750561ee3..000000000 --- a/contrib/autoboost/boost/concept/detail/concept_def.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP -# define BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP -# include -# include -# include -# include -#endif // BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP - -// BOOST_concept(SomeName, (p1)(p2)...(pN)) -// -// Expands to "template struct SomeName" -// -// Also defines an equivalent SomeNameConcept for backward compatibility. -// Maybe in the next release we can kill off the "Concept" suffix for good. -# define BOOST_concept(name, params) \ - template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ - struct name; /* forward declaration */ \ - \ - template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ - struct BOOST_PP_CAT(name,Concept) \ - : name< BOOST_PP_SEQ_ENUM(params) > \ - { \ - }; \ - \ - template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ - struct name - -// Helper for BOOST_concept, above. -# define BOOST_CONCEPT_typename(r, ignored, index, t) \ - BOOST_PP_COMMA_IF(index) typename t - diff --git a/contrib/autoboost/boost/concept/detail/concept_undef.hpp b/contrib/autoboost/boost/concept/detail/concept_undef.hpp deleted file mode 100644 index 713db8912..000000000 --- a/contrib/autoboost/boost/concept/detail/concept_undef.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -# undef BOOST_concept_typename -# undef BOOST_concept diff --git a/contrib/autoboost/boost/concept/detail/general.hpp b/contrib/autoboost/boost/concept/detail/general.hpp deleted file mode 100644 index cc9d492b2..000000000 --- a/contrib/autoboost/boost/concept/detail/general.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP -# define BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP - -# include -# include - -# ifdef BOOST_OLD_CONCEPT_SUPPORT -# include -# include -# endif - -// This implementation works on Comeau and GCC, all the way back to -// 2.95 -namespace autoboost { namespace concepts { - -template -struct requirement_; - -namespace detail -{ - template struct instantiate {}; -} - -template -struct requirement -{ - static void failed() { ((Model*)0)->~Model(); } -}; - -struct failed {}; - -template -struct requirement -{ - static void failed() { ((Model*)0)->~Model(); } -}; - -# ifdef BOOST_OLD_CONCEPT_SUPPORT - -template -struct constraint -{ - static void failed() { ((Model*)0)->constraints(); } -}; - -template -struct requirement_ - : mpl::if_< - concepts::not_satisfied - , constraint - , requirement - >::type -{}; - -# else - -// For GCC-2.x, these can't have exactly the same name -template -struct requirement_ - : requirement -{}; - -# endif - -// Version check from https://svn.boost.org/trac/boost/changeset/82886 -// (boost/static_assert.hpp) -#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) -#define BOOST_CONCEPT_UNUSED_TYPEDEF __attribute__((unused)) -#else -#define BOOST_CONCEPT_UNUSED_TYPEDEF /**/ -#endif - -# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ - typedef ::autoboost::concepts::detail::instantiate< \ - &::autoboost::concepts::requirement_::failed> \ - BOOST_PP_CAT(boost_concept_check,__LINE__) \ - BOOST_CONCEPT_UNUSED_TYPEDEF - -}} - -#endif // BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/has_constraints.hpp b/contrib/autoboost/boost/concept/detail/has_constraints.hpp deleted file mode 100644 index 317025e25..000000000 --- a/contrib/autoboost/boost/concept/detail/has_constraints.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP -# define BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP - -# include -# include -# include - -namespace autoboost { namespace concepts { - -namespace detail -{ - -// Here we implement the metafunction that detects whether a -// constraints metafunction exists - typedef char yes; - typedef char (&no)[2]; - - template - struct wrap_constraints {}; - -#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580) || defined(__CUDACC__) - // Work around the following bogus error in Sun Studio 11, by - // turning off the has_constraints function entirely: - // Error: complex expression not allowed in dependent template - // argument expression - inline no has_constraints_(...); -#else - template - inline yes has_constraints_(Model*, wrap_constraints* = 0); - inline no has_constraints_(...); -#endif -} - -// This would be called "detail::has_constraints," but it has a strong -// tendency to show up in error messages. -template -struct not_satisfied -{ - BOOST_STATIC_CONSTANT( - bool - , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) ); - typedef mpl::bool_ type; -}; - -}} // namespace autoboost::concepts::detail - -#endif // BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/msvc.hpp b/contrib/autoboost/boost/concept/detail/msvc.hpp deleted file mode 100644 index 29675bfc8..000000000 --- a/contrib/autoboost/boost/concept/detail/msvc.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP -# define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP - -# include -# include -# include - -# ifdef BOOST_OLD_CONCEPT_SUPPORT -# include -# include -# endif - -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4100) -# endif - -namespace autoboost { namespace concepts { - - -template -struct check -{ - virtual void failed(Model* x) - { - x->~Model(); - } -}; - -# ifndef BOOST_NO_PARTIAL_SPECIALIZATION -struct failed {}; -template -struct check -{ - virtual void failed(Model* x) - { - x->~Model(); - } -}; -# endif - -# ifdef BOOST_OLD_CONCEPT_SUPPORT - -namespace detail -{ - // No need for a virtual function here, since evaluating - // not_satisfied below will have already instantiated the - // constraints() member. - struct constraint {}; -} - -template -struct require - : mpl::if_c< - not_satisfied::value - , detail::constraint -# ifndef BOOST_NO_PARTIAL_SPECIALIZATION - , check -# else - , check -# endif - >::type -{}; - -# else - -template -struct require -# ifndef BOOST_NO_PARTIAL_SPECIALIZATION - : check -# else - : check -# endif -{}; - -# endif - -# if BOOST_WORKAROUND(BOOST_MSVC, == 1310) - -// -// The iterator library sees some really strange errors unless we -// do things this way. -// -template -struct require -{ - virtual void failed(Model*) - { - require(); - } -}; - -# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ -enum \ -{ \ - BOOST_PP_CAT(boost_concept_check,__LINE__) = \ - sizeof(::autoboost::concepts::require) \ -} - -# else // Not vc-7.1 - -template -require -require_(void(*)(Model)); - -# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ -enum \ -{ \ - BOOST_PP_CAT(boost_concept_check,__LINE__) = \ - sizeof(::autoboost::concepts::require_((ModelFnPtr)0)) \ -} - -# endif -}} - -# ifdef BOOST_MSVC -# pragma warning(pop) -# endif - -#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/usage.hpp b/contrib/autoboost/boost/concept/usage.hpp deleted file mode 100644 index 85486bacd..000000000 --- a/contrib/autoboost/boost/concept/usage.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_USAGE_DWA2006919_HPP -# define BOOST_CONCEPT_USAGE_DWA2006919_HPP - -# include -# include -# include - -namespace autoboost { namespace concepts { - -template -struct usage_requirements -{ - ~usage_requirements() { ((Model*)0)->~Model(); } -}; - -# if BOOST_WORKAROUND(__GNUC__, <= 3) - -# define BOOST_CONCEPT_USAGE(model) \ - model(); /* at least 2.96 and 3.4.3 both need this :( */ \ - BOOST_CONCEPT_ASSERT((autoboost::concepts::usage_requirements)); \ - ~model() - -# else - -# define BOOST_CONCEPT_USAGE(model) \ - BOOST_CONCEPT_ASSERT((autoboost::concepts::usage_requirements)); \ - ~model() - -# endif - -}} // namespace autoboost::concepts - -#endif // BOOST_CONCEPT_USAGE_DWA2006919_HPP From d0e881b6d9ec8db92d58c3c546884779854e954d Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:19:18 -0800 Subject: [PATCH 26/57] Eliminating boost::test Boost::Test is a unit testing package that we don't need; we already have an embedded dependency on Google Test and don't need another testing/mock object framework. --- contrib/autoboost/boost/test/debug.hpp | 101 -- contrib/autoboost/boost/test/debug_config.hpp | 24 - .../autoboost/boost/test/detail/config.hpp | 104 -- .../boost/test/detail/enable_warnings.hpp | 30 - .../autoboost/boost/test/detail/fwd_decl.hpp | 48 - .../boost/test/detail/global_typedef.hpp | 88 -- .../autoboost/boost/test/detail/log_level.hpp | 43 - .../boost/test/detail/suppress_warnings.hpp | 31 - .../test/detail/unit_test_parameters.hpp | 69 - .../boost/test/detail/workaround.hpp | 65 - .../boost/test/execution_monitor.hpp | 263 ---- .../boost/test/floating_point_comparison.hpp | 286 ---- contrib/autoboost/boost/test/framework.hpp | 112 -- .../test/impl/compiler_log_formatter.ipp | 222 --- .../autoboost/boost/test/impl/cpp_main.ipp | 139 -- contrib/autoboost/boost/test/impl/debug.ipp | 970 ------------ .../boost/test/impl/exception_safety.ipp | 537 ------- .../boost/test/impl/execution_monitor.ipp | 1367 ----------------- .../autoboost/boost/test/impl/framework.ipp | 503 ------ .../boost/test/impl/interaction_based.ipp | 90 -- .../boost/test/impl/logged_expectations.ipp | 246 --- .../test/impl/plain_report_formatter.ipp | 198 --- .../boost/test/impl/progress_monitor.ipp | 110 -- .../boost/test/impl/results_collector.ipp | 294 ---- .../boost/test/impl/results_reporter.ipp | 202 --- .../autoboost/boost/test/impl/test_main.ipp | 68 - .../autoboost/boost/test/impl/test_tools.ipp | 628 -------- .../boost/test/impl/unit_test_log.ipp | 444 ------ .../boost/test/impl/unit_test_main.ipp | 246 --- .../boost/test/impl/unit_test_monitor.ipp | 101 -- .../boost/test/impl/unit_test_parameters.ipp | 527 ------- .../boost/test/impl/unit_test_suite.ipp | 346 ----- .../boost/test/impl/xml_log_formatter.ipp | 180 --- .../boost/test/impl/xml_report_formatter.ipp | 115 -- .../boost/test/interaction_based.hpp | 262 ---- contrib/autoboost/boost/test/mock_object.hpp | 328 ---- .../test/output/compiler_log_formatter.hpp | 68 - .../test/output/plain_report_formatter.hpp | 62 - .../boost/test/output/xml_log_formatter.hpp | 72 - .../test/output/xml_report_formatter.hpp | 58 - .../boost/test/output_test_stream.hpp | 78 - .../autoboost/boost/test/predicate_result.hpp | 88 -- .../autoboost/boost/test/progress_monitor.hpp | 70 - .../boost/test/results_collector.hpp | 112 -- .../autoboost/boost/test/results_reporter.hpp | 88 -- .../autoboost/boost/test/test_observer.hpp | 65 - contrib/autoboost/boost/test/test_tools.hpp | 719 --------- contrib/autoboost/boost/test/unit_test.hpp | 66 - .../autoboost/boost/test/unit_test_log.hpp | 177 --- .../boost/test/unit_test_log_formatter.hpp | 123 -- .../boost/test/unit_test_monitor.hpp | 69 - .../autoboost/boost/test/unit_test_suite.hpp | 245 --- .../boost/test/unit_test_suite_impl.hpp | 434 ------ .../autoboost/boost/test/utils/algorithm.hpp | 228 --- .../autoboost/boost/test/utils/assign_op.hpp | 41 - .../utils/basic_cstring/basic_cstring.hpp | 731 --------- .../utils/basic_cstring/basic_cstring_fwd.hpp | 40 - .../utils/basic_cstring/bcs_char_traits.hpp | 150 -- .../test/utils/basic_cstring/compare.hpp | 115 -- .../boost/test/utils/basic_cstring/io.hpp | 73 - .../autoboost/boost/test/utils/callback.hpp | 310 ---- .../boost/test/utils/class_properties.hpp | 221 --- .../boost/test/utils/custom_manip.hpp | 63 - .../boost/test/utils/fixed_mapping.hpp | 124 -- .../autoboost/boost/test/utils/foreach.hpp | 281 ---- .../utils/iterator/input_iterator_facade.hpp | 109 -- .../test/utils/iterator/token_iterator.hpp | 418 ----- .../boost/test/utils/lazy_ostream.hpp | 114 -- .../boost/test/utils/named_params.hpp | 329 ---- contrib/autoboost/boost/test/utils/rtti.hpp | 64 - .../boost/test/utils/runtime/argument.hpp | 112 -- .../utils/runtime/cla/argument_factory.hpp | 218 --- .../test/utils/runtime/cla/argv_traverser.hpp | 98 -- .../test/utils/runtime/cla/argv_traverser.ipp | 209 --- .../utils/runtime/cla/basic_parameter.hpp | 85 - .../test/utils/runtime/cla/char_parameter.hpp | 98 -- .../test/utils/runtime/cla/char_parameter.ipp | 57 - .../cla/detail/argument_value_usage.hpp | 82 - .../utils/runtime/cla/dual_name_parameter.hpp | 96 -- .../utils/runtime/cla/dual_name_parameter.ipp | 90 -- .../boost/test/utils/runtime/cla/fwd.hpp | 55 - .../test/utils/runtime/cla/id_policy.hpp | 145 -- .../test/utils/runtime/cla/id_policy.ipp | 118 -- .../runtime/cla/iface/argument_factory.hpp | 51 - .../utils/runtime/cla/iface/id_policy.hpp | 73 - .../boost/test/utils/runtime/cla/modifier.hpp | 69 - .../utils/runtime/cla/named_parameter.hpp | 93 -- .../utils/runtime/cla/named_parameter.ipp | 129 -- .../test/utils/runtime/cla/parameter.hpp | 150 -- .../boost/test/utils/runtime/cla/parser.hpp | 153 -- .../boost/test/utils/runtime/cla/parser.ipp | 258 ---- .../utils/runtime/cla/typed_parameter.hpp | 70 - .../test/utils/runtime/cla/validation.hpp | 55 - .../test/utils/runtime/cla/validation.ipp | 65 - .../utils/runtime/cla/value_generator.hpp | 81 - .../test/utils/runtime/cla/value_handler.hpp | 57 - .../boost/test/utils/runtime/config.hpp | 156 -- .../test/utils/runtime/env/environment.hpp | 172 --- .../test/utils/runtime/env/environment.ipp | 125 -- .../boost/test/utils/runtime/env/fwd.hpp | 54 - .../boost/test/utils/runtime/env/modifier.hpp | 47 - .../boost/test/utils/runtime/env/variable.hpp | 223 --- .../boost/test/utils/runtime/fwd.hpp | 41 - .../runtime/interpret_argument_value.hpp | 163 -- .../boost/test/utils/runtime/parameter.hpp | 38 - .../boost/test/utils/runtime/trace.hpp | 30 - .../boost/test/utils/runtime/validation.hpp | 82 - .../boost/test/utils/trivial_singleton.hpp | 74 - .../boost/test/utils/wrap_stringstream.hpp | 164 -- .../boost/test/utils/xml_printer.hpp | 118 -- .../libs/test/src/compiler_log_formatter.cpp | 18 - contrib/autoboost/libs/test/src/cpp_main.cpp | 19 - contrib/autoboost/libs/test/src/debug.cpp | 24 - .../libs/test/src/exception_safety.cpp | 19 - .../libs/test/src/execution_monitor.cpp | 18 - contrib/autoboost/libs/test/src/framework.cpp | 18 - .../libs/test/src/interaction_based.cpp | 18 - .../libs/test/src/logged_expectations.cpp | 18 - .../libs/test/src/plain_report_formatter.cpp | 18 - .../libs/test/src/progress_monitor.cpp | 18 - .../libs/test/src/results_collector.cpp | 18 - .../libs/test/src/results_reporter.cpp | 18 - contrib/autoboost/libs/test/src/test_main.cpp | 18 - .../autoboost/libs/test/src/test_tools.cpp | 18 - .../autoboost/libs/test/src/unit_test_log.cpp | 18 - .../libs/test/src/unit_test_main.cpp | 18 - .../libs/test/src/unit_test_monitor.cpp | 18 - .../libs/test/src/unit_test_parameters.cpp | 18 - .../libs/test/src/unit_test_suite.cpp | 18 - .../libs/test/src/xml_log_formatter.cpp | 18 - .../libs/test/src/xml_report_formatter.cpp | 18 - 131 files changed, 20032 deletions(-) delete mode 100644 contrib/autoboost/boost/test/debug.hpp delete mode 100644 contrib/autoboost/boost/test/debug_config.hpp delete mode 100644 contrib/autoboost/boost/test/detail/config.hpp delete mode 100644 contrib/autoboost/boost/test/detail/enable_warnings.hpp delete mode 100644 contrib/autoboost/boost/test/detail/fwd_decl.hpp delete mode 100644 contrib/autoboost/boost/test/detail/global_typedef.hpp delete mode 100644 contrib/autoboost/boost/test/detail/log_level.hpp delete mode 100644 contrib/autoboost/boost/test/detail/suppress_warnings.hpp delete mode 100644 contrib/autoboost/boost/test/detail/unit_test_parameters.hpp delete mode 100644 contrib/autoboost/boost/test/detail/workaround.hpp delete mode 100644 contrib/autoboost/boost/test/execution_monitor.hpp delete mode 100644 contrib/autoboost/boost/test/floating_point_comparison.hpp delete mode 100644 contrib/autoboost/boost/test/framework.hpp delete mode 100644 contrib/autoboost/boost/test/impl/compiler_log_formatter.ipp delete mode 100644 contrib/autoboost/boost/test/impl/cpp_main.ipp delete mode 100644 contrib/autoboost/boost/test/impl/debug.ipp delete mode 100644 contrib/autoboost/boost/test/impl/exception_safety.ipp delete mode 100644 contrib/autoboost/boost/test/impl/execution_monitor.ipp delete mode 100644 contrib/autoboost/boost/test/impl/framework.ipp delete mode 100644 contrib/autoboost/boost/test/impl/interaction_based.ipp delete mode 100644 contrib/autoboost/boost/test/impl/logged_expectations.ipp delete mode 100644 contrib/autoboost/boost/test/impl/plain_report_formatter.ipp delete mode 100644 contrib/autoboost/boost/test/impl/progress_monitor.ipp delete mode 100644 contrib/autoboost/boost/test/impl/results_collector.ipp delete mode 100644 contrib/autoboost/boost/test/impl/results_reporter.ipp delete mode 100644 contrib/autoboost/boost/test/impl/test_main.ipp delete mode 100644 contrib/autoboost/boost/test/impl/test_tools.ipp delete mode 100644 contrib/autoboost/boost/test/impl/unit_test_log.ipp delete mode 100644 contrib/autoboost/boost/test/impl/unit_test_main.ipp delete mode 100644 contrib/autoboost/boost/test/impl/unit_test_monitor.ipp delete mode 100644 contrib/autoboost/boost/test/impl/unit_test_parameters.ipp delete mode 100644 contrib/autoboost/boost/test/impl/unit_test_suite.ipp delete mode 100644 contrib/autoboost/boost/test/impl/xml_log_formatter.ipp delete mode 100644 contrib/autoboost/boost/test/impl/xml_report_formatter.ipp delete mode 100644 contrib/autoboost/boost/test/interaction_based.hpp delete mode 100644 contrib/autoboost/boost/test/mock_object.hpp delete mode 100644 contrib/autoboost/boost/test/output/compiler_log_formatter.hpp delete mode 100644 contrib/autoboost/boost/test/output/plain_report_formatter.hpp delete mode 100644 contrib/autoboost/boost/test/output/xml_log_formatter.hpp delete mode 100644 contrib/autoboost/boost/test/output/xml_report_formatter.hpp delete mode 100644 contrib/autoboost/boost/test/output_test_stream.hpp delete mode 100644 contrib/autoboost/boost/test/predicate_result.hpp delete mode 100644 contrib/autoboost/boost/test/progress_monitor.hpp delete mode 100644 contrib/autoboost/boost/test/results_collector.hpp delete mode 100644 contrib/autoboost/boost/test/results_reporter.hpp delete mode 100644 contrib/autoboost/boost/test/test_observer.hpp delete mode 100644 contrib/autoboost/boost/test/test_tools.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test_log.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test_log_formatter.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test_monitor.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test_suite.hpp delete mode 100644 contrib/autoboost/boost/test/unit_test_suite_impl.hpp delete mode 100644 contrib/autoboost/boost/test/utils/algorithm.hpp delete mode 100644 contrib/autoboost/boost/test/utils/assign_op.hpp delete mode 100644 contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring.hpp delete mode 100644 contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp delete mode 100644 contrib/autoboost/boost/test/utils/basic_cstring/bcs_char_traits.hpp delete mode 100644 contrib/autoboost/boost/test/utils/basic_cstring/compare.hpp delete mode 100644 contrib/autoboost/boost/test/utils/basic_cstring/io.hpp delete mode 100644 contrib/autoboost/boost/test/utils/callback.hpp delete mode 100644 contrib/autoboost/boost/test/utils/class_properties.hpp delete mode 100644 contrib/autoboost/boost/test/utils/custom_manip.hpp delete mode 100644 contrib/autoboost/boost/test/utils/fixed_mapping.hpp delete mode 100644 contrib/autoboost/boost/test/utils/foreach.hpp delete mode 100644 contrib/autoboost/boost/test/utils/iterator/input_iterator_facade.hpp delete mode 100644 contrib/autoboost/boost/test/utils/iterator/token_iterator.hpp delete mode 100644 contrib/autoboost/boost/test/utils/lazy_ostream.hpp delete mode 100644 contrib/autoboost/boost/test/utils/named_params.hpp delete mode 100644 contrib/autoboost/boost/test/utils/rtti.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/argument.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/argument_factory.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/basic_parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/fwd.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/id_policy.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/id_policy.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/iface/argument_factory.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/iface/id_policy.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/modifier.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/parser.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/parser.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/typed_parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/validation.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/validation.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/value_generator.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/cla/value_handler.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/config.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/env/environment.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/env/environment.ipp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/env/fwd.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/env/modifier.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/env/variable.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/fwd.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/interpret_argument_value.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/parameter.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/trace.hpp delete mode 100644 contrib/autoboost/boost/test/utils/runtime/validation.hpp delete mode 100644 contrib/autoboost/boost/test/utils/trivial_singleton.hpp delete mode 100644 contrib/autoboost/boost/test/utils/wrap_stringstream.hpp delete mode 100644 contrib/autoboost/boost/test/utils/xml_printer.hpp delete mode 100644 contrib/autoboost/libs/test/src/compiler_log_formatter.cpp delete mode 100644 contrib/autoboost/libs/test/src/cpp_main.cpp delete mode 100644 contrib/autoboost/libs/test/src/debug.cpp delete mode 100644 contrib/autoboost/libs/test/src/exception_safety.cpp delete mode 100644 contrib/autoboost/libs/test/src/execution_monitor.cpp delete mode 100644 contrib/autoboost/libs/test/src/framework.cpp delete mode 100644 contrib/autoboost/libs/test/src/interaction_based.cpp delete mode 100644 contrib/autoboost/libs/test/src/logged_expectations.cpp delete mode 100644 contrib/autoboost/libs/test/src/plain_report_formatter.cpp delete mode 100644 contrib/autoboost/libs/test/src/progress_monitor.cpp delete mode 100644 contrib/autoboost/libs/test/src/results_collector.cpp delete mode 100644 contrib/autoboost/libs/test/src/results_reporter.cpp delete mode 100644 contrib/autoboost/libs/test/src/test_main.cpp delete mode 100644 contrib/autoboost/libs/test/src/test_tools.cpp delete mode 100644 contrib/autoboost/libs/test/src/unit_test_log.cpp delete mode 100644 contrib/autoboost/libs/test/src/unit_test_main.cpp delete mode 100644 contrib/autoboost/libs/test/src/unit_test_monitor.cpp delete mode 100644 contrib/autoboost/libs/test/src/unit_test_parameters.cpp delete mode 100644 contrib/autoboost/libs/test/src/unit_test_suite.cpp delete mode 100644 contrib/autoboost/libs/test/src/xml_log_formatter.cpp delete mode 100644 contrib/autoboost/libs/test/src/xml_report_formatter.cpp diff --git a/contrib/autoboost/boost/test/debug.hpp b/contrib/autoboost/boost/test/debug.hpp deleted file mode 100644 index 90e4b6e60..000000000 --- a/contrib/autoboost/boost/test/debug.hpp +++ /dev/null @@ -1,101 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2006-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines portable debug interfaces -// *************************************************************************** - -#ifndef BOOST_TEST_DEBUG_API_HPP_112006GER -#define BOOST_TEST_DEBUG_API_HPP_112006GER - -// Boost.Test -#include -#include -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace debug { - -// ************************************************************************** // -// ************** check if program is running under debugger ************** // -// ************************************************************************** // - -bool BOOST_TEST_DECL under_debugger(); - -// ************************************************************************** // -// ************** cause program to break execution ************** // -// ************** in debugger at call point ************** // -// ************************************************************************** // - -void BOOST_TEST_DECL debugger_break(); - -// ************************************************************************** // -// ************** gui debugger setup ************** // -// ************************************************************************** // - -struct dbg_startup_info { - long pid; - bool break_or_continue; - unit_test::const_string binary_path; - unit_test::const_string display; - unit_test::const_string init_done_lock; -}; - -typedef unit_test::callback1 dbg_starter; - -// ************************************************************************** // -// ************** debugger setup ************** // -// ************************************************************************** // - -#if BOOST_WORKAROUND( BOOST_MSVC, <1300) - -std::string BOOST_TEST_DECL set_debugger( unit_test::const_string dbg_id ); - -#else - -std::string BOOST_TEST_DECL set_debugger( unit_test::const_string dbg_id, dbg_starter s = dbg_starter() ); - -#endif - - -// ************************************************************************** // -// ************** attach debugger to the current process ************** // -// ************************************************************************** // - -bool BOOST_TEST_DECL attach_debugger( bool break_or_continue = true ); - -// ************************************************************************** // -// ************** switch on/off detect memory leaks feature ************** // -// ************************************************************************** // - -void BOOST_TEST_DECL detect_memory_leaks( bool on_off ); - -// ************************************************************************** // -// ************** cause program to break execution in ************** // -// ************** debugger at specific allocation point ************** // -// ************************************************************************** // - -void BOOST_TEST_DECL break_memory_alloc( long mem_alloc_order_num ); - -} // namespace debug - -} // namespace autoboost - -#include - -#endif diff --git a/contrib/autoboost/boost/test/debug_config.hpp b/contrib/autoboost/boost/test/debug_config.hpp deleted file mode 100644 index 17f41a60a..000000000 --- a/contrib/autoboost/boost/test/debug_config.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2006-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : user's config for Boost.Test debugging support -// *************************************************************************** - -#ifndef BOOST_TEST_DEBUG_CONFIG_HPP_112006GER -#define BOOST_TEST_DEBUG_CONFIG_HPP_112006GER - -// ';' separated list of supported debuggers -// #define BOOST_TEST_DBG_LIST gdb;dbx - -// maximum size of /proc/pid/stat file -// #define BOOST_TEST_STAT_LINE_MAX - -#endif diff --git a/contrib/autoboost/boost/test/detail/config.hpp b/contrib/autoboost/boost/test/detail/config.hpp deleted file mode 100644 index 4b12f0399..000000000 --- a/contrib/autoboost/boost/test/detail/config.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : as a central place for global configuration switches -// *************************************************************************** - -#ifndef BOOST_TEST_CONFIG_HPP_071894GER -#define BOOST_TEST_CONFIG_HPP_071894GER - -// Boost -#include // compilers workarounds -#include - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) || \ - BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \ - (defined __sgi && BOOST_WORKAROUND(_COMPILER_VERSION, BOOST_TESTED_AT(730))) -# define BOOST_TEST_SHIFTED_LINE -#endif - -//____________________________________________________________________________// - -#if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)) -# define BOOST_TEST_CALL_DECL __cdecl -#else -# define BOOST_TEST_CALL_DECL /**/ -#endif - -//____________________________________________________________________________// - -#if !defined(BOOST_NO_STD_LOCALE) && \ - !BOOST_WORKAROUND(BOOST_MSVC, < 1310) && \ - !defined(__MWERKS__) -# define BOOST_TEST_USE_STD_LOCALE 1 -#endif - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x570) || \ - BOOST_WORKAROUND( __COMO__, <= 0x433 ) || \ - BOOST_WORKAROUND( __INTEL_COMPILER, <= 800 ) || \ - defined(__sgi) && _COMPILER_VERSION <= 730 || \ - BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \ - defined(__DECCXX) || \ - defined(__DMC__) -# define BOOST_TEST_NO_PROTECTED_USING -#endif - -//____________________________________________________________________________// - -#if defined(__GNUC__) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) -#define BOOST_TEST_PROTECTED_VIRTUAL virtual -#else -#define BOOST_TEST_PROTECTED_VIRTUAL -#endif - -//____________________________________________________________________________// - -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ - !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \ - !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530)) -# define BOOST_TEST_SUPPORT_INTERACTION_TESTING 1 -#endif - -//____________________________________________________________________________// - -#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK) -# define BOOST_TEST_DYN_LINK -#endif - -#if defined(BOOST_TEST_INCLUDED) -# undef BOOST_TEST_DYN_LINK -#endif - -#if defined(BOOST_TEST_DYN_LINK) -# define BOOST_TEST_ALTERNATIVE_INIT_API - -# ifdef BOOST_TEST_SOURCE -# define BOOST_TEST_DECL BOOST_SYMBOL_EXPORT -# else -# define BOOST_TEST_DECL BOOST_SYMBOL_IMPORT -# endif // BOOST_TEST_SOURCE -#else -# define BOOST_TEST_DECL -#endif - -#if !defined(BOOST_TEST_MAIN) && defined(BOOST_AUTO_TEST_MAIN) -#define BOOST_TEST_MAIN BOOST_AUTO_TEST_MAIN -#endif - -#if !defined(BOOST_TEST_MAIN) && defined(BOOST_TEST_MODULE) -#define BOOST_TEST_MAIN BOOST_TEST_MODULE -#endif - -#endif // BOOST_TEST_CONFIG_HPP_071894GER diff --git a/contrib/autoboost/boost/test/detail/enable_warnings.hpp b/contrib/autoboost/boost/test/detail/enable_warnings.hpp deleted file mode 100644 index 7c11ba235..000000000 --- a/contrib/autoboost/boost/test/detail/enable_warnings.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : enable previosly suppressed warnings -// *************************************************************************** - -#ifdef BOOST_MSVC -# pragma warning(default: 4511) // copy constructor can't not be generated -# pragma warning(default: 4512) // assignment operator can't not be generated -# pragma warning(default: 4100) // unreferenced formal parameter -# pragma warning(default: 4996) // was declared deprecated -# pragma warning(default: 4355) // 'this' : used in base member initializer list -# pragma warning(default: 4706) // assignment within conditional expression -# pragma warning(default: 4251) // class 'A' needs to have dll-interface to be used by clients of class 'B' -# pragma warning(default: 4127) // conditional expression is constant -# pragma warning(default: 4290) // C++ exception specification ignored except to ... -# pragma warning(default: 4180) // qualifier applied to function type has no meaning; ignored -# pragma warning(default: 4275) // non dll-interface class ... used as base for dll-interface class ... -# pragma warning(default: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data -# pragma warning(default: 4511) // 'class' : copy constructor could not be generated -# pragma warning(pop) -#endif diff --git a/contrib/autoboost/boost/test/detail/fwd_decl.hpp b/contrib/autoboost/boost/test/detail/fwd_decl.hpp deleted file mode 100644 index 274aca37c..000000000 --- a/contrib/autoboost/boost/test/detail/fwd_decl.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains forward eclarations for Boost.Test data types -// *************************************************************************** - -#ifndef BOOST_TEST_FWD_DECL_HPP_011605GER -#define BOOST_TEST_FWD_DECL_HPP_011605GER - -namespace autoboost { - -class execution_monitor; -class execution_exception; - -namespace unit_test { - -class test_unit; -class test_case; -class test_suite; -class master_test_suite_t; - -class test_tree_visitor; -class test_observer; - -// singletons -class unit_test_monitor_t; -class unit_test_log_t; - -class unit_test_log_formatter; -struct log_entry_data; -struct log_checkpoint_data; - -class lazy_ostream; - -} // namespace unit_test - -} // namespace autoboost - -#endif // BOOST_TEST_FWD_DECL_HPP_011605GER - diff --git a/contrib/autoboost/boost/test/detail/global_typedef.hpp b/contrib/autoboost/boost/test/detail/global_typedef.hpp deleted file mode 100644 index ef04ae97d..000000000 --- a/contrib/autoboost/boost/test/detail/global_typedef.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : some trivial global typedefs -// *************************************************************************** - -#ifndef BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER -#define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER - -#include -#define BOOST_TEST_L( s ) autoboost::unit_test::const_string( s, sizeof( s ) - 1 ) -#define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) ) -#define BOOST_TEST_EMPTY_STRING BOOST_TEST_L( "" ) - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -typedef unsigned long counter_t; - -//____________________________________________________________________________// - -enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT }; - -//____________________________________________________________________________// - -enum output_format { INV_OF, CLF /* compiler log format */, XML /* XML */ }; - -//____________________________________________________________________________// - -enum test_unit_type { tut_case = 0x01, tut_suite = 0x10, tut_any = 0x11 }; - -//____________________________________________________________________________// - -typedef unsigned long test_unit_id; - -const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF; -const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE; -const test_unit_id MIN_TEST_CASE_ID = 0x00010000; -const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00; -const test_unit_id MIN_TEST_SUITE_ID = 0x00000001; - -//____________________________________________________________________________// - -namespace ut_detail { - -inline test_unit_type -test_id_2_unit_type( test_unit_id id ) -{ - return (id & 0xFFFF0000) != 0 ? tut_case : tut_suite; -} - -//____________________________________________________________________________// - -// helper templates to prevent ODR violations -template -struct static_constant { - static T value; -}; - -template -T static_constant::value; - -//____________________________________________________________________________// - -} // namespace ut_detail - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER diff --git a/contrib/autoboost/boost/test/detail/log_level.hpp b/contrib/autoboost/boost/test/detail/log_level.hpp deleted file mode 100644 index 7b47dbb3e..000000000 --- a/contrib/autoboost/boost/test/detail/log_level.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : shared definition for unit test log levels -// *************************************************************************** - -#ifndef BOOST_TEST_LOG_LEVEL_HPP_011605GER -#define BOOST_TEST_LOG_LEVEL_HPP_011605GER - -namespace autoboost { -namespace unit_test { - -// ************************************************************************** // -// ************** log levels ************** // -// ************************************************************************** // - -// each log level includes all subsequent higher loging levels -enum log_level { - invalid_log_level = -1, - log_successful_tests = 0, - log_test_units = 1, - log_messages = 2, - log_warnings = 3, - log_all_errors = 4, // reported by unit test macros - log_cpp_exception_errors = 5, // uncaught C++ exceptions - log_system_errors = 6, // including timeouts, signals, traps - log_fatal_errors = 7, // including unit test macros or - // fatal system errors - log_nothing = 8 -}; - -} // namespace unit_test -} // namespace autoboost - -#endif // BOOST_TEST_LOG_LEVEL_HPP_011605GER diff --git a/contrib/autoboost/boost/test/detail/suppress_warnings.hpp b/contrib/autoboost/boost/test/detail/suppress_warnings.hpp deleted file mode 100644 index d5c95266e..000000000 --- a/contrib/autoboost/boost/test/detail/suppress_warnings.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : suppress some warnings -// *************************************************************************** - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4511) // copy constructor can't not be generated -# pragma warning(disable: 4512) // assignment operator can't not be generated -# pragma warning(disable: 4100) // unreferenced formal parameter -# pragma warning(disable: 4996) // was declared deprecated -# pragma warning(disable: 4355) // 'this' : used in base member initializer list -# pragma warning(disable: 4706) // assignment within conditional expression -# pragma warning(disable: 4251) // class 'A' needs to have dll-interface to be used by clients of class 'B' -# pragma warning(disable: 4127) // conditional expression is constant -# pragma warning(disable: 4290) // C++ exception specification ignored except to ... -# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored -# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ... -# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data -# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated -#endif - diff --git a/contrib/autoboost/boost/test/detail/unit_test_parameters.hpp b/contrib/autoboost/boost/test/detail/unit_test_parameters.hpp deleted file mode 100644 index 513262668..000000000 --- a/contrib/autoboost/boost/test/detail/unit_test_parameters.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : storage for unit test framework parameters information -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER - -#include -#include - -#include - -// STL -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** runtime_config ************** // -// ************************************************************************** // - -namespace runtime_config { - -BOOST_TEST_DECL void init( int& argc, char** argv ); - -BOOST_TEST_DECL unit_test::log_level log_level(); -BOOST_TEST_DECL bool no_result_code(); -BOOST_TEST_DECL unit_test::report_level report_level(); -BOOST_TEST_DECL const_string test_to_run(); -BOOST_TEST_DECL const_string break_exec_path(); -BOOST_TEST_DECL bool save_pattern(); -BOOST_TEST_DECL bool show_build_info(); -BOOST_TEST_DECL bool show_progress(); -BOOST_TEST_DECL bool catch_sys_errors(); -BOOST_TEST_DECL bool auto_start_dbg(); -BOOST_TEST_DECL bool use_alt_stack(); -BOOST_TEST_DECL bool detect_fp_exceptions(); -BOOST_TEST_DECL output_format report_format(); -BOOST_TEST_DECL output_format log_format(); -BOOST_TEST_DECL std::ostream* report_sink(); -BOOST_TEST_DECL std::ostream* log_sink(); -BOOST_TEST_DECL long detect_memory_leaks(); -BOOST_TEST_DECL int random_seed(); - -} // namespace runtime_config - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER diff --git a/contrib/autoboost/boost/test/detail/workaround.hpp b/contrib/autoboost/boost/test/detail/workaround.hpp deleted file mode 100644 index 6bbbdf80e..000000000 --- a/contrib/autoboost/boost/test/detail/workaround.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains mics. workarounds -// *************************************************************************** - -#ifndef BOOST_TEST_WORKAROUND_HPP_021005GER -#define BOOST_TEST_WORKAROUND_HPP_021005GER - -// Boost -#include // compilers workarounds and std::ptrdiff_t - -// STL -#include // for std::distance - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace ut_detail { - -#ifdef BOOST_NO_STD_DISTANCE -template -std::ptrdiff_t distance( T const& x_, T const& y_ ) -{ - std::ptrdiff_t res = 0; - - std::distance( x_, y_, res ); - - return res; -} - -//____________________________________________________________________________// - -#else -using std::distance; -#endif - -template inline void ignore_unused_variable_warning(const T&) {} - -} // namespace ut_detail - -} // namespace unit_test - -namespace unit_test_framework = unit_test; - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_WORKAROUND_HPP_021005GER diff --git a/contrib/autoboost/boost/test/execution_monitor.hpp b/contrib/autoboost/boost/test/execution_monitor.hpp deleted file mode 100644 index 831f6bb4c..000000000 --- a/contrib/autoboost/boost/test/execution_monitor.hpp +++ /dev/null @@ -1,263 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// (C) Copyright Beman Dawes 2001. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines abstract monitor interfaces and implements execution exception -// The original Boost Test Library included an implementation detail function -// named catch_exceptions() which caught otherwise uncaught C++ exceptions. -// It was derived from an existing test framework by Beman Dawes. The -// intent was to expand later to catch other detectable but platform dependent -// error events like Unix signals or Windows structured C exceptions. -// -// Requests from early adopters of the Boost Test Library included -// configurable levels of error message detail, elimination of templates, -// separation of error reporting, and making the catch_exceptions() facilities -// available as a public interface. Support for unit testing also stretched -// the function based design. Implementation within the header became less -// attractive due to the need to include many huge system dependent headers, -// although still preferable in certain cases. -// -// All those issues have been addressed by introducing the class-based -// design presented here. -// *************************************************************************** - -#ifndef BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER -#define BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER - -// Boost.Test -#include -#include -#include -#include - -// Boost -#include -#include -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace detail { - -// ************************************************************************** // -// ************** detail::translate_exception_base ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL translate_exception_base { -public: - // Constructor - explicit translate_exception_base( autoboost::scoped_ptr& next ) - { - next.swap( m_next ); - } - - // Destructor - virtual ~translate_exception_base() {} - - virtual int operator()( unit_test::callback0 const& F ) = 0; - -protected: - // Data members - autoboost::scoped_ptr m_next; -}; - -} // namespace detail - -// ************************************************************************** // -// ************** execution_exception ************** // -// ************************************************************************** // - -// design rationale: fear of being out (or nearly out) of memory. - -class BOOST_TEST_DECL execution_exception { - typedef autoboost::unit_test::const_string const_string; -public: - enum error_code { - // These values are sometimes used as program return codes. - // The particular values have been chosen to avoid conflicts with - // commonly used program return codes: values < 100 are often user - // assigned, values > 255 are sometimes used to report system errors. - // Gaps in values allow for orderly expansion. - - no_error = 0, // for completeness only; never returned - user_error = 200, // user reported non-fatal error - cpp_exception_error = 205, // see note (1) below - system_error = 210, // see note (2) below - timeout_error = 215, // only detectable on certain platforms - user_fatal_error = 220, // user reported fatal error - system_fatal_error = 225 // see note (2) below - - // Note 1: Only uncaught C++ exceptions are treated as errors. - // If the application catches a C++ exception, it will never reach - // the execution_monitor. - - // Note 2: These errors include Unix signals and Windows structured - // exceptions. They are often initiated by hardware traps. - // - // The implementation decides what is a fatal_system_exception and what is - // just a system_exception. Fatal errors are so likely to have corrupted - // machine state (like a stack overflow or addressing exception) that it - // is unreasonable to continue execution. - }; - - struct BOOST_TEST_DECL location { - explicit location( char const* file_name = 0, size_t line_num = 0, char const* func = 0 ); - - const_string m_file_name; - size_t m_line_num; - const_string m_function; - }; - - // Constructor - execution_exception( error_code ec_, const_string what_msg_, location const& location_ ); // max length 256 inc '\0' - - // Access methods - error_code code() const { return m_error_code; } - const_string what() const { return m_what; } - location const& where() const { return m_location; } - -private: - // Data members - error_code m_error_code; - const_string m_what; - location m_location; -}; // execution_exception - -// ************************************************************************** // -// ************** execution_monitor ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL execution_monitor { -public: - // Constructor - execution_monitor() - : p_catch_system_errors( true ) - , p_auto_start_dbg( false ) - , p_timeout( 0 ) - , p_use_alt_stack( true ) - , p_detect_fp_exceptions( false ) - {} - - // Public properties - - // The p_catch_system_errors parameter specifies whether the monitor should - // try to catch system errors/exceptions that would cause program to crash - // in regular case - unit_test::readwrite_property p_catch_system_errors; - // The p_auto_start_dbg parameter specifies whether the monitor should - // try to attach debugger in case of caught system error - unit_test::readwrite_property p_auto_start_dbg; - // The p_timeout parameter specifies the seconds that elapse before - // a timer_error occurs. May be ignored on some platforms. - unit_test::readwrite_property p_timeout; - // The p_use_alt_stack parameter specifies whether the monitor should - // use alternative stack for the signal catching - unit_test::readwrite_property p_use_alt_stack; - // The p_detect_fp_exceptions parameter specifies whether the monitor should - // try to detect hardware floating point exceptions - unit_test::readwrite_property p_detect_fp_exceptions; - - int execute( unit_test::callback0 const& F ); - // Returns: Value returned by function call F(). - // - // Effects: Calls executes supplied function F inside a try/catch block which also may - // include other unspecified platform dependent error detection code. - // - // Throws: execution_exception on an uncaught C++ exception, - // a hardware or software signal, trap, or other exception. - // - // Note: execute() doesn't consider it an error for F to return a non-zero value. - - // register custom (user supplied) exception translator - template - void register_exception_translator( ExceptionTranslator const& tr, autoboost::type* = 0 ); - -private: - // implementation helpers - int catch_signals( unit_test::callback0 const& F ); - - // Data members - autoboost::scoped_ptr m_custom_translators; - autoboost::scoped_array m_alt_stack; -}; // execution_monitor - -namespace detail { - -// ************************************************************************** // -// ************** detail::translate_exception ************** // -// ************************************************************************** // - -template -class translate_exception : public translate_exception_base -{ - typedef autoboost::scoped_ptr base_ptr; -public: - explicit translate_exception( ExceptionTranslator const& tr, base_ptr& next ) - : translate_exception_base( next ), m_translator( tr ) {} - - int operator()( unit_test::callback0 const& F ) - { - try { - return m_next ? (*m_next)( F ) : F(); - } catch( Exception const& e ) { - m_translator( e ); - return autoboost::exit_exception_failure; - } - } - -private: - // Data members - ExceptionTranslator m_translator; -}; - -} // namespace detail - -template -void -execution_monitor::register_exception_translator( ExceptionTranslator const& tr, autoboost::type* ) -{ - m_custom_translators.reset( - new detail::translate_exception( tr,m_custom_translators ) ); -} - -// ************************************************************************** // -// ************** execution_aborted ************** // -// ************************************************************************** // - -struct execution_aborted {}; - -// ************************************************************************** // -// ************** system_error ************** // -// ************************************************************************** // - -class system_error { -public: - // Constructor - explicit system_error( char const* exp ); - - unit_test::readonly_property p_errno; - unit_test::readonly_property p_failed_exp; -}; - -#define BOOST_TEST_SYS_ASSERT( exp ) if( (exp) ) ; else throw ::autoboost::system_error( BOOST_STRINGIZE( exp ) ) - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif diff --git a/contrib/autoboost/boost/test/floating_point_comparison.hpp b/contrib/autoboost/boost/test/floating_point_comparison.hpp deleted file mode 100644 index 20adf9d08..000000000 --- a/contrib/autoboost/boost/test/floating_point_comparison.hpp +++ /dev/null @@ -1,286 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines algoirthms for comparing 2 floating point values -// *************************************************************************** - -#ifndef BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER -#define BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER - -// Boost.Test -#include -#include -#include - -// Boost -#include // for std::numeric_limits -#include // for numeric::conversion_traits -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace test_tools { - -using unit_test::readonly_property; - -// ************************************************************************** // -// ************** floating_point_comparison_type ************** // -// ************************************************************************** // - -enum floating_point_comparison_type { - FPC_STRONG, // "Very close" - equation 1' in docs, the default - FPC_WEAK // "Close enough" - equation 2' in docs. - -}; - -// ************************************************************************** // -// ************** details ************** // -// ************************************************************************** // - -namespace tt_detail { - -// FPT is Floating-Point Type: float, double, long double or User-Defined. -template -inline FPT -fpt_abs( FPT fpv ) -{ - return fpv < static_cast(0) ? -fpv : fpv; -} - -//____________________________________________________________________________// - -template -struct fpt_limits { - static FPT min_value() - { - return std::numeric_limits::is_specialized - ? (std::numeric_limits::min)() - : 0; - } - static FPT max_value() - { - return std::numeric_limits::is_specialized - ? (std::numeric_limits::max)() - : static_cast(1000000); // for the our purpuses it doesn't really matter what value is returned here - } -}; - -//____________________________________________________________________________// - -// both f1 and f2 are unsigned here -template -inline FPT -safe_fpt_division( FPT f1, FPT f2 ) -{ - // Avoid overflow. - if( (f2 < static_cast(1)) && (f1 > f2*fpt_limits::max_value()) ) - return fpt_limits::max_value(); - - // Avoid underflow. - if( (f1 == static_cast(0)) || - ((f2 > static_cast(1)) && (f1 < f2*fpt_limits::min_value())) ) - return static_cast(0); - - return f1/f2; -} - -//____________________________________________________________________________// - -} // namespace tt_detail - -// ************************************************************************** // -// ************** tolerance presentation types ************** // -// ************************************************************************** // - -template -struct percent_tolerance_t { - explicit percent_tolerance_t( FPT v ) : m_value( v ) {} - - FPT m_value; -}; - -//____________________________________________________________________________// - -template -Out& operator<<( Out& out, percent_tolerance_t t ) -{ - return out << t.m_value; -} - -//____________________________________________________________________________// - -template -inline percent_tolerance_t -percent_tolerance( FPT v ) -{ - return percent_tolerance_t( v ); -} - -//____________________________________________________________________________// - -template -struct fraction_tolerance_t { - explicit fraction_tolerance_t( FPT v ) : m_value( v ) {} - - FPT m_value; -}; - -//____________________________________________________________________________// - -template -Out& operator<<( Out& out, fraction_tolerance_t t ) -{ - return out << t.m_value; -} - -//____________________________________________________________________________// - -template -inline fraction_tolerance_t -fraction_tolerance( FPT v ) -{ - return fraction_tolerance_t( v ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** close_at_tolerance ************** // -// ************************************************************************** // - -template -class close_at_tolerance { -public: - // Public typedefs - typedef bool result_type; - - // Constructor - template - explicit close_at_tolerance( percent_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) - : p_fraction_tolerance( tt_detail::fpt_abs( static_cast(0.01)*tolerance.m_value ) ) - , p_strong_or_weak( fpc_type == FPC_STRONG ) - , m_report_modifier( 100. ) - {} - template - explicit close_at_tolerance( fraction_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) - : p_fraction_tolerance( tt_detail::fpt_abs( tolerance.m_value ) ) - , p_strong_or_weak( fpc_type == FPC_STRONG ) - , m_report_modifier( 1. ) - {} - - predicate_result operator()( FPT left, FPT right ) const - { - FPT diff = tt_detail::fpt_abs( left - right ); - FPT d1 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) ); - FPT d2 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( left ) ); - - predicate_result res( p_strong_or_weak - ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get()) - : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()) ); - - if( !res ) - res.message() << (( d1 <= p_fraction_tolerance.get() ? d2 : d1 ) * m_report_modifier); - - return res; - } - - // Public properties - readonly_property p_fraction_tolerance; - readonly_property p_strong_or_weak; -private: - // Data members - FPT m_report_modifier; -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** check_is_close ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL check_is_close_t { - // Public typedefs - typedef bool result_type; - - template - predicate_result - operator()( FPT1 left, FPT2 right, percent_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) const - { - // deduce "better" type from types of arguments being compared - // if one type is floating and the second integral we use floating type and - // value of integral type is promoted to the floating. The same for float and double - // But we don't want to compare two values of integral types using this tool. - typedef typename numeric::conversion_traits::supertype FPT; - BOOST_STATIC_ASSERT( !is_integral::value ); - - close_at_tolerance pred( tolerance, fpc_type ); - - return pred( left, right ); - } - template - predicate_result - operator()( FPT1 left, FPT2 right, fraction_tolerance_t tolerance, - floating_point_comparison_type fpc_type = FPC_STRONG ) const - { - // same as in a comment above - typedef typename numeric::conversion_traits::supertype FPT; - BOOST_STATIC_ASSERT( !is_integral::value ); - - close_at_tolerance pred( tolerance, fpc_type ); - - return pred( left, right ); - } -}; - -namespace { -check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant::value; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** check_is_small ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL check_is_small_t { - // Public typedefs - typedef bool result_type; - - template - bool - operator()( FPT fpv, FPT tolerance ) const - { - return tt_detail::fpt_abs( fpv ) < tt_detail::fpt_abs( tolerance ); - } -}; - -namespace { -check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant::value; -} - -//____________________________________________________________________________// - -} // namespace test_tools - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_FLOATING_POINT_COMAPARISON_HPP_071894GER diff --git a/contrib/autoboost/boost/test/framework.hpp b/contrib/autoboost/boost/test/framework.hpp deleted file mode 100644 index 3fb87abba..000000000 --- a/contrib/autoboost/boost/test/framework.hpp +++ /dev/null @@ -1,112 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines framework interface -// *************************************************************************** - -#ifndef BOOST_TEST_FRAMEWORK_HPP_020805GER -#define BOOST_TEST_FRAMEWORK_HPP_020805GER - -// Boost.Test -#include -#include -#include - -#include - -// STL -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** init_unit_test_func ************** // -// ************************************************************************** // - -#ifdef BOOST_TEST_ALTERNATIVE_INIT_API -typedef bool (*init_unit_test_func)(); -#else -typedef test_suite* (*init_unit_test_func)( int, char* [] ); -#endif - -// ************************************************************************** // -// ************** framework ************** // -// ************************************************************************** // - -namespace framework { - -// initialization -BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] ); -BOOST_TEST_DECL bool is_initialized(); - -// mutation access methods -BOOST_TEST_DECL void register_test_unit( test_case* tc ); -BOOST_TEST_DECL void register_test_unit( test_suite* ts ); -BOOST_TEST_DECL void deregister_test_unit( test_unit* tu ); -BOOST_TEST_DECL void clear(); - -BOOST_TEST_DECL void register_observer( test_observer& ); -BOOST_TEST_DECL void deregister_observer( test_observer& ); -BOOST_TEST_DECL void reset_observers(); - -BOOST_TEST_DECL master_test_suite_t& master_test_suite(); - -// constant access methods -BOOST_TEST_DECL test_case const& current_test_case(); - -BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type ); -template -UnitType& get( test_unit_id id ) -{ - return static_cast( get( id, static_cast(UnitType::type) ) ); -} - -// test initiation -BOOST_TEST_DECL void run( test_unit_id = INV_TEST_UNIT_ID, bool continue_test = true ); -BOOST_TEST_DECL void run( test_unit const*, bool continue_test = true ); - -// public test events dispatchers -BOOST_TEST_DECL void assertion_result( bool passed ); -BOOST_TEST_DECL void exception_caught( execution_exception const& ); -BOOST_TEST_DECL void test_unit_aborted( test_unit const& ); - -// ************************************************************************** // -// ************** framework errors ************** // -// ************************************************************************** // - -struct internal_error : std::runtime_error { - internal_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {} -}; - -struct setup_error : std::runtime_error { - setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {} -}; - -#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg ) - -struct nothing_to_test {}; // not really an error - -} // namespace framework - -} // unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_FRAMEWORK_HPP_020805GER - diff --git a/contrib/autoboost/boost/test/impl/compiler_log_formatter.ipp b/contrib/autoboost/boost/test/impl/compiler_log_formatter.ipp deleted file mode 100644 index 66c617023..000000000 --- a/contrib/autoboost/boost/test/impl/compiler_log_formatter.ipp +++ /dev/null @@ -1,222 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements compiler like Log formatter -// *************************************************************************** - -#ifndef BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER -#define BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER - -// Boost.Test -#include -#include -#include -#include -#include - -// Boost -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -// ************************************************************************** // -// ************** compiler_log_formatter ************** // -// ************************************************************************** // - -namespace { - -const_string -test_phase_identifier() -{ - return framework::is_initialized() - ? const_string( framework::current_test_case().p_name.get() ) - : BOOST_TEST_L( "Test setup" ); -} - -} // local namespace - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_start( std::ostream& output, counter_t test_cases_amount ) -{ - if( test_cases_amount > 0 ) - output << "Running " << test_cases_amount << " test " - << (test_cases_amount > 1 ? "cases" : "case") << "...\n"; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_finish( std::ostream& ostr ) -{ - ostr.flush(); -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_build_info( std::ostream& output ) -{ - output << "Platform: " << BOOST_PLATFORM << '\n' - << "Compiler: " << BOOST_COMPILER << '\n' - << "STL : " << BOOST_STDLIB << '\n' - << "Boost : " << BOOST_VERSION/100000 << "." - << BOOST_VERSION/100 % 1000 << "." - << BOOST_VERSION % 100 << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const& tu ) -{ - output << "Entering test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, unsigned long elapsed ) -{ - output << "Leaving test " << tu.p_type_name << " \"" << tu.p_name << "\""; - - if( elapsed > 0 ) { - output << "; testing time: "; - if( elapsed % 1000 == 0 ) - output << elapsed/1000 << "ms"; - else - output << elapsed << "mks"; - } - - output << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::test_unit_skipped( std::ostream& output, test_unit const& tu ) -{ - output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << "is skipped" << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_exception( std::ostream& output, log_checkpoint_data const& checkpoint_data, execution_exception const& ex ) -{ - execution_exception::location const& loc = ex.where(); - print_prefix( output, loc.m_file_name, loc.m_line_num ); - - output << "fatal error in \"" << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": "; - - output << ex.what(); - - if( !checkpoint_data.m_file_name.is_empty() ) { - output << '\n'; - print_prefix( output, checkpoint_data.m_file_name, checkpoint_data.m_line_num ); - output << "last checkpoint"; - if( !checkpoint_data.m_message.empty() ) - output << ": " << checkpoint_data.m_message; - } - - output << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data const& entry_data, log_entry_types let ) -{ - switch( let ) { - case BOOST_UTL_ET_INFO: - print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - output << "info: "; - break; - case BOOST_UTL_ET_MESSAGE: - break; - case BOOST_UTL_ET_WARNING: - print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - output << "warning in \"" << test_phase_identifier() << "\": "; - break; - case BOOST_UTL_ET_ERROR: - print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - output << "error in \"" << test_phase_identifier() << "\": "; - break; - case BOOST_UTL_ET_FATAL_ERROR: - print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - output << "fatal error in \"" << test_phase_identifier() << "\": "; - break; - } -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_entry_value( std::ostream& output, const_string value ) -{ - output << value; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_entry_value( std::ostream& output, lazy_ostream const& value ) -{ - output << value; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::log_entry_finish( std::ostream& output ) -{ - output << std::endl; -} - -//____________________________________________________________________________// - -void -compiler_log_formatter::print_prefix( std::ostream& output, const_string file, std::size_t line ) -{ -#ifdef __APPLE_CC__ - // Xcode-compatible logging format, idea by Richard Dingwall at - // . - output << file << ':' << line << ": "; -#else - output << file << '(' << line << "): "; -#endif -} - -//____________________________________________________________________________// - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER diff --git a/contrib/autoboost/boost/test/impl/cpp_main.ipp b/contrib/autoboost/boost/test/impl/cpp_main.ipp deleted file mode 100644 index 60b70ced5..000000000 --- a/contrib/autoboost/boost/test/impl/cpp_main.ipp +++ /dev/null @@ -1,139 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// (C) Copyright Beman Dawes 1995-2001. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : main function implementation for Program Executon Monitor -// *************************************************************************** - -#ifndef BOOST_TEST_CPP_MAIN_IPP_012205GER -#define BOOST_TEST_CPP_MAIN_IPP_012205GER - -// Boost.Test -#include -#include -#include - -// Boost -#include // for exit codes -#include // for workarounds - -// STL -#include -#include // std::getenv -#include // std::strerror - -#include - -//____________________________________________________________________________// - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::getenv; using ::strerror; } -#endif - -namespace { - -struct cpp_main_caller { - cpp_main_caller( int (*cpp_main_func)( int argc, char* argv[] ), int argc, char** argv ) - : m_cpp_main_func( cpp_main_func ) - , m_argc( argc ) - , m_argv( argv ) {} - - int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); } - -private: - // Data members - int (*m_cpp_main_func)( int argc, char* argv[] ); - int m_argc; - char** m_argv; -}; - -} // local namespace - -// ************************************************************************** // -// ************** prg_exec_monitor_main ************** // -// ************************************************************************** // - -namespace autoboost { - -int BOOST_TEST_DECL -prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char* argv[] ) -{ - int result = 0; - - try { - autoboost::unit_test::const_string p( std::getenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS" ) ); - ::autoboost::execution_monitor ex_mon; - - ex_mon.p_catch_system_errors.value = p != "no"; - - result = ex_mon.execute( - ::autoboost::unit_test::callback0( cpp_main_caller( cpp_main, argc, argv ) ) ); - - if( result == 0 ) - result = ::autoboost::exit_success; - else if( result != ::autoboost::exit_success ) { - std::cout << "\n**** error return code: " << result << std::endl; - result = ::autoboost::exit_failure; - } - } - catch( ::autoboost::execution_exception const& exex ) { - std::cout << "\n**** exception(" << exex.code() << "): " << exex.what() << std::endl; - result = ::autoboost::exit_exception_failure; - } - catch( ::autoboost::system_error const& ex ) { - std::cout << "\n**** failed to initialize execution monitor." - << "\n**** expression at fault: " << ex.p_failed_exp - << "\n**** error(" << ex.p_errno << "): " << std::strerror( ex.p_errno ) << std::endl; - result = ::autoboost::exit_exception_failure; - } - - if( result != ::autoboost::exit_success ) { - std::cerr << "******** errors detected; see standard output for details ********" << std::endl; - } - else { - // Some prefer a confirming message when all is well, while others don't - // like the clutter. Use an environment variable to avoid command - // line argument modifications; for use in production programs - // that's a no-no in some organizations. - ::autoboost::unit_test::const_string p( std::getenv( "BOOST_PRG_MON_CONFIRM" ) ); - if( p != "no" ) { - std::cerr << std::flush << "no errors detected" << std::endl; - } - } - - return result; -} - -} // namespace autoboost - -#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN) - -// ************************************************************************** // -// ************** main function for tests using lib ************** // -// ************************************************************************** // - -int cpp_main( int argc, char* argv[] ); // prototype for user's cpp_main() - -int BOOST_TEST_CALL_DECL -main( int argc, char* argv[] ) -{ - return ::autoboost::prg_exec_monitor_main( &cpp_main, argc, argv ); -} - -//____________________________________________________________________________// - -#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_CPP_MAIN_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/debug.ipp b/contrib/autoboost/boost/test/impl/debug.ipp deleted file mode 100644 index d056128fa..000000000 --- a/contrib/autoboost/boost/test/impl/debug.ipp +++ /dev/null @@ -1,970 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2006-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : debug interfaces implementation -// *************************************************************************** - -#ifndef BOOST_TEST_DEBUG_API_IPP_112006GER -#define BOOST_TEST_DEBUG_API_IPP_112006GER - -// Boost.Test -#include -#include -#include - -#include -#include - -// Implementation on Windows -#if defined(_WIN32) && !defined(UNDER_CE) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 - -# define BOOST_WIN32_BASED_DEBUG - -// SYSTEM API -# include -# include -# include -# include - -# if !defined(NDEBUG) && defined(_MSC_VER) -# define BOOST_MS_CRT_BASED_DEBUG -# include -# endif - - -# if BOOST_WORKAROUND( BOOST_MSVC, <1300) -# define snprintf _snprintf -# endif - -# ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::memset; using ::sprintf; } -# endif - -#elif defined(unix) || defined(__unix) // ********************* UNIX - -# define BOOST_UNIX_BASED_DEBUG - -// Boost.Test -#include -#include - -// STL -#include // std::memcpy -#include -#include -#include // !! ?? cstdarg - -// SYSTEM API -# include -# include -# include - -# include -# include -# include -# include -# include -# include - -# if defined(sun) || defined(__sun) - -# define BOOST_SUN_BASED_DEBUG - -# ifndef BOOST_TEST_DBG_LIST -# define BOOST_TEST_DBG_LIST dbx;gdb -# endif - -# define BOOST_TEST_CNL_DBG dbx -# define BOOST_TEST_GUI_DBG dbx-ddd - -# include - -# elif defined(linux) || defined(__linux) - -# define BOOST_LINUX_BASED_DEBUG - -# include - -# ifndef BOOST_TEST_STAT_LINE_MAX -# define BOOST_TEST_STAT_LINE_MAX 500 -# endif - -# ifndef BOOST_TEST_DBG_LIST -# define BOOST_TEST_DBG_LIST gdb -# endif - -# define BOOST_TEST_CNL_DBG gdb -# define BOOST_TEST_GUI_DBG gdb-xterm - -# endif - -#endif - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace debug { - -using unit_test::const_string; - -// ************************************************************************** // -// ************** debug::info_t ************** // -// ************************************************************************** // - -namespace { - -#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32 - -template -inline void -dyn_symbol( T& res, char const* module_name, char const* symbol_name ) -{ - HMODULE m = ::GetModuleHandleA( module_name ); - - if( !m ) - m = ::LoadLibraryA( module_name ); - - res = reinterpret_cast( ::GetProcAddress( m, symbol_name ) ); -} - -//____________________________________________________________________________// - -static struct info_t { - typedef BOOL (WINAPI* IsDebuggerPresentT)(); - typedef LONG (WINAPI* RegQueryValueExT)( HKEY, char const* /*LPTSTR*/, LPDWORD, LPDWORD, LPBYTE, LPDWORD ); - typedef LONG (WINAPI* RegOpenKeyT)( HKEY, char const* /*LPCTSTR*/, PHKEY ); - typedef LONG (WINAPI* RegCloseKeyT)( HKEY ); - - info_t(); - - IsDebuggerPresentT m_is_debugger_present; - RegOpenKeyT m_reg_open_key; - RegQueryValueExT m_reg_query_value; - RegCloseKeyT m_reg_close_key; - -} s_info; - -//____________________________________________________________________________// - -info_t::info_t() -{ - dyn_symbol( m_is_debugger_present, "kernel32", "IsDebuggerPresent" ); - dyn_symbol( m_reg_open_key, "advapi32", "RegOpenKeyA" ); - dyn_symbol( m_reg_query_value, "advapi32", "RegQueryValueExA" ); - dyn_symbol( m_reg_close_key, "advapi32", "RegCloseKey" ); -} - -//____________________________________________________________________________// - -#elif defined(BOOST_UNIX_BASED_DEBUG) - -// ************************************************************************** // -// ************** fd_holder ************** // -// ************************************************************************** // - -struct fd_holder { - explicit fd_holder( int fd ) : m_fd( fd ) {} - ~fd_holder() - { - if( m_fd != -1 ) - ::close( m_fd ); - } - - operator int() { return m_fd; } - -private: - // Data members - int m_fd; -}; - - -// ************************************************************************** // -// ************** process_info ************** // -// ************************************************************************** // - -struct process_info { - // Constructor - explicit process_info( int pid ); - - // access methods - int parent_pid() const { return m_parent_pid; } - const_string binary_name() const { return m_binary_name; } - const_string binary_path() const { return m_binary_path; } - -private: - // Data members - int m_parent_pid; - const_string m_binary_name; - const_string m_binary_path; - -#if defined(BOOST_SUN_BASED_DEBUG) - struct psinfo m_psi; -#elif defined(BOOST_LINUX_BASED_DEBUG) - char m_stat_line[BOOST_TEST_STAT_LINE_MAX+1]; -#endif - char m_binary_path_buff[500+1]; // !! ?? -}; - -//____________________________________________________________________________// - -process_info::process_info( int pid ) -: m_parent_pid( 0 ) -{ -#if defined(BOOST_SUN_BASED_DEBUG) - char fname_buff[30]; - - ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/psinfo", pid ); - - fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) ); - - if( psinfo_fd == -1 ) - return; - - if( ::read( psinfo_fd, &m_psi, sizeof(m_psi) ) == -1 ) - return; - - m_parent_pid = m_psi.pr_ppid; - - m_binary_name.assign( m_psi.pr_fname ); - - //-------------------------- // - - ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/as", pid ); - - fd_holder as_fd( ::open( fname_buff, O_RDONLY ) ); - uintptr_t binary_name_pos; - - // !! ?? could we avoid reading whole m_binary_path_buff? - if( as_fd == -1 || - ::lseek( as_fd, m_psi.pr_argv, SEEK_SET ) == -1 || - ::read ( as_fd, &binary_name_pos, sizeof(binary_name_pos) ) == -1 || - ::lseek( as_fd, binary_name_pos, SEEK_SET ) == -1 || - ::read ( as_fd, m_binary_path_buff, sizeof(m_binary_path_buff) ) == -1 ) - return; - - m_binary_path.assign( m_binary_path_buff ); - -#elif defined(BOOST_LINUX_BASED_DEBUG) - char fname_buff[30]; - - ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/stat", pid ); - - fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) ); - - if( psinfo_fd == -1 ) - return; - - ssize_t num_read = ::read( psinfo_fd, m_stat_line, sizeof(m_stat_line)-1 ); - if( num_read == -1 ) - return; - - m_stat_line[num_read] = 0; - - char const* name_beg = m_stat_line; - while( *name_beg && *name_beg != '(' ) - ++name_beg; - - char const* name_end = name_beg+1; - while( *name_end && *name_end != ')' ) - ++name_end; - - std::sscanf( name_end+1, "%*s%d", &m_parent_pid ); - - m_binary_name.assign( name_beg+1, name_end ); - - ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/exe", pid ); - num_read = ::readlink( fname_buff, m_binary_path_buff, sizeof(m_binary_path_buff)-1 ); - - if( num_read == -1 ) - return; - - m_binary_path_buff[num_read] = 0; - m_binary_path.assign( m_binary_path_buff, num_read ); -#endif -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** prepare_window_title ************** // -// ************************************************************************** // - -static char* -prepare_window_title( dbg_startup_info const& dsi ) -{ - typedef unit_test::const_string str_t; - - static char title_str[50]; - - str_t path_sep( "\\/" ); - - str_t::iterator it = unit_test::find_last_of( dsi.binary_path.begin(), dsi.binary_path.end(), - path_sep.begin(), path_sep.end() ); - - if( it == dsi.binary_path.end() ) - it = dsi.binary_path.begin(); - else - ++it; - - ::snprintf( title_str, sizeof(title_str), "%*s %ld", (int)(dsi.binary_path.end()-it), it, dsi.pid ); - - return title_str; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** save_execlp ************** // -// ************************************************************************** // - -typedef unit_test::basic_cstring mbuffer; - -inline char* -copy_arg( mbuffer& dest, const_string arg ) -{ - if( dest.size() < arg.size()+1 ) - return 0; - - char* res = dest.begin(); - - std::memcpy( res, arg.begin(), arg.size()+1 ); - - dest.trim_left( arg.size()+1 ); - - return res; -} - -//____________________________________________________________________________// - -bool -safe_execlp( char const* file, ... ) -{ - static char* argv_buff[200]; - - va_list args; - char const* arg; - - // first calculate actual number of arguments - int num_args = 2; // file name and 0 at least - - va_start( args, file ); - while( !!(arg = va_arg( args, char const* )) ) - num_args++; - va_end( args ); - - // reserve space for the argument pointers array - char** argv_it = argv_buff; - mbuffer work_buff( reinterpret_cast(argv_buff), sizeof(argv_buff) ); - work_buff.trim_left( num_args * sizeof(char*) ); - - // copy all the argument values into local storage - if( !(*argv_it++ = copy_arg( work_buff, file )) ) - return false; - - printf( "!! %s\n", file ); - - va_start( args, file ); - while( !!(arg = va_arg( args, char const* )) ) { - printf( "!! %s\n", arg ); - if( !(*argv_it++ = copy_arg( work_buff, arg )) ) - return false; - } - va_end( args ); - - *argv_it = 0; - - return ::execvp( file, argv_buff ) != -1; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** start_debugger_in_emacs ************** // -// ************************************************************************** // - -static void -start_debugger_in_emacs( dbg_startup_info const& dsi, char const* emacs_name, char const* dbg_command ) -{ - char const* title = prepare_window_title( dsi ); - - if( !title ) - return; - - dsi.display.is_empty() - ? safe_execlp( emacs_name, "-title", title, "--eval", dbg_command, 0 ) - : safe_execlp( emacs_name, "-title", title, "-display", dsi.display.begin(), "--eval", dbg_command, 0 ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** gdb starters ************** // -// ************************************************************************** // - -static char const* -prepare_gdb_cmnd_file( dbg_startup_info const& dsi ) -{ - // prepare pid value - char pid_buff[16]; - ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid ); - unit_test::const_string pid_str( pid_buff ); - - static char cmd_file_name[] = "/tmp/btl_gdb_cmd_XXXXXX"; // !! ?? - - // prepare commands - fd_holder cmd_fd( ::mkstemp( cmd_file_name ) ); - - if( cmd_fd == -1 ) - return 0; - -#define WRITE_STR( str ) if( ::write( cmd_fd, str.begin(), str.size() ) == -1 ) return 0; -#define WRITE_CSTR( str ) if( ::write( cmd_fd, str, sizeof( str )-1 ) == -1 ) return 0; - - WRITE_CSTR( "file " ); - WRITE_STR( dsi.binary_path ); - WRITE_CSTR( "\nattach " ); - WRITE_STR( pid_str ); - WRITE_CSTR( "\nshell unlink " ); - WRITE_STR( dsi.init_done_lock ); - WRITE_CSTR( "\ncont" ); - if( dsi.break_or_continue ) - WRITE_CSTR( "\nup 4" ); - - WRITE_CSTR( "\necho \\n" ); // !! ?? - WRITE_CSTR( "\nlist -" ); - WRITE_CSTR( "\nlist" ); - WRITE_CSTR( "\nshell unlink " ); - WRITE_CSTR( cmd_file_name ); - - return cmd_file_name; -} - -//____________________________________________________________________________// - -static void -start_gdb_in_console( dbg_startup_info const& dsi ) -{ - char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi ); - - if( !cmnd_file_name ) - return; - - safe_execlp( "gdb", "-q", "-x", cmnd_file_name, 0 ); -} - -//____________________________________________________________________________// - -static void -start_gdb_in_xterm( dbg_startup_info const& dsi ) -{ - char const* title = prepare_window_title( dsi ); - char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi ); - - if( !title || !cmnd_file_name ) - return; - - safe_execlp( "xterm", "-T", title, "-display", dsi.display.begin(), - "-bg", "black", "-fg", "white", "-geometry", "88x30+10+10", "-fn", "9x15", "-e", - "gdb", "-q", "-x", cmnd_file_name, 0 ); -} - -//____________________________________________________________________________// - -static void -start_gdb_in_emacs( dbg_startup_info const& dsi ) -{ - char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi ); - if( !cmnd_file_name ) - return; - - char dbg_cmd_buff[500]; // !! ?? - ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), "(progn (gdb \"gdb -q -x %s\"))", cmnd_file_name ); - - start_debugger_in_emacs( dsi, "emacs", dbg_cmd_buff ); -} - -//____________________________________________________________________________// - -static void -start_gdb_in_xemacs( dbg_startup_info const& ) -{ - // !! ?? -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** dbx starters ************** // -// ************************************************************************** // - -static char const* -prepare_dbx_cmd_line( dbg_startup_info const& dsi, bool list_source = true ) -{ - static char cmd_line_buff[500]; // !! ?? - - ::snprintf( cmd_line_buff, sizeof(cmd_line_buff), "unlink %s;cont;%s%s", - dsi.init_done_lock.begin(), - dsi.break_or_continue ? "up 2;": "", - list_source ? "echo \" \";list -w3;" : "" ); - - return cmd_line_buff; -} - -//____________________________________________________________________________// - -static void -start_dbx_in_console( dbg_startup_info const& dsi ) -{ - char pid_buff[16]; - ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid ); - - safe_execlp( "dbx", "-q", "-c", prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 ); -} - -//____________________________________________________________________________// - -static void -start_dbx_in_xterm( dbg_startup_info const& dsi ) -{ - char const* title = prepare_window_title( dsi ); - if( !title ) - return; - - char pid_buff[16]; // !! ?? - ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid ); - - safe_execlp( "xterm", "-T", title, "-display", dsi.display.begin(), - "-bg", "black", "-fg", "white", "-geometry", "88x30+10+10", "-fn", "9x15", "-e", - "dbx", "-q", "-c", prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 ); -} - -//____________________________________________________________________________// - -static void -start_dbx_in_emacs( dbg_startup_info const& /*dsi*/ ) -{ -// char dbg_cmd_buff[500]; // !! ?? -// -// ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), "(progn (dbx \"dbx -q -c cont %s %ld\"))", dsi.binary_path.begin(), dsi.pid ); - -// start_debugger_in_emacs( dsi, "emacs", dbg_cmd_buff ); -} - -//____________________________________________________________________________// - -static void -start_dbx_in_xemacs( dbg_startup_info const& ) -{ - // !! ?? -} - -//____________________________________________________________________________// - -static void -start_dbx_in_ddd( dbg_startup_info const& dsi ) -{ - char const* title = prepare_window_title( dsi ); - if( !title ) - return; - - char pid_buff[16]; // !! ?? - ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid ); - - safe_execlp( "ddd", "-display", dsi.display.begin(), - "--dbx", "-q", "-c", prepare_dbx_cmd_line( dsi, false ), dsi.binary_path.begin(), pid_buff, 0 ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** debug::info_t ************** // -// ************************************************************************** // - -static struct info_t { - // Constructor - info_t(); - - // Public properties - unit_test::readwrite_property p_dbg; - - // Data members - std::map m_dbg_starter_reg; -} s_info; - -//____________________________________________________________________________// - -info_t::info_t() -{ - p_dbg.value = ::getenv( "DISPLAY" ) - ? std::string( BOOST_STRINGIZE( BOOST_TEST_GUI_DBG ) ) - : std::string( BOOST_STRINGIZE( BOOST_TEST_CNL_DBG ) ); - - m_dbg_starter_reg[std::string("gdb")] = &start_gdb_in_console; - m_dbg_starter_reg[std::string("gdb-emacs")] = &start_gdb_in_emacs; - m_dbg_starter_reg[std::string("gdb-xterm")] = &start_gdb_in_xterm; - m_dbg_starter_reg[std::string("gdb-xemacs")] = &start_gdb_in_xemacs; - - m_dbg_starter_reg[std::string("dbx")] = &start_dbx_in_console; - m_dbg_starter_reg[std::string("dbx-emacs")] = &start_dbx_in_emacs; - m_dbg_starter_reg[std::string("dbx-xterm")] = &start_dbx_in_xterm; - m_dbg_starter_reg[std::string("dbx-xemacs")] = &start_dbx_in_xemacs; - m_dbg_starter_reg[std::string("dbx-ddd")] = &start_dbx_in_ddd; -} - -//____________________________________________________________________________// - -#endif - -} // local namespace - -// ************************************************************************** // -// ************** check if program is running under debugger ************** // -// ************************************************************************** // - -bool -under_debugger() -{ -#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32 - - return !!s_info.m_is_debugger_present && s_info.m_is_debugger_present(); - -#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX - - // !! ?? could/should we cache the result somehow? - const_string dbg_list = BOOST_TEST_STRINGIZE( BOOST_TEST_DBG_LIST ); - - pid_t pid = ::getpid(); - - while( pid != 0 ) { - process_info pi( pid ); - - // !! ?? should we use tokenizer here instead? - if( dbg_list.find( pi.binary_name() ) != const_string::npos ) - return true; - - pid = (pi.parent_pid() == pid ? 0 : pi.parent_pid()); - } - - return false; - -#else // ****************************************************** default - - return false; - -#endif -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** cause program to break execution ************** // -// ************** in debugger at call point ************** // -// ************************************************************************** // - -void -debugger_break() -{ - // !! ?? auto-start debugger? - -#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32 - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1300) || \ - BOOST_WORKAROUND(__GNUC__, >= 3) && !defined(__MINGW32__) || \ - defined(__INTEL_COMPILER) -# define BOOST_DEBUG_BREAK __debugbreak -#else -# define BOOST_DEBUG_BREAK DebugBreak -#endif - -#ifndef __MINGW32__ - if( !under_debugger() ) { - __try { - __try { - BOOST_DEBUG_BREAK(); - } - __except( UnhandledExceptionFilter(GetExceptionInformation()) ) - { - // User opted to ignore the breakpoint - return; - } - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - // If we got here, the user has pushed Debug. Debugger is already attached to our process and we - // continue to let the another BOOST_DEBUG_BREAK to be called. - } - } -#endif - - BOOST_DEBUG_BREAK(); - -#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX - - ::kill( ::getpid(), SIGTRAP ); - -#else // ****************************************************** default - -#endif -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** console debugger setup ************** // -// ************************************************************************** // - -#if defined(BOOST_UNIX_BASED_DEBUG) // ************************ UNIX - -std::string -set_debugger( unit_test::const_string dbg_id, dbg_starter s ) -{ - std::string old = s_info.p_dbg; - - assign_op( s_info.p_dbg.value, dbg_id, 0 ); - - if( !!s ) - s_info.m_dbg_starter_reg[s_info.p_dbg] = s; - - return old; -} - -#else // ***************************************************** default - -std::string -set_debugger( unit_test::const_string, dbg_starter ) -{ - return std::string(); -} - -#endif - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** attach debugger to the current process ************** // -// ************************************************************************** // - -bool -attach_debugger( bool break_or_continue ) -{ - if( under_debugger() ) - return false; - -#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32 - - const int MAX_CMD_LINE = 200; - - // *************************************************** // - // Debugger "ready" event - - SECURITY_ATTRIBUTES attr; - attr.nLength = sizeof(attr); - attr.lpSecurityDescriptor = NULL; - attr.bInheritHandle = true; - - // manual resettable, initially non signaled, unnamed event, - // that will signal me that debugger initialization is done - HANDLE dbg_init_done_ev = ::CreateEvent( - &attr, // pointer to security attributes - true, // flag for manual-reset event - false, // flag for initial state - NULL // pointer to event-object name - ); - - if( !dbg_init_done_ev ) - return false; - - // *************************************************** // - // Debugger command line format - - HKEY reg_key; - - if( !s_info.m_reg_open_key || (*s_info.m_reg_open_key)( - HKEY_LOCAL_MACHINE, // handle of open key - "Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", // name of subkey to open - ®_key ) != ERROR_SUCCESS ) // address of handle of open key - return false; - - char format[MAX_CMD_LINE]; - DWORD format_size = MAX_CMD_LINE; - DWORD type = REG_SZ; - - if( !s_info.m_reg_query_value || (*s_info.m_reg_query_value)( - reg_key, // handle of open key - "Debugger", // name of subkey to query - 0, // reserved - &type, // value type - (LPBYTE)format, // buffer for returned string - &format_size ) != ERROR_SUCCESS ) // in: buffer size; out: actual size of returned string - return false; - - if( !s_info.m_reg_close_key || (*s_info.m_reg_close_key)( reg_key ) != ERROR_SUCCESS ) - return false; - - // *************************************************** // - // Debugger command line - - char cmd_line[MAX_CMD_LINE]; - std::sprintf( cmd_line, format, ::GetCurrentProcessId(), dbg_init_done_ev ); - - // *************************************************** // - // Debugger window parameters - - STARTUPINFOA startup_info; - std::memset( &startup_info, 0, sizeof(startup_info) ); - - startup_info.cb = sizeof(startup_info); - startup_info.dwFlags = STARTF_USESHOWWINDOW; - startup_info.wShowWindow = SW_SHOWNORMAL; - - // debugger process s_info - PROCESS_INFORMATION debugger_info; - - bool created = !!::CreateProcessA( - NULL, // pointer to name of executable module; NULL - use the one in command line - cmd_line, // pointer to command line string - NULL, // pointer to process security attributes; NULL - debugger's handle can't be inherited - NULL, // pointer to thread security attributes; NULL - debugger's handle can't be inherited - true, // debugger inherit opened handles - 0, // priority flags; 0 - normal priority - NULL, // pointer to new environment block; NULL - use this process environment - NULL, // pointer to current directory name; NULL - use this process correct directory - &startup_info, // pointer to STARTUPINFO that specifies main window appearance - &debugger_info // pointer to PROCESS_INFORMATION that will contain the new process identification - ); - - if( created ) - ::WaitForSingleObject( dbg_init_done_ev, INFINITE ); - - ::CloseHandle( dbg_init_done_ev ); - - if( !created ) - return false; - - if( break_or_continue ) - debugger_break(); - - return true; - -#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX - - char init_done_lock_fn[] = "/tmp/btl_dbg_init_done_XXXXXX"; - fd_holder init_done_lock_fd( ::mkstemp( init_done_lock_fn ) ); - - if( init_done_lock_fd == -1 ) - return false; - - pid_t child_pid = fork(); - - if( child_pid == -1 ) - return false; - - if( child_pid != 0 ) { // parent process - here we will start the debugger - dbg_startup_info dsi; - - process_info pi( child_pid ); - if( pi.binary_path().is_empty() ) - ::exit( -1 ); - - dsi.pid = child_pid; - dsi.break_or_continue = break_or_continue; - dsi.binary_path = pi.binary_path(); - dsi.display = ::getenv( "DISPLAY" ); - dsi.init_done_lock = init_done_lock_fn; - - dbg_starter starter = s_info.m_dbg_starter_reg[s_info.p_dbg]; - if( !!starter ) - starter( dsi ); - - ::perror( "Boost.Test execution monitor failed to start a debugger:" ); - - ::exit( -1 ); - } - - // child process - here we will continue our test module execution ; // !! ?? should it be vice versa - - while( ::access( init_done_lock_fn, F_OK ) == 0 ) { - struct timeval to = { 0, 100 }; - - ::select( 0, 0, 0, 0, &to ); - } - -// char dummy; -// while( ::read( init_done_lock_fd, &dummy, sizeof(char) ) == 0 ); - - if( break_or_continue ) - debugger_break(); - - return true; - -#else // ****************************************************** default - - return false; - -#endif -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** switch on/off detect memory leaks feature ************** // -// ************************************************************************** // - -void -detect_memory_leaks( bool on_off ) -{ - unit_test::ut_detail::ignore_unused_variable_warning( on_off ); - -#ifdef BOOST_MS_CRT_BASED_DEBUG - int flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); - - if( !on_off ) - flags &= ~_CRTDBG_LEAK_CHECK_DF; - else { - flags |= _CRTDBG_LEAK_CHECK_DF; - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); - } - - _CrtSetDbgFlag ( flags ); -#endif // BOOST_MS_CRT_BASED_DEBUG -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** cause program to break execution in ************** // -// ************** debugger at specific allocation point ************** // -// ************************************************************************** // - -void -break_memory_alloc( long mem_alloc_order_num ) -{ - unit_test::ut_detail::ignore_unused_variable_warning( mem_alloc_order_num ); - -#ifdef BOOST_MS_CRT_BASED_DEBUG - _CrtSetBreakAlloc( mem_alloc_order_num ); -#endif // BOOST_MS_CRT_BASED_DEBUG -} - -} // namespace debug - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_DEBUG_API_IPP_112006GER - diff --git a/contrib/autoboost/boost/test/impl/exception_safety.ipp b/contrib/autoboost/boost/test/impl/exception_safety.ipp deleted file mode 100644 index cf697ebcf..000000000 --- a/contrib/autoboost/boost/test/impl/exception_safety.ipp +++ /dev/null @@ -1,537 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Facilities to perform exception safety tests -// *************************************************************************** - -#ifndef BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER -#define BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER - -// Boost.Test -#include - -#if BOOST_TEST_SUPPORT_INTERACTION_TESTING - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -// Boost -#include - -// STL -#include -#include -#include -#include -#include -#include - -//____________________________________________________________________________// - -namespace autoboost { - -using namespace ::autoboost::unit_test; - -namespace itest { - -// ************************************************************************** // -// ************** execution_path_point ************** // -// ************************************************************************** // - -enum exec_path_point_type { EPP_SCOPE, EPP_EXCEPT, EPP_DECISION, EPP_ALLOC }; - -struct execution_path_point { - execution_path_point( exec_path_point_type t, const_string file, std::size_t line_num ) - : m_type( t ) - , m_file_name( file ) - , m_line_num( line_num ) - {} - - exec_path_point_type m_type; - const_string m_file_name; - std::size_t m_line_num; - - // Execution path point specific - struct decision_data { - bool value; - unsigned forced_exception_point; - }; - struct scope_data { - unsigned size; - char const* name; - }; - struct except_data { - char const* description; - }; - struct alloc_data { - void* ptr; - std::size_t size; - }; - - union { - struct decision_data m_decision; - struct scope_data m_scope; - struct except_data m_except; - struct alloc_data m_alloc; - }; -}; - -// ************************************************************************** // -// ************** exception safety test implementation ************** // -// ************************************************************************** // - -struct exception_safety_tester : itest::manager, test_observer { - // helpers types - struct unique_exception {}; - - // Constructor - explicit exception_safety_tester( const_string test_name ); - ~exception_safety_tester(); - - // check last run and prepare for next - bool next_execution_path(); - - // memory tracking - - // manager interface implementation - virtual void exception_point( const_string file, std::size_t line_num, const_string description ); - virtual bool decision_point( const_string file, std::size_t line_num ); - virtual unsigned enter_scope( const_string file, std::size_t line_num, const_string scope_name ); - virtual void leave_scope( unsigned enter_scope_point ); - virtual void allocated( const_string file, std::size_t line_num, void* p, std::size_t s ); - virtual void freed( void* p ); - - // test observer interface - virtual void assertion_result( bool passed ); - virtual int priority() { return (std::numeric_limits::max)(); } // we want this observer to run the last - -private: - void failure_point(); - void report_error(); - - typedef std::vector exec_path; - typedef std::map registry; - - // Data members - bool m_internal_activity; - - unsigned m_exception_point_counter; - unsigned m_forced_exception_point; - - unsigned m_exec_path_point; - exec_path m_execution_path; - - unsigned m_exec_path_counter; - unsigned m_break_exec_path; - - bool m_invairant_failed; - registry m_memory_in_use; -}; - -//____________________________________________________________________________// - -struct activity_guard { - bool& m_v; - - activity_guard( bool& v ) : m_v( v ) { m_v = true; } - ~activity_guard() { m_v = false; } -}; - -//____________________________________________________________________________// - -exception_safety_tester::exception_safety_tester( const_string test_name ) -: m_internal_activity( true ) -, m_exception_point_counter( 0 ) -, m_forced_exception_point( 1 ) -, m_exec_path_point( 0 ) -, m_exec_path_counter( 1 ) -, m_break_exec_path( static_cast(-1) ) -, m_invairant_failed( false ) -{ - framework::register_observer( *this ); - - if( !runtime_config::break_exec_path().is_empty() ) { - using namespace unit_test; - - string_token_iterator tit( runtime_config::break_exec_path(), - (dropped_delimeters = ":",kept_delimeters = " ") ); - - const_string test_to_break = *tit; - - if( test_to_break == test_name ) { - ++tit; - - m_break_exec_path = lexical_cast( *tit ); - } - } - - m_internal_activity = false; -} - -//____________________________________________________________________________// - -exception_safety_tester::~exception_safety_tester() -{ - m_internal_activity = true; - - framework::deregister_observer( *this ); -} - -//____________________________________________________________________________// - -bool -exception_safety_tester::next_execution_path() -{ - activity_guard ag( m_internal_activity ); - - // check memory usage - if( m_execution_path.size() > 0 ) { - bool errors_detected = m_invairant_failed || (m_memory_in_use.size() != 0); - framework::assertion_result( !errors_detected ); - - if( errors_detected ) - report_error(); - - m_memory_in_use.clear(); - } - - m_exec_path_point = 0; - m_exception_point_counter = 0; - m_invairant_failed = false; - ++m_exec_path_counter; - - while( m_execution_path.size() > 0 ) { - switch( m_execution_path.back().m_type ) { - case EPP_SCOPE: - case EPP_ALLOC: - m_execution_path.pop_back(); - break; - - case EPP_DECISION: - if( !m_execution_path.back().m_decision.value ) { - m_execution_path.pop_back(); - break; - } - - m_execution_path.back().m_decision.value = false; - m_forced_exception_point = m_execution_path.back().m_decision.forced_exception_point; - return true; - - case EPP_EXCEPT: - m_execution_path.pop_back(); - ++m_forced_exception_point; - return true; - } - } - - BOOST_TEST_MESSAGE( "Total tested " << --m_exec_path_counter << " execution path" ); - - return false; -} - -//____________________________________________________________________________// - -void -exception_safety_tester::exception_point( const_string file, std::size_t line_num, const_string description ) -{ - activity_guard ag( m_internal_activity ); - - if( ++m_exception_point_counter == m_forced_exception_point ) { - m_execution_path.push_back( - execution_path_point( EPP_EXCEPT, file, line_num ) ); - - m_execution_path.back().m_except.description = description.begin(); - - ++m_exec_path_point; - - failure_point(); - } -} - -//____________________________________________________________________________// - -bool -exception_safety_tester::decision_point( const_string file, std::size_t line_num ) -{ - activity_guard ag( m_internal_activity ); - - if( m_exec_path_point < m_execution_path.size() ) { - BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_DECISION && - m_execution_path[m_exec_path_point].m_file_name == file && - m_execution_path[m_exec_path_point].m_line_num == line_num, - "Function under test exibit non-deterministic behavior" ); - } - else { - m_execution_path.push_back( - execution_path_point( EPP_DECISION, file, line_num ) ); - - m_execution_path.back().m_decision.value = true; - m_execution_path.back().m_decision.forced_exception_point = m_forced_exception_point; - } - - return m_execution_path[m_exec_path_point++].m_decision.value; -} - -//____________________________________________________________________________// - -unsigned -exception_safety_tester::enter_scope( const_string file, std::size_t line_num, const_string scope_name ) -{ - activity_guard ag( m_internal_activity ); - - if( m_exec_path_point < m_execution_path.size() ) { - BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_SCOPE && - m_execution_path[m_exec_path_point].m_file_name == file && - m_execution_path[m_exec_path_point].m_line_num == line_num, - "Function under test exibit non-deterministic behavior" ); - } - else { - m_execution_path.push_back( - execution_path_point( EPP_SCOPE, file, line_num ) ); - } - - m_execution_path[m_exec_path_point].m_scope.size = 0; - m_execution_path[m_exec_path_point].m_scope.name = scope_name.begin(); - - return m_exec_path_point++; -} - -//____________________________________________________________________________// - -void -exception_safety_tester::leave_scope( unsigned enter_scope_point ) -{ - activity_guard ag( m_internal_activity ); - - BOOST_REQUIRE_MESSAGE( m_execution_path[enter_scope_point].m_type == EPP_SCOPE, - "Function under test exibit non-deterministic behavior" ); - - m_execution_path[enter_scope_point].m_scope.size = m_exec_path_point - enter_scope_point; -} - -//____________________________________________________________________________// - -void -exception_safety_tester::allocated( const_string file, std::size_t line_num, void* p, std::size_t s ) -{ - if( m_internal_activity ) - return; - - activity_guard ag( m_internal_activity ); - - if( m_exec_path_point < m_execution_path.size() ) - BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_ALLOC, - "Function under test exibit non-deterministic behavior" ); - else - m_execution_path.push_back( - execution_path_point( EPP_ALLOC, file, line_num ) ); - - m_execution_path[m_exec_path_point].m_alloc.ptr = p; - m_execution_path[m_exec_path_point].m_alloc.size = s; - - m_memory_in_use.insert( std::make_pair( p, m_exec_path_point++ ) ); -} - -//____________________________________________________________________________// - -void -exception_safety_tester::freed( void* p ) -{ - if( m_internal_activity ) - return; - - activity_guard ag( m_internal_activity ); - - registry::iterator it = m_memory_in_use.find( p ); - if( it != m_memory_in_use.end() ) { - m_execution_path[it->second].m_alloc.ptr = 0; - m_memory_in_use.erase( it ); - } -} - -//____________________________________________________________________________// - -void -exception_safety_tester::assertion_result( bool passed ) -{ - if( !m_internal_activity && !passed ) { - m_invairant_failed = true; - - failure_point(); - } -} - -//____________________________________________________________________________// - -void -exception_safety_tester::failure_point() -{ - if( m_exec_path_counter == m_break_exec_path ) - debug::debugger_break(); - - throw unique_exception(); -} - -//____________________________________________________________________________// - -namespace { - -inline void -format_location( wrap_stringstream& formatter, execution_path_point const& /*p*/, unsigned indent ) -{ - if( indent ) - formatter << std::left << std::setw( indent ) << ""; - -// !! ?? optional if( p.m_file_name ) -// formatter << p.m_file_name << '(' << p.m_line_num << "): "; -} - -//____________________________________________________________________________// - -template -inline void -format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt end, unsigned indent = 0 ) -{ - while( it != end ) { - switch( it->m_type ) { - case EPP_SCOPE: - format_location( formatter, *it, indent ); - formatter << "> \"" << it->m_scope.name << "\"\n"; - format_execution_path( formatter, it+1, it + it->m_scope.size, indent + 2 ); - format_location( formatter, *it, indent ); - formatter << "< \"" << it->m_scope.name << "\"\n"; - it += it->m_scope.size; - break; - - case EPP_DECISION: - format_location( formatter, *it, indent ); - formatter << "Decision made as " << std::boolalpha << it->m_decision.value << '\n'; - ++it; - break; - - case EPP_EXCEPT: - format_location( formatter, *it, indent ); - formatter << "Forced failure"; - if( it->m_except.description ) - formatter << ": " << it->m_except.description; - formatter << "\n"; - ++it; - break; - - case EPP_ALLOC: - if( it->m_alloc.ptr ) { - format_location( formatter, *it, indent ); - formatter << "Allocated memory block 0x" << std::uppercase << it->m_alloc.ptr - << ", " << it->m_alloc.size << " bytes long: <"; - - unsigned i; - for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) { - unsigned char c = static_cast(it->m_alloc.ptr)[i]; - if( (std::isprint)( c ) ) - formatter << c; - else - formatter << '.'; - } - - formatter << "> "; - - for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) { - unsigned c = static_cast(it->m_alloc.ptr)[i]; - formatter << std::hex << std::uppercase << c << ' '; - } - - formatter << "\n"; - } - ++it; - break; - } - } -} - -//____________________________________________________________________________// - -} // local namespace - -void -exception_safety_tester::report_error() -{ - activity_guard ag( m_internal_activity ); - - unit_test_log << unit_test::log::begin( m_execution_path.back().m_file_name, - m_execution_path.back().m_line_num ) - << log_all_errors; - - wrap_stringstream formatter; - - if( m_invairant_failed ) - formatter << "Failed invariant"; - - if( m_memory_in_use.size() != 0 ) { - if( m_invairant_failed ) - formatter << " and "; - - formatter << static_cast(m_memory_in_use.size()) << " memory leak"; - if( m_memory_in_use.size() > 1 ) - formatter << 's'; - } - formatter << " detected in the execution path " << m_exec_path_counter << ":\n"; - - format_execution_path( formatter, m_execution_path.begin(), m_execution_path.end() ); - - unit_test_log << const_string( formatter.str() ) << unit_test::log::end(); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** exception safety test ************** // -// ************************************************************************** // - -void BOOST_TEST_DECL -exception_safety( callback0<> const& F, const_string test_name ) -{ - exception_safety_tester est( test_name ); - - do { - try { - F(); - } - catch( exception_safety_tester::unique_exception const& ) {} - - } while( est.next_execution_path() ); -} - -//____________________________________________________________________________// - -} // namespace itest - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // non-ancient compiler - -#endif // BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER diff --git a/contrib/autoboost/boost/test/impl/execution_monitor.ipp b/contrib/autoboost/boost/test/impl/execution_monitor.ipp deleted file mode 100644 index b73fc5bec..000000000 --- a/contrib/autoboost/boost/test/impl/execution_monitor.ipp +++ /dev/null @@ -1,1367 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// (C) Copyright Beman Dawes and Ullrich Koethe 1995-2001. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : provides execution monitor implementation for all supported -// configurations, including Microsoft structured exception based, unix signals -// based and special workarounds for borland -// -// Note that when testing requirements or user wishes preclude use of this -// file as a separate compilation unit, it may be included as a header file. -// -// Header dependencies are deliberately restricted to reduce coupling to other -// boost libraries. -// *************************************************************************** - -#ifndef BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER -#define BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include - -// Boost -#include // for exit codes -#include // for workarounds -#include // for get_error_info -#include // for current_exception_cast - -// STL -#include // for std::string -#include // for std::bad_alloc -#include // for std::bad_cast, std::bad_typeid -#include // for std::exception, std::bad_exception -#include // for std exception hierarchy -#include // for C string API -#include // for assert -#include // for NULL -#include // for vsnprintf -#include // for varargs - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::strerror; using ::strlen; using ::strncat; } -#endif - -// to use vsnprintf -#if defined(__SUNPRO_CC) || defined(__SunOS) -# include -# include -using std::va_list; -#endif - -// to use vsnprintf -#if defined(__QNXNTO__) -# include -#endif - -#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) && \ - (!defined(__COMO__) && !defined(__MWERKS__) && !defined(__GNUC__) || \ - BOOST_WORKAROUND(__MWERKS__, >= 0x3000)) - -# define BOOST_SEH_BASED_SIGNAL_HANDLING - -# include - -# if defined(__MWERKS__) || (defined(_MSC_VER) && !defined(UNDER_CE)) -# include -# endif - -# if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 || defined(__MWERKS__) -# include -# endif - -# if defined(__BORLANDC__) && __BORLANDC__ < 0x560 - typedef unsigned uintptr_t; -# endif - -# if BOOST_WORKAROUND(_MSC_VER, < 1300 ) || defined(UNDER_CE) -typedef void* uintptr_t; -# endif - -// for the FP control routines -#include - -#ifndef EM_INVALID -#define EM_INVALID _EM_INVALID -#endif - -#ifndef EM_DENORMAL -#define EM_DENORMAL _EM_DENORMAL -#endif - -#ifndef EM_ZERODIVIDE -#define EM_ZERODIVIDE _EM_ZERODIVIDE -#endif - -#ifndef EM_OVERFLOW -#define EM_OVERFLOW _EM_OVERFLOW -#endif - -#ifndef EM_UNDERFLOW -#define EM_UNDERFLOW _EM_UNDERFLOW -#endif - -#ifndef MCW_EM -#define MCW_EM _MCW_EM -#endif - -# if !defined(NDEBUG) && defined(_MSC_VER) && !defined(UNDER_CE) -# include -# define BOOST_TEST_CRT_HOOK_TYPE _CRT_REPORT_HOOK -# define BOOST_TEST_CRT_ASSERT _CRT_ASSERT -# define BOOST_TEST_CRT_ERROR _CRT_ERROR -# define BOOST_TEST_CRT_SET_HOOK(H) _CrtSetReportHook(H) -# else -# define BOOST_TEST_CRT_HOOK_TYPE void* -# define BOOST_TEST_CRT_ASSERT 2 -# define BOOST_TEST_CRT_ERROR 1 -# define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H) -# endif - -# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE) - -typedef void* _invalid_parameter_handler; - -inline _invalid_parameter_handler -_set_invalid_parameter_handler( _invalid_parameter_handler arg ) -{ - return arg; -} - -# endif - -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE) - -namespace { void _set_se_translator( void* ) {} } - -# endif - -#elif defined(BOOST_HAS_SIGACTION) - -# define BOOST_SIGACTION_BASED_SIGNAL_HANDLING - -# include -# include -# include - -# if defined(__FreeBSD__) - -# ifndef SIGPOLL -# define SIGPOLL SIGIO -# endif - -# if (__FreeBSD_version < 70100) - -# define ILL_ILLADR 0 // ILL_RESAD_FAULT -# define ILL_PRVOPC ILL_PRIVIN_FAULT -# define ILL_ILLOPN 2 // ILL_RESOP_FAULT -# define ILL_COPROC ILL_FPOP_FAULT - -# define BOOST_TEST_LIMITED_SIGNAL_DETAILS -# define BOOST_TEST_IGNORE_SIGCHLD - -# endif -# endif - -# if !defined(__CYGWIN__) && !defined(__QNXNTO__) -# define BOOST_TEST_USE_ALT_STACK -# endif - -# if defined(SIGPOLL) && !defined(__CYGWIN__) && \ - !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && \ - !defined(__NetBSD__) && \ - !defined(__QNXNTO__) -# define BOOST_TEST_CATCH_SIGPOLL -# endif - -# ifdef BOOST_TEST_USE_ALT_STACK -# define BOOST_TEST_ALT_STACK_SIZE SIGSTKSZ -# endif - -#else - -# define BOOST_NO_SIGNAL_HANDLING - -#endif - -#ifndef UNDER_CE -#include -#endif - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -// ************************************************************************** // -// ************** report_error ************** // -// ************************************************************************** // - -namespace detail { - -#ifdef __BORLANDC__ -# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) std::vsnprintf( (a1), (a2), (a3), (a4) ) -#elif BOOST_WORKAROUND(_MSC_VER, <= 1310) || \ - BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \ - defined(UNDER_CE) -# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) _vsnprintf( (a1), (a2), (a3), (a4) ) -#else -# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) vsnprintf( (a1), (a2), (a3), (a4) ) -#endif - -template -typename ErrorInfo::value_type -extract( autoboost::exception const* ex ) -{ - if( !ex ) - return 0; - - typename ErrorInfo::value_type const * val = autoboost::get_error_info( *ex ); - - return val ? *val : 0; -} - -//____________________________________________________________________________// - -static void -report_error( execution_exception::error_code ec, autoboost::exception const* be, char const* format, va_list* args ) -{ - static const int REPORT_ERROR_BUFFER_SIZE = 512; - static char buf[REPORT_ERROR_BUFFER_SIZE]; - - BOOST_TEST_VSNPRINTF( buf, sizeof(buf)-1, format, *args ); - buf[sizeof(buf)-1] = 0; - - va_end( *args ); - - throw execution_exception( ec, buf, execution_exception::location( extract( be ), - extract( be ), - extract( be ) ) ); -} - -//____________________________________________________________________________// - -static void -report_error( execution_exception::error_code ec, char const* format, ... ) -{ - va_list args; - va_start( args, format ); - - report_error( ec, 0, format, &args ); -} - -//____________________________________________________________________________// - -static void -report_error( execution_exception::error_code ec, autoboost::exception const* be, char const* format, ... ) -{ - va_list args; - va_start( args, format ); - - report_error( ec, be, format, &args ); -} - -//____________________________________________________________________________// - -template -inline int -do_invoke( Tr const& tr, Functor const& F ) -{ - return tr ? (*tr)( F ) : F(); -} - -//____________________________________________________________________________// - -} // namespace detail - -#if defined(BOOST_SIGACTION_BASED_SIGNAL_HANDLING) - -// ************************************************************************** // -// ************** Sigaction based signal handling ************** // -// ************************************************************************** // - -namespace detail { - -// ************************************************************************** // -// ************** autoboost::detail::system_signal_exception ************** // -// ************************************************************************** // - -class system_signal_exception { -public: - // Constructor - system_signal_exception() - : m_sig_info( 0 ) - , m_context( 0 ) - {} - - // Access methods - void operator()( siginfo_t* i, void* c ) - { - m_sig_info = i; - m_context = c; - } - void report() const; - -private: - // Data members - siginfo_t* m_sig_info; // system signal detailed info - void* m_context; // signal context -}; - -//____________________________________________________________________________// - -void -system_signal_exception::report() const -{ - if( !m_sig_info ) - return; // no error actually occur? - - switch( m_sig_info->si_code ) { - case SI_USER: - report_error( execution_exception::system_error, - "signal: generated by kill() (or family); uid=%d; pid=%d", - (int)m_sig_info->si_uid, (int)m_sig_info->si_pid ); - break; - case SI_QUEUE: - report_error( execution_exception::system_error, - "signal: sent by sigqueue()" ); - break; - case SI_TIMER: - report_error( execution_exception::system_error, - "signal: the expiration of a timer set by timer_settimer()" ); - break; - case SI_ASYNCIO: - report_error( execution_exception::system_error, - "signal: generated by the completion of an asynchronous I/O request" ); - break; - case SI_MESGQ: - report_error( execution_exception::system_error, - "signal: generated by the the arrival of a message on an empty message queue" ); - break; - default: - break; - } - - switch( m_sig_info->si_signo ) { - case SIGILL: - switch( m_sig_info->si_code ) { -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - case ILL_ILLOPC: - report_error( execution_exception::system_fatal_error, - "signal: illegal opcode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_ILLTRP: - report_error( execution_exception::system_fatal_error, - "signal: illegal trap; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_PRVREG: - report_error( execution_exception::system_fatal_error, - "signal: privileged register; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_BADSTK: - report_error( execution_exception::system_fatal_error, - "signal: internal stack error; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; -#endif - case ILL_ILLOPN: - report_error( execution_exception::system_fatal_error, - "signal: illegal operand; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_ILLADR: - report_error( execution_exception::system_fatal_error, - "signal: illegal addressing mode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_PRVOPC: - report_error( execution_exception::system_fatal_error, - "signal: privileged opcode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case ILL_COPROC: - report_error( execution_exception::system_fatal_error, - "signal: co-processor error; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - default: - report_error( execution_exception::system_fatal_error, - "signal: SIGILL, si_code: %d (illegal instruction; address of failing instruction: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); - break; - } - break; - - case SIGFPE: - switch( m_sig_info->si_code ) { - case FPE_INTDIV: - report_error( execution_exception::system_error, - "signal: integer divide by zero; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_INTOVF: - report_error( execution_exception::system_error, - "signal: integer overflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTDIV: - report_error( execution_exception::system_error, - "signal: floating point divide by zero; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTOVF: - report_error( execution_exception::system_error, - "signal: floating point overflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTUND: - report_error( execution_exception::system_error, - "signal: floating point underflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTRES: - report_error( execution_exception::system_error, - "signal: floating point inexact result; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTINV: - report_error( execution_exception::system_error, - "signal: invalid floating point operation; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - case FPE_FLTSUB: - report_error( execution_exception::system_error, - "signal: subscript out of range; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); - break; - default: - report_error( execution_exception::system_error, - "signal: SIGFPE, si_code: %d (errnoneous arithmetic operations; address of failing instruction: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); - break; - } - break; - - case SIGSEGV: - switch( m_sig_info->si_code ) { -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - case SEGV_MAPERR: - report_error( execution_exception::system_fatal_error, - "memory access violation at address: 0x%08lx: no mapping at fault address", - m_sig_info->si_addr ); - break; - case SEGV_ACCERR: - report_error( execution_exception::system_fatal_error, - "memory access violation at address: 0x%08lx: invalid permissions", - m_sig_info->si_addr ); - break; -#endif - default: - report_error( execution_exception::system_fatal_error, - "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); - break; - } - break; - - case SIGBUS: - switch( m_sig_info->si_code ) { -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - case BUS_ADRALN: - report_error( execution_exception::system_fatal_error, - "memory access violation at address: 0x%08lx: invalid address alignment", - m_sig_info->si_addr ); - break; - case BUS_ADRERR: - report_error( execution_exception::system_fatal_error, - "memory access violation at address: 0x%08lx: non-existent physical address", - m_sig_info->si_addr ); - break; - case BUS_OBJERR: - report_error( execution_exception::system_fatal_error, - "memory access violation at address: 0x%08lx: object specific hardware error", - m_sig_info->si_addr ); - break; -#endif - default: - report_error( execution_exception::system_fatal_error, - "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); - break; - } - break; - - case SIGCHLD: - switch( m_sig_info->si_code ) { -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - case CLD_EXITED: - report_error( execution_exception::system_error, - "child has exited; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; - case CLD_KILLED: - report_error( execution_exception::system_error, - "child was killed; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; - case CLD_DUMPED: - report_error( execution_exception::system_error, - "child terminated abnormally; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; - case CLD_TRAPPED: - report_error( execution_exception::system_error, - "traced child has trapped; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; - case CLD_STOPPED: - report_error( execution_exception::system_error, - "child has stopped; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; - case CLD_CONTINUED: - report_error( execution_exception::system_error, - "stopped child had continued; pid: %d; uid: %d; exit value: %d", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status ); - break; -#endif - default: - report_error( execution_exception::system_error, - "signal: SIGCHLD, si_code: %d (child process has terminated; pid: %d; uid: %d; exit value: %d)", - (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status, m_sig_info->si_code ); - break; - } - break; - -#if defined(BOOST_TEST_CATCH_SIGPOLL) - - case SIGPOLL: - switch( m_sig_info->si_code ) { -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - case POLL_IN: - report_error( execution_exception::system_error, - "data input available; band event %d", - (int)m_sig_info->si_band ); - break; - case POLL_OUT: - report_error( execution_exception::system_error, - "output buffers available; band event %d", - (int)m_sig_info->si_band ); - break; - case POLL_MSG: - report_error( execution_exception::system_error, - "input message available; band event %d", - (int)m_sig_info->si_band ); - break; - case POLL_ERR: - report_error( execution_exception::system_error, - "i/o error; band event %d", - (int)m_sig_info->si_band ); - break; - case POLL_PRI: - report_error( execution_exception::system_error, - "high priority input available; band event %d", - (int)m_sig_info->si_band ); - break; -#if defined(POLL_ERR) && defined(POLL_HUP) && (POLL_ERR - POLL_HUP) - case POLL_HUP: - report_error( execution_exception::system_error, - "device disconnected; band event %d", - (int)m_sig_info->si_band ); - break; -#endif -#endif - default: - report_error( execution_exception::system_error, - "signal: SIGPOLL, si_code: %d (asynchronous I/O event occured; band event %d)", - (int)m_sig_info->si_band, m_sig_info->si_code ); - break; - } - break; - -#endif - - case SIGABRT: - report_error( execution_exception::system_error, - "signal: SIGABRT (application abort requested)" ); - break; - - case SIGALRM: - report_error( execution_exception::timeout_error, - "signal: SIGALRM (timeout while executing function)" ); - break; - - default: - report_error( execution_exception::system_error, "unrecognized signal" ); - } -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** autoboost::detail::signal_action ************** // -// ************************************************************************** // - -// Forward declaration -extern "C" { -static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context ); -static void execution_monitor_attaching_signal_handler( int sig, siginfo_t* info, void* context ); -} - -class signal_action { - typedef struct sigaction* sigaction_ptr; -public: - //Constructor - signal_action(); - signal_action( int sig, bool install, bool attach_dbg, char* alt_stack ); - ~signal_action(); - -private: - // Data members - int m_sig; - bool m_installed; - struct sigaction m_new_action; - struct sigaction m_old_action; -}; - -//____________________________________________________________________________// - -signal_action::signal_action() -: m_installed( false ) -{} - -//____________________________________________________________________________// - -signal_action::signal_action( int sig, bool install, bool attach_dbg, char* alt_stack ) -: m_sig( sig ) -, m_installed( install ) -{ - if( !install ) - return; - - std::memset( &m_new_action, 0, sizeof(struct sigaction) ); - - BOOST_TEST_SYS_ASSERT( ::sigaction( m_sig , sigaction_ptr(), &m_new_action ) != -1 ); - - if( m_new_action.sa_sigaction || m_new_action.sa_handler ) { - m_installed = false; - return; - } - - m_new_action.sa_flags |= SA_SIGINFO; - m_new_action.sa_sigaction = attach_dbg ? &execution_monitor_attaching_signal_handler - : &execution_monitor_jumping_signal_handler; - BOOST_TEST_SYS_ASSERT( sigemptyset( &m_new_action.sa_mask ) != -1 ); - -#ifdef BOOST_TEST_USE_ALT_STACK - if( alt_stack ) - m_new_action.sa_flags |= SA_ONSTACK; -#endif - - BOOST_TEST_SYS_ASSERT( ::sigaction( m_sig, &m_new_action, &m_old_action ) != -1 ); -} - -//____________________________________________________________________________// - -signal_action::~signal_action() -{ - if( m_installed ) - ::sigaction( m_sig, &m_old_action , sigaction_ptr() ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** autoboost::detail::signal_handler ************** // -// ************************************************************************** // - -class signal_handler { -public: - // Constructor - explicit signal_handler( bool catch_system_errors, int timeout, bool attach_dbg, char* alt_stack ); - - // Destructor - ~signal_handler(); - - // access methods - static sigjmp_buf& jump_buffer() - { - assert( !!s_active_handler ); - - return s_active_handler->m_sigjmp_buf; - } - - static system_signal_exception& sys_sig() - { - assert( !!s_active_handler ); - - return s_active_handler->m_sys_sig; - } - -private: - // Data members - signal_handler* m_prev_handler; - int m_timeout; - - signal_action m_ILL_action; - signal_action m_FPE_action; - signal_action m_SEGV_action; - signal_action m_BUS_action; - signal_action m_CHLD_action; - signal_action m_POLL_action; - signal_action m_ABRT_action; - signal_action m_ALRM_action; - - sigjmp_buf m_sigjmp_buf; - system_signal_exception m_sys_sig; - - static signal_handler* s_active_handler; -}; - -// !! need to be placed in thread specific storage -typedef signal_handler* signal_handler_ptr; -signal_handler* signal_handler::s_active_handler = signal_handler_ptr(); - -//____________________________________________________________________________// - -signal_handler::signal_handler( bool catch_system_errors, int timeout, bool attach_dbg, char* alt_stack ) -: m_prev_handler( s_active_handler ) -, m_timeout( timeout ) -, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack ) -, m_FPE_action ( SIGFPE , catch_system_errors, attach_dbg, alt_stack ) -, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack ) -, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack ) -#ifndef BOOST_TEST_IGNORE_SIGCHLD -, m_CHLD_action( SIGCHLD, catch_system_errors, attach_dbg, alt_stack ) -#endif -#ifdef BOOST_TEST_CATCH_SIGPOLL -, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack ) -#endif -, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack ) -, m_ALRM_action( SIGALRM, timeout > 0 , attach_dbg, alt_stack ) -{ - s_active_handler = this; - - if( m_timeout > 0 ) { - ::alarm( 0 ); - ::alarm( timeout ); - } - -#ifdef BOOST_TEST_USE_ALT_STACK - if( alt_stack ) { - stack_t sigstk; - std::memset( &sigstk, 0, sizeof(stack_t) ); - - BOOST_TEST_SYS_ASSERT( ::sigaltstack( 0, &sigstk ) != -1 ); - - if( sigstk.ss_flags & SS_DISABLE ) { - sigstk.ss_sp = alt_stack; - sigstk.ss_size = BOOST_TEST_ALT_STACK_SIZE; - sigstk.ss_flags = 0; - BOOST_TEST_SYS_ASSERT( ::sigaltstack( &sigstk, 0 ) != -1 ); - } - } -#endif -} - -//____________________________________________________________________________// - -signal_handler::~signal_handler() -{ - assert( s_active_handler == this ); - - if( m_timeout > 0 ) - ::alarm( 0 ); - -#ifdef BOOST_TEST_USE_ALT_STACK -#ifdef __GNUC__ - // We shouldn't need to explicitly initialize all the members here, - // but gcc warns if we don't, so add initializers for each of the - // members specified in the POSIX std: - stack_t sigstk = { 0, 0, 0 }; -#else - stack_t sigstk = { }; -#endif - - sigstk.ss_size = MINSIGSTKSZ; - sigstk.ss_flags = SS_DISABLE; - BOOST_TEST_SYS_ASSERT( ::sigaltstack( &sigstk, 0 ) != -1 ); -#endif - - s_active_handler = m_prev_handler; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** execution_monitor_signal_handler ************** // -// ************************************************************************** // - -extern "C" { - -static bool ignore_sigchild( siginfo_t* info ) -{ - return info->si_signo == SIGCHLD -#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS - && info->si_code == CLD_EXITED -#endif -#ifdef BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE - ; -#else - && (int)info->si_status == 0; -#endif -} - -//____________________________________________________________________________// - -static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context ) -{ - if( ignore_sigchild( info ) ) - return; - - signal_handler::sys_sig()( info, context ); - - siglongjmp( signal_handler::jump_buffer(), sig ); -} - -//____________________________________________________________________________// - -static void execution_monitor_attaching_signal_handler( int sig, siginfo_t* info, void* context ) -{ - if( ignore_sigchild( info ) ) - return; - - if( !debug::attach_debugger( false ) ) - execution_monitor_jumping_signal_handler( sig, info, context ); - - // debugger attached; it will handle the signal - BOOST_TEST_SYS_ASSERT( ::signal( sig, SIG_DFL ) != SIG_ERR ); -} - -//____________________________________________________________________________// - -} - -} // namespace detail - -// ************************************************************************** // -// ************** execution_monitor::catch_signals ************** // -// ************************************************************************** // - -int -execution_monitor::catch_signals( unit_test::callback0 const& F ) -{ - using namespace detail; - -#if defined(__CYGWIN__) - p_catch_system_errors.value = false; -#endif - -#ifdef BOOST_TEST_USE_ALT_STACK - if( !!p_use_alt_stack && !m_alt_stack ) - m_alt_stack.reset( new char[BOOST_TEST_ALT_STACK_SIZE] ); -#else - p_use_alt_stack.value = false; -#endif - - signal_handler local_signal_handler( p_catch_system_errors, p_timeout, p_auto_start_dbg, - !p_use_alt_stack ? 0 : m_alt_stack.get() ); - - if( !sigsetjmp( signal_handler::jump_buffer(), 1 ) ) - return detail::do_invoke( m_custom_translators , F ); - else - throw local_signal_handler.sys_sig(); -} - -//____________________________________________________________________________// - -#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING) - -// ************************************************************************** // -// ************** Microsoft structured exception handling ************** // -// ************************************************************************** // - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) -namespace { void _set_se_translator( void* ) {} } -#endif - -namespace detail { - -// ************************************************************************** // -// ************** autoboost::detail::system_signal_exception ************** // -// ************************************************************************** // - -class system_signal_exception { -public: - // Constructor - explicit system_signal_exception( execution_monitor* em ) - : m_em( em ) - , m_se_id( 0 ) - , m_fault_address( 0 ) - , m_dir( false ) - {} - - void report() const; - int operator()( unsigned int id, _EXCEPTION_POINTERS* exps ); - -private: - // Data members - execution_monitor* m_em; - - unsigned int m_se_id; - void* m_fault_address; - bool m_dir; -}; - -static void -seh_catch_preventer( unsigned int /* id */, _EXCEPTION_POINTERS* /* exps */ ) -{ - throw; -} - -//____________________________________________________________________________// - -int -system_signal_exception::operator()( unsigned int id, _EXCEPTION_POINTERS* exps ) -{ - const unsigned int MSFT_CPP_EXCEPT = 0xE06d7363; // EMSC - - if( !m_em->p_catch_system_errors || (id == MSFT_CPP_EXCEPT) ) - return EXCEPTION_CONTINUE_SEARCH; - - if( !!m_em->p_auto_start_dbg && debug::attach_debugger( false ) ) { - m_em->p_catch_system_errors.value = false; - _set_se_translator( &seh_catch_preventer ); - - return EXCEPTION_CONTINUE_EXECUTION; - } - - m_se_id = id; - if( m_se_id == EXCEPTION_ACCESS_VIOLATION && exps->ExceptionRecord->NumberParameters == 2 ) { - m_fault_address = (void*)exps->ExceptionRecord->ExceptionInformation[1]; - m_dir = exps->ExceptionRecord->ExceptionInformation[0] == 0; - } - - return EXCEPTION_EXECUTE_HANDLER; -} - -//____________________________________________________________________________// - -void -system_signal_exception::report() const -{ - switch( m_se_id ) { - // cases classified as system_fatal_error - case EXCEPTION_ACCESS_VIOLATION: { - if( !m_fault_address ) - detail::report_error( execution_exception::system_fatal_error, "memory access violation" ); - else - detail::report_error( - execution_exception::system_fatal_error, - "memory access violation occurred at address 0x%08lx, while attempting to %s", - m_fault_address, - m_dir ? " read inaccessible data" - : " write to an inaccessible (or protected) address" - ); - break; - } - - case EXCEPTION_ILLEGAL_INSTRUCTION: - detail::report_error( execution_exception::system_fatal_error, "illegal instruction" ); - break; - - case EXCEPTION_PRIV_INSTRUCTION: - detail::report_error( execution_exception::system_fatal_error, "tried to execute an instruction whose operation is not allowed in the current machine mode" ); - break; - - case EXCEPTION_IN_PAGE_ERROR: - detail::report_error( execution_exception::system_fatal_error, "access to a memory page that is not present" ); - break; - - case EXCEPTION_STACK_OVERFLOW: - detail::report_error( execution_exception::system_fatal_error, "stack overflow" ); - break; - - case EXCEPTION_NONCONTINUABLE_EXCEPTION: - detail::report_error( execution_exception::system_fatal_error, "tried to continue execution after a non continuable exception occurred" ); - break; - - // cases classified as (non-fatal) system_trap - case EXCEPTION_DATATYPE_MISALIGNMENT: - detail::report_error( execution_exception::system_error, "data misalignment" ); - break; - - case EXCEPTION_INT_DIVIDE_BY_ZERO: - detail::report_error( execution_exception::system_error, "integer divide by zero" ); - break; - - case EXCEPTION_INT_OVERFLOW: - detail::report_error( execution_exception::system_error, "integer overflow" ); - break; - - case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: - detail::report_error( execution_exception::system_error, "array bounds exceeded" ); - break; - - case EXCEPTION_FLT_DIVIDE_BY_ZERO: - detail::report_error( execution_exception::system_error, "floating point divide by zero" ); - break; - - case EXCEPTION_FLT_STACK_CHECK: - detail::report_error( execution_exception::system_error, - "stack overflowed or underflowed as the result of a floating-point operation" ); - break; - - case EXCEPTION_FLT_DENORMAL_OPERAND: - detail::report_error( execution_exception::system_error, - "operand of floating point operation is denormal" ); - break; - -# if 0 // !! ?? - case EXCEPTION_FLT_INEXACT_RESULT: - detail::report_error( execution_exception::system_error, - "result of a floating-point operation cannot be represented exactly" ); - break; -#endif - - case EXCEPTION_FLT_OVERFLOW: - detail::report_error( execution_exception::system_error, - "exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type" ); - break; - - case EXCEPTION_FLT_UNDERFLOW: - detail::report_error( execution_exception::system_error, - "exponent of a floating-point operation is less than the magnitude allowed by the corresponding type" ); - break; - - case EXCEPTION_FLT_INVALID_OPERATION: - detail::report_error( execution_exception::system_error, "floating point error" ); - break; - - case EXCEPTION_BREAKPOINT: - detail::report_error( execution_exception::system_error, "breakpoint encountered" ); - break; - - default: - detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id ); - break; - } -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** assert_reporting_function ************** // -// ************************************************************************** // - -int BOOST_TEST_CALL_DECL -assert_reporting_function( int reportType, char* userMessage, int* ) -{ - switch( reportType ) { - case BOOST_TEST_CRT_ASSERT: - detail::report_error( execution_exception::user_error, userMessage ); - - return 1; // return value and retVal are not important since we never reach this line - case BOOST_TEST_CRT_ERROR: - detail::report_error( execution_exception::system_error, userMessage ); - - return 1; // return value and retVal are not important since we never reach this line - default: - return 0; // use usual reporting method - } -} // assert_reporting_function - -//____________________________________________________________________________// - -void BOOST_TEST_CALL_DECL -invalid_param_handler( wchar_t const* /* expr */, - wchar_t const* /* func */, - wchar_t const* /* file */, - unsigned int /* line */, - uintptr_t /* reserved */) -{ - detail::report_error( execution_exception::user_error, - "Invalid parameter detected by C runtime library" ); -} - -//____________________________________________________________________________// - -void BOOST_TEST_CALL_DECL -switch_fp_exceptions( bool on_off ) -{ - if( !on_off ) - _clearfp(); - - int cw = ::_controlfp( 0, 0 ); - - int exceptions_mask = EM_INVALID|EM_DENORMAL|EM_ZERODIVIDE|EM_OVERFLOW|EM_UNDERFLOW; - - if( on_off ) - cw &= ~exceptions_mask; // Set the exception masks on, turn exceptions off - else - cw |= exceptions_mask; // Set the exception masks off, turn exceptions on - - if( on_off ) - _clearfp(); - - // Set the control word - ::_controlfp( cw, MCW_EM ); -} - -//____________________________________________________________________________// - -} // namespace detail - -// ************************************************************************** // -// ************** execution_monitor::catch_signals ************** // -// ************************************************************************** // - -int -execution_monitor::catch_signals( unit_test::callback0 const& F ) -{ - _invalid_parameter_handler old_iph = _invalid_parameter_handler(); - BOOST_TEST_CRT_HOOK_TYPE old_crt_hook = 0; - - if( !p_catch_system_errors ) - _set_se_translator( &detail::seh_catch_preventer ); - else { - if( !!p_detect_fp_exceptions ) - detail::switch_fp_exceptions( true ); - - old_crt_hook = BOOST_TEST_CRT_SET_HOOK( &detail::assert_reporting_function ); - - old_iph = _set_invalid_parameter_handler( - reinterpret_cast<_invalid_parameter_handler>( &detail::invalid_param_handler ) ); - } - - detail::system_signal_exception SSE( this ); - - int ret_val = 0; - - __try { - __try { - ret_val = detail::do_invoke( m_custom_translators, F ); - } - __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) { - throw SSE; - } - } - __finally { - if( !!p_catch_system_errors ) { - if( !!p_detect_fp_exceptions ) - detail::switch_fp_exceptions( false ); - - BOOST_TEST_CRT_SET_HOOK( old_crt_hook ); - - _set_invalid_parameter_handler( old_iph ); - } - } - - return ret_val; -} - -//____________________________________________________________________________// - -#else // default signal handler - -namespace detail { - -class system_signal_exception { -public: - void report() const {} -}; - -} // namespace detail - -int -execution_monitor::catch_signals( unit_test::callback0 const& F ) -{ - return detail::do_invoke( m_custom_translators , F ); -} - -//____________________________________________________________________________// - -#endif // choose signal handler - -// ************************************************************************** // -// ************** execution_monitor::execute ************** // -// ************************************************************************** // - -int -execution_monitor::execute( unit_test::callback0 const& F ) -{ - if( debug::under_debugger() ) - p_catch_system_errors.value = false; - - try { - return catch_signals( F ); - } - - // Catch-clause reference arguments are a bit different from function - // arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't - // required. Programmers ask for const anyhow, so we supply it. That's - // easier than answering questions about non-const usage. - - catch( char const* ex ) - { detail::report_error( execution_exception::cpp_exception_error, - "C string: %s", ex ); } - catch( std::string const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - "std::string: %s", ex.c_str() ); } - - // std:: exceptions - - catch( std::bad_alloc const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_alloc: %s", ex.what() ); } - -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) - catch( std::bad_cast const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_cast" ); } - catch( std::bad_typeid const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_typeid" ); } -#else - catch( std::bad_cast const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_cast: %s", ex.what() ); } - catch( std::bad_typeid const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_typeid: %s", ex.what() ); } -#endif - - catch( std::bad_exception const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::bad_exception: %s", ex.what() ); } - catch( std::domain_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::domain_error: %s", ex.what() ); } - catch( std::invalid_argument const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::invalid_argument: %s", ex.what() ); } - catch( std::length_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::length_error: %s", ex.what() ); } - catch( std::out_of_range const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::out_of_range: %s", ex.what() ); } - catch( std::range_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::range_error: %s", ex.what() ); } - catch( std::overflow_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::overflow_error: %s", ex.what() ); } - catch( std::underflow_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::underflow_error: %s", ex.what() ); } - catch( std::logic_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::logic_error: %s", ex.what() ); } - catch( std::runtime_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::runtime_error: %s", ex.what() ); } - catch( std::exception const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - current_exception_cast(), - "std::exception: %s", ex.what() ); } - - catch( autoboost::exception const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - &ex, - "unknown autoboost::exception" ); } - - // system errors - catch( system_error const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - "system_error produced by: %s: %s", ex.p_failed_exp.get(), std::strerror( ex.p_errno ) ); } - catch( detail::system_signal_exception const& ex ) - { ex.report(); } - - // not an error - catch( execution_aborted const& ) - { return 0; } - - // just forward - catch( execution_exception const& ) - { throw; } - - // unknown error - catch( ... ) - { detail::report_error( execution_exception::cpp_exception_error, "unknown type" ); } - - return 0; // never reached; supplied to quiet compiler warnings -} // execute - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** system_error ************** // -// ************************************************************************** // - -system_error::system_error( char const* exp ) -#ifdef UNDER_CE -: p_errno( GetLastError() ) -#else -: p_errno( errno ) -#endif -, p_failed_exp( exp ) -{} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** execution_exception ************** // -// ************************************************************************** // - -execution_exception::execution_exception( error_code ec_, const_string what_msg_, location const& location_ ) -: m_error_code( ec_ ) -, m_what( what_msg_.empty() ? BOOST_TEST_L( "uncaught exception, system error or abort requested" ) : what_msg_ ) -, m_location( location_ ) -{} - -//____________________________________________________________________________// - -execution_exception::location::location( char const* file_name, size_t line_num, char const* func ) -: m_file_name( file_name ? file_name : "unknown location" ) -, m_line_num( line_num ) -, m_function( func ) -{} - -//____________________________________________________________________________// - -} // namespace autoboost - -#include - -#endif // BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER - diff --git a/contrib/autoboost/boost/test/impl/framework.ipp b/contrib/autoboost/boost/test/impl/framework.ipp deleted file mode 100644 index 7a87efb81..000000000 --- a/contrib/autoboost/boost/test/impl/framework.ipp +++ /dev/null @@ -1,503 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements framework API - main driver for the test -// *************************************************************************** - -#ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER -#define BOOST_TEST_FRAMEWORK_IPP_021005GER - -// Boost.Test -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -// Boost -#include - -// STL -#include -#include -#include -#include - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::time; using ::srand; } -#endif - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_start calls wrapper ************** // -// ************************************************************************** // - -namespace ut_detail { - -struct test_start_caller { - test_start_caller( test_observer* to, counter_t tc_amount ) - : m_to( to ) - , m_tc_amount( tc_amount ) - {} - - int operator()() - { - m_to->test_start( m_tc_amount ); - return 0; - } - -private: - // Data members - test_observer* m_to; - counter_t m_tc_amount; -}; - -//____________________________________________________________________________// - -struct test_init_caller { - explicit test_init_caller( init_unit_test_func init_func ) - : m_init_func( init_func ) - {} - int operator()() - { -#ifdef BOOST_TEST_ALTERNATIVE_INIT_API - if( !(*m_init_func)() ) - throw std::runtime_error( "test module initialization failed" ); -#else - test_suite* manual_test_units = (*m_init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv ); - - if( manual_test_units ) - framework::master_test_suite().add( manual_test_units ); -#endif - return 0; - } - - // Data members - init_unit_test_func m_init_func; -}; - -} - -// ************************************************************************** // -// ************** framework ************** // -// ************************************************************************** // - -class framework_impl : public test_tree_visitor { -public: - framework_impl() - : m_master_test_suite( 0 ) - , m_curr_test_case( INV_TEST_UNIT_ID ) - , m_next_test_case_id( MIN_TEST_CASE_ID ) - , m_next_test_suite_id( MIN_TEST_SUITE_ID ) - , m_is_initialized( false ) - , m_test_in_progress( false ) - {} - - ~framework_impl() { clear(); } - - void clear() - { - while( !m_test_units.empty() ) { - test_unit_store::value_type const& tu = *m_test_units.begin(); - test_unit* tu_ptr = tu.second; - - // the delete will erase this element from map - if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite ) - delete (test_suite const*)tu_ptr; - else - delete (test_case const*)tu_ptr; - } - } - - void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; } - - // test_tree_visitor interface implementation - void visit( test_case const& tc ) - { - if( !tc.check_dependencies() ) { - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_skipped( tc ); - - return; - } - - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_start( tc ); - - autoboost::timer tc_timer; - test_unit_id bkup = m_curr_test_case; - m_curr_test_case = tc.p_id; - unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc ); - - unsigned long elapsed = static_cast( tc_timer.elapsed() * 1e6 ); - - if( unit_test_monitor.is_critical_error( run_result ) ) { - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_aborted(); - } - - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_finish( tc, elapsed ); - - m_curr_test_case = bkup; - - if( unit_test_monitor.is_critical_error( run_result ) ) - throw test_being_aborted(); - } - - bool test_suite_start( test_suite const& ts ) - { - if( !ts.check_dependencies() ) { - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_skipped( ts ); - - return false; - } - - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_start( ts ); - - return true; - } - - void test_suite_finish( test_suite const& ts ) - { - BOOST_TEST_FOREACH( test_observer*, to, m_observers ) - to->test_unit_finish( ts, 0 ); - } - - ////////////////////////////////////////////////////////////////// - struct priority_order { - bool operator()( test_observer* lhs, test_observer* rhs ) const - { - return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs)); - } - }; - - typedef std::map test_unit_store; - typedef std::set observer_store; - - master_test_suite_t* m_master_test_suite; - test_unit_id m_curr_test_case; - test_unit_store m_test_units; - - test_unit_id m_next_test_case_id; - test_unit_id m_next_test_suite_id; - - bool m_is_initialized; - bool m_test_in_progress; - - observer_store m_observers; -}; - -//____________________________________________________________________________// - -namespace { - -#if defined(__CYGWIN__) -framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; } -#else -framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; } -#endif - -} // local namespace - -//____________________________________________________________________________// - -namespace framework { - -void -init( init_unit_test_func init_func, int argc, char* argv[] ) -{ - runtime_config::init( argc, argv ); - - // set the log level and format - unit_test_log.set_threshold_level( runtime_config::log_level() ); - unit_test_log.set_format( runtime_config::log_format() ); - - // set the report level and format - results_reporter::set_level( runtime_config::report_level() ); - results_reporter::set_format( runtime_config::report_format() ); - - register_observer( results_collector ); - register_observer( unit_test_log ); - - if( runtime_config::show_progress() ) - register_observer( progress_monitor ); - - if( runtime_config::detect_memory_leaks() > 0 ) { - debug::detect_memory_leaks( true ); - debug::break_memory_alloc( runtime_config::detect_memory_leaks() ); - } - - // init master unit test suite - master_test_suite().argc = argc; - master_test_suite().argv = argv; - - try { - autoboost::execution_monitor em; - - ut_detail::test_init_caller tic( init_func ); - - em.execute( tic ); - } - catch( execution_exception const& ex ) { - throw setup_error( ex.what() ); - } - - s_frk_impl().m_is_initialized = true; -} - -//____________________________________________________________________________// - -bool -is_initialized() -{ - return s_frk_impl().m_is_initialized; -} - -//____________________________________________________________________________// - -void -register_test_unit( test_case* tc ) -{ - BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) ); - - test_unit_id new_id = s_frk_impl().m_next_test_case_id; - - BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) ); - - typedef framework_impl::test_unit_store::value_type map_value_type; - - s_frk_impl().m_test_units.insert( map_value_type( new_id, tc ) ); - s_frk_impl().m_next_test_case_id++; - - s_frk_impl().set_tu_id( *tc, new_id ); -} - -//____________________________________________________________________________// - -void -register_test_unit( test_suite* ts ) -{ - BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) ); - - test_unit_id new_id = s_frk_impl().m_next_test_suite_id; - - BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) ); - - typedef framework_impl::test_unit_store::value_type map_value_type; - s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) ); - s_frk_impl().m_next_test_suite_id++; - - s_frk_impl().set_tu_id( *ts, new_id ); -} - -//____________________________________________________________________________// - -void -deregister_test_unit( test_unit* tu ) -{ - s_frk_impl().m_test_units.erase( tu->p_id ); -} - -//____________________________________________________________________________// - -void -clear() -{ - s_frk_impl().clear(); -} - -//____________________________________________________________________________// - -void -register_observer( test_observer& to ) -{ - s_frk_impl().m_observers.insert( &to ); -} - -//____________________________________________________________________________// - -void -deregister_observer( test_observer& to ) -{ - s_frk_impl().m_observers.erase( &to ); -} - -//____________________________________________________________________________// - -void -reset_observers() -{ - s_frk_impl().m_observers.clear(); -} - -//____________________________________________________________________________// - -master_test_suite_t& -master_test_suite() -{ - if( !s_frk_impl().m_master_test_suite ) - s_frk_impl().m_master_test_suite = new master_test_suite_t; - - return *s_frk_impl().m_master_test_suite; -} - -//____________________________________________________________________________// - -test_case const& -current_test_case() -{ - return get( s_frk_impl().m_curr_test_case ); -} - -//____________________________________________________________________________// - -test_unit& -get( test_unit_id id, test_unit_type t ) -{ - test_unit* res = s_frk_impl().m_test_units[id]; - - if( (res->p_type & t) == 0 ) - throw internal_error( "Invalid test unit type" ); - - return *res; -} - -//____________________________________________________________________________// - -void -run( test_unit_id id, bool continue_test ) -{ - if( id == INV_TEST_UNIT_ID ) - id = master_test_suite().p_id; - - test_case_counter tcc; - traverse_test_tree( id, tcc ); - - BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty() - ? BOOST_TEST_L( "test tree is empty" ) - : BOOST_TEST_L( "no test cases matching filter" ) ); - - bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress; - bool was_in_progress = s_frk_impl().m_test_in_progress; - - s_frk_impl().m_test_in_progress = true; - - if( call_start_finish ) { - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) { - autoboost::execution_monitor em; - - try { - em.execute( ut_detail::test_start_caller( to, tcc.p_count ) ); - } - catch( execution_exception const& ex ) { - throw setup_error( ex.what() ); - } - } - } - - switch( runtime_config::random_seed() ) { - case 0: - break; - case 1: { - unsigned int seed = static_cast( std::time( 0 ) ); - BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed ); - std::srand( seed ); - break; - } - default: - BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << runtime_config::random_seed() ); - std::srand( runtime_config::random_seed() ); - } - - try { - traverse_test_tree( id, s_frk_impl() ); - } - catch( test_being_aborted const& ) { - // abort already reported - } - - if( call_start_finish ) { - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) - to->test_finish(); - } - - s_frk_impl().m_test_in_progress = was_in_progress; -} - -//____________________________________________________________________________// - -void -run( test_unit const* tu, bool continue_test ) -{ - run( tu->p_id, continue_test ); -} - -//____________________________________________________________________________// - -void -assertion_result( bool passed ) -{ - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) - to->assertion_result( passed ); -} - -//____________________________________________________________________________// - -void -exception_caught( execution_exception const& ex ) -{ - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) - to->exception_caught( ex ); -} - -//____________________________________________________________________________// - -void -test_unit_aborted( test_unit const& tu ) -{ - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) - to->test_unit_aborted( tu ); -} - -//____________________________________________________________________________// - -} // namespace framework - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_FRAMEWORK_IPP_021005GER diff --git a/contrib/autoboost/boost/test/impl/interaction_based.ipp b/contrib/autoboost/boost/test/impl/interaction_based.ipp deleted file mode 100644 index 7d627849d..000000000 --- a/contrib/autoboost/boost/test/impl/interaction_based.ipp +++ /dev/null @@ -1,90 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Facilities to perform interaction-based testing -// *************************************************************************** - -#ifndef BOOST_TEST_INTERACTION_BASED_IPP_112105GER -#define BOOST_TEST_INTERACTION_BASED_IPP_112105GER - -// Boost.Test -#include - -#if BOOST_TEST_SUPPORT_INTERACTION_TESTING - -// Boost.Test -#include -#include -#include -#include -#include // for setup_error - -#include - -// STL -#include -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace itest { // interaction-based testing - -// ************************************************************************** // -// ************** manager ************** // -// ************************************************************************** // - -manager::manager() -{ - instance_ptr( true, this ); -} - -//____________________________________________________________________________// - -manager::~manager() -{ - instance_ptr( true ); -} - -//____________________________________________________________________________// - -manager* -manager::instance_ptr( bool reset, manager* new_ptr ) -{ - static manager dummy( 0 ); - - static manager* ptr = &dummy; - - if( reset ) { - if( new_ptr ) { - BOOST_TEST_SETUP_ASSERT( ptr == &dummy, BOOST_TEST_L( "Can't run two interation based test the same time" ) ); - - ptr = new_ptr; - } - else - ptr = &dummy; - } - - return ptr; -} - -} // namespace itest - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // not ancient compiler - -#endif // BOOST_TEST_INTERACTION_BASED_IPP_112105GER diff --git a/contrib/autoboost/boost/test/impl/logged_expectations.ipp b/contrib/autoboost/boost/test/impl/logged_expectations.ipp deleted file mode 100644 index a92809d2f..000000000 --- a/contrib/autoboost/boost/test/impl/logged_expectations.ipp +++ /dev/null @@ -1,246 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, ELOG_VER 1.0. (See accompanying file -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Facilities to perform interaction based testng of logged expectations -// *************************************************************************** - -#ifndef BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER -#define BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER - -// Boost.Test -#include - -#if BOOST_TEST_SUPPORT_INTERACTION_TESTING - -#include - -#include -#include - -#include -#include - -#include - -// Boost -#include - -// STL -#include - -//____________________________________________________________________________// - -namespace autoboost { - -using namespace ::autoboost::unit_test; - -namespace itest { - -// ************************************************************************** // -// ************** logged expectation test implementation ************** // -// ************************************************************************** // - -struct expectations_logger : itest::manager { - // Constructor - expectations_logger( const_string log_file_name, bool test_or_log ); - - virtual bool decision_point( const_string, std::size_t ); - virtual unsigned enter_scope( const_string, std::size_t, const_string scope_name ); - virtual void allocated( const_string, std::size_t, void*, std::size_t s ); - virtual void data_flow( const_string d ); - virtual std::string return_value( const_string default_value ); - -private: - // Data members - bool m_test_or_log; - std::fstream m_log_file; -}; - -literal_string ELOG_VER = "1.0"; -literal_string CLMN_SEP = "|"; -static const char LINE_SEP = '\n'; - -literal_string FILE_SIG = "ELOG"; -literal_string SCOPE_SIG = "SCOPE"; -literal_string ALLOC_SIG = "ALLOC"; -literal_string DP_SIG = "SWITCH"; -literal_string DATA_SIG = "DATA"; -literal_string RETURN_SIG = "RETURN"; - -//____________________________________________________________________________// - -expectations_logger::expectations_logger( const_string log_file_name, bool test_or_log ) -: m_test_or_log( test_or_log ) -{ - BOOST_REQUIRE_MESSAGE( !log_file_name.is_empty(), "Empty expectations log file name" ); - - m_log_file.open( log_file_name.begin(), test_or_log ? std::ios::in : std::ios::out ); - - BOOST_REQUIRE_MESSAGE( m_log_file.is_open(), - "Can't open expectations log file " << log_file_name - << " for " << ( m_test_or_log ? "reading" : "writing") ); - - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, FILE_SIG ); - ++tit; - BOOST_CHECK_EQUAL( *tit, ELOG_VER ); - } - else { - m_log_file << FILE_SIG << CLMN_SEP << ELOG_VER << LINE_SEP; - } -} - -//____________________________________________________________________________// - -bool -expectations_logger::decision_point( const_string, std::size_t ) -{ - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, DP_SIG ); ++tit; - return lexical_cast( *tit ); - } - else { - m_log_file << DP_SIG << CLMN_SEP << std::boolalpha << true << LINE_SEP; - - return true; - } -} - -//____________________________________________________________________________// - -unsigned -expectations_logger::enter_scope( const_string, std::size_t, const_string scope_name ) -{ - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, SCOPE_SIG ); ++tit; - BOOST_CHECK_EQUAL( *tit, scope_name ); - } - else { - m_log_file << SCOPE_SIG << CLMN_SEP << scope_name << LINE_SEP; - } - - return 0; -} - -//____________________________________________________________________________// - -void -expectations_logger::allocated( const_string, std::size_t, void*, std::size_t s ) -{ - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, ALLOC_SIG ); ++tit; - BOOST_CHECK_EQUAL( lexical_cast( *tit ), s ); - } - else { - m_log_file << ALLOC_SIG << CLMN_SEP << s << LINE_SEP; - } -} - -//____________________________________________________________________________// - -void -expectations_logger::data_flow( const_string d ) -{ - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, DATA_SIG ); ++tit; - BOOST_CHECK_EQUAL( *tit, d ); - } - else { - m_log_file << DATA_SIG << CLMN_SEP << d << LINE_SEP; - } -} - -//____________________________________________________________________________// - -std::string -expectations_logger::return_value( const_string default_value ) -{ - if( m_test_or_log ) { - std::string line; - - std::getline( m_log_file, line, LINE_SEP ); - - const_string cline( line ); - string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none)); - - BOOST_CHECK_EQUAL( *tit, RETURN_SIG ); ++tit; - - return std::string( tit->begin(), tit->size() ); - } - else { - m_log_file << RETURN_SIG << CLMN_SEP << default_value << LINE_SEP; - - return std::string(); - } -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** logged expectations test ************** // -// ************************************************************************** // - -void BOOST_TEST_DECL -logged_expectations( callback0<> const& F, const_string log_file_name, bool test_or_log ) -{ - expectations_logger el( log_file_name, test_or_log ); - - F(); -} - -//____________________________________________________________________________// - -} // namespace itest - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // not ancient compiler - -#endif // BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER diff --git a/contrib/autoboost/boost/test/impl/plain_report_formatter.ipp b/contrib/autoboost/boost/test/impl/plain_report_formatter.ipp deleted file mode 100644 index f9969ccc0..000000000 --- a/contrib/autoboost/boost/test/impl/plain_report_formatter.ipp +++ /dev/null @@ -1,198 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : plain report formatter definition -// *************************************************************************** - -#ifndef BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER -#define BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER - -// Boost.Test -#include -#include -#include -#include - -#include - -// STL -#include -#include -#include - -#include - -# ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::log10; } -# endif - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -namespace { - -typedef custom_manip quote; - -template -inline std::ostream& -operator<<( custom_printer const& p, T const& value ) -{ - *p << '"' << value << '"'; - - return *p; -} - -//____________________________________________________________________________// - -void -print_stat_value( std::ostream& ostr, counter_t v, counter_t indent, counter_t total, - const_string name, const_string res ) -{ - if( v > 0 ) { - ostr << std::setw( indent ) << "" - << v << ' ' << name << ( v != 1 ? "s" : "" ); - if( total > 0 ) - ostr << " out of " << total; - - ostr << ' ' << res << '\n'; - } -} - -//____________________________________________________________________________// - -} // local namespace - -// ************************************************************************** // -// ************** plain_report_formatter ************** // -// ************************************************************************** // - -void -plain_report_formatter::results_report_start( std::ostream& ostr ) -{ - m_indent = 0; - ostr << '\n'; -} - -//____________________________________________________________________________// - -void -plain_report_formatter::results_report_finish( std::ostream& ostr ) -{ - ostr.flush(); -} - -//____________________________________________________________________________// - -void -plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr ) -{ - test_results const& tr = results_collector.results( tu.p_id ); - - const_string descr; - - if( tr.passed() ) - descr = "passed"; - else if( tr.p_skipped ) - descr = "skipped"; - else if( tr.p_aborted ) - descr = "aborted"; - else - descr = "failed"; - - ostr << std::setw( m_indent ) << "" - << "Test " << (tu.p_type == tut_case ? "case " : "suite " ) << quote() << tu.p_name << ' ' << descr; - - if( tr.p_skipped ) { - ostr << " due to " << (tu.check_dependencies() ? "test aborting\n" : "failed dependancy\n" ); - m_indent += 2; - return; - } - - counter_t total_assertions = tr.p_assertions_passed + tr.p_assertions_failed; - counter_t total_tc = tr.p_test_cases_passed + tr.p_test_cases_failed + tr.p_test_cases_skipped; - - if( total_assertions > 0 || total_tc > 0 ) - ostr << " with:"; - - ostr << '\n'; - m_indent += 2; - - print_stat_value( ostr, tr.p_assertions_passed, m_indent, total_assertions, "assertion", "passed" ); - print_stat_value( ostr, tr.p_assertions_failed, m_indent, total_assertions, "assertion", "failed" ); - print_stat_value( ostr, tr.p_expected_failures, m_indent, 0 , "failure" , "expected" ); - print_stat_value( ostr, tr.p_test_cases_passed, m_indent, total_tc , "test case", "passed" ); - print_stat_value( ostr, tr.p_test_cases_failed, m_indent, total_tc , "test case", "failed" ); - print_stat_value( ostr, tr.p_test_cases_skipped, m_indent, total_tc , "test case", "skipped" ); - print_stat_value( ostr, tr.p_test_cases_aborted, m_indent, total_tc , "test case", "aborted" ); - - ostr << '\n'; -} - -//____________________________________________________________________________// - -void -plain_report_formatter::test_unit_report_finish( test_unit const&, std::ostream& ) -{ - m_indent -= 2; -} - -//____________________________________________________________________________// - -void -plain_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr ) -{ - test_results const& tr = results_collector.results( tu.p_id ); - - if( tr.passed() ) { - ostr << "*** No errors detected\n"; - return; - } - - if( tr.p_skipped ) { - ostr << "*** Test " << tu.p_type_name << " skipped due to " - << (tu.check_dependencies() ? "test aborting\n" : "failed dependancy\n" ); - return; - } - - if( tr.p_assertions_failed == 0 ) { - ostr << "*** errors detected in test " << tu.p_type_name << " " << quote() << tu.p_name - << "; see standard output for details\n"; - return; - } - - counter_t num_failures = tr.p_assertions_failed; - - ostr << "*** " << num_failures << " failure" << ( num_failures != 1 ? "s" : "" ) << " detected"; - - if( tr.p_expected_failures > 0 ) - ostr << " (" << tr.p_expected_failures << " failure" << ( tr.p_expected_failures != 1 ? "s" : "" ) << " expected)"; - - ostr << " in test " << tu.p_type_name << " " << quote() << tu.p_name << "\n"; -} - -//____________________________________________________________________________// - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER diff --git a/contrib/autoboost/boost/test/impl/progress_monitor.ipp b/contrib/autoboost/boost/test/impl/progress_monitor.ipp deleted file mode 100644 index 630b49e87..000000000 --- a/contrib/autoboost/boost/test/impl/progress_monitor.ipp +++ /dev/null @@ -1,110 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements simple text based progress monitor -// *************************************************************************** - -#ifndef BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER -#define BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER - -// Boost.Test -#include -#include - -#include - -// Boost -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** progress_monitor ************** // -// ************************************************************************** // - -namespace { - -struct progress_monitor_impl { - // Constructor - progress_monitor_impl() - : m_stream( runtime_config::log_sink() ) - {} - - std::ostream* m_stream; - scoped_ptr m_progress_display; -}; - -progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; } - -} // local namespace - -//____________________________________________________________________________// - -void -progress_monitor_t::test_start( counter_t test_cases_amount ) -{ - s_pm_impl().m_progress_display.reset( new progress_display( test_cases_amount, *s_pm_impl().m_stream ) ); -} - -//____________________________________________________________________________// - -void -progress_monitor_t::test_aborted() -{ - (*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count(); -} - -//____________________________________________________________________________// - -void -progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long ) -{ - if( tu.p_type == tut_case ) - ++(*s_pm_impl().m_progress_display); -} - -//____________________________________________________________________________// - -void -progress_monitor_t::test_unit_skipped( test_unit const& tu ) -{ - test_case_counter tcc; - traverse_test_tree( tu, tcc ); - - (*s_pm_impl().m_progress_display) += tcc.p_count; -} - -//____________________________________________________________________________// - -void -progress_monitor_t::set_stream( std::ostream& ostr ) -{ - s_pm_impl().m_stream = &ostr; -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER diff --git a/contrib/autoboost/boost/test/impl/results_collector.ipp b/contrib/autoboost/boost/test/impl/results_collector.ipp deleted file mode 100644 index 2d5699ccf..000000000 --- a/contrib/autoboost/boost/test/impl/results_collector.ipp +++ /dev/null @@ -1,294 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements Unit Test results collecting facility. -// *************************************************************************** - -#ifndef BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER -#define BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER - -// Boost.Test -#include -#include -#include -#include - -// Boost -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_results ************** // -// ************************************************************************** // - -test_results::test_results() -{ - clear(); -} - -//____________________________________________________________________________// - -bool -test_results::passed() const -{ - return !p_skipped && - p_test_cases_failed == 0 && - p_assertions_failed <= p_expected_failures && - !p_aborted; -} - -//____________________________________________________________________________// - -int -test_results::result_code() const -{ - return passed() ? exit_success - : ( (p_assertions_failed > p_expected_failures || p_skipped ) - ? exit_test_failure - : exit_exception_failure ); -} - -//____________________________________________________________________________// - -void -test_results::operator+=( test_results const& tr ) -{ - p_assertions_passed.value += tr.p_assertions_passed; - p_assertions_failed.value += tr.p_assertions_failed; - p_test_cases_passed.value += tr.p_test_cases_passed; - p_test_cases_failed.value += tr.p_test_cases_failed; - p_test_cases_skipped.value += tr.p_test_cases_skipped; - p_test_cases_aborted.value += tr.p_test_cases_aborted; -} - -//____________________________________________________________________________// - -void -test_results::clear() -{ - p_assertions_passed.value = 0; - p_assertions_failed.value = 0; - p_expected_failures.value = 0; - p_test_cases_passed.value = 0; - p_test_cases_failed.value = 0; - p_test_cases_skipped.value = 0; - p_test_cases_aborted.value = 0; - p_aborted.value = false; - p_skipped.value = true; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** results_collector ************** // -// ************************************************************************** // - -#if !BOOST_WORKAROUND(BOOST_MSVC, <1300) - -namespace { - -struct results_collector_impl { - std::map m_results_store; -}; - -results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; return the_inst; } - -} // local namespace - -#else - -struct results_collector_impl { - std::map m_results_store; -}; - -static results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; return the_inst; } - -#endif - -//____________________________________________________________________________// - -void -results_collector_t::test_start( counter_t ) -{ - s_rc_impl().m_results_store.clear(); -} - -//____________________________________________________________________________// - -void -results_collector_t::test_finish() -{ - // do nothing -} - -//____________________________________________________________________________// - -void -results_collector_t::test_aborted() -{ - // do nothing -} - -//____________________________________________________________________________// - -void -results_collector_t::test_unit_start( test_unit const& tu ) -{ - // init test_results entry - test_results& tr = s_rc_impl().m_results_store[tu.p_id]; - - tr.clear(); - - tr.p_expected_failures.value = tu.p_expected_failures; - tr.p_skipped.value = false; -} - -//____________________________________________________________________________// - -class results_collect_helper : public test_tree_visitor { -public: - explicit results_collect_helper( test_results& tr, test_unit const& ts ) : m_tr( tr ), m_ts( ts ) {} - - void visit( test_case const& tc ) - { - test_results const& tr = results_collector.results( tc.p_id ); - m_tr += tr; - - if( tr.passed() ) - m_tr.p_test_cases_passed.value++; - else if( tr.p_skipped ) - m_tr.p_test_cases_skipped.value++; - else { - if( tr.p_aborted ) - m_tr.p_test_cases_aborted.value++; - m_tr.p_test_cases_failed.value++; - } - } - bool test_suite_start( test_suite const& ts ) - { - if( m_ts.p_id == ts.p_id ) - return true; - else { - m_tr += results_collector.results( ts.p_id ); - return false; - } - } - -private: - // Data members - test_results& m_tr; - test_unit const& m_ts; -}; - -//____________________________________________________________________________// - -void -results_collector_t::test_unit_finish( test_unit const& tu, unsigned long ) -{ - if( tu.p_type == tut_suite ) { - results_collect_helper ch( s_rc_impl().m_results_store[tu.p_id], tu ); - - traverse_test_tree( tu, ch ); - } - else { - test_results const& tr = s_rc_impl().m_results_store[tu.p_id]; - - bool num_failures_match = tr.p_aborted || tr.p_assertions_failed >= tr.p_expected_failures; - if( !num_failures_match ) - BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " has fewer failures than expected" ); - - bool check_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0); - if( !check_any_assertions ) - BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " did not check any assertions" ); - } -} - -//____________________________________________________________________________// - -void -results_collector_t::test_unit_skipped( test_unit const& tu ) -{ - if( tu.p_type == tut_suite ) { - test_case_counter tcc; - traverse_test_tree( tu, tcc ); - - test_results& tr = s_rc_impl().m_results_store[tu.p_id]; - - tr.clear(); - - tr.p_skipped.value = true; - tr.p_test_cases_skipped.value = tcc.p_count; - } -} - -//____________________________________________________________________________// - -void -results_collector_t::assertion_result( bool passed ) -{ - test_results& tr = s_rc_impl().m_results_store[framework::current_test_case().p_id]; - - if( passed ) - tr.p_assertions_passed.value++; - else - tr.p_assertions_failed.value++; - - if( tr.p_assertions_failed == 1 ) - first_failed_assertion(); -} - -//____________________________________________________________________________// - -void -results_collector_t::exception_caught( execution_exception const& ) -{ - test_results& tr = s_rc_impl().m_results_store[framework::current_test_case().p_id]; - - tr.p_assertions_failed.value++; -} - -//____________________________________________________________________________// - -void -results_collector_t::test_unit_aborted( test_unit const& tu ) -{ - s_rc_impl().m_results_store[tu.p_id].p_aborted.value = true; -} - -//____________________________________________________________________________// - -test_results const& -results_collector_t::results( test_unit_id id ) const -{ - return s_rc_impl().m_results_store[id]; -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER diff --git a/contrib/autoboost/boost/test/impl/results_reporter.ipp b/contrib/autoboost/boost/test/impl/results_reporter.ipp deleted file mode 100644 index cb309e3db..000000000 --- a/contrib/autoboost/boost/test/impl/results_reporter.ipp +++ /dev/null @@ -1,202 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : result reporting facilties -// *************************************************************************** - -#ifndef BOOST_TEST_RESULTS_REPORTER_IPP_020105GER -#define BOOST_TEST_RESULTS_REPORTER_IPP_020105GER - -// Boost.Test -#include -#include -#include -#include -#include -#include - -#include - -// Boost -#include -#include -typedef ::autoboost::io::ios_base_all_saver io_saver_type; - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace results_reporter { - -// ************************************************************************** // -// ************** result reporter implementation ************** // -// ************************************************************************** // - -namespace { - -struct results_reporter_impl : test_tree_visitor { - // Constructor - results_reporter_impl() - : m_output( runtime_config::report_sink() ) - , m_stream_state_saver( new io_saver_type( *m_output ) ) - , m_report_level( CONFIRMATION_REPORT ) - , m_formatter( new output::plain_report_formatter ) - {} - - // test tree visitor interface implementation - void visit( test_case const& tc ) - { - m_formatter->test_unit_report_start( tc, *m_output ); - m_formatter->test_unit_report_finish( tc, *m_output ); - } - bool test_suite_start( test_suite const& ts ) - { - m_formatter->test_unit_report_start( ts, *m_output ); - - if( m_report_level == DETAILED_REPORT && !results_collector.results( ts.p_id ).p_skipped ) - return true; - - m_formatter->test_unit_report_finish( ts, *m_output ); - return false; - } - void test_suite_finish( test_suite const& ts ) - { - m_formatter->test_unit_report_finish( ts, *m_output ); - } - - typedef scoped_ptr saver_ptr; - - // Data members - std::ostream* m_output; - saver_ptr m_stream_state_saver; - report_level m_report_level; - scoped_ptr m_formatter; -}; - -results_reporter_impl& s_rr_impl() { static results_reporter_impl the_inst; return the_inst; } - -} // local namespace - -// ************************************************************************** // -// ************** report configuration ************** // -// ************************************************************************** // - -void -set_level( report_level l ) -{ - if( l != INV_REPORT_LEVEL ) - s_rr_impl().m_report_level = l; -} - -//____________________________________________________________________________// - -void -set_stream( std::ostream& ostr ) -{ - s_rr_impl().m_output = &ostr; - s_rr_impl().m_stream_state_saver.reset( new io_saver_type( ostr ) ); -} - -//____________________________________________________________________________// - -std::ostream& -get_stream() -{ - return *s_rr_impl().m_output; -} - -//____________________________________________________________________________// - -void -set_format( output_format rf ) -{ - switch( rf ) { - case CLF: - set_format( new output::plain_report_formatter ); - break; - case XML: - set_format( new output::xml_report_formatter ); - break; - default: - break; - } -} - -//____________________________________________________________________________// - -void -set_format( results_reporter::format* f ) -{ - if( f ) - s_rr_impl().m_formatter.reset( f ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** report initiation ************** // -// ************************************************************************** // - -void -make_report( report_level l, test_unit_id id ) -{ - if( l == INV_REPORT_LEVEL ) - l = s_rr_impl().m_report_level; - - if( l == NO_REPORT ) - return; - - if( id == INV_TEST_UNIT_ID ) - id = framework::master_test_suite().p_id; - - s_rr_impl().m_stream_state_saver->restore(); - - report_level bkup = s_rr_impl().m_report_level; - s_rr_impl().m_report_level = l; - - s_rr_impl().m_formatter->results_report_start( *s_rr_impl().m_output ); - - switch( l ) { - case CONFIRMATION_REPORT: - s_rr_impl().m_formatter->do_confirmation_report( framework::get( id ), *s_rr_impl().m_output ); - break; - case SHORT_REPORT: - case DETAILED_REPORT: - traverse_test_tree( id, s_rr_impl() ); - break; - default: - break; - } - - s_rr_impl().m_formatter->results_report_finish( *s_rr_impl().m_output ); - s_rr_impl().m_report_level = bkup; -} - -//____________________________________________________________________________// - -} // namespace results_reporter - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_RESULTS_REPORTER_IPP_020105GER diff --git a/contrib/autoboost/boost/test/impl/test_main.ipp b/contrib/autoboost/boost/test/impl/test_main.ipp deleted file mode 100644 index 40ded515e..000000000 --- a/contrib/autoboost/boost/test/impl/test_main.ipp +++ /dev/null @@ -1,68 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// (C) Copyright Beman Dawes 1995-2001. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $$Revision$ -// -// Description : implements main function for Test Execution Monitor. -// *************************************************************************** - -#ifndef BOOST_TEST_TEST_MAIN_IPP_012205GER -#define BOOST_TEST_TEST_MAIN_IPP_012205GER - -// Boost.Test -#include -#include -#include - -// Boost -#include - -#include - -//____________________________________________________________________________// - -extern int test_main( int argc, char* argv[] ); // prototype for user's test_main() - -struct test_main_caller { - test_main_caller( int argc, char** argv ) : m_argc( argc ), m_argv( argv ) {} - - void operator()() { - int test_main_result = test_main( m_argc, m_argv ); - - // translate a test_main non-success return into a test error - BOOST_CHECK( test_main_result == 0 || test_main_result == autoboost::exit_success ); - } - -private: - // Data members - int m_argc; - char** m_argv; -}; - -// ************************************************************************** // -// ************** test main ************** // -// ************************************************************************** // - -::autoboost::unit_test::test_suite* -init_unit_test_suite( int argc, char* argv[] ) { - using namespace ::autoboost::unit_test; - - framework::master_test_suite().p_name.value = "Test Program"; - - framework::master_test_suite().add( BOOST_TEST_CASE( test_main_caller( argc, argv ) ) ); - - return 0; -} - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TEST_MAIN_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/test_tools.ipp b/contrib/autoboost/boost/test/impl/test_tools.ipp deleted file mode 100644 index b68e7b708..000000000 --- a/contrib/autoboost/boost/test/impl/test_tools.ipp +++ /dev/null @@ -1,628 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : supplies offline implementation for the Test Tools -// *************************************************************************** - -#ifndef BOOST_TEST_TEST_TOOLS_IPP_012205GER -#define BOOST_TEST_TEST_TOOLS_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include -#include // execution_aborted -#include - -// Boost -#include - -// STL -#include -#include -#include -#include -#include -#include -#include - -// !! should we use #include -#include - -#include - -//____________________________________________________________________________// - -# ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::strcmp; using ::strlen; using ::isprint; } -#if !defined( BOOST_NO_CWCHAR ) -namespace std { using ::wcscmp; } -#endif -# endif - -namespace autoboost { - -namespace test_tools { - -// ************************************************************************** // -// ************** print_log_value ************** // -// ************************************************************************** // - -void -print_log_value::operator()( std::ostream& ostr, char t ) -{ - if( (std::isprint)( static_cast(t) ) ) - ostr << '\'' << t << '\''; - else - ostr << std::hex -#if BOOST_TEST_USE_STD_LOCALE - << std::showbase -#else - << "0x" -#endif - << static_cast(t); -} - -//____________________________________________________________________________// - -void -print_log_value::operator()( std::ostream& ostr, unsigned char t ) -{ - ostr << std::hex - // showbase is only available for new style streams: -#if BOOST_TEST_USE_STD_LOCALE - << std::showbase -#else - << "0x" -#endif - << static_cast(t); -} - -//____________________________________________________________________________// - -void -print_log_value::operator()( std::ostream& ostr, char const* t ) -{ - ostr << ( t ? t : "null string" ); -} - -//____________________________________________________________________________// - -void -print_log_value::operator()( std::ostream& ostr, wchar_t const* t ) -{ - ostr << ( t ? t : L"null string" ); -} - -//____________________________________________________________________________// - -namespace tt_detail { - -// ************************************************************************** // -// ************** TOOL BOX Implementation ************** // -// ************************************************************************** // - -using ::autoboost::unit_test::lazy_ostream; - -bool -check_impl( predicate_result const& pr, lazy_ostream const& check_descr, - const_string file_name, std::size_t line_num, - tool_level tl, check_type ct, - std::size_t num_of_args, ... ) -{ - using namespace unit_test; - - if( !framework::is_initialized() ) - throw std::runtime_error( "can't use testing tools before framework is initialized" ); - - if( !!pr ) - tl = PASS; - - log_level ll; - char const* prefix; - char const* suffix; - - switch( tl ) { - case PASS: - ll = log_successful_tests; - prefix = "check "; - suffix = " passed"; - break; - case WARN: - ll = log_warnings; - prefix = "condition "; - suffix = " is not satisfied"; - break; - case CHECK: - ll = log_all_errors; - prefix = "check "; - suffix = " failed"; - break; - case REQUIRE: - ll = log_fatal_errors; - prefix = "critical check "; - suffix = " failed"; - break; - default: - return true; - } - - switch( ct ) { - case CHECK_PRED: - unit_test_log << unit_test::log::begin( file_name, line_num ) - << ll << prefix << check_descr << suffix; - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - - case CHECK_MSG: - unit_test_log << unit_test::log::begin( file_name, line_num ) << ll; - - if( tl == PASS ) - unit_test_log << prefix << "'" << check_descr << "'" << suffix; - else - unit_test_log << check_descr; - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - - case CHECK_EQUAL: - case CHECK_NE: - case CHECK_LT: - case CHECK_LE: - case CHECK_GT: - case CHECK_GE: { - static char const* check_str [] = { " == ", " != ", " < " , " <= ", " > " , " >= " }; - static char const* rever_str [] = { " != ", " == ", " >= ", " > " , " <= ", " < " }; - - va_list args; - - va_start( args, num_of_args ); - char const* arg1_descr = va_arg( args, char const* ); - lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* ); - char const* arg2_descr = va_arg( args, char const* ); - lazy_ostream const* arg2_val = va_arg( args, lazy_ostream const* ); - - unit_test_log << unit_test::log::begin( file_name, line_num ) - << ll << prefix << arg1_descr << check_str[ct-CHECK_EQUAL] << arg2_descr << suffix; - - if( tl != PASS ) - unit_test_log << " [" << *arg1_val << rever_str[ct-CHECK_EQUAL] << *arg2_val << "]" ; - - va_end( args ); - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - } - - case CHECK_CLOSE: - case CHECK_CLOSE_FRACTION: { - va_list args; - - va_start( args, num_of_args ); - char const* arg1_descr = va_arg( args, char const* ); - lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* ); - char const* arg2_descr = va_arg( args, char const* ); - lazy_ostream const* arg2_val = va_arg( args, lazy_ostream const* ); - /* toler_descr = */ va_arg( args, char const* ); - lazy_ostream const* toler_val = va_arg( args, lazy_ostream const* ); - - unit_test_log << unit_test::log::begin( file_name, line_num ) << ll; - - unit_test_log << "difference{" << pr.message() << (ct == CHECK_CLOSE ? "%" : "") - << "} between " << arg1_descr << "{" << *arg1_val - << "} and " << arg2_descr << "{" << *arg2_val - << ( tl == PASS ? "} doesn't exceed " : "} exceeds " ) - << *toler_val; - if( ct == CHECK_CLOSE ) - unit_test_log << "%"; - - va_end( args ); - - unit_test_log << unit_test::log::end(); - break; - } - case CHECK_SMALL: { - va_list args; - - va_start( args, num_of_args ); - char const* arg1_descr = va_arg( args, char const* ); - lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* ); - /* toler_descr = */ va_arg( args, char const* ); - lazy_ostream const* toler_val = va_arg( args, lazy_ostream const* ); - - unit_test_log << unit_test::log::begin( file_name, line_num ) << ll; - - unit_test_log << "absolute value of " << arg1_descr << "{" << *arg1_val << "}" - << ( tl == PASS ? " doesn't exceed " : " exceeds " ) - << *toler_val; - - va_end( args ); - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - } - - case CHECK_PRED_WITH_ARGS: { - unit_test_log << unit_test::log::begin( file_name, line_num ) - << ll << prefix << check_descr; - - // print predicate call description - { - va_list args; - va_start( args, num_of_args ); - - unit_test_log << "( "; - for( std::size_t i = 0; i < num_of_args; ++i ) { - unit_test_log << va_arg( args, char const* ); - va_arg( args, lazy_ostream const* ); // skip argument value; - - if( i != num_of_args-1 ) - unit_test_log << ", "; - } - unit_test_log << " )" << suffix; - va_end( args ); - } - - if( tl != PASS ) { - va_list args; - va_start( args, num_of_args ); - - unit_test_log << " for ( "; - for( std::size_t i = 0; i < num_of_args; ++i ) { - va_arg( args, char const* ); // skip argument description; - unit_test_log << *va_arg( args, lazy_ostream const* ); - - if( i != num_of_args-1 ) - unit_test_log << ", "; - } - unit_test_log << " )"; - va_end( args ); - } - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - } - - case CHECK_EQUAL_COLL: { - va_list args; - - va_start( args, num_of_args ); - char const* left_begin_descr = va_arg( args, char const* ); - char const* left_end_descr = va_arg( args, char const* ); - char const* right_begin_descr = va_arg( args, char const* ); - char const* right_end_descr = va_arg( args, char const* ); - - unit_test_log << unit_test::log::begin( file_name, line_num ) - << ll << prefix - << "{ " << left_begin_descr << ", " << left_end_descr << " } == { " - << right_begin_descr << ", " << right_end_descr << " }" - << suffix; - - va_end( args ); - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - } - - case CHECK_BITWISE_EQUAL: { - va_list args; - - va_start( args, num_of_args ); - char const* left_descr = va_arg( args, char const* ); - char const* right_descr = va_arg( args, char const* ); - - unit_test_log << unit_test::log::begin( file_name, line_num ) - << ll << prefix << left_descr << " =.= " << right_descr << suffix; - - va_end( args ); - - if( !pr.has_empty_message() ) - unit_test_log << ". " << pr.message(); - - unit_test_log << unit_test::log::end(); - break; - } - } - - switch( tl ) { - case PASS: - framework::assertion_result( true ); - return true; - - case WARN: - return false; - - case CHECK: - framework::assertion_result( false ); - return false; - - case REQUIRE: - framework::assertion_result( false ); - - framework::test_unit_aborted( framework::current_test_case() ); - - throw execution_aborted(); - } - - return true; -} - -//____________________________________________________________________________// - -predicate_result -equal_impl( char const* left, char const* right ) -{ - return (left && right) ? std::strcmp( left, right ) == 0 : (left == right); -} - -//____________________________________________________________________________// - -#if !defined( BOOST_NO_CWCHAR ) - -predicate_result -equal_impl( wchar_t const* left, wchar_t const* right ) -{ - return (left && right) ? std::wcscmp( left, right ) == 0 : (left == right); -} - -#endif // !defined( BOOST_NO_CWCHAR ) - -//____________________________________________________________________________// - -bool -is_defined_impl( const_string symbol_name, const_string symbol_value ) -{ - symbol_value.trim_left( 2 ); - return symbol_name != symbol_value; -} - -//____________________________________________________________________________// - -} // namespace tt_detail - -// ************************************************************************** // -// ************** output_test_stream ************** // -// ************************************************************************** // - -struct output_test_stream::Impl -{ - std::fstream m_pattern; - bool m_match_or_save; - bool m_text_or_binary; - std::string m_synced_string; - - char get_char() - { - char res; - do { - m_pattern.get( res ); - } while( m_text_or_binary && res == '\r' && !m_pattern.fail() && !m_pattern.eof() ); - - return res; - } - - void check_and_fill( predicate_result& res ) - { - if( !res.p_predicate_value ) - res.message() << "Output content: \"" << m_synced_string << '\"'; - } -}; - -//____________________________________________________________________________// - -output_test_stream::output_test_stream( const_string pattern_file_name, bool match_or_save, bool text_or_binary ) -: m_pimpl( new Impl ) -{ - if( !pattern_file_name.is_empty() ) { - std::ios::openmode m = match_or_save ? std::ios::in : std::ios::out; - if( !text_or_binary ) - m |= std::ios::binary; - - m_pimpl->m_pattern.open( pattern_file_name.begin(), m ); - - BOOST_WARN_MESSAGE( m_pimpl->m_pattern.is_open(), - "Can't open pattern file " << pattern_file_name - << " for " << (match_or_save ? "reading" : "writing") ); - } - - m_pimpl->m_match_or_save = match_or_save; - m_pimpl->m_text_or_binary = text_or_binary; -} - -//____________________________________________________________________________// - -output_test_stream::~output_test_stream() -{ - delete m_pimpl; -} - -//____________________________________________________________________________// - -predicate_result -output_test_stream::is_empty( bool flush_stream ) -{ - sync(); - - result_type res( m_pimpl->m_synced_string.empty() ); - - m_pimpl->check_and_fill( res ); - - if( flush_stream ) - flush(); - - return res; -} - -//____________________________________________________________________________// - -predicate_result -output_test_stream::check_length( std::size_t length_, bool flush_stream ) -{ - sync(); - - result_type res( m_pimpl->m_synced_string.length() == length_ ); - - m_pimpl->check_and_fill( res ); - - if( flush_stream ) - flush(); - - return res; -} - -//____________________________________________________________________________// - -predicate_result -output_test_stream::is_equal( const_string arg, bool flush_stream ) -{ - sync(); - - result_type res( const_string( m_pimpl->m_synced_string ) == arg ); - - m_pimpl->check_and_fill( res ); - - if( flush_stream ) - flush(); - - return res; -} - -//____________________________________________________________________________// - -predicate_result -output_test_stream::match_pattern( bool flush_stream ) -{ - sync(); - - result_type result( true ); - - if( !m_pimpl->m_pattern.is_open() ) { - result = false; - result.message() << "Pattern file can't be opened!"; - } - else { - if( m_pimpl->m_match_or_save ) { - for ( std::string::size_type i = 0; i < m_pimpl->m_synced_string.length(); ++i ) { - char c = m_pimpl->get_char(); - - result = !m_pimpl->m_pattern.fail() && - !m_pimpl->m_pattern.eof() && - (m_pimpl->m_synced_string[i] == c); - - if( !result ) { - std::string::size_type suffix_size = (std::min)( m_pimpl->m_synced_string.length() - i, - static_cast(5) ); - - // try to log area around the mismatch - result.message() << "Mismatch at position " << i << '\n' - << "..." << m_pimpl->m_synced_string.substr( i, suffix_size ) << "..." << '\n' - << "..." << c; - - std::string::size_type counter = suffix_size; - while( --counter ) { - char c = m_pimpl->get_char(); - - if( m_pimpl->m_pattern.fail() || m_pimpl->m_pattern.eof() ) - break; - - result.message() << c; - } - - result.message() << "..."; - - // skip rest of the bytes. May help for further matching - m_pimpl->m_pattern.ignore( - static_cast( m_pimpl->m_synced_string.length() - i - suffix_size) ); - break; - } - } - } - else { - m_pimpl->m_pattern.write( m_pimpl->m_synced_string.c_str(), - static_cast( m_pimpl->m_synced_string.length() ) ); - m_pimpl->m_pattern.flush(); - } - } - - if( flush_stream ) - flush(); - - return result; -} - -//____________________________________________________________________________// - -void -output_test_stream::flush() -{ - m_pimpl->m_synced_string.erase(); - -#ifndef BOOST_NO_STRINGSTREAM - str( std::string() ); -#else - seekp( 0, std::ios::beg ); -#endif -} - -//____________________________________________________________________________// - -std::size_t -output_test_stream::length() -{ - sync(); - - return m_pimpl->m_synced_string.length(); -} - -//____________________________________________________________________________// - -void -output_test_stream::sync() -{ -#ifdef BOOST_NO_STRINGSTREAM - m_pimpl->m_synced_string.assign( str(), pcount() ); - freeze( false ); -#else - m_pimpl->m_synced_string = str(); -#endif -} - -//____________________________________________________________________________// - -} // namespace test_tools - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TEST_TOOLS_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/unit_test_log.ipp b/contrib/autoboost/boost/test/impl/unit_test_log.ipp deleted file mode 100644 index 40c34b361..000000000 --- a/contrib/autoboost/boost/test/impl/unit_test_log.ipp +++ /dev/null @@ -1,444 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implemets Unit Test Log -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER -#define BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include - -#include - -#include - -#include -#include - -// Boost -#include -#include -typedef ::autoboost::io::ios_base_all_saver io_saver_type; - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** entry_value_collector ************** // -// ************************************************************************** // - -namespace ut_detail { - -entry_value_collector const& -entry_value_collector::operator<<( lazy_ostream const& v ) const -{ - unit_test_log << v; - - return *this; -} - -//____________________________________________________________________________// - -entry_value_collector const& -entry_value_collector::operator<<( const_string v ) const -{ - unit_test_log << v; - - return *this; -} - -//____________________________________________________________________________// - -entry_value_collector::~entry_value_collector() -{ - if( m_last ) - unit_test_log << log::end(); -} - -//____________________________________________________________________________// - -} // namespace ut_detail - -// ************************************************************************** // -// ************** unit_test_log ************** // -// ************************************************************************** // - -namespace { - -struct unit_test_log_impl { - // Constructor - unit_test_log_impl() - : m_stream( runtime_config::log_sink() ) - , m_stream_state_saver( new io_saver_type( *m_stream ) ) - , m_threshold_level( log_all_errors ) - , m_log_formatter( new output::compiler_log_formatter ) - { - } - - // log data - typedef scoped_ptr formatter_ptr; - typedef scoped_ptr saver_ptr; - - std::ostream* m_stream; - saver_ptr m_stream_state_saver; - log_level m_threshold_level; - formatter_ptr m_log_formatter; - - // entry data - bool m_entry_in_progress; - bool m_entry_started; - log_entry_data m_entry_data; - - // check point data - log_checkpoint_data m_checkpoint_data; - - // helper functions - std::ostream& stream() { return *m_stream; } - void set_checkpoint( const_string file, std::size_t line_num, const_string msg ) - { - assign_op( m_checkpoint_data.m_message, msg, 0 ); - m_checkpoint_data.m_file_name = file; - m_checkpoint_data.m_line_num = line_num; - } -}; - -unit_test_log_impl& s_log_impl() { static unit_test_log_impl the_inst; return the_inst; } - -} // local namespace - -//____________________________________________________________________________// - -void -unit_test_log_t::test_start( counter_t test_cases_amount ) -{ - if( s_log_impl().m_threshold_level == log_nothing ) - return; - - s_log_impl().m_log_formatter->log_start( s_log_impl().stream(), test_cases_amount ); - - if( runtime_config::show_build_info() ) - s_log_impl().m_log_formatter->log_build_info( s_log_impl().stream() ); - - s_log_impl().m_entry_in_progress = false; -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_finish() -{ - if( s_log_impl().m_threshold_level == log_nothing ) - return; - - s_log_impl().m_log_formatter->log_finish( s_log_impl().stream() ); - - s_log_impl().stream().flush(); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_aborted() -{ - BOOST_TEST_LOG_ENTRY( log_messages ) << "Test is aborted"; -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_unit_start( test_unit const& tu ) -{ - if( s_log_impl().m_threshold_level > log_test_units ) - return; - - if( s_log_impl().m_entry_in_progress ) - *this << log::end(); - - s_log_impl().m_log_formatter->test_unit_start( s_log_impl().stream(), tu ); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_unit_finish( test_unit const& tu, unsigned long elapsed ) -{ - if( s_log_impl().m_threshold_level > log_test_units ) - return; - - s_log_impl().m_checkpoint_data.clear(); - - if( s_log_impl().m_entry_in_progress ) - *this << log::end(); - - s_log_impl().m_log_formatter->test_unit_finish( s_log_impl().stream(), tu, elapsed ); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_unit_skipped( test_unit const& tu ) -{ - if( s_log_impl().m_threshold_level > log_test_units ) - return; - - if( s_log_impl().m_entry_in_progress ) - *this << log::end(); - - s_log_impl().m_log_formatter->test_unit_skipped( s_log_impl().stream(), tu ); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::test_unit_aborted( test_unit const& ) -{ - // do nothing -} - -//____________________________________________________________________________// - -void -unit_test_log_t::assertion_result( bool ) -{ - // do nothing -} - -//____________________________________________________________________________// - -void -unit_test_log_t::exception_caught( execution_exception const& ex ) -{ - log_level l = - ex.code() <= execution_exception::cpp_exception_error ? log_cpp_exception_errors : - (ex.code() <= execution_exception::timeout_error ? log_system_errors - : log_fatal_errors ); - - if( l >= s_log_impl().m_threshold_level ) { - if( s_log_impl().m_entry_in_progress ) - *this << log::end(); - - s_log_impl().m_log_formatter->log_exception( s_log_impl().stream(), s_log_impl().m_checkpoint_data, ex ); - } -} - -//____________________________________________________________________________// - -void -unit_test_log_t::set_checkpoint( const_string file, std::size_t line_num, const_string msg ) -{ - s_log_impl().set_checkpoint( file, line_num, msg ); -} - -//____________________________________________________________________________// - -char -set_unix_slash( char in ) -{ - return in == '\\' ? '/' : in; -} - -unit_test_log_t& -unit_test_log_t::operator<<( log::begin const& b ) -{ - if( s_log_impl().m_entry_in_progress ) - *this << log::end(); - - s_log_impl().m_stream_state_saver->restore(); - - s_log_impl().m_entry_data.clear(); - - assign_op( s_log_impl().m_entry_data.m_file_name, b.m_file_name, 0 ); - - // normalize file name - std::transform( s_log_impl().m_entry_data.m_file_name.begin(), s_log_impl().m_entry_data.m_file_name.end(), - s_log_impl().m_entry_data.m_file_name.begin(), - &set_unix_slash ); - - s_log_impl().m_entry_data.m_line_num = b.m_line_num; - - return *this; -} - -//____________________________________________________________________________// - -unit_test_log_t& -unit_test_log_t::operator<<( log::end const& ) -{ - if( s_log_impl().m_entry_in_progress ) - s_log_impl().m_log_formatter->log_entry_finish( s_log_impl().stream() ); - - s_log_impl().m_entry_in_progress = false; - - return *this; -} - -//____________________________________________________________________________// - -unit_test_log_t& -unit_test_log_t::operator<<( log_level l ) -{ - s_log_impl().m_entry_data.m_level = l; - - return *this; -} - -//____________________________________________________________________________// - -ut_detail::entry_value_collector -unit_test_log_t::operator()( log_level l ) -{ - *this << l; - - return ut_detail::entry_value_collector(); -} - -//____________________________________________________________________________// - -bool -unit_test_log_t::log_entry_start() -{ - if( s_log_impl().m_entry_in_progress ) - return true; - - switch( s_log_impl().m_entry_data.m_level ) { - case log_successful_tests: - s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_INFO ); - break; - case log_messages: - s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_MESSAGE ); - break; - case log_warnings: - s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_WARNING ); - break; - case log_all_errors: - case log_cpp_exception_errors: - case log_system_errors: - s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_ERROR ); - break; - case log_fatal_errors: - s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR ); - break; - case log_nothing: - case log_test_units: - case invalid_log_level: - return false; - } - - s_log_impl().m_entry_in_progress = true; - - return true; -} - -//____________________________________________________________________________// - -unit_test_log_t& -unit_test_log_t::operator<<( const_string value ) -{ - if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() ) - s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value ); - - return *this; -} - -//____________________________________________________________________________// - -unit_test_log_t& -unit_test_log_t::operator<<( lazy_ostream const& value ) -{ - if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() ) - s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value ); - - return *this; -} - -//____________________________________________________________________________// - -void -unit_test_log_t::set_stream( std::ostream& str ) -{ - if( s_log_impl().m_entry_in_progress ) - return; - - s_log_impl().m_stream = &str; - s_log_impl().m_stream_state_saver.reset( new io_saver_type( str ) ); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::set_threshold_level( log_level lev ) -{ - if( s_log_impl().m_entry_in_progress || lev == invalid_log_level ) - return; - - s_log_impl().m_threshold_level = lev; -} - -//____________________________________________________________________________// - -void -unit_test_log_t::set_format( output_format log_format ) -{ - if( s_log_impl().m_entry_in_progress ) - return; - - if( log_format == CLF ) - set_formatter( new output::compiler_log_formatter ); - else - set_formatter( new output::xml_log_formatter ); -} - -//____________________________________________________________________________// - -void -unit_test_log_t::set_formatter( unit_test_log_formatter* the_formatter ) -{ - s_log_impl().m_log_formatter.reset( the_formatter ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** unit_test_log_formatter ************** // -// ************************************************************************** // - -void -unit_test_log_formatter::log_entry_value( std::ostream& ostr, lazy_ostream const& value ) -{ - log_entry_value( ostr, (wrap_stringstream().ref() << value).str() ); -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/unit_test_main.ipp b/contrib/autoboost/boost/test/impl/unit_test_main.ipp deleted file mode 100644 index b5338ae2a..000000000 --- a/contrib/autoboost/boost/test/impl/unit_test_main.ipp +++ /dev/null @@ -1,246 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : main function implementation for Unit Test Framework -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER -#define BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include - -#include - -#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) -#define BOOST_TEST_SUPPORT_RUN_BY_NAME -#include -#endif - -// Boost -#include -#include - -// STL -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_case_filter ************** // -// ************************************************************************** // - -class test_case_filter : public test_tree_visitor { -public: - struct single_filter { - single_filter( const_string in ) - { - if( in == "*" ) - m_kind = SFK_ALL; - else if( first_char( in ) == '*' && last_char( in ) == '*' ) { - m_kind = SFK_SUBSTR; - m_value = in.substr( 1, in.size()-1 ); - } - else if( first_char( in ) == '*' ) { - m_kind = SFK_TRAILING; - m_value = in.substr( 1 ); - } - else if( last_char( in ) == '*' ) { - m_kind = SFK_LEADING; - m_value = in.substr( 0, in.size()-1 ); - } - else { - m_kind = SFK_MATCH; - m_value = in; - } - }; - - bool pass( test_unit const& tu ) const - { - const_string name( tu.p_name ); - - switch( m_kind ) { - default: - case SFK_ALL: - return true; - - case SFK_LEADING: - return name.substr( 0, m_value.size() ) == m_value; - - case SFK_TRAILING: - return name.size() >= m_value.size() && name.substr( name.size() - m_value.size() ) == m_value; - - case SFK_SUBSTR: - return name.find( m_value ) != const_string::npos; - - case SFK_MATCH: - return m_value == tu.p_name.get(); - } - } - enum kind { SFK_ALL, SFK_LEADING, SFK_TRAILING, SFK_SUBSTR, SFK_MATCH }; - - kind m_kind; - const_string m_value; - }; - // Constructor -#ifndef BOOST_TEST_SUPPORT_RUN_BY_NAME - explicit test_case_filter( const_string ) : m_depth( 0 ) {} -#else - explicit test_case_filter( const_string tc_to_run ) - : m_depth( 0 ) - { - string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) ); - - while( tit != string_token_iterator() ) { - m_filters.push_back( - std::vector( string_token_iterator( *tit, (dropped_delimeters = ",", kept_delimeters = dt_none) ), - string_token_iterator() ) ); - - ++tit; - } - } -#endif - - void filter_unit( test_unit const& tu ) - { - if( (++m_depth - 1) > m_filters.size() ) { - tu.p_enabled.value = true; - return; - } - - if( m_depth == 1 ) - return; - - std::vector const& filters = m_filters[m_depth-2]; - - tu.p_enabled.value = - std::find_if( filters.begin(), filters.end(), bind( &single_filter::pass, _1, autoboost::ref(tu) ) ) != filters.end(); - } - - // test tree visitor interface - virtual void visit( test_case const& tc ) - { - if( m_depth < m_filters.size() ) { - tc.p_enabled.value = false; - return; - } - - filter_unit( tc ); - - --m_depth; - } - - virtual bool test_suite_start( test_suite const& ts ) - { - filter_unit( ts ); - - if( !ts.p_enabled ) - --m_depth; - - return ts.p_enabled; - } - - virtual void test_suite_finish( test_suite const& ) { --m_depth; } - -private: - // Data members - std::vector > m_filters; - unsigned m_depth; -}; - -// ************************************************************************** // -// ************** unit_test_main ************** // -// ************************************************************************** // - -int BOOST_TEST_DECL -unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) -{ - try { - framework::init( init_func, argc, argv ); - - if( !runtime_config::test_to_run().is_empty() ) { - test_case_filter filter( runtime_config::test_to_run() ); - - traverse_test_tree( framework::master_test_suite().p_id, filter ); - } - - framework::run(); - - results_reporter::make_report(); - - return runtime_config::no_result_code() - ? autoboost::exit_success - : results_collector.results( framework::master_test_suite().p_id ).result_code(); - } - catch( framework::nothing_to_test const& ) { - return autoboost::exit_success; - } - catch( framework::internal_error const& ex ) { - results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl; - - return autoboost::exit_exception_failure; - } - catch( framework::setup_error const& ex ) { - results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl; - - return autoboost::exit_exception_failure; - } - catch( ... ) { - results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl; - - return autoboost::exit_exception_failure; - } -} - -} // namespace unit_test - -} // namespace autoboost - -#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN) - -// ************************************************************************** // -// ************** main function for tests using lib ************** // -// ************************************************************************** // - -int BOOST_TEST_CALL_DECL -main( int argc, char* argv[] ) -{ - // prototype for user's unit test init function -#ifdef BOOST_TEST_ALTERNATIVE_INIT_API - extern bool init_unit_test(); - - autoboost::unit_test::init_unit_test_func init_func = &init_unit_test; -#else - extern ::autoboost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ); - - autoboost::unit_test::init_unit_test_func init_func = &init_unit_test_suite; -#endif - - return ::autoboost::unit_test::unit_test_main( init_func, argc, argv ); -} - -#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/unit_test_monitor.ipp b/contrib/autoboost/boost/test/impl/unit_test_monitor.ipp deleted file mode 100644 index c39fda7f0..000000000 --- a/contrib/autoboost/boost/test/impl/unit_test_monitor.ipp +++ /dev/null @@ -1,101 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements specific subclass of Executon Monitor used by Unit -// Test Framework to monitor test cases run. -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER -#define BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include - -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace { - -template -struct zero_return_wrapper_t { - explicit zero_return_wrapper_t( F const& f ) : m_f( f ) {} - - int operator()() { m_f(); return 0; } - - F const& m_f; -}; - -template -zero_return_wrapper_t -zero_return_wrapper( F const& f ) -{ - return zero_return_wrapper_t( f ); -} - -} - -// ************************************************************************** // -// ************** unit_test_monitor ************** // -// ************************************************************************** // - -unit_test_monitor_t::error_level -unit_test_monitor_t::execute_and_translate( test_case const& tc ) -{ - try { - p_catch_system_errors.value = runtime_config::catch_sys_errors(); - p_timeout.value = tc.p_timeout.get(); - p_auto_start_dbg.value = runtime_config::auto_start_dbg(); - p_use_alt_stack.value = runtime_config::use_alt_stack(); - p_detect_fp_exceptions.value = runtime_config::detect_fp_exceptions(); - - execute( callback0( zero_return_wrapper( tc.test_func() ) ) ); - } - catch( execution_exception const& ex ) { - framework::exception_caught( ex ); - framework::test_unit_aborted( framework::current_test_case() ); - - // translate execution_exception::error_code to error_level - switch( ex.code() ) { - case execution_exception::no_error: return test_ok; - case execution_exception::user_error: return unexpected_exception; - case execution_exception::cpp_exception_error: return unexpected_exception; - case execution_exception::system_error: return os_exception; - case execution_exception::timeout_error: return os_timeout; - case execution_exception::user_fatal_error: - case execution_exception::system_fatal_error: return fatal_error; - default: return unexpected_exception; - } - } - - return test_ok; -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/unit_test_parameters.ipp b/contrib/autoboost/boost/test/impl/unit_test_parameters.ipp deleted file mode 100644 index 90d4862de..000000000 --- a/contrib/autoboost/boost/test/impl/unit_test_parameters.ipp +++ /dev/null @@ -1,527 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple implementation for Unit Test Framework parameter -// handling routines. May be rewritten in future to use some kind of -// command-line arguments parsing facility and environment variable handling -// facility -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER -#define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include -#include -#include -#include - -// Boost.Runtime.Param -#include -#include - -namespace rt = autoboost::runtime; -namespace cla = rt::cla; - - -#ifndef UNDER_CE -#include - -namespace env = rt::env; -#endif - - -// Boost -#include -#include -#include -#include - -// STL -#include -#include -#include -#include - -#include - -//____________________________________________________________________________// - -# ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::getenv; using ::strncmp; using ::strcmp; } -# endif - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** input operations for unit_test's enums ************** // -// ************************************************************************** // - -std::istream& -operator>>( std::istream& in, unit_test::log_level& ll ) -{ - static fixed_mapping > log_level_name( - "all" , log_successful_tests, - "success" , log_successful_tests, - "test_suite" , log_test_units, - "unit_scope" , log_test_units, - "message" , log_messages, - "warning" , log_warnings, - "error" , log_all_errors, - "cpp_exception" , log_cpp_exception_errors, - "system_error" , log_system_errors, - "fatal_error" , log_fatal_errors, - "nothing" , log_nothing, - - invalid_log_level - ); - - std::string val; - in >> val; - - ll = log_level_name[val]; - BOOST_TEST_SETUP_ASSERT( ll != unit_test::invalid_log_level, "invalid log level " + val ); - - return in; -} - -//____________________________________________________________________________// - -std::istream& -operator>>( std::istream& in, unit_test::report_level& rl ) -{ - fixed_mapping > report_level_name ( - "confirm", CONFIRMATION_REPORT, - "short", SHORT_REPORT, - "detailed", DETAILED_REPORT, - "no", NO_REPORT, - - INV_REPORT_LEVEL - ); - - std::string val; - in >> val; - - rl = report_level_name[val]; - BOOST_TEST_SETUP_ASSERT( rl != INV_REPORT_LEVEL, "invalid report level " + val ); - - return in; -} - -//____________________________________________________________________________// - -std::istream& -operator>>( std::istream& in, unit_test::output_format& of ) -{ - fixed_mapping > output_format_name ( - "HRF", unit_test::CLF, - "CLF", unit_test::CLF, - "XML", unit_test::XML, - - unit_test::INV_OF - ); - - std::string val; - in >> val; - - of = output_format_name[val]; - BOOST_TEST_SETUP_ASSERT( of != unit_test::INV_OF, "invalid output format " + val ); - - return in; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** runtime_config ************** // -// ************************************************************************** // - -namespace runtime_config { - -namespace { - -// framework parameters and corresponding command-line arguments -std::string AUTO_START_DBG = "auto_start_dbg"; -std::string BREAK_EXEC_PATH = "break_exec_path"; -std::string BUILD_INFO = "build_info"; -std::string CATCH_SYS_ERRORS = "catch_system_errors"; -std::string DETECT_FP_EXCEPT = "detect_fp_exceptions"; -std::string DETECT_MEM_LEAKS = "detect_memory_leaks"; -std::string LOG_FORMAT = "log_format"; -std::string LOG_LEVEL = "log_level"; -std::string LOG_SINK = "log_sink"; -std::string OUTPUT_FORMAT = "output_format"; -std::string RANDOM_SEED = "random"; -std::string REPORT_FORMAT = "report_format"; -std::string REPORT_LEVEL = "report_level"; -std::string REPORT_SINK = "report_sink"; -std::string RESULT_CODE = "result_code"; -std::string TESTS_TO_RUN = "run_test"; -std::string SAVE_TEST_PATTERN = "save_pattern"; -std::string SHOW_PROGRESS = "show_progress"; -std::string USE_ALT_STACK = "use_alt_stack"; - -fixed_mapping parameter_2_env_var( - AUTO_START_DBG , "BOOST_TEST_AUTO_START_DBG", - BREAK_EXEC_PATH , "BOOST_TEST_BREAK_EXEC_PATH", - BUILD_INFO , "BOOST_TEST_BUILD_INFO", - CATCH_SYS_ERRORS , "BOOST_TEST_CATCH_SYSTEM_ERRORS", - DETECT_FP_EXCEPT , "BOOST_TEST_DETECT_FP_EXCEPTIONS", - DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK", - LOG_FORMAT , "BOOST_TEST_LOG_FORMAT", - LOG_LEVEL , "BOOST_TEST_LOG_LEVEL", - LOG_SINK , "BOOST_TEST_LOG_SINK", - OUTPUT_FORMAT , "BOOST_TEST_OUTPUT_FORMAT", - RANDOM_SEED , "BOOST_TEST_RANDOM", - REPORT_FORMAT , "BOOST_TEST_REPORT_FORMAT", - REPORT_LEVEL , "BOOST_TEST_REPORT_LEVEL", - REPORT_SINK , "BOOST_TEST_REPORT_SINK", - RESULT_CODE , "BOOST_TEST_RESULT_CODE", - TESTS_TO_RUN , "BOOST_TESTS_TO_RUN", - SAVE_TEST_PATTERN , "BOOST_TEST_SAVE_PATTERN", - SHOW_PROGRESS , "BOOST_TEST_SHOW_PROGRESS", - USE_ALT_STACK , "BOOST_TEST_USE_ALT_STACK", - - "" -); - -//____________________________________________________________________________// - -// storage for the CLAs -cla::parser s_cla_parser; -std::string s_empty; - -output_format s_report_format; -output_format s_log_format; - -//____________________________________________________________________________// - -template -T -retrieve_parameter( const_string parameter_name, cla::parser const& s_cla_parser, T const& default_value = T(), T const& optional_value = T() ) -{ - rt::const_argument_ptr arg = s_cla_parser[parameter_name]; - if( arg ) { - if( rtti::type_id() == rtti::type_id() || - !static_cast( arg->p_formal_parameter.get() ).p_optional_value ) - return s_cla_parser.get( parameter_name ); - - optional val = s_cla_parser.get >( parameter_name ); - if( val ) - return *val; - else - return optional_value; - } - - autoboost::optional v; - -#ifndef UNDER_CE - env::get( parameter_2_env_var[parameter_name], v ); -#endif - - if( v ) - return *v; - else - return default_value; -} - -//____________________________________________________________________________// - -} // local namespace - -void -init( int& argc, char** argv ) -{ - using namespace cla; - - try { - s_cla_parser - cla::ignore_mismatch - << cla::dual_name_parameter( AUTO_START_DBG + "|d" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Automatically starts debugger if system level error (signal) occurs") - << cla::named_parameter( BREAK_EXEC_PATH ) - - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "For the exception safety testing allows to break at specific execution path") - << cla::dual_name_parameter( BUILD_INFO + "|i" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Shows library build information" ) - << cla::dual_name_parameter( CATCH_SYS_ERRORS + "|s" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Allows to switch between catching and ignoring system errors (signals)") - << cla::named_parameter( DETECT_FP_EXCEPT ) - - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "Allows to switch between catching and ignoring floating point exceptions") - << cla::named_parameter( DETECT_MEM_LEAKS ) - - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "Allows to switch between catching and ignoring memory leaks") - << cla::dual_name_parameter( LOG_FORMAT + "|f" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies log format") - << cla::dual_name_parameter( LOG_LEVEL + "|l" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies log level") - << cla::dual_name_parameter( LOG_SINK + "|k" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies log sink:stdout(default),stderr or file name") - << cla::dual_name_parameter( OUTPUT_FORMAT + "|o" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies output format (both log and report)") - << cla::dual_name_parameter( RANDOM_SEED + "|a" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value, - cla::description = "Allows to switch between sequential and random order of test units execution.\n" - "Optionally allows to specify concrete seed for random number generator") - << cla::dual_name_parameter( REPORT_FORMAT + "|m" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies report format") - << cla::dual_name_parameter(REPORT_LEVEL + "|r") - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies report level") - << cla::dual_name_parameter( REPORT_SINK + "|e" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Specifies report sink:stderr(default),stdout or file name") - << cla::dual_name_parameter( RESULT_CODE + "|c" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Allows to disable test modules's result code generation") - << cla::dual_name_parameter( TESTS_TO_RUN + "|t" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Allows to filter which test units to run") - << cla::named_parameter( SAVE_TEST_PATTERN ) - - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "Allows to switch between saving and matching against test pattern file") - << cla::dual_name_parameter( SHOW_PROGRESS + "|p" ) - - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, - cla::description = "Turns on progress display") - << cla::named_parameter( USE_ALT_STACK ) - - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "Turns on/off usage of an alternative stack for signal handling") - - << cla::dual_name_parameter( "help|?" ) - - (cla::prefix = "--|-",cla::separator = "=",cla::guess_name,cla::optional, - cla::description = "this help message") - ; - - s_cla_parser.parse( argc, argv ); - - if( s_cla_parser["help"] ) { - s_cla_parser.help( std::cout ); - throw framework::nothing_to_test(); - } - - s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::CLF ); - s_log_format = retrieve_parameter( LOG_FORMAT, s_cla_parser, unit_test::CLF ); - - unit_test::output_format of = retrieve_parameter( OUTPUT_FORMAT, s_cla_parser, unit_test::INV_OF ); - - if( of != unit_test::INV_OF ) - s_report_format = s_log_format = of; - } - catch( rt::logic_error const& ex ) { - std::ostringstream err; - - err << "Fail to process runtime parameters: " << ex.msg() << std::endl; - s_cla_parser.usage( err ); - - throw framework::setup_error( err.str() ); - } -} - -//____________________________________________________________________________// - -unit_test::log_level -log_level() -{ - return retrieve_parameter( LOG_LEVEL, s_cla_parser, unit_test::log_all_errors ); -} - -//____________________________________________________________________________// - -bool -no_result_code() -{ - return !retrieve_parameter( RESULT_CODE, s_cla_parser, true ); -} - -//____________________________________________________________________________// - -unit_test::report_level -report_level() -{ - return retrieve_parameter( REPORT_LEVEL, s_cla_parser, unit_test::CONFIRMATION_REPORT ); -} - -//____________________________________________________________________________// - -const_string -test_to_run() -{ - static std::string s_test_to_run = retrieve_parameter( TESTS_TO_RUN, s_cla_parser, s_empty ); - - return s_test_to_run; -} - -//____________________________________________________________________________// - -const_string -break_exec_path() -{ - static std::string s_break_exec_path = retrieve_parameter( BREAK_EXEC_PATH, s_cla_parser, s_empty ); - - return s_break_exec_path; -} - -//____________________________________________________________________________// - -bool -save_pattern() -{ - return retrieve_parameter( SAVE_TEST_PATTERN, s_cla_parser, false ); -} - -//____________________________________________________________________________// - -bool -show_progress() -{ - return retrieve_parameter( SHOW_PROGRESS, s_cla_parser, false ); -} - -//____________________________________________________________________________// - -bool -show_build_info() -{ - return retrieve_parameter( BUILD_INFO, s_cla_parser, false ); -} - -//____________________________________________________________________________// - -bool -catch_sys_errors() -{ - return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser, -#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP - false -#else - true -#endif - ); -} - -//____________________________________________________________________________// - -bool -auto_start_dbg() -{ - // !! set debugger as an option - return retrieve_parameter( AUTO_START_DBG, s_cla_parser, false ); -; -} - -//____________________________________________________________________________// - -bool -use_alt_stack() -{ - return retrieve_parameter( USE_ALT_STACK, s_cla_parser, true ); -} - -//____________________________________________________________________________// - -bool -detect_fp_exceptions() -{ - return retrieve_parameter( DETECT_FP_EXCEPT, s_cla_parser, false ); -} - -//____________________________________________________________________________// - -output_format -report_format() -{ - return s_report_format; -} - -//____________________________________________________________________________// - -output_format -log_format() -{ - return s_log_format; -} - -//____________________________________________________________________________// - -std::ostream* -report_sink() -{ - std::string sink_name = retrieve_parameter( REPORT_SINK, s_cla_parser, s_empty ); - - if( sink_name.empty() || sink_name == "stderr" ) - return &std::cerr; - - if( sink_name == "stdout" ) - return &std::cout; - - static std::ofstream log_file( sink_name.c_str() ); - return &log_file; -} - -//____________________________________________________________________________// - -std::ostream* -log_sink() -{ - std::string sink_name = retrieve_parameter( LOG_SINK, s_cla_parser, s_empty ); - - if( sink_name.empty() || sink_name == "stdout" ) - return &std::cout; - - if( sink_name == "stderr" ) - return &std::cerr; - - static std::ofstream report_file( sink_name.c_str() ); - return &report_file; -} - -//____________________________________________________________________________// - -long -detect_memory_leaks() -{ - return retrieve_parameter( DETECT_MEM_LEAKS, s_cla_parser, static_cast(1) ); -} - -//____________________________________________________________________________// - -int -random_seed() -{ - return retrieve_parameter( RANDOM_SEED, s_cla_parser, 0, 1 ); -} - -//____________________________________________________________________________// - -} // namespace runtime_config - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/unit_test_suite.ipp b/contrib/autoboost/boost/test/impl/unit_test_suite.ipp deleted file mode 100644 index ef86993d3..000000000 --- a/contrib/autoboost/boost/test/impl/unit_test_suite.ipp +++ /dev/null @@ -1,346 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : privides core implementation for Unit Test Framework. -// Extensions can be provided in separate files -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER -#define BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER - -// Boost.Test -#include -#include -#include -#include -#include -#include - -// Boost -#include - -// STL -#include -#include - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) && \ - BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) \ - /**/ - using std::rand; // rand is in std and random_shuffle is in _STL -#endif - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_unit ************** // -// ************************************************************************** // - -test_unit::test_unit( const_string name, test_unit_type t ) -: p_type( t ) -, p_type_name( t == tut_case ? "case" : "suite" ) -, p_id( INV_TEST_UNIT_ID ) -, p_name( std::string( name.begin(), name.size() ) ) -, p_enabled( true ) -{ -} - -//____________________________________________________________________________// - -test_unit::~test_unit() -{ - framework::deregister_test_unit( this ); -} - -//____________________________________________________________________________// - -void -test_unit::depends_on( test_unit* tu ) -{ - m_dependencies.push_back( tu->p_id ); -} - -//____________________________________________________________________________// - -bool -test_unit::check_dependencies() const -{ - BOOST_TEST_FOREACH( test_unit_id, tu_id, m_dependencies ) { - if( !unit_test::results_collector.results( tu_id ).passed() ) - return false; - } - - return true; -} - -//____________________________________________________________________________// - -void -test_unit::increase_exp_fail( unsigned num ) -{ - p_expected_failures.value += num; - - if( p_parent_id != 0 ) - framework::get( p_parent_id ).increase_exp_fail( num ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** test_case ************** // -// ************************************************************************** // - -test_case::test_case( const_string name, callback0<> const& test_func ) -: test_unit( name, static_cast(type) ) -, m_test_func( test_func ) -{ - // !! weirdest MSVC BUG; try to remove this statement; looks like it eats first token of next statement -#if BOOST_WORKAROUND(BOOST_MSVC,<1300) - 0; -#endif - framework::register_test_unit( this ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** test_suite ************** // -// ************************************************************************** // - -//____________________________________________________________________________// - -test_suite::test_suite( const_string name ) -: test_unit( name, static_cast(type) ) -{ - framework::register_test_unit( this ); -} - -//____________________________________________________________________________// - -void -test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout ) -{ - if( timeout != 0 ) - tu->p_timeout.value = timeout; - - m_members.push_back( tu->p_id ); - tu->p_parent_id.value = p_id; - - if( tu->p_expected_failures ) - increase_exp_fail( tu->p_expected_failures ); - - if( expected_failures ) - tu->increase_exp_fail( expected_failures ); -} - -//____________________________________________________________________________// - -void -test_suite::add( test_unit_generator const& gen, unsigned timeout ) -{ - test_unit* tu; - while((tu = gen.next(), tu)) - add( tu, 0, timeout ); -} - -//____________________________________________________________________________// - -void -test_suite::remove( test_unit_id id ) -{ - std::vector::iterator it = std::find( m_members.begin(), m_members.end(), id ); - - if( it != m_members.end() ) - m_members.erase( it ); -} - -//____________________________________________________________________________// - -test_unit_id -test_suite::get( const_string tu_name ) const -{ - BOOST_TEST_FOREACH( test_unit_id, id, m_members ) { - if( tu_name == framework::get( id, ut_detail::test_id_2_unit_type( id ) ).p_name.get() ) - return id; - } - - return INV_TEST_UNIT_ID; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** traverse_test_tree ************** // -// ************************************************************************** // - -void -traverse_test_tree( test_case const& tc, test_tree_visitor& V ) -{ - if( tc.p_enabled ) - V.visit( tc ); -} - -//____________________________________________________________________________// - -void -traverse_test_tree( test_suite const& suite, test_tree_visitor& V ) -{ - if( !suite.p_enabled || !V.test_suite_start( suite ) ) - return; - - try { - if( runtime_config::random_seed() == 0 ) { - BOOST_TEST_FOREACH( test_unit_id, id, suite.m_members ) - traverse_test_tree( id, V ); - } - else { - std::vector members( suite.m_members ); - std::random_shuffle( members.begin(), members.end() ); - BOOST_TEST_FOREACH( test_unit_id, id, members ) - traverse_test_tree( id, V ); - } - - } catch( test_being_aborted const& ) { - V.test_suite_finish( suite ); - framework::test_unit_aborted( suite ); - - throw; - } - - V.test_suite_finish( suite ); -} - -//____________________________________________________________________________// - -void -traverse_test_tree( test_unit_id id, test_tree_visitor& V ) -{ - if( ut_detail::test_id_2_unit_type( id ) == tut_case ) - traverse_test_tree( framework::get( id ), V ); - else - traverse_test_tree( framework::get( id ), V ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** test_case_counter ************** // -// ************************************************************************** // - -void -test_case_counter::visit( test_case const& tc ) -{ - if( tc.p_enabled ) - ++p_count.value; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** object generators ************** // -// ************************************************************************** // - -namespace ut_detail { - -std::string -normalize_test_case_name( const_string name ) -{ - return ( name[0] == '&' - ? std::string( name.begin()+1, name.size()-1 ) - : std::string( name.begin(), name.size() ) ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** auto_test_unit_registrar ************** // -// ************************************************************************** // - -auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, counter_t exp_fail ) -{ - curr_ts_store().back()->add( tc, exp_fail ); -} - -//____________________________________________________________________________// - -auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name ) -{ - test_unit_id id = curr_ts_store().back()->get( ts_name ); - - test_suite* ts; - - if( id != INV_TEST_UNIT_ID ) { - ts = &framework::get( id ); // !! test for invalid tu type - BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id ); - } - else { - ts = new test_suite( ts_name ); - curr_ts_store().back()->add( ts ); - } - - curr_ts_store().push_back( ts ); -} - -//____________________________________________________________________________// - -auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen ) -{ - curr_ts_store().back()->add( tc_gen ); -} - -//____________________________________________________________________________// - -auto_test_unit_registrar::auto_test_unit_registrar( int ) -{ - if( curr_ts_store().size() == 0 ) - return; // report error? - - curr_ts_store().pop_back(); -} - -//____________________________________________________________________________// - -std::list& -auto_test_unit_registrar::curr_ts_store() -{ - static std::list inst( 1, &framework::master_test_suite() ); - return inst; -} - -//____________________________________________________________________________// - -} // namespace ut_detail - -// ************************************************************************** // -// ************** global_fixture ************** // -// ************************************************************************** // - -global_fixture::global_fixture() -{ - framework::register_observer( *this ); -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER diff --git a/contrib/autoboost/boost/test/impl/xml_log_formatter.ipp b/contrib/autoboost/boost/test/impl/xml_log_formatter.ipp deleted file mode 100644 index 7a33766ad..000000000 --- a/contrib/autoboost/boost/test/impl/xml_log_formatter.ipp +++ /dev/null @@ -1,180 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements XML Log formatter -// *************************************************************************** - -#ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER -#define BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER - -// Boost.Test -#include -#include -#include -#include - -#include - -// Boost -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -static const_string tu_type_name( test_unit const& tu ) -{ - return tu.p_type == tut_case ? "TestCase" : "TestSuite"; -} - -// ************************************************************************** // -// ************** xml_log_formatter ************** // -// ************************************************************************** // - -void -xml_log_formatter::log_start( std::ostream& ostr, counter_t ) -{ - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::log_finish( std::ostream& ostr ) -{ - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::log_build_info( std::ostream& ostr ) -{ - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu ) -{ - ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << ">"; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed ) -{ - if( tu.p_type == tut_case ) - ostr << "" << elapsed << ""; - - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu ) -{ - ostr << "<" << tu_type_name( tu ) - << " name" << attr_value() << tu.p_name.get() - << " skipped" << attr_value() << "yes" - << "/>"; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::log_exception( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex ) -{ - execution_exception::location const& loc = ex.where(); - - ostr << "" << cdata() << ex.what(); - - if( !checkpoint_data.m_file_name.is_empty() ) { - ostr << "" - << cdata() << checkpoint_data.m_message - << ""; - } - - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& entry_data, log_entry_types let ) -{ - static literal_string xml_tags[] = { "Info", "Message", "Warning", "Error", "FatalError" }; - - m_curr_tag = xml_tags[let]; - ostr << '<' << m_curr_tag - << BOOST_TEST_L( " file" ) << attr_value() << entry_data.m_file_name - << BOOST_TEST_L( " line" ) << attr_value() << entry_data.m_line_num - << BOOST_TEST_L( ">" ); - - m_curr_tag.clear(); -} - -//____________________________________________________________________________// - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER diff --git a/contrib/autoboost/boost/test/impl/xml_report_formatter.ipp b/contrib/autoboost/boost/test/impl/xml_report_formatter.ipp deleted file mode 100644 index 37fa6593b..000000000 --- a/contrib/autoboost/boost/test/impl/xml_report_formatter.ipp +++ /dev/null @@ -1,115 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : XML report formatter -// *************************************************************************** - -#ifndef BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER -#define BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER - -// Boost.Test -#include -#include -#include - -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -void -xml_report_formatter::results_report_start( std::ostream& ostr ) -{ - ostr << ""; -} - -//____________________________________________________________________________// - -void -xml_report_formatter::results_report_finish( std::ostream& ostr ) -{ - ostr << ""; -} - - -//____________________________________________________________________________// - -void -xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr ) -{ - test_results const& tr = results_collector.results( tu.p_id ); - - const_string descr; - - if( tr.passed() ) - descr = "passed"; - else if( tr.p_skipped ) - descr = "skipped"; - else if( tr.p_aborted ) - descr = "aborted"; - else - descr = "failed"; - - ostr << '<' << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" ) - << " name" << attr_value() << tu.p_name.get() - << " result" << attr_value() << descr - << " assertions_passed" << attr_value() << tr.p_assertions_passed - << " assertions_failed" << attr_value() << tr.p_assertions_failed - << " expected_failures" << attr_value() << tr.p_expected_failures; - - if( tu.p_type == tut_suite ) - ostr << " test_cases_passed" << attr_value() << tr.p_test_cases_passed - << " test_cases_failed" << attr_value() << tr.p_test_cases_failed - << " test_cases_skipped" << attr_value() << tr.p_test_cases_skipped - << " test_cases_aborted" << attr_value() << tr.p_test_cases_aborted; - - - ostr << '>'; -} - -//____________________________________________________________________________// - -void -xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr ) -{ - ostr << "'; -} - -//____________________________________________________________________________// - -void -xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr ) -{ - test_unit_report_start( tu, ostr ); - test_unit_report_finish( tu, ostr ); -} - -//____________________________________________________________________________// - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER diff --git a/contrib/autoboost/boost/test/interaction_based.hpp b/contrib/autoboost/boost/test/interaction_based.hpp deleted file mode 100644 index a4523b20b..000000000 --- a/contrib/autoboost/boost/test/interaction_based.hpp +++ /dev/null @@ -1,262 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Facilities to perform interaction-based testing -// *************************************************************************** - -#ifndef BOOST_TEST_INTERACTION_BASED_HPP_112105GER -#define BOOST_TEST_INTERACTION_BASED_HPP_112105GER - -// Boost.Test -#include -#include - -#include - -#include - -// Boost -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** BOOST_ITEST_EPOINT ************** // -// ************************************************************************** // - -#define BOOST_ITEST_EPOINT( description ) \ - ::autoboost::itest::manager::instance().exception_point( BOOST_TEST_L(__FILE__), __LINE__, description ) -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_DPOINT ************** // -// ************************************************************************** // - -#define BOOST_ITEST_DPOINT() \ - ::autoboost::itest::manager::instance().decision_point( BOOST_TEST_L(__FILE__), __LINE__ ) -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_SCOPE ************** // -// ************************************************************************** // - -#define BOOST_ITEST_SCOPE( scope_name ) \ - ::autoboost::itest::scope_guard itest_scope_guard ## __LINE__( BOOST_TEST_L(__FILE__), __LINE__, BOOST_STRINGIZE(scope_name) ) -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_NEW ************** // -// ************************************************************************** // - -#define BOOST_ITEST_NEW( type_name ) \ - new ( ::autoboost::itest::location( BOOST_TEST_L(__FILE__), __LINE__ ) ) type_name -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_DATA_FLOW ************** // -// ************************************************************************** // - -#define BOOST_ITEST_DATA_FLOW( v ) \ - ::autoboost::itest::manager::instance().generic_data_flow( v ) -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_RETURN ************** // -// ************************************************************************** // - -#define BOOST_ITEST_RETURN( type, default_value ) \ - ::autoboost::itest::manager::instance().generic_return( default_value ) -/**/ - -// ************************************************************************** // -// ************** BOOST_ITEST_MOCK_FUNC ************** // -// ************************************************************************** // - -#define BOOST_ITEST_MOCK_FUNC( function_name ) \ - BOOST_ITEST_SCOPE( function_name ); \ - BOOST_ITEST_EPOINT( 0 ); \ - return ::autoboost::itest::mock_object<>::prototype(); \ -/**/ - -namespace autoboost { - -namespace itest { // interaction-based testing - -using unit_test::const_string; - -// ************************************************************************** // -// ************** manager ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL manager { -public: - // instance access - static manager& instance() { return *instance_ptr(); } - - // Mock objects interface hooks - virtual void exception_point( const_string /*file*/, - std::size_t /*line_num*/, - const_string /*descr*/ ){} - virtual bool decision_point( const_string /*file*/, - std::size_t /*line_num*/ ) { return true; } - virtual unsigned enter_scope( const_string /*file*/, - std::size_t /*line_num*/, - const_string /*scope_name*/){ return 0; } - virtual void leave_scope( unsigned ) {} - virtual void allocated( const_string /*file*/, - std::size_t /*line_num*/, - void* /*p*/, std::size_t /*s*/ ) {} - virtual void freed( void* /*p*/ ) {} - virtual void data_flow( const_string /*d*/ ) {} - virtual std::string return_value( const_string /*default_value */ ) { return ""; } - - template - void generic_data_flow( T const& t ) - { - wrap_stringstream ws; - - data_flow( (ws << t).str() ); - } - template - T generic_return( DefaultValueType const& dv ) - { - wrap_stringstream ws; - - std::string const& res = return_value( (ws << dv).str() ); - - if( res.empty() ) - return dv; - - return lexical_cast( res ); - } - -protected: - manager(); -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -public: -#endif - BOOST_TEST_PROTECTED_VIRTUAL ~manager(); - -private: - struct dummy_constr{}; - explicit manager( dummy_constr* ) {} - - static manager* instance_ptr( bool reset = false, manager* ptr = 0 ); -}; // manager - -// ************************************************************************** // -// ************** scope_guard ************** // -// ************************************************************************** // - -class scope_guard { -public: - // Constructor - scope_guard( const_string file, std::size_t line_num, const_string scope_name ) - { - m_scope_index = manager::instance().enter_scope( file, line_num, scope_name ); - } - ~scope_guard() - { - manager::instance().leave_scope( m_scope_index ); - } - - unsigned m_scope_index; -}; - -// ************************************************************************** // -// ************** location ************** // -// ************************************************************************** // - -struct location { - location( const_string file, std::size_t line ) - : m_file_name( file ) - , m_line_num( line ) - {} - - const_string m_file_name; - std::size_t m_line_num; -}; - -} // namespace itest - -} // namespace autoboost - -// ************************************************************************** // -// ************** operator new overload ************** // -// ************************************************************************** // - -#if !defined(BOOST_ITEST_NO_NEW_OVERLOADS) - -// STL -#include - -# ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::malloc; using ::free; } -# endif -# ifdef _CRTDBG_MAP_ALLOC -namespace std { using ::_malloc_dbg; using ::_free_dbg; } -# endif - -inline void* -operator new( std::size_t s, ::autoboost::itest::location const& l ) -{ - void* res = std::malloc(s ? s : 1); - - if( res ) - ::autoboost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s ); - else - throw std::bad_alloc(); - - return res; -} - -//____________________________________________________________________________// - -inline void* -operator new[]( std::size_t s, ::autoboost::itest::location const& l ) -{ - void* res = std::malloc(s ? s : 1); - - if( res ) - ::autoboost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s ); - else - throw std::bad_alloc(); - - return res; -} - -//____________________________________________________________________________// - -inline void -operator delete( void* p, ::autoboost::itest::location const& ) -{ - ::autoboost::itest::manager::instance().freed( p ); - - std::free( p ); -} - -//____________________________________________________________________________// - -inline void -operator delete[]( void* p, ::autoboost::itest::location const& ) -{ - ::autoboost::itest::manager::instance().freed( p ); - - std::free( p ); -} - -//____________________________________________________________________________// - -#endif - -#include - -#endif // BOOST_TEST_INTERACTION_BASED_HPP_112105GER diff --git a/contrib/autoboost/boost/test/mock_object.hpp b/contrib/autoboost/boost/test/mock_object.hpp deleted file mode 100644 index 5ffb4f1fc..000000000 --- a/contrib/autoboost/boost/test/mock_object.hpp +++ /dev/null @@ -1,328 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Facilities to perform exception safety_tests -// *************************************************************************** - -#ifndef BOOST_TEST_MOCK_OBJECT_HPP_112205GER -#define BOOST_TEST_MOCK_OBJECT_HPP_112205GER - -// Boost.Test -#include -#include - -// Boost -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace itest { - -// ************************************************************************** // -// ************** mock_object_base ************** // -// ************************************************************************** // - -class mock_object_base { -public: - mock_object_base() {} - - template - mock_object_base( T1 const& ) {} - - template - mock_object_base( T1 const&, T2 const& ) {} - - template - mock_object_base( T1 const&, T2 const&, T3 const& ) {} - - template - mock_object_base( T1 const&, T2 const&, T3 const&, T4 const& ) {} - - template - mock_object_base( T1 const&, T2 const&, T3 const&, T4 const&, T5 const& ) {} -}; - -// ************************************************************************** // -// ************** mock_object implementation helpers ************** // -// ************************************************************************** // - -#define MO_OP_IMPL( op, descr, ret ) \ - BOOST_ITEST_SCOPE( mock_object::operator op ); \ - BOOST_ITEST_EPOINT( descr ); \ - return ret \ -/**/ - -#define MO_UNARY_OP( op, descr ) \ -self_type const& operator op() const \ -{ \ - MO_OP_IMPL( op, descr, prototype() ); \ -} \ -/**/ - -#define MO_UNARY_BOOL_OP( op, descr ) \ -bool operator op() const \ -{ \ - MO_OP_IMPL( op, descr, (!!BOOST_ITEST_DPOINT()) ); \ -} \ -/**/ - -#define MO_BINARY_OP( op, descr ) \ -template \ -inline mock_object const& \ -operator op( mock_object const& mo, \ - mock_object const& ) \ -{ \ - MO_OP_IMPL( op, descr, mo ); \ -} \ - \ -template \ -inline mock_object const& \ -operator op( mock_object const& mo, T const& ) \ -{ \ - MO_OP_IMPL( op, descr, mo ); \ -} \ - \ -template \ -inline mock_object const& \ -operator op( T const&, mock_object const& mo ) \ -{ \ - MO_OP_IMPL( op, descr, mo ); \ -} \ -/**/ - -#define MO_BINARY_BOOL_OP( op, descr ) \ -template \ -inline bool \ -operator op( mock_object const&, \ - mock_object const& ) \ -{ \ - MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \ -} \ - \ -template \ -inline bool \ -operator op( mock_object const&, T const& ) \ -{ \ - MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \ -} \ - \ -template \ -inline bool \ -operator op( T const&, mock_object const& ) \ -{ \ - MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \ -} \ -/**/ - -// ************************************************************************** // -// ************** mock_object ************** // -// ************************************************************************** // - -template -class mock_object; - -template -class mock_object : public Base { - // Private typeefs - typedef mock_object self_type; - struct dummy { void nonnull() {}; }; - typedef void (dummy::*safe_bool)(); - - // prototype constructor - mock_object( dummy* ) {} - -public: - static mock_object& prototype() - { - static mock_object p( reinterpret_cast(0) ); - return p; - } - - // Constructors - mock_object() - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object default constructor" ); - } - - template - mock_object( T1 const& arg1 ) - : mock_object_base( arg1 ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object constructor" ); - } - - template - mock_object( T1 const& arg1, T2 const& arg2 ) - : mock_object_base( arg1, arg2 ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object constructor" ); - } - - template - mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3 ) - : mock_object_base( arg1, arg2, arg3 ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object constructor" ); - } - - template - mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 ) - : mock_object_base( arg1, arg2, arg3, arg4 ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object constructor" ); - } - - template - mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4, T5 const& arg5 ) - : mock_object_base( arg1, arg2, arg3, arg4, arg5 ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object constructor" ); - } - - mock_object( mock_object const& ) - { - BOOST_ITEST_SCOPE( mock_object::mock_object ); - BOOST_ITEST_EPOINT( "Mock object copy constructor" ); - } - - // assignment - self_type const& operator =( mock_object const& ) const - { - MO_OP_IMPL( =, "Copy assignment", prototype() ); - } - - template - self_type const& operator =( T const& ) const - { - MO_OP_IMPL( =, "Copy assignment", prototype() ); - } - - // Unary operators - MO_UNARY_BOOL_OP( !, "Logical NOT operator" ) - MO_UNARY_OP( &, "Address-of operator" ) - MO_UNARY_OP( ~, "One's complement operator" ) - MO_UNARY_OP( *, "Pointer dereference" ) - MO_UNARY_OP( +, "Unary plus" ) - - // Increment and Decrement - MO_UNARY_OP( ++, "Prefix increment" ) - MO_UNARY_OP( --, "Prefix decrement" ) - self_type const& operator ++(int) const - { - MO_OP_IMPL( ++, "Postfix increment", prototype() ); - } - self_type const& operator --(int) const - { - MO_OP_IMPL( --, "Postfix decrement", prototype() ); - } - - // Bool context convertion - operator safe_bool() const - { - MO_OP_IMPL( safe_bool, "Bool context conversion", - (BOOST_ITEST_DPOINT() ? 0 : &dummy::nonnull) ); - } - - // Function-call operators - self_type const& operator ()() const - { - MO_OP_IMPL( (), "0-arity function-call", prototype() ); - } - template - self_type const& operator ()( T1 const& arg1 ) const - { - MO_OP_IMPL( (), "1-arity function-call", prototype() ); - } - template - self_type const& operator ()( T1 const&, T2 const& ) const - { - MO_OP_IMPL( (), "2-arity function-call", prototype() ); - } - template - self_type const& operator ()( T1 const&, T2 const&, T3 const& ) const - { - MO_OP_IMPL( (), "3-arity function-call", prototype() ); - } - template - self_type const& operator ()( T1 const&, T2 const&, T3 const&, T4 const& ) const - { - MO_OP_IMPL( (), "4-arity function-call", prototype() ); - } - template - self_type const& operator ()( T1 const&, T2 const&, T3 const&, T4 const&, T5 const& ) const - { - MO_OP_IMPL( (), "5-arity function-call", prototype() ); - } - - // Substripting - template - self_type const& operator []( T const& ) const - { - MO_OP_IMPL( [], "Substripting", prototype() ); - } - - // Class member access - self_type const* operator->() const - { - MO_OP_IMPL( ->, "Class member access", this ); - } -}; - -// !! MO_BINARY_OP( BOOST_PP_COMMA(), "Comma operator" ) - -MO_BINARY_BOOL_OP( !=, "Inequality" ) -MO_BINARY_OP( %, "Modulus" ) -MO_BINARY_OP( %=, "Modulus/assignment" ) -MO_BINARY_OP( &, "Bitwise AND" ) -MO_BINARY_BOOL_OP( &&, "Logical AND" ) -MO_BINARY_OP( &=, "Bitwise AND/assignment" ) -MO_BINARY_OP( *, "Multiplication" ) -MO_BINARY_OP( *=, "Multiplication/assignment" ) -MO_BINARY_OP( +, "Addition" ) -MO_BINARY_OP( +=, "Addition/assignment" ) -//MO_BINARY_OP( -, "Subtraction" ) -MO_BINARY_OP( -=, "Subtraction/assignment" ) -MO_BINARY_OP( ->*, "Pointer-to-member selection" ) -MO_BINARY_OP( /, "Division" ) -MO_BINARY_OP( /=, "Division/assignment" ) -MO_BINARY_BOOL_OP( <, "Less than" ) -MO_BINARY_OP( <<=, "Left shift/assignment" ) -MO_BINARY_BOOL_OP( <=, "Less than or equal to" ) -MO_BINARY_BOOL_OP( ==, "Equality" ) -MO_BINARY_BOOL_OP( >, "Greater than" ) -MO_BINARY_BOOL_OP( >=, "Greater than or equal to" ) -MO_BINARY_OP( >>=, "Right shift/assignment" ) -MO_BINARY_OP( ^, "Exclusive OR" ) -MO_BINARY_OP( ^=, "Exclusive OR/assignment" ) -MO_BINARY_OP( |, "Bitwise inclusive OR" ) -MO_BINARY_OP( |=, "Bitwise inclusive OR/assignment" ) -MO_BINARY_BOOL_OP( ||, "Logical OR" ) - -MO_BINARY_OP( <<, "Left shift" ) -MO_BINARY_OP( >>, "Right shift" ) - -} // namespace itest - -} // namespace autoboost - -#include - -#endif // BOOST_TEST_MOCK_OBJECT_HPP_112205GER diff --git a/contrib/autoboost/boost/test/output/compiler_log_formatter.hpp b/contrib/autoboost/boost/test/output/compiler_log_formatter.hpp deleted file mode 100644 index 8a7393ca0..000000000 --- a/contrib/autoboost/boost/test/output/compiler_log_formatter.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains compiler like Log formatter definition -// *************************************************************************** - -#ifndef BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER -#define BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER - -// Boost.Test -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -// ************************************************************************** // -// ************** compiler_log_formatter ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL compiler_log_formatter : public unit_test_log_formatter { -public: - // Formatter interface - void log_start( std::ostream&, counter_t test_cases_amount ); - void log_finish( std::ostream& ); - void log_build_info( std::ostream& ); - - void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); - void test_unit_skipped( std::ostream&, test_unit const& tu ); - - void log_exception( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); - - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ); - void log_entry_value( std::ostream&, const_string value ); - void log_entry_value( std::ostream&, lazy_ostream const& value ); - void log_entry_finish( std::ostream& ); - -protected: - virtual void print_prefix( std::ostream&, const_string file, std::size_t line ); -}; - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER diff --git a/contrib/autoboost/boost/test/output/plain_report_formatter.hpp b/contrib/autoboost/boost/test/output/plain_report_formatter.hpp deleted file mode 100644 index 677e5107c..000000000 --- a/contrib/autoboost/boost/test/output/plain_report_formatter.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : plain report formatter implementation -// *************************************************************************** - -#ifndef BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER -#define BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER - -// Boost.Test -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -// ************************************************************************** // -// ************** plain_report_formatter ************** // -// ************************************************************************** // - -class plain_report_formatter : public results_reporter::format { -public: - // Formatter interface - void results_report_start( std::ostream& ostr ); - void results_report_finish( std::ostream& ostr ); - - void test_unit_report_start( test_unit const&, std::ostream& ostr ); - void test_unit_report_finish( test_unit const&, std::ostream& ostr ); - - void do_confirmation_report( test_unit const&, std::ostream& ostr ); - -private: - // Data members - counter_t m_indent; -}; - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER diff --git a/contrib/autoboost/boost/test/output/xml_log_formatter.hpp b/contrib/autoboost/boost/test/output/xml_log_formatter.hpp deleted file mode 100644 index a74309ee3..000000000 --- a/contrib/autoboost/boost/test/output/xml_log_formatter.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains XML Log formatter definition -// *************************************************************************** - -#ifndef BOOST_TEST_XML_LOG_FORMATTER_020105GER -#define BOOST_TEST_XML_LOG_FORMATTER_020105GER - -// Boost.Test -#include -#include - -// STL -#include // std::size_t - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -// ************************************************************************** // -// ************** xml_log_formatter ************** // -// ************************************************************************** // - -class xml_log_formatter : public unit_test_log_formatter { -public: - // Formatter interface - void log_start( std::ostream&, counter_t test_cases_amount ); - void log_finish( std::ostream& ); - void log_build_info( std::ostream& ); - - void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); - void test_unit_skipped( std::ostream&, test_unit const& tu ); - - void log_exception( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); - - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ); - using unit_test_log_formatter::log_entry_value; // bring base class functions into overload set - void log_entry_value( std::ostream&, const_string value ); - void log_entry_finish( std::ostream& ); - -private: - // Data members - const_string m_curr_tag; -}; - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_XML_LOG_FORMATTER_020105GER diff --git a/contrib/autoboost/boost/test/output/xml_report_formatter.hpp b/contrib/autoboost/boost/test/output/xml_report_formatter.hpp deleted file mode 100644 index 9a5c0fbb7..000000000 --- a/contrib/autoboost/boost/test/output/xml_report_formatter.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : XML report formatter implementation -// *************************************************************************** - -#ifndef BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER -#define BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER - -// Boost.Test -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace output { - -// ************************************************************************** // -// ************** xml_report_formatter ************** // -// ************************************************************************** // - -class xml_report_formatter : public results_reporter::format { -public: - // Formatter interface - void results_report_start( std::ostream& ostr ); - void results_report_finish( std::ostream& ostr ); - - void test_unit_report_start( test_unit const&, std::ostream& ostr ); - void test_unit_report_finish( test_unit const&, std::ostream& ostr ); - - void do_confirmation_report( test_unit const&, std::ostream& ostr ); -}; - -} // namespace output - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER diff --git a/contrib/autoboost/boost/test/output_test_stream.hpp b/contrib/autoboost/boost/test/output_test_stream.hpp deleted file mode 100644 index 329756d1c..000000000 --- a/contrib/autoboost/boost/test/output_test_stream.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : output_test_stream class definition -// *************************************************************************** - -#ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER -#define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER - -// Boost.Test -#include -#include -#include - -// STL -#include // for std::size_t - -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** output_test_stream ************** // -// ************************************************************************** // - -// class to be used to simplify testing of ostream-based output operations - -namespace autoboost { - -namespace test_tools { - -class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream { - typedef unit_test::const_string const_string; - typedef predicate_result result_type; -public: - // Constructor - explicit output_test_stream( const_string pattern_file_name = const_string(), - bool match_or_save = true, - bool text_or_binary = true ); - - // Destructor - ~output_test_stream(); - - // checking function - result_type is_empty( bool flush_stream = true ); - result_type check_length( std::size_t length, bool flush_stream = true ); - result_type is_equal( const_string arg_, bool flush_stream = true ); - result_type match_pattern( bool flush_stream = true ); - - // explicit flush - void flush(); - -private: - // helper functions - std::size_t length(); - void sync(); - - struct Impl; - Impl* m_pimpl; -}; - -} // namespace test_tools - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER diff --git a/contrib/autoboost/boost/test/predicate_result.hpp b/contrib/autoboost/boost/test/predicate_result.hpp deleted file mode 100644 index ff35e7752..000000000 --- a/contrib/autoboost/boost/test/predicate_result.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : enhanced result for test predicate that include message explaining failure -// *************************************************************************** - -#ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER -#define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER - -// Boost.Test -#include -#include -#include - -// Boost -#include -#include - -// STL -#include // for std::size_t - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace test_tools { - -// ************************************************************************** // -// ************** predicate_result ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL predicate_result { - typedef unit_test::const_string const_string; - struct dummy { void nonnull() {}; }; - typedef void (dummy::*safe_bool)(); - -public: - // Constructor - predicate_result( bool pv_ ) - : p_predicate_value( pv_ ) - {} - - template - predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {} - - // Access methods - bool operator!() const { return !p_predicate_value; } - void operator=( bool pv_ ) { p_predicate_value.value = pv_; } - operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; } - - // Public properties - BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value; - - // Access methods - bool has_empty_message() const { return !m_message; } - wrap_stringstream& message() - { - if( !m_message ) - m_message.reset( new wrap_stringstream ); - - return *m_message; - } - const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); } - -private: - // Data members - shared_ptr m_message; -}; - -} // namespace test_tools - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER diff --git a/contrib/autoboost/boost/test/progress_monitor.hpp b/contrib/autoboost/boost/test/progress_monitor.hpp deleted file mode 100644 index 6692d0766..000000000 --- a/contrib/autoboost/boost/test/progress_monitor.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines simple text based progress monitor -// *************************************************************************** - -#ifndef BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER -#define BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER - -// Boost.Test -#include -#include - -// STL -#include // for std::ostream& - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** progress_monitor ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL progress_monitor_t : public test_observer, public singleton { -public: - // test observer interface - void test_start( counter_t test_cases_amount ); - void test_finish() {} - void test_aborted(); - - void test_unit_start( test_unit const& ) {} - void test_unit_finish( test_unit const&, unsigned long ); - void test_unit_skipped( test_unit const& ); - void test_unit_aborted( test_unit const& ) {} - - void assertion_result( bool ) {} - void exception_caught( execution_exception const& ) {} - - // configuration - void set_stream( std::ostream& ); - -private: - BOOST_TEST_SINGLETON_CONS( progress_monitor_t ); -}; // progress_monitor_t - -BOOST_TEST_SINGLETON_INST( progress_monitor ) - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER - diff --git a/contrib/autoboost/boost/test/results_collector.hpp b/contrib/autoboost/boost/test/results_collector.hpp deleted file mode 100644 index 377270bba..000000000 --- a/contrib/autoboost/boost/test/results_collector.hpp +++ /dev/null @@ -1,112 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines class unit_test_result that is responsible for -// gathering test results and presenting this information to end-user -// *************************************************************************** - -#ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER -#define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER - -// Boost.Test -#include - -#include -#include - -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** first failed assertion debugger hook ************** // -// ************************************************************************** // - -namespace { -inline void first_failed_assertion() {} -} - -// ************************************************************************** // -// ************** test_results ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_results { -public: - test_results(); - - typedef BOOST_READONLY_PROPERTY( counter_t, (results_collector_t)(test_results)(results_collect_helper) ) counter_prop; - typedef BOOST_READONLY_PROPERTY( bool, (results_collector_t)(test_results)(results_collect_helper) ) bool_prop; - - counter_prop p_assertions_passed; - counter_prop p_assertions_failed; - counter_prop p_expected_failures; - counter_prop p_test_cases_passed; - counter_prop p_test_cases_failed; - counter_prop p_test_cases_skipped; - counter_prop p_test_cases_aborted; - bool_prop p_aborted; - bool_prop p_skipped; - - // "conclusion" methods - bool passed() const; - int result_code() const; - - // collection helper - void operator+=( test_results const& ); - - void clear(); -}; - -// ************************************************************************** // -// ************** results_collector ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton { -public: - // test_observer interface implementation - void test_start( counter_t test_cases_amount ); - void test_finish(); - void test_aborted(); - - void test_unit_start( test_unit const& ); - void test_unit_finish( test_unit const&, unsigned long elapsed ); - void test_unit_skipped( test_unit const& ); - void test_unit_aborted( test_unit const& ); - - void assertion_result( bool passed ); - void exception_caught( execution_exception const& ); - - // results access - test_results const& results( test_unit_id ) const; - -private: - BOOST_TEST_SINGLETON_CONS( results_collector_t ); -}; - -BOOST_TEST_SINGLETON_INST( results_collector ) - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/results_reporter.hpp b/contrib/autoboost/boost/test/results_reporter.hpp deleted file mode 100644 index b567a2cb2..000000000 --- a/contrib/autoboost/boost/test/results_reporter.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines class unit_test_result that is responsible for -// gathering test results and presenting this information to end-user -// *************************************************************************** - -#ifndef BOOST_TEST_RESULTS_REPORTER_HPP_021205GER -#define BOOST_TEST_RESULTS_REPORTER_HPP_021205GER - -// Boost.Test -#include -#include - -// STL -#include // for std::ostream& - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace results_reporter { - -// ************************************************************************** // -// ************** formatter interface ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL format { -public: - // Destructor - virtual ~format() {} - - virtual void results_report_start( std::ostream& ostr ) = 0; - virtual void results_report_finish( std::ostream& ostr ) = 0; - - virtual void test_unit_report_start( test_unit const&, std::ostream& ostr ) = 0; - virtual void test_unit_report_finish( test_unit const&, std::ostream& ostr ) = 0; - - virtual void do_confirmation_report( test_unit const&, std::ostream& ostr ) = 0; -}; - -// ************************************************************************** // -// ************** report configuration ************** // -// ************************************************************************** // - -BOOST_TEST_DECL void set_level( report_level ); -BOOST_TEST_DECL void set_stream( std::ostream& ); -BOOST_TEST_DECL void set_format( output_format ); -BOOST_TEST_DECL void set_format( results_reporter::format* ); - -BOOST_TEST_DECL std::ostream& get_stream(); - -// ************************************************************************** // -// ************** report initiation ************** // -// ************************************************************************** // - -BOOST_TEST_DECL void make_report( report_level l = INV_REPORT_LEVEL, test_unit_id = INV_TEST_UNIT_ID ); -inline void confirmation_report( test_unit_id id = INV_TEST_UNIT_ID ) -{ make_report( CONFIRMATION_REPORT, id ); } -inline void short_report( test_unit_id id = INV_TEST_UNIT_ID ) -{ make_report( SHORT_REPORT, id ); } -inline void detailed_report( test_unit_id id = INV_TEST_UNIT_ID ) -{ make_report( DETAILED_REPORT, id ); } - -} // namespace results_reporter - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_RESULTS_REPORTER_HPP_021205GER - diff --git a/contrib/autoboost/boost/test/test_observer.hpp b/contrib/autoboost/boost/test/test_observer.hpp deleted file mode 100644 index bae5f2753..000000000 --- a/contrib/autoboost/boost/test/test_observer.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines abstract interface for test observer -// *************************************************************************** - -#ifndef BOOST_TEST_TEST_OBSERVER_HPP_021005GER -#define BOOST_TEST_TEST_OBSERVER_HPP_021005GER - -// Boost.Test -#include -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_observer ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_observer { -public: - // test observer interface - virtual void test_start( counter_t /* test_cases_amount */ ) {} - virtual void test_finish() {} - virtual void test_aborted() {} - - virtual void test_unit_start( test_unit const& ) {} - virtual void test_unit_finish( test_unit const&, unsigned long /* elapsed */ ) {} - virtual void test_unit_skipped( test_unit const& ) {} - virtual void test_unit_aborted( test_unit const& ) {} - - virtual void assertion_result( bool /* passed */ ) {} - virtual void exception_caught( execution_exception const& ) {} - - virtual int priority() { return 0; } - -protected: - BOOST_TEST_PROTECTED_VIRTUAL ~test_observer() {} -}; - -} // unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TEST_OBSERVER_HPP_021005GER - diff --git a/contrib/autoboost/boost/test/test_tools.hpp b/contrib/autoboost/boost/test/test_tools.hpp deleted file mode 100644 index 9bf7bcc1f..000000000 --- a/contrib/autoboost/boost/test/test_tools.hpp +++ /dev/null @@ -1,719 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains definition for all test tools in test toolbox -// *************************************************************************** - -#ifndef BOOST_TEST_TEST_TOOLS_HPP_012705GER -#define BOOST_TEST_TEST_TOOLS_HPP_012705GER - -// Boost.Test -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -// Boost -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -// STL -#include // for std::size_t -#include -#include // for std::boolalpha -#include // for CHAR_BIT - -#ifdef BOOST_MSVC -# pragma warning(disable: 4127) // conditional expression is constant -#endif - -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** TOOL BOX ************** // -// ************************************************************************** // - -// In macros below following argument abbreviations are used: -// P - predicate -// M - message -// S - statement -// E - exception -// L - left argument -// R - right argument -// TL - tool level -// CT - check type -// ARGS - arguments list - -#define BOOST_TEST_TOOL_IMPL( func, P, check_descr, TL, CT ) \ - ::autoboost::test_tools::tt_detail::func( \ - P, \ - ::autoboost::unit_test::lazy_ostream::instance() << check_descr, \ - BOOST_TEST_L(__FILE__), \ - static_cast(__LINE__), \ - ::autoboost::test_tools::tt_detail::TL, \ - ::autoboost::test_tools::tt_detail::CT \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \ -do { \ - BOOST_TEST_PASSPOINT(); \ - BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\ -} while( ::autoboost::test_tools::dummy_cond ) \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_TEST_PASS_ARG_INFO( r, data, arg ) , arg, BOOST_STRINGIZE( arg ) - -#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \ -do { \ - BOOST_TEST_PASSPOINT(); \ - BOOST_TEST_TOOL_IMPL( check_frwd, P, check_descr, TL, CT ) \ - BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \ -} while( ::autoboost::test_tools::dummy_cond ) \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_WARN( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED ) -#define BOOST_CHECK( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED ) -#define BOOST_REQUIRE( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED ) - -//____________________________________________________________________________// - -#define BOOST_WARN_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, WARN, CHECK_MSG ) -#define BOOST_CHECK_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, CHECK, CHECK_MSG ) -#define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, REQUIRE, CHECK_MSG ) - -//____________________________________________________________________________// - -#define BOOST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M ) -#define BOOST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M ) - -//____________________________________________________________________________// - -#define BOOST_CHECK_THROW_IMPL( S, E, P, prefix, TL ) \ - try { \ - BOOST_TEST_PASSPOINT(); \ - S; \ - BOOST_CHECK_IMPL( false, "exception " BOOST_STRINGIZE( E ) " is expected", TL, CHECK_MSG ); } \ - catch( E const& ex ) { \ - ::autoboost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \ - BOOST_CHECK_IMPL( P, prefix BOOST_STRINGIZE( E ) " is caught", TL, CHECK_MSG ); \ - } \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_WARN_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", WARN ) -#define BOOST_CHECK_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", CHECK ) -#define BOOST_REQUIRE_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", REQUIRE ) - -//____________________________________________________________________________// - -#define BOOST_WARN_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", WARN ) -#define BOOST_CHECK_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", CHECK ) -#define BOOST_REQUIRE_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", REQUIRE ) - -//____________________________________________________________________________// - -#define BOOST_CHECK_NO_THROW_IMPL( S, TL ) \ - try { \ - S; \ - BOOST_CHECK_IMPL( true, "no exceptions thrown by " BOOST_STRINGIZE( S ), TL, CHECK_MSG ); } \ - catch( ... ) { \ - BOOST_CHECK_IMPL( false, "exception thrown by " BOOST_STRINGIZE( S ), TL, CHECK_MSG ); \ - } \ -/**/ - -#define BOOST_WARN_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, WARN ) -#define BOOST_CHECK_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, CHECK ) -#define BOOST_REQUIRE_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, REQUIRE ) - -//____________________________________________________________________________// - -#define BOOST_WARN_EQUAL( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::equal_impl_frwd(), "", WARN, CHECK_EQUAL, (L)(R) ) -#define BOOST_CHECK_EQUAL( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::equal_impl_frwd(), "", CHECK, CHECK_EQUAL, (L)(R) ) -#define BOOST_REQUIRE_EQUAL( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::equal_impl_frwd(), "", REQUIRE, CHECK_EQUAL, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_NE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R) ) -#define BOOST_CHECK_NE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R) ) -#define BOOST_REQUIRE_NE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_LT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R) ) -#define BOOST_CHECK_LT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R) ) -#define BOOST_REQUIRE_LT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_LE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R) ) -#define BOOST_CHECK_LE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R) ) -#define BOOST_REQUIRE_LE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_GT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R) ) -#define BOOST_CHECK_GT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R) ) -#define BOOST_REQUIRE_GT( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_GE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R) ) -#define BOOST_CHECK_GE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R) ) -#define BOOST_REQUIRE_GE( L, R ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_CLOSE( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", WARN, CHECK_CLOSE, \ - (L)(R)(::autoboost::test_tools::percent_tolerance(T)) ) -#define BOOST_CHECK_CLOSE( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE, \ - (L)(R)(::autoboost::test_tools::percent_tolerance(T)) ) -#define BOOST_REQUIRE_CLOSE( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE, \ - (L)(R)(::autoboost::test_tools::percent_tolerance(T)) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_CLOSE_FRACTION( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", WARN, CHECK_CLOSE_FRACTION, \ - (L)(R)(::autoboost::test_tools::fraction_tolerance(T)) ) -#define BOOST_CHECK_CLOSE_FRACTION( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE_FRACTION, \ - (L)(R)(::autoboost::test_tools::fraction_tolerance(T)) ) -#define BOOST_REQUIRE_CLOSE_FRACTION( L, R, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE_FRACTION, \ - (L)(R)(::autoboost::test_tools::fraction_tolerance(T)) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_SMALL( FPV, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_small, "", WARN, CHECK_SMALL, (FPV)(T) ) -#define BOOST_CHECK_SMALL( FPV, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_small, "", CHECK, CHECK_SMALL, (FPV)(T) ) -#define BOOST_REQUIRE_SMALL( FPV, T ) \ - BOOST_CHECK_WITH_ARGS_IMPL( ::autoboost::test_tools::check_is_small, "", REQUIRE, CHECK_SMALL, (FPV)(T) ) - -//____________________________________________________________________________// - -#define BOOST_WARN_PREDICATE( P, ARGS ) \ - BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED_WITH_ARGS, ARGS ) -#define BOOST_CHECK_PREDICATE( P, ARGS ) \ - BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED_WITH_ARGS, ARGS ) -#define BOOST_REQUIRE_PREDICATE( P, ARGS ) \ - BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED_WITH_ARGS, ARGS ) - -//____________________________________________________________________________// - -#define BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, TL ) \ - BOOST_TEST_TOOL_IMPL( check_impl, ::autoboost::test_tools::tt_detail::equal_coll_impl( \ - (L_begin), (L_end), (R_begin), (R_end) ), "", TL, CHECK_EQUAL_COLL ), \ - 4, \ - BOOST_STRINGIZE( L_begin ), BOOST_STRINGIZE( L_end ), \ - BOOST_STRINGIZE( R_begin ), BOOST_STRINGIZE( R_end ) ) \ -/**/ - -#define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \ - BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, WARN ) -#define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \ - BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, CHECK ) -#define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \ - BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, REQUIRE ) - -//____________________________________________________________________________// - -#define BOOST_BITWISE_EQUAL_IMPL( L, R, TL ) \ - BOOST_TEST_TOOL_IMPL( check_impl, \ - ::autoboost::test_tools::tt_detail::bitwise_equal_impl( (L), (R) ), \ - "", TL, CHECK_BITWISE_EQUAL ), \ - 2, BOOST_STRINGIZE( L ), BOOST_STRINGIZE( R ) ) \ -/**/ - -#define BOOST_WARN_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, WARN ) -#define BOOST_CHECK_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, CHECK ) -#define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, REQUIRE ) - -//____________________________________________________________________________// - -#define BOOST_IS_DEFINED( symb ) ::autoboost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) ) - -//____________________________________________________________________________// - -// ***************************** // -// deprecated interface - -#define BOOST_BITWISE_EQUAL( L, R ) BOOST_CHECK_BITWISE_EQUAL( L, R ) -#define BOOST_MESSAGE( M ) BOOST_TEST_MESSAGE( M ) -#define BOOST_CHECKPOINT( M ) BOOST_TEST_CHECKPOINT( M ) - -namespace autoboost { - -namespace test_tools { - -typedef unit_test::const_string const_string; - -namespace { bool dummy_cond = false; } - -// ************************************************************************** // -// ************** print_log_value ************** // -// ************************************************************************** // - -template -struct print_log_value { - void operator()( std::ostream& ostr, T const& t ) - { - // avoid warning: 'autoboost::test_tools::::dummy_cond' defined but not used - if (::autoboost::test_tools::dummy_cond) {} - - typedef typename mpl::or_,is_function,is_abstract >::type cant_use_nl; - - set_precision( ostr, cant_use_nl() ); - - ostr << t; // by default print the value - } - - void set_precision( std::ostream& ostr, mpl::false_ ) - { - if( std::numeric_limits::is_specialized && std::numeric_limits::radix == 2 ) - ostr.precision( 2 + std::numeric_limits::digits * 301/1000 ); - } - - void set_precision( std::ostream&, mpl::true_ ) {} -}; - -//____________________________________________________________________________// - -#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \ -namespace autoboost { namespace test_tools { \ -template<> \ -struct print_log_value { \ - void operator()( std::ostream&, the_type const& ) {} \ -}; \ -}} \ -/**/ - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -template -struct print_log_value< T[N] > { - void operator()( std::ostream& ostr, T const* t ) - { - ostr << t; - } -}; -#endif - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, bool t ) - { - ostr << std::boolalpha << t; - } -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, char t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, unsigned char t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, char const* t ); -}; - -//____________________________________________________________________________// - -template<> -struct BOOST_TEST_DECL print_log_value { - void operator()( std::ostream& ostr, wchar_t const* t ); -}; - -//____________________________________________________________________________// - -namespace tt_detail { - -// ************************************************************************** // -// ************** tools classification ************** // -// ************************************************************************** // - -enum check_type { - CHECK_PRED, - CHECK_MSG, - CHECK_EQUAL, - CHECK_NE, - CHECK_LT, - CHECK_LE, - CHECK_GT, - CHECK_GE, - CHECK_CLOSE, - CHECK_CLOSE_FRACTION, - CHECK_SMALL, - CHECK_BITWISE_EQUAL, - CHECK_PRED_WITH_ARGS, - CHECK_EQUAL_COLL -}; - -enum tool_level { - WARN, CHECK, REQUIRE, PASS -}; - -// ************************************************************************** // -// ************** print_helper ************** // -// ************************************************************************** // -// Adds level of indirection to the output operation, allowing us to customize -// it for types that do not support operator << directly or for any other reason - -template -struct print_helper_t { - explicit print_helper_t( T const& t ) : m_t( t ) {} - - T const& m_t; -}; - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// Borland suffers premature pointer decay passing arrays by reference -template -struct print_helper_t< T[N] > { - explicit print_helper_t( T const * t ) : m_t( t ) {} - - T const * m_t; -}; -#endif - -//____________________________________________________________________________// - -template -inline print_helper_t print_helper( T const& t ) -{ - return print_helper_t( t ); -} - -//____________________________________________________________________________// - -template -inline std::ostream& -operator<<( std::ostream& ostr, print_helper_t const& ph ) -{ - print_log_value()( ostr, ph.m_t ); - - return ostr; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** TOOL BOX Implementation ************** // -// ************************************************************************** // - -BOOST_TEST_DECL -bool check_impl( predicate_result const& pr, ::autoboost::unit_test::lazy_ostream const& check_descr, - const_string file_name, std::size_t line_num, - tool_level tl, check_type ct, - std::size_t num_args, ... ); - -//____________________________________________________________________________// - -#define TEMPL_PARAMS( z, m, dummy ) , typename BOOST_JOIN( Arg, m ) -#define FUNC_PARAMS( z, m, dummy ) \ - , BOOST_JOIN( Arg, m ) const& BOOST_JOIN( arg, m ) \ - , char const* BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ -/**/ - -#define PRED_PARAMS( z, m, dummy ) BOOST_PP_COMMA_IF( m ) BOOST_JOIN( arg, m ) - -#define ARG_INFO( z, m, dummy ) \ - , BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \ - , &static_cast(unit_test::lazy_ostream::instance() \ - << ::autoboost::test_tools::tt_detail::print_helper( BOOST_JOIN( arg, m ) )) \ -/**/ - -#define IMPL_FRWD( z, n, dummy ) \ -template \ -inline bool \ -check_frwd( Pred P, unit_test::lazy_ostream const& check_descr, \ - const_string file_name, std::size_t line_num, \ - tool_level tl, check_type ct \ - BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), FUNC_PARAMS, _ ) \ -) \ -{ \ - return \ - check_impl( P( BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), PRED_PARAMS, _ ) ), \ - check_descr, file_name, line_num, tl, ct, \ - BOOST_PP_ADD( n, 1 ) \ - BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) \ - ); \ -} \ -/**/ - -#ifndef BOOST_TEST_MAX_PREDICATE_ARITY -#define BOOST_TEST_MAX_PREDICATE_ARITY 5 -#endif - -BOOST_PP_REPEAT( BOOST_TEST_MAX_PREDICATE_ARITY, IMPL_FRWD, _ ) - -#undef TEMPL_PARAMS -#undef FUNC_PARAMS -#undef PRED_INFO -#undef ARG_INFO -#undef IMPL_FRWD - -//____________________________________________________________________________// - -template -predicate_result equal_impl( Left const& left, Right const& right ) -{ - return left == right; -} - -//____________________________________________________________________________// - -predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right ); -inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( char* left, char* right ) { return equal_impl( static_cast(left), static_cast(right) ); } - -#if !defined( BOOST_NO_CWCHAR ) -predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right ); -inline predicate_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -inline predicate_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast(left), static_cast(right) ); } -#endif - -//____________________________________________________________________________// - -struct equal_impl_frwd { - template - inline predicate_result - call_impl( Left const& left, Right const& right, mpl::false_ ) const - { - return equal_impl( left, right ); - } - - template - inline predicate_result - call_impl( Left const& left, Right const& right, mpl::true_ ) const - { - return (*this)( right, &left[0] ); - } - - template - inline predicate_result - operator()( Left const& left, Right const& right ) const - { - typedef typename is_array::type left_is_array; - return call_impl( left, right, left_is_array() ); - } -}; - -//____________________________________________________________________________// - -struct ne_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return !equal_impl_frwd()( left, right ); - } -}; - -//____________________________________________________________________________// - -struct lt_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left < right; - } -}; - -//____________________________________________________________________________// - -struct le_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left <= right; - } -}; - -//____________________________________________________________________________// - -struct gt_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left > right; - } -}; - -//____________________________________________________________________________// - -struct ge_impl { - template - predicate_result operator()( Left const& left, Right const& right ) - { - return left >= right; - } -}; - -//____________________________________________________________________________// - -template -inline predicate_result -equal_coll_impl( Left left_begin, Left left_end, Right right_begin, Right right_end ) -{ - predicate_result res( true ); - std::size_t pos = 0; - - for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) { - if( *left_begin != *right_begin ) { - res = false; - res.message() << "\nMismatch in a position " << pos << ": " << *left_begin << " != " << *right_begin; - } - } - - if( left_begin != left_end ) { - std::size_t r_size = pos; - while( left_begin != left_end ) { - ++pos; - ++left_begin; - } - - res = false; - res.message() << "\nCollections size mismatch: " << pos << " != " << r_size; - } - - if( right_begin != right_end ) { - std::size_t l_size = pos; - while( right_begin != right_end ) { - ++pos; - ++right_begin; - } - - res = false; - res.message() << "\nCollections size mismatch: " << l_size << " != " << pos; - } - - return res; -} - -//____________________________________________________________________________// - -template -inline predicate_result -bitwise_equal_impl( Left const& left, Right const& right ) -{ - predicate_result res( true ); - - std::size_t left_bit_size = sizeof(Left)*CHAR_BIT; - std::size_t right_bit_size = sizeof(Right)*CHAR_BIT; - - static Left const leftOne( 1 ); - static Right const rightOne( 1 ); - - std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size; - - for( std::size_t counter = 0; counter < total_bits; ++counter ) { - if( ( left & ( leftOne << counter ) ) != ( right & ( rightOne << counter ) ) ) { - res = false; - res.message() << "\nMismatch in a position " << counter; - } - } - - if( left_bit_size != right_bit_size ) { - res = false; - res.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size; - } - - return res; -} - -//____________________________________________________________________________// - -bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value ); - -//____________________________________________________________________________// - -} // namespace tt_detail - -} // namespace test_tools - -namespace test_toolbox = test_tools; - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TEST_TOOLS_HPP_012705GER diff --git a/contrib/autoboost/boost/test/unit_test.hpp b/contrib/autoboost/boost/test/unit_test.hpp deleted file mode 100644 index b3b487137..000000000 --- a/contrib/autoboost/boost/test/unit_test.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Entry point for the end user into the Unit Test Framework. -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_HPP_071894GER - -// Boost.Test -#include -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** Auto Linking ************** // -// ************************************************************************** // - -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TEST_NO_LIB) && \ - !defined(BOOST_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED) -# define BOOST_LIB_NAME autoboost_unit_test_framework - -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEST_DYN_LINK) -# define BOOST_DYN_LINK -# endif - -# include - -#endif // auto-linking disabled - -// ************************************************************************** // -// ************** unit_test_main ************** // -// ************************************************************************** // - -namespace autoboost { namespace unit_test { - -int BOOST_TEST_DECL unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ); - -}} - -#if defined(BOOST_TEST_DYN_LINK) && defined(BOOST_TEST_MAIN) && !defined(BOOST_TEST_NO_MAIN) - -// ************************************************************************** // -// ************** main function for tests using dll ************** // -// ************************************************************************** // - -int BOOST_TEST_CALL_DECL -main( int argc, char* argv[] ) -{ - return ::autoboost::unit_test::unit_test_main( &init_unit_test, argc, argv ); -} - -//____________________________________________________________________________// - -#endif // BOOST_TEST_DYN_LINK && BOOST_TEST_MAIN && !BOOST_TEST_NO_MAIN - -#endif // BOOST_TEST_UNIT_TEST_HPP_071894GER diff --git a/contrib/autoboost/boost/test/unit_test_log.hpp b/contrib/autoboost/boost/test/unit_test_log.hpp deleted file mode 100644 index 10932ec93..000000000 --- a/contrib/autoboost/boost/test/unit_test_log.hpp +++ /dev/null @@ -1,177 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines singleton class unit_test_log and all manipulators. -// unit_test_log has output stream like interface. It's implementation is -// completely hidden with pimple idiom -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER - -// Boost.Test -#include - -#include -#include -#include - -#include -#include -#include - -// Boost -#include - -// STL -#include // for std::ostream& - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** log manipulators ************** // -// ************************************************************************** // - -namespace log { - -struct BOOST_TEST_DECL begin { - begin( const_string fn, std::size_t ln ) - : m_file_name( fn ) - , m_line_num( ln ) - {} - - const_string m_file_name; - std::size_t m_line_num; -}; - -struct end {}; - -} // namespace log - -// ************************************************************************** // -// ************** entry_value_collector ************** // -// ************************************************************************** // - -namespace ut_detail { - -class BOOST_TEST_DECL entry_value_collector { -public: - // Constructors - entry_value_collector() : m_last( true ) {} - entry_value_collector( entry_value_collector const& rhs ) : m_last( true ) { rhs.m_last = false; } - ~entry_value_collector(); - - // collection interface - entry_value_collector const& operator<<( lazy_ostream const& ) const; - entry_value_collector const& operator<<( const_string ) const; - -private: - // Data members - mutable bool m_last; -}; - -} // namespace ut_detail - -// ************************************************************************** // -// ************** unit_test_log ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton { -public: - // test_observer interface implementation - void test_start( counter_t test_cases_amount ); - void test_finish(); - void test_aborted(); - - void test_unit_start( test_unit const& ); - void test_unit_finish( test_unit const&, unsigned long elapsed ); - void test_unit_skipped( test_unit const& ); - void test_unit_aborted( test_unit const& ); - - void assertion_result( bool passed ); - void exception_caught( execution_exception const& ); - - virtual int priority() { return 1; } - - // log configuration methods - void set_stream( std::ostream& ); - void set_threshold_level( log_level ); - void set_format( output_format ); - void set_formatter( unit_test_log_formatter* ); - - // test progress logging - void set_checkpoint( const_string file, std::size_t line_num, const_string msg = const_string() ); - - // entry logging - unit_test_log_t& operator<<( log::begin const& ); // begin entry - unit_test_log_t& operator<<( log::end const& ); // end entry - unit_test_log_t& operator<<( log_level ); // set entry level - unit_test_log_t& operator<<( const_string ); // log entry value - unit_test_log_t& operator<<( lazy_ostream const& ); // log entry value - - ut_detail::entry_value_collector operator()( log_level ); // initiate entry collection - -private: - bool log_entry_start(); - - BOOST_TEST_SINGLETON_CONS( unit_test_log_t ); -}; // unit_test_log_t - -BOOST_TEST_SINGLETON_INST( unit_test_log ) - -// helper macros -#define BOOST_TEST_LOG_ENTRY( ll ) \ - (::autoboost::unit_test::unit_test_log \ - << ::autoboost::unit_test::log::begin( BOOST_TEST_L(__FILE__), __LINE__ ))(ll) \ -/**/ - -} // namespace unit_test - -} // namespace autoboost - -// ************************************************************************** // -// ************** Unit test log interface helpers ************** // -// ************************************************************************** // - -#define BOOST_TEST_MESSAGE( M ) \ - BOOST_TEST_LOG_ENTRY( ::autoboost::unit_test::log_messages ) \ - << (::autoboost::unit_test::lazy_ostream::instance() << M) \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_TEST_PASSPOINT() \ - ::autoboost::unit_test::unit_test_log.set_checkpoint( \ - BOOST_TEST_L(__FILE__), \ - static_cast(__LINE__) ) \ -/**/ - -//____________________________________________________________________________// - -#define BOOST_TEST_CHECKPOINT( M ) \ - ::autoboost::unit_test::unit_test_log.set_checkpoint( \ - BOOST_TEST_L(__FILE__), \ - static_cast(__LINE__), \ - (::autoboost::wrap_stringstream().ref() << M).str() ) \ -/**/ - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/unit_test_log_formatter.hpp b/contrib/autoboost/boost/test/unit_test_log_formatter.hpp deleted file mode 100644 index c3b52d038..000000000 --- a/contrib/autoboost/boost/test/unit_test_log_formatter.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2003-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER - -// Boost.Test -#include -#include -#include - -#include - -// STL -#include -#include // for std::string - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** log_entry_data ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL log_entry_data { - log_entry_data() - { - m_file_name.reserve( 200 ); - } - - std::string m_file_name; - std::size_t m_line_num; - log_level m_level; - - void clear() - { - m_file_name.erase(); - m_line_num = 0; - m_level = log_nothing; - } -}; - -// ************************************************************************** // -// ************** checkpoint_data ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL log_checkpoint_data -{ - const_string m_file_name; - std::size_t m_line_num; - std::string m_message; - - void clear() - { - m_file_name.clear(); - m_line_num = 0; - m_message = std::string(); - } -}; - -// ************************************************************************** // -// ************** unit_test_log_formatter ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL unit_test_log_formatter { -public: - enum log_entry_types { BOOST_UTL_ET_INFO, - BOOST_UTL_ET_MESSAGE, - BOOST_UTL_ET_WARNING, - BOOST_UTL_ET_ERROR, - BOOST_UTL_ET_FATAL_ERROR }; - - // Destructor - virtual ~unit_test_log_formatter() {} - - // Formatter interface - virtual void log_start( std::ostream&, counter_t test_cases_amount ) = 0; - virtual void log_finish( std::ostream& ) = 0; - virtual void log_build_info( std::ostream& ) = 0; - - virtual void test_unit_start( std::ostream&, test_unit const& tu ) = 0; - virtual void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) = 0; - virtual void test_unit_skipped( std::ostream&, test_unit const& ) = 0; - - virtual void log_exception( std::ostream& os, log_checkpoint_data const& cd, execution_exception const& ex ) - { - // for backward compatibility - log_exception( os, cd, ex.what() ); - } - virtual void log_exception( std::ostream&, log_checkpoint_data const&, const_string /* explanation */ ) {} - - virtual void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) = 0; - virtual void log_entry_value( std::ostream&, const_string value ) = 0; - virtual void log_entry_value( std::ostream&, lazy_ostream const& value ); // there is a default impl - virtual void log_entry_finish( std::ostream& ) = 0; -}; - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/unit_test_monitor.hpp b/contrib/autoboost/boost/test/unit_test_monitor.hpp deleted file mode 100644 index 26aa7c762..000000000 --- a/contrib/autoboost/boost/test/unit_test_monitor.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines specific version of execution monitor used to managed -// run unit of test cases. Translates execution exception into error level -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER -#define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER - -// Boost.Test -#include -#include -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** unit_test_monitor ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL unit_test_monitor_t : public singleton, public execution_monitor { -public: - enum error_level { - test_fail = 1, - test_ok = 0, - constructor_error = -1, - unexpected_exception = -2, - os_exception = -3, - os_timeout = -4, - fatal_error = -5, // includes both system and user - destructor_error = -6 - }; - - static bool is_critical_error( error_level e ) { return e <= fatal_error; } - - // monitor method - error_level execute_and_translate( test_case const& ); - -private: - BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t ); -}; - -BOOST_TEST_SINGLETON_INST( unit_test_monitor ) - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER diff --git a/contrib/autoboost/boost/test/unit_test_suite.hpp b/contrib/autoboost/boost/test/unit_test_suite.hpp deleted file mode 100644 index 75b72706f..000000000 --- a/contrib/autoboost/boost/test/unit_test_suite.hpp +++ /dev/null @@ -1,245 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines Unit Test Framework public API -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER - -// Boost.Test -#include -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** Non-auto (explicit) test case interface ************** // -// ************************************************************************** // - -#define BOOST_TEST_CASE( test_function ) \ -autoboost::unit_test::make_test_case( autoboost::unit_test::callback0<>(test_function), BOOST_TEST_STRINGIZE( test_function ) ) -#define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ -autoboost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance ) - -// ************************************************************************** // -// ************** BOOST_TEST_SUITE ************** // -// ************************************************************************** // - -#define BOOST_TEST_SUITE( testsuite_name ) \ -( new autoboost::unit_test::test_suite( testsuite_name ) ) - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_SUITE ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TEST_SUITE( suite_name ) \ -namespace suite_name { \ -BOOST_AUTO_TU_REGISTRAR( suite_name )( BOOST_STRINGIZE( suite_name ) ); \ -/**/ - -// ************************************************************************** // -// ************** BOOST_FIXTURE_TEST_SUITE ************** // -// ************************************************************************** // - -#define BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \ -BOOST_AUTO_TEST_SUITE( suite_name ) \ -typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \ -/**/ - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_SUITE_END ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TEST_SUITE_END() \ -BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \ -} \ -/**/ - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \ -struct BOOST_AUTO_TC_UNIQUE_ID( test_name ); \ - \ -static struct BOOST_JOIN( test_name, _exp_fail_num_spec ) \ -: autoboost::unit_test::ut_detail:: \ - auto_tc_exp_fail \ -{ \ - BOOST_JOIN( test_name, _exp_fail_num_spec )() \ - : autoboost::unit_test::ut_detail:: \ - auto_tc_exp_fail( n ) \ - {} \ -} BOOST_JOIN( test_name, _exp_fail_num_spec_inst ); \ - \ -/**/ - -// ************************************************************************** // -// ************** BOOST_FIXTURE_TEST_CASE ************** // -// ************************************************************************** // - -#define BOOST_FIXTURE_TEST_CASE( test_name, F ) \ -struct test_name : public F { void test_method(); }; \ - \ -static void BOOST_AUTO_TC_INVOKER( test_name )() \ -{ \ - test_name t; \ - t.test_method(); \ -} \ - \ -struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \ - \ -BOOST_AUTO_TU_REGISTRAR( test_name )( \ - autoboost::unit_test::make_test_case( \ - &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \ - autoboost::unit_test::ut_detail::auto_tc_exp_fail< \ - BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \ - \ -void test_name::test_method() \ -/**/ - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_CASE ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TEST_CASE( test_name ) \ -BOOST_FIXTURE_TEST_CASE( test_name, BOOST_AUTO_TEST_CASE_FIXTURE ) -/**/ - -// ************************************************************************** // -// ************** BOOST_FIXTURE_TEST_CASE_TEMPLATE ************** // -// ************************************************************************** // - -#define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \ -template \ -struct test_name : public F \ -{ void test_method(); }; \ - \ -struct BOOST_AUTO_TC_INVOKER( test_name ) { \ - template \ - static void run( autoboost::type* = 0 ) \ - { \ - test_name t; \ - t.test_method(); \ - } \ -}; \ - \ -BOOST_AUTO_TU_REGISTRAR( test_name )( \ - autoboost::unit_test::ut_detail::template_test_case_gen< \ - BOOST_AUTO_TC_INVOKER( test_name ),TL >( \ - BOOST_STRINGIZE( test_name ) ) ); \ - \ -template \ -void test_name::test_method() \ -/**/ - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_CASE_TEMPLATE ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \ -BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, BOOST_AUTO_TEST_CASE_FIXTURE ) - -// ************************************************************************** // -// ************** BOOST_TEST_CASE_TEMPLATE ************** // -// ************************************************************************** // - -#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \ - autoboost::unit_test::ut_detail::template_test_case_gen( \ - BOOST_TEST_STRINGIZE( name ) ) \ -/**/ - -// ************************************************************************** // -// ************** BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** // -// ************************************************************************** // - -#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \ -template \ -void BOOST_JOIN( name, _impl )( autoboost::type* ); \ - \ -struct name { \ - template \ - static void run( autoboost::type* frwrd = 0 ) \ - { \ - BOOST_JOIN( name, _impl )( frwrd ); \ - } \ -}; \ - \ -template \ -void BOOST_JOIN( name, _impl )( autoboost::type* ) \ -/**/ - -// ************************************************************************** // -// ************** BOOST_GLOBAL_FIXURE ************** // -// ************************************************************************** // - -#define BOOST_GLOBAL_FIXTURE( F ) \ -static autoboost::unit_test::ut_detail::global_fixture_impl BOOST_JOIN( gf_, F ) ; \ -/**/ - -// ************************************************************************** // -// ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** // -// ************************************************************************** // - -namespace autoboost { namespace unit_test { namespace ut_detail { - -struct nil_t {}; - -} // namespace ut_detail -} // unit_test -} // namespace autoboost - -// Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code. -typedef ::autoboost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE; - -// ************************************************************************** // -// ************** Auto registration facility helper macros ************** // -// ************************************************************************** // - -#define BOOST_AUTO_TU_REGISTRAR( test_name ) \ -static autoboost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ ) -#define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker ) -#define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id ) - -// ************************************************************************** // -// ************** BOOST_TEST_MAIN ************** // -// ************************************************************************** // - -#if defined(BOOST_TEST_MAIN) - -#ifdef BOOST_TEST_ALTERNATIVE_INIT_API -bool init_unit_test() { -#else -::autoboost::unit_test::test_suite* -init_unit_test_suite( int, char* [] ) { -#endif - -#ifdef BOOST_TEST_MODULE - using namespace ::autoboost::unit_test; - assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 ); - -#endif - -#ifdef BOOST_TEST_ALTERNATIVE_INIT_API - return true; -} -#else - return 0; -} -#endif - -#endif - -//____________________________________________________________________________// - -#endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/unit_test_suite_impl.hpp b/contrib/autoboost/boost/test/unit_test_suite_impl.hpp deleted file mode 100644 index a86c1ad27..000000000 --- a/contrib/autoboost/boost/test/unit_test_suite_impl.hpp +++ /dev/null @@ -1,434 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines test_unit, test_case, test_case_results, test_suite and test_tree_visitor -// *************************************************************************** - -#ifndef BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER -#define BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER - -// Boost.Test -#include -#include -#include -#include -#include -#include -#include - -// Boost -#include -#include -#include -#include -#include - -// STL -#include // for typeid -#include // for std::string -#include // for std::list -#include // for std::vector - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** test_unit ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_unit { -public: - enum { type = tut_any }; - - // Constructor - test_unit( const_string tu_name, test_unit_type t ); - - // dependencies management - void depends_on( test_unit* tu ); - bool check_dependencies() const; - - // Public r/o properties - typedef BOOST_READONLY_PROPERTY(test_unit_id,(framework_impl)) id_t; - typedef BOOST_READONLY_PROPERTY(test_unit_id,(test_suite)) parent_id_t; - readonly_property p_type; // type for this test unit - readonly_property p_type_name; // "case"/"suite" - id_t p_id; // unique id for this test unit - parent_id_t p_parent_id; // parent test suite id - - // Public r/w properties - readwrite_property p_name; // name for this test unit - readwrite_property p_timeout; // timeout for the test unit execution - readwrite_property p_expected_failures; // number of expected failures in this test unit - mutable readwrite_property p_enabled; // enabled status for this unit - - void increase_exp_fail( unsigned num ); - -protected: - ~test_unit(); - -private: - // Data members - std::list m_dependencies; -}; - -// ************************************************************************** // -// ************** test_case_generator ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_unit_generator { -public: - virtual test_unit* next() const = 0; - -protected: - BOOST_TEST_PROTECTED_VIRTUAL ~test_unit_generator() {} -}; - -// ************************************************************************** // -// ************** test_case ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_case : public test_unit { -public: - enum { type = tut_case }; - - // Constructor - test_case( const_string tc_name, callback0<> const& test_func ); - - // Access methods - callback0<> const& test_func() const { return m_test_func; } - -private: - friend class framework_impl; - ~test_case() {} - - // BOOST_MSVC <= 1200 have problems with callback as property - // Data members - callback0<> m_test_func; -}; - -// ************************************************************************** // -// ************** test_suite ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_suite : public test_unit { -public: - enum { type = tut_suite }; - - // Constructor - explicit test_suite( const_string ts_name ); - - // test unit list management - void add( test_unit* tu, counter_t expected_failures = 0, unsigned timeout = 0 ); - void add( test_unit_generator const& gen, unsigned timeout = 0 ); - void remove( test_unit_id id ); - - // access methods - test_unit_id get( const_string tu_name ) const; - std::size_t size() const { return m_members.size(); } - -protected: - friend BOOST_TEST_DECL - void traverse_test_tree( test_suite const&, test_tree_visitor& ); - friend class framework_impl; - virtual ~test_suite() {} - - // Data members - std::vector m_members; -}; - -// ************************************************************************** // -// ************** master_test_suite ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL master_test_suite_t : public test_suite { -public: - master_test_suite_t() : test_suite( "Master Test Suite" ) - , argc( 0 ) - , argv( 0 ) - {} - - // Data members - int argc; - char** argv; -}; - - -// ************************************************************************** // -// ************** test_tree_visitor ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL test_tree_visitor { -public: - // test tree visitor interface - virtual void visit( test_case const& ) {} - virtual bool test_suite_start( test_suite const& ) { return true; } - virtual void test_suite_finish( test_suite const& ) {} - -protected: - BOOST_TEST_PROTECTED_VIRTUAL ~test_tree_visitor() {} -}; - -// ************************************************************************** // -// ************** traverse_test_tree ************** // -// ************************************************************************** // - -BOOST_TEST_DECL void traverse_test_tree( test_case const&, test_tree_visitor& ); -BOOST_TEST_DECL void traverse_test_tree( test_suite const&, test_tree_visitor& ); -BOOST_TEST_DECL void traverse_test_tree( test_unit_id , test_tree_visitor& ); - -//____________________________________________________________________________// - -inline void -traverse_test_tree( test_unit const& tu, test_tree_visitor& V ) -{ - if( tu.p_type == tut_case ) - traverse_test_tree( static_cast( tu ), V ); - else - traverse_test_tree( static_cast( tu ), V ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** test_case_counter ************** // -// ************************************************************************** // - -class test_case_counter : public test_tree_visitor { -public: - // Constructor - test_case_counter() : p_count( 0 ) {} - - BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count; -private: - // test tree visitor interface - virtual void visit( test_case const& ); - virtual bool test_suite_start( test_suite const& ts ) { return ts.p_enabled; } -}; - -// ************************************************************************** // -// ************** test_being_aborted ************** // -// ************************************************************************** // - -struct BOOST_TEST_DECL test_being_aborted {}; - -// ************************************************************************** // -// ************** object generators ************** // -// ************************************************************************** // - -namespace ut_detail { - -BOOST_TEST_DECL std::string normalize_test_case_name( const_string tu_name ); - -template -struct user_tc_method_invoker { - typedef void (UserTestCase::*TestMethod )(); - - user_tc_method_invoker( shared_ptr inst, TestMethod test_method ) - : m_inst( inst ), m_test_method( test_method ) {} - - void operator()() { ((*m_inst).*m_test_method)(); } - - shared_ptr m_inst; - TestMethod m_test_method; -}; - -} // namespace ut_detail - -//____________________________________________________________________________// - -inline test_case* -make_test_case( callback0<> const& test_func, const_string tc_name ) -{ - return new test_case( ut_detail::normalize_test_case_name( tc_name ), test_func ); -} - -//____________________________________________________________________________// - -template -inline test_case* -make_test_case( void (UserTestCase::* test_method )(), - const_string tc_name, - autoboost::shared_ptr user_test_case ) -{ - return new test_case( ut_detail::normalize_test_case_name( tc_name ), - ut_detail::user_tc_method_invoker( user_test_case, test_method ) ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** auto_test_unit_registrar ************** // -// ************************************************************************** // - -namespace ut_detail { - -struct BOOST_TEST_DECL auto_test_unit_registrar -{ - // Constructors - auto_test_unit_registrar( test_case* tc, counter_t exp_fail ); - explicit auto_test_unit_registrar( const_string ts_name ); - explicit auto_test_unit_registrar( test_unit_generator const& tc_gen ); - explicit auto_test_unit_registrar( int ); - -private: - static std::list& curr_ts_store(); -}; - -//____________________________________________________________________________// - -template -struct auto_tc_exp_fail { - auto_tc_exp_fail() : m_value( 0 ) {} - - explicit auto_tc_exp_fail( unsigned v ) - : m_value( v ) - { - instance() = this; - } - - static auto_tc_exp_fail*& instance() - { - static auto_tc_exp_fail inst; - static auto_tc_exp_fail* inst_ptr = &inst; - - return inst_ptr; - } - - unsigned value() const { return m_value; } - -private: - // Data members - unsigned m_value; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -// ************************************************************************** // -// ************** global_fixture ************** // -// ************************************************************************** // - -class BOOST_TEST_DECL global_fixture : public test_observer { -public: - // Constructor - global_fixture(); -}; - -//____________________________________________________________________________// - -namespace ut_detail { - -template -struct global_fixture_impl : public global_fixture { - // Constructor - global_fixture_impl(): m_fixure( 0 ) {} - - // test observer interface - virtual void test_start( counter_t ) { m_fixure = new F; } - virtual void test_finish() { delete m_fixure; m_fixure = 0; } - virtual void test_aborted() { delete m_fixure; m_fixure = 0; } - -private: - // Data members - F* m_fixure; -}; - -// ************************************************************************** // -// ************** test_case_template_invoker ************** // -// ************************************************************************** // - -template -class test_case_template_invoker { -public: - void operator()() { TestCaseTemplate::run( (autoboost::type*)0 ); } -}; - -// ************************************************************************** // -// ************** generate_test_case_4_type ************** // -// ************************************************************************** // - -template -struct generate_test_case_4_type { - explicit generate_test_case_4_type( const_string tc_name, Generator& G ) - : m_test_case_name( tc_name ) - , m_holder( G ) - {} - - template - void operator()( mpl::identity ) - { - std::string full_name; - assign_op( full_name, m_test_case_name, 0 ); - full_name += '<'; - full_name += typeid(TestType).name(); - if( autoboost::is_const::value ) - full_name += " const"; - full_name += '>'; - - m_holder.m_test_cases.push_back( - new test_case( full_name, test_case_template_invoker() ) ); - } - -private: - // Data members - const_string m_test_case_name; - Generator& m_holder; -}; - -// ************************************************************************** // -// ************** test_case_template ************** // -// ************************************************************************** // - -template -class template_test_case_gen : public test_unit_generator { -public: - // Constructor - template_test_case_gen( const_string tc_name ) - { - typedef generate_test_case_4_type, - TestCaseTemplate - > single_test_gen; - mpl::for_each >( single_test_gen( tc_name, *this ) ); - } - - virtual test_unit* next() const - { - if( m_test_cases.empty() ) - return 0; - - test_unit* res = m_test_cases.front(); - m_test_cases.pop_front(); - - return res; - } - - // Data members - mutable std::list m_test_cases; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -} // unit_test - -} // namespace autoboost - -#include - -#endif // BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/utils/algorithm.hpp b/contrib/autoboost/boost/test/utils/algorithm.hpp deleted file mode 100644 index a1f7e07f2..000000000 --- a/contrib/autoboost/boost/test/utils/algorithm.hpp +++ /dev/null @@ -1,228 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : addition to STL algorithms -// *************************************************************************** - -#ifndef BOOST_ALGORITHM_HPP_062304GER -#define BOOST_ALGORITHM_HPP_062304GER - -#include -#include // std::find -#include // std::bind1st - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -/// @brief this algorithm search through two collections for first mismatch position that get returned as a pair -/// of iterators, first pointing to the mismatch position in first collection, second iterator in second one - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -template -inline std::pair -mismatch( InputIter1 first1, InputIter1 last1, - InputIter2 first2, InputIter2 last2 ) -{ - while( first1 != last1 && first2 != last2 && *first1 == *first2 ) { - ++first1; - ++first2; - } - - return std::pair(first1, first2); -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through two collections for first mismatch position that get returned as a pair -/// of iterators, first pointing to the mismatch position in first collection, second iterator in second one. This algorithms -/// uses supplied predicate for collection elements comparison - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -/// @param pred - predicate to be used for search -template -inline std::pair -mismatch( InputIter1 first1, InputIter1 last1, - InputIter2 first2, InputIter2 last2, - Predicate pred ) -{ - while( first1 != last1 && first2 != last2 && pred( *first1, *first2 ) ) { - ++first1; - ++first2; - } - - return std::pair(first1, first2); -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for first element that does not belong a second one - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -template -inline ForwardIterator1 -find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2 ) -{ - while( first1 != last1 ) { - if( std::find( first2, last2, *first1 ) == last2 ) - break; - ++first1; - } - - return first1; -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for first element that does not satisfy binary -/// predicate in conjunction will any element in second collection - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -/// @param pred - predicate to be used for search -template -inline ForwardIterator1 -find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - Predicate pred ) -{ - while( first1 != last1 ) { - if( std::find_if( first2, last2, std::bind1st( pred, *first1 ) ) == last2 ) - break; - ++first1; - } - - return first1; -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for last element that belongs to a second one - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -template -inline BidirectionalIterator1 -find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2 ) -{ - if( first1 == last1 || first2 == last2 ) - return last1; - - BidirectionalIterator1 it1 = last1; - while( --it1 != first1 && std::find( first2, last2, *it1 ) == last2 ) {} - - return it1 == first1 && std::find( first2, last2, *it1 ) == last2 ? last1 : it1; -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for last element that satisfy binary -/// predicate in conjunction will at least one element in second collection - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -/// @param pred - predicate to be used for search -template -inline BidirectionalIterator1 -find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - Predicate pred ) -{ - if( first1 == last1 || first2 == last2 ) - return last1; - - BidirectionalIterator1 it1 = last1; - while( --it1 != first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ) {} - - return it1 == first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1; -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for last element that does not belong to a second one - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -template -inline BidirectionalIterator1 -find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2 ) -{ - if( first1 == last1 || first2 == last2 ) - return last1; - - BidirectionalIterator1 it1 = last1; - while( --it1 != first1 && std::find( first2, last2, *it1 ) != last2 ) {} - - return it1 == first1 && std::find( first2, last2, *it1 ) != last2 ? last1 : it1; -} - -//____________________________________________________________________________// - -/// @brief this algorithm search through first collection for last element that does not satisfy binary -/// predicate in conjunction will any element in second collection - -/// @param first1 - first collection begin iterator -/// @param last1 - first collection end iterator -/// @param first2 - second collection begin iterator -/// @param last2 - second collection end iterator -/// @param pred - predicate to be used for search -template -inline BidirectionalIterator1 -find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - Predicate pred ) -{ - if( first1 == last1 || first2 == last2 ) - return last1; - - BidirectionalIterator1 it1 = last1; - while( --it1 != first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) != last2 ) {} - - return it1 == first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1; -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_ALGORITHM_HPP_062304GER - - diff --git a/contrib/autoboost/boost/test/utils/assign_op.hpp b/contrib/autoboost/boost/test/utils/assign_op.hpp deleted file mode 100644 index e0170aba9..000000000 --- a/contrib/autoboost/boost/test/utils/assign_op.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : overloadable assignment -// *************************************************************************** - -#ifndef BOOST_TEST_ASSIGN_OP_033005GER -#define BOOST_TEST_ASSIGN_OP_033005GER - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** generic assign operator ************** // -// ************************************************************************** // - -// generic -template -inline void -assign_op( T& t, S const& s, long ) -{ - t = s; -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -#endif // BOOST_TEST_ASSIGN_OP_033005GER - diff --git a/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring.hpp b/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring.hpp deleted file mode 100644 index 74e8822dc..000000000 --- a/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring.hpp +++ /dev/null @@ -1,731 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : class basic_cstring wraps C string and provide std_string like -// interface -// *************************************************************************** - -#ifndef BOOST_TEST_BASIC_CSTRING_HPP_071894GER -#define BOOST_TEST_BASIC_CSTRING_HPP_071894GER - -// Boost.Test -#include -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** basic_cstring ************** // -// ************************************************************************** // - -template -class basic_cstring { - typedef basic_cstring self_type; -public: - // Subtypes - typedef ut_detail::bcs_char_traits traits_type; - typedef typename ut_detail::bcs_char_traits::std_string std_string; - - typedef CharT value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - typedef value_type const* const_iterator; - typedef value_type* iterator; - - // !! should also present reverse_iterator, const_reverse_iterator - -#if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - enum npos_type { npos = static_cast(-1) }; -#else - // IBM/VisualAge version 6 is not able to handle enums larger than 4 bytes. - // But size_type is 8 bytes in 64bit mode. - static const size_type npos = -1 ; -#endif - - static pointer null_str(); - - // Constructors; default copy constructor is generated by compiler - basic_cstring(); - basic_cstring( std_string const& s ); - basic_cstring( pointer s ); - basic_cstring( pointer s, size_type arg_size ); - basic_cstring( pointer first, pointer last ); - - // data access methods - value_type operator[]( size_type index ) const; - value_type at( size_type index ) const; - - // size operators - size_type size() const; - bool is_empty() const; - void clear(); - void resize( size_type new_len ); - - // !! only for STL container conformance use is_empty instead - bool empty() const; - - // Trimming - self_type& trim_right( size_type trim_size ); - self_type& trim_left( size_type trim_size ); - self_type& trim_right( iterator it ); - self_type& trim_left( iterator it ); -#ifndef __IBMCPP__ - self_type& trim_left( self_type exclusions = self_type() ) ; - self_type& trim_right( self_type exclusions = self_type() ) ; - self_type& trim( self_type exclusions = self_type() ) ; -#else - // VisualAge version 6 has in this case a problem with the default arguments. - self_type& trim_left( self_type exclusions ) ; - self_type& trim_right( self_type exclusions ) ; - self_type& trim( self_type exclusions ) ; - self_type& trim_left() { trim_left( self_type() ) ; } - self_type& trim_right() { trim_right( self_type() ) ; } - self_type& trim() { trim( self_type() ) ; } -#endif - - // Assignment operators - basic_cstring& operator=( self_type const& s ); - basic_cstring& operator=( std_string const& s ); - basic_cstring& operator=( pointer s ); - - template - basic_cstring& assign( basic_cstring const& s ) { *this = basic_cstring( s.begin(), s.end() ); return *this; } - basic_cstring& assign( self_type const& s, size_type pos, size_type len ); - basic_cstring& assign( std_string const& s ); - basic_cstring& assign( std_string const& s, size_type pos, size_type len ); - basic_cstring& assign( pointer s ); - basic_cstring& assign( pointer s, size_type len ); - basic_cstring& assign( pointer f, pointer l ); - - // swapping - void swap( self_type& s ); - - // Iterators - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - // !! should have rbegin, rend - - // substring search operation - size_type find( basic_cstring ) const; - size_type rfind( basic_cstring ) const; - self_type substr( size_type beg_index, size_type end_index = npos ) const; - -private: - static self_type default_trim_ex(); - - // Data members - iterator m_begin; - iterator m_end; -}; - -//____________________________________________________________________________// - -template -inline typename basic_cstring::pointer -basic_cstring::null_str() -{ - static CharT null = 0; - return &null; -} - -//____________________________________________________________________________// - -template -inline -basic_cstring::basic_cstring() -: m_begin( null_str() ) -, m_end( m_begin ) -{ -} - -//____________________________________________________________________________// - -template -inline -basic_cstring::basic_cstring( std_string const& s ) -: m_begin( s.c_str() ) -, m_end( m_begin + s.size() ) -{ -} - -//____________________________________________________________________________// - -template -inline -basic_cstring::basic_cstring( pointer s ) -: m_begin( s ? s : null_str() ) -, m_end ( m_begin + (s ? traits_type::length( s ) : 0 ) ) -{ -} - -//____________________________________________________________________________// - -template -inline -basic_cstring::basic_cstring( pointer s, size_type arg_size ) -: m_begin( s ), m_end( m_begin + arg_size ) -{ -} - -//____________________________________________________________________________// - -template -inline -basic_cstring::basic_cstring( pointer first, pointer last ) -: m_begin( first ) -, m_end( last ) -{ -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::value_type -basic_cstring::operator[]( size_type index ) const -{ - return m_begin[index]; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::value_type -basic_cstring::at( size_type index ) const -{ - if( m_begin + index >= m_end ) - return static_cast(0); - - return m_begin[index]; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::size_type -basic_cstring::size() const -{ - return m_end - m_begin; -} - -//____________________________________________________________________________// - -template -inline bool -basic_cstring::is_empty() const -{ - return m_end == m_begin; -} - -//____________________________________________________________________________// - -template -inline bool -basic_cstring::empty() const -{ - return is_empty(); -} - -//____________________________________________________________________________// - -template -inline void -basic_cstring::clear() -{ - m_begin = m_end; -} - -//____________________________________________________________________________// - -template -inline void -basic_cstring::resize( size_type new_len ) -{ - if( m_begin + new_len < m_end ) - m_end = m_begin + new_len; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_left( size_type trim_size ) -{ - m_begin += trim_size; - if( m_end <= m_begin ) - clear(); - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_left( iterator it ) -{ - m_begin = it; - if( m_end <= m_begin ) - clear(); - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_left( basic_cstring exclusions ) -{ - if( exclusions.is_empty() ) - exclusions = default_trim_ex(); - - iterator it; - for( it = begin(); it != end(); ++it ) { - if( traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast(0) ) - break; - } - - return trim_left( it ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_right( size_type trim_size ) -{ - m_end -= trim_size; - if( m_end <= m_begin ) - clear(); - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_right( iterator it ) -{ - m_end = it; - if( m_end <= m_begin ) - clear(); - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim_right( basic_cstring exclusions ) -{ - if( exclusions.is_empty() ) - exclusions = default_trim_ex(); - - iterator it; - - for( it = end()-1; it != begin()-1; --it ) { - if( self_type::traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast(0) ) - break; - } - - return trim_right( it+1 ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::trim( basic_cstring exclusions ) -{ - trim_left( exclusions ); - trim_right( exclusions ); - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::operator=( basic_cstring const& s ) -{ - m_begin = s.m_begin; - m_end = s.m_end; - - return *this; -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::operator=( std_string const& s ) -{ - return *this = self_type( s ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::operator=( pointer s ) -{ - return *this = self_type( s ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( basic_cstring const& s, size_type pos, size_type len ) -{ - return *this = self_type( s.m_begin + pos, len ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( std_string const& s ) -{ - return *this = self_type( s ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( std_string const& s, size_type pos, size_type len ) -{ - return *this = self_type( s.c_str() + pos, len ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( pointer s ) -{ - return *this = self_type( s ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( pointer s, size_type len ) -{ - return *this = self_type( s, len ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring& -basic_cstring::assign( pointer f, pointer l ) -{ - return *this = self_type( f, l ); -} - -//____________________________________________________________________________// - -template -inline void -basic_cstring::swap( basic_cstring& s ) -{ - // do not want to include alogrithm - pointer tmp1 = m_begin; - pointer tmp2 = m_end; - - m_begin = s.m_begin; - m_end = s.m_end; - - s.m_begin = tmp1; - s.m_end = tmp2; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::iterator -basic_cstring::begin() -{ - return m_begin; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::const_iterator -basic_cstring::begin() const -{ - return m_begin; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::iterator -basic_cstring::end() -{ - return m_end; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::const_iterator -basic_cstring::end() const -{ - return m_end; -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::size_type -basic_cstring::find( basic_cstring str ) const -{ - if( str.is_empty() || str.size() > size() ) - return static_cast(npos); - - const_iterator it = begin(); - const_iterator last = end() - str.size() + 1; - - while( it != last ) { - if( traits_type::compare( it, str.begin(), str.size() ) == 0 ) - break; - - ++it; - } - - return it == last ? static_cast(npos) : it - begin(); -} - -//____________________________________________________________________________// - -template -inline typename basic_cstring::size_type -basic_cstring::rfind( basic_cstring str ) const -{ - if( str.is_empty() || str.size() > size() ) - return static_cast(npos); - - const_iterator it = end() - str.size(); - const_iterator last = begin()-1; - - while( it != last ) { - if( traits_type::compare( it, str.begin(), str.size() ) == 0 ) - break; - - --it; - } - - return it == last ? static_cast(npos) : static_cast(it - begin()); -} - -//____________________________________________________________________________// - -template -inline basic_cstring -basic_cstring::substr( size_type beg_index, size_type end_index ) const -{ - return beg_index > size() - ? self_type() - : end_index > size() - ? self_type( m_begin + beg_index, m_end ) - : self_type( m_begin + beg_index, m_begin + end_index ); -} - -//____________________________________________________________________________// - -template -inline basic_cstring -basic_cstring::default_trim_ex() -{ - static CharT ws[3] = { CharT(' '), CharT('\t'), CharT('\n') }; // !! wide case - - return self_type( ws, 3 ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** comparison operators ************** // -// ************************************************************************** // - -template -inline bool -operator==( basic_cstring const& s1, basic_cstring const& s2 ) -{ - typedef typename basic_cstring::traits_type traits_type; - return s1.size() == s2.size() && - traits_type::compare( s1.begin(), s2.begin(), s1.size() ) == 0; -} - -//____________________________________________________________________________// - -template -inline bool -operator==( basic_cstring const& s1, CharT2* s2 ) -{ -#if !defined(__DMC__) - return s1 == basic_cstring( s2 ); -#else - return s1 == basic_cstring( s2 ); -#endif -} - -//____________________________________________________________________________// - -template -inline bool -operator==( basic_cstring const& s1, typename basic_cstring::std_string const& s2 ) -{ - return s1 == basic_cstring( s2 ); -} - -//____________________________________________________________________________// - -template -inline bool -operator==( CharT1* s2, basic_cstring const& s1 ) -{ - return s1 == s2; -} - -//____________________________________________________________________________// - -template -inline bool -operator==( typename basic_cstring::std_string const& s2, basic_cstring const& s1 ) -{ - return s1 == s2; -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( basic_cstring const& s1, CharT* s2 ) -{ - return !(s1 == s2); -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( CharT* s2, basic_cstring const& s1 ) -{ - return !(s1 == s2); -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( basic_cstring const& s1, basic_cstring const& s2 ) -{ - return !(s1 == s2); -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( basic_cstring const& s1, typename basic_cstring::std_string const& s2 ) -{ - return !(s1 == s2); -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( typename basic_cstring::std_string const& s2, basic_cstring const& s1 ) -{ - return !(s1 == s2); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** first_char ************** // -// ************************************************************************** // - -template -inline typename basic_cstring::value_type -first_char( basic_cstring source ) -{ - typedef typename basic_cstring::value_type string_value_type; - - return source.is_empty() ? static_cast(0) : *source.begin(); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** last_char ************** // -// ************************************************************************** // - -template -inline typename basic_cstring::value_type -last_char( basic_cstring source ) -{ - typedef typename basic_cstring::value_type string_value_type; - - return source.is_empty() ? static_cast(0) : *(source.end()-1); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** assign_op ************** // -// ************************************************************************** // - -template -inline void -assign_op( std::basic_string& target, basic_cstring src, int ) -{ - target.assign( src.begin(), src.size() ); -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_BASIC_CSTRING_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp b/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp deleted file mode 100644 index de49e2a16..000000000 --- a/contrib/autoboost/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : basic_cstring class wrap C string and provide std_string like -// interface -// *************************************************************************** - -#ifndef BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER -#define BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER - -#include - -namespace autoboost { - -namespace unit_test { - -template class basic_cstring; -typedef basic_cstring const_string; -#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041)) -typedef const_string literal_string; -#else -typedef const_string const literal_string; -#endif - -typedef char const* const c_literal_string; - -} // namespace unit_test - -} // namespace autoboost - -#endif // BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/utils/basic_cstring/bcs_char_traits.hpp b/contrib/autoboost/boost/test/utils/basic_cstring/bcs_char_traits.hpp deleted file mode 100644 index b33fe0850..000000000 --- a/contrib/autoboost/boost/test/utils/basic_cstring/bcs_char_traits.hpp +++ /dev/null @@ -1,150 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : generic char traits class; wraps std::char_traits -// *************************************************************************** - -#ifndef BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER -#define BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER - -// Boost -#include -#include -#include -#include - -// STL -#include // std::char_traits -#include // std::size_t - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace ut_detail { - -template struct bcs_base_char { typedef CharT type; }; - -template<> struct bcs_base_char { typedef char type; }; -template<> struct bcs_base_char { typedef char type; }; -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) -template<> struct bcs_base_char { typedef char type; }; -#endif - -template<> struct bcs_base_char { typedef wchar_t type; }; - -// ************************************************************************** // -// ************** bcs_char_traits ************** // -// ************************************************************************** // - -template -struct bcs_char_traits_impl -{ -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typedef CharT const const_char; -#else - typedef typename autoboost::add_const::type const_char; -#endif - static bool eq( CharT c1, CharT c2 ) - { - return c1 == c2; - } - static bool lt( CharT c1, CharT c2 ) - { - return c1 < c2; - } - - static int compare( const_char* cstr1, const_char* cstr2, std::size_t n ) - { - while( n > 0 ) { - if( !eq( *cstr1, *cstr2 ) ) - return lt( *cstr1, *cstr2 ) ? -1 : 1; - ++cstr1; - ++cstr2; - --n; - } - - return 0; - } - - static std::size_t length( const_char* cstr ) - { - const_char null_char = CharT(); - - const_char* ptr = cstr; - while( !eq( *ptr, null_char ) ) - ++ptr; - - return ptr - cstr; - } - - static const_char* find( const_char* s, std::size_t n, CharT c ) - { - while( n > 0 ) { - if( eq( *s, c ) ) - return s; - - ++s; - --n; - } - return 0; - } -}; - -#ifdef BOOST_CLASSIC_IOSTREAMS -template -struct char_traits_with_find : std::string_char_traits { - static CharT const* find( CharT const* s, std::size_t n, CharT c ) - { - while( n > 0 ) { - if( eq( *s, c ) ) - return s; - - ++s; - --n; - } - return 0; - } -}; - -template<> struct bcs_char_traits_impl : char_traits_with_find {}; -template<> struct bcs_char_traits_impl : char_traits_with_find {}; -#else -template<> struct bcs_char_traits_impl : std::char_traits {}; -template<> struct bcs_char_traits_impl : std::char_traits {}; -#endif - -template -class bcs_char_traits : public bcs_char_traits_impl { - typedef typename ut_detail::bcs_base_char::type the_base_char; -public: -#ifdef BOOST_CLASSIC_IOSTREAMS - typedef std::basic_string > std_string; -#else - typedef std::basic_string > std_string; -#endif -}; - -} // namespace ut_detail - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/basic_cstring/compare.hpp b/contrib/autoboost/boost/test/utils/basic_cstring/compare.hpp deleted file mode 100644 index ac3038a98..000000000 --- a/contrib/autoboost/boost/test/utils/basic_cstring/compare.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : class basic_cstring comparisons implementation -// *************************************************************************** - -#ifndef BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER -#define BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER - -// Boost.Test -#include - -// STL -#include -#include - -#include - -//____________________________________________________________________________// - -# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) -namespace std { using ::toupper; } -# endif - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** case_ins_compare ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct case_ins -{ - static bool eq( CharT c1, CharT c2 ) { return (std::toupper)( c1 ) == (std::toupper)( c2 ); } - static bool lt( CharT c1, CharT c2 ) { return (std::toupper)( c1 ) < (std::toupper)( c2 ); } - - static int compare( CharT const* s1, CharT const* s2, std::size_t n ) - { - for( std::size_t i = 0; i < n; ++i ) { - if( !eq( s1[i], s2[i] ) ) - return lt( s1[i], s2[i] ) ? -1 : 1; - } - return 0; - } -}; - -} // namespace ut_detail - -// ************************************************************************** // -// ************** case_ins_eq ************** // -// ************************************************************************** // - -template -inline bool -case_ins_eq( basic_cstring x, basic_cstring y ) -{ - return x.size() == y.size() && ut_detail::case_ins::compare( x.begin(), y.begin(), x.size() ) == 0; -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** case_ins_less ************** // -// ************************************************************************** // - -template -class case_ins_less : public std::binary_function,basic_cstring,bool> -{ -public: - bool operator()( basic_cstring x, basic_cstring y ) const - { - return x.size() != y.size() - ? x.size() < y.size() - : ut_detail::case_ins::compare( x.begin(), y.begin(), x.size() ) < 0; - } -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** operator < ************** // -// ************************************************************************** // - -template -inline bool -operator <( autoboost::unit_test::basic_cstring const& x, - autoboost::unit_test::basic_cstring const& y ) -{ - typedef typename autoboost::unit_test::basic_cstring::traits_type traits_type; - return x.size() != y.size() - ? x.size() < y.size() - : traits_type::compare( x.begin(), y.begin(), x.size() ) < 0; -} - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/basic_cstring/io.hpp b/contrib/autoboost/boost/test/utils/basic_cstring/io.hpp deleted file mode 100644 index 0a738e69e..000000000 --- a/contrib/autoboost/boost/test/utils/basic_cstring/io.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : basic_cstring i/o implementation -// *************************************************************************** - -#ifndef BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER -#define BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER - -// Boost.Test -#include - -// STL -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -#ifdef BOOST_CLASSIC_IOSTREAMS - -template -inline std::ostream& -operator<<( std::ostream& os, basic_cstring const& str ) -{ - typedef typename ut_detail::bcs_base_char::type char_type; - char_type const* const beg = reinterpret_cast( str.begin() ); - char_type const* const end = reinterpret_cast( str.end() ); - os << std::basic_string( beg, end - beg ); - - return os; -} - -#else - -template -inline std::basic_ostream& -operator<<( std::basic_ostream& os, basic_cstring const& str ) -{ - CharT1 const* const beg = reinterpret_cast( str.begin() ); // !! - CharT1 const* const end = reinterpret_cast( str.end() ); - os << std::basic_string( beg, end - beg ); - - return os; -} - -#endif - -//____________________________________________________________________________// - - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/callback.hpp b/contrib/autoboost/boost/test/utils/callback.hpp deleted file mode 100644 index 749946fbc..000000000 --- a/contrib/autoboost/boost/test/utils/callback.hpp +++ /dev/null @@ -1,310 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : -// *************************************************************************** - -#ifndef BOOST_TEST_CALLBACK_020505GER -#define BOOST_TEST_CALLBACK_020505GER - -// Boost -#include -#include -#include - -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(BOOST_INTEL, <= 700) -# define BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR -#endif - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace ut_detail { - -struct unused {}; - -template -struct invoker { - template - R invoke( Functor& f ) { return f(); } - template - R invoke( Functor& f, T1 t1 ) { return f( t1 ); } - template - R invoke( Functor& f, T1 t1, T2 t2 ) { return f( t1, t2 ); } - template - R invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { return f( t1, t2, t3 ); } -}; - -//____________________________________________________________________________// - -template<> -struct invoker { - template - unused invoke( Functor& f ) { f(); return unused(); } - template - unused invoke( Functor& f, T1 t1 ) { f( t1 ); return unused(); } - template - unused invoke( Functor& f, T1 t1, T2 t2 ) { f( t1, t2 ); return unused(); } - template - unused invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { f( t1, t2, t3 ); return unused(); } -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -// ************************************************************************** // -// ************** unit_test::callback0 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback0_impl { - virtual ~callback0_impl() {} - - virtual R invoke() = 0; -}; - -//____________________________________________________________________________// - -template -struct callback0_impl_t : callback0_impl { - // Constructor - explicit callback0_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke() { return invoker().invoke( m_f ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback0 { -public: - // Constructors - callback0() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback0( callback0 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback0( Functor f ) - : m_impl( new ut_detail::callback0_impl_t( f ) ) {} - - void operator=( callback0 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback0_impl_t( f ) ); } - - R operator()() const { return m_impl->invoke(); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - autoboost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback1 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback1_impl { - virtual ~callback1_impl() {} - - virtual R invoke( T1 t1 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback1_impl_t : callback1_impl { - // Constructor - explicit callback1_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1 ) { return invoker().invoke( m_f, t1 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback1 { -public: - // Constructors - callback1() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback1( callback1 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback1( Functor f ) - : m_impl( new ut_detail::callback1_impl_t( f ) ) {} - - void operator=( callback1 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback1_impl_t( f ) ); } - - R operator()( T1 t1 ) const { return m_impl->invoke( t1 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - autoboost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback2 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback2_impl { - virtual ~callback2_impl() {} - - virtual R invoke( T1 t1, T2 t2 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback2_impl_t : callback2_impl { - // Constructor - explicit callback2_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1, T2 t2 ) { return invoker().template invoke( m_f, t1, t2 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback2 { -public: - // Constructors - callback2() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback2( callback2 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback2( Functor f ) : m_impl( new ut_detail::callback2_impl_t( f ) ) {} - - void operator=( callback2 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback2_impl_t( f ) ); } - - R operator()( T1 t1, T2 t2 ) const { return m_impl->invoke( t1, t2 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - autoboost::shared_ptr > m_impl; -}; - -// ************************************************************************** // -// ************** unit_test::callback3 ************** // -// ************************************************************************** // - -namespace ut_detail { - -template -struct callback3_impl { - virtual ~callback3_impl() {} - - virtual R invoke( T1 t1, T2 t2, T3 t3 ) = 0; -}; - -//____________________________________________________________________________// - -template -struct callback3_impl_t : callback3_impl { - // Constructor - explicit callback3_impl_t( Functor f ) : m_f( f ) {} - - virtual R invoke( T1 t1, T2 t2, T3 t3 ) { return invoker().invoke( m_f, t1, t2, t3 ); } - -private: - // Data members - Functor m_f; -}; - -//____________________________________________________________________________// - -} // namespace ut_detail - -template -class callback3 { -public: - // Constructors - callback3() {} -#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - callback3( callback3 const& rhs ) : m_impl( rhs.m_impl ) {} -#endif - - template - callback3( Functor f ) - : m_impl( new ut_detail::callback3_impl_t( f ) ) {} - - void operator=( callback3 const& rhs ) { m_impl = rhs.m_impl; } - - template - void operator=( Functor f ) { m_impl.reset( new ut_detail::callback3_impl_t( f ) ); } - - R operator()( T1 t1, T2 t2, T3 t3 ) const { return m_impl->invoke( t1, t2, t3 ); } - - bool operator!() const { return !m_impl; } - -private: - // Data members - autoboost::shared_ptr > m_impl; -}; - -} // namespace unit_test - -} // namespace autoboost - -#undef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_CALLBACK_020505GER diff --git a/contrib/autoboost/boost/test/utils/class_properties.hpp b/contrib/autoboost/boost/test/utils/class_properties.hpp deleted file mode 100644 index 4df8b78b0..000000000 --- a/contrib/autoboost/boost/test/utils/class_properties.hpp +++ /dev/null @@ -1,221 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple facility that mimmic notion of read-only read-write -// properties in C++ classes. Original idea by Henrik Ravn. -// *************************************************************************** - -#ifndef BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER -#define BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER - -// Boost.Test -#include - -// Boost -#if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) -#include -#endif -#include -#include -#include -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** class_property ************** // -// ************************************************************************** // - -template -class class_property { -protected: - typedef typename call_traits::const_reference read_access_t; - typedef typename call_traits::param_type write_param_t; - typedef typename add_pointer::type>::type address_res_t; -public: - // Constructor - class_property() : value( PropertyType() ) {} - explicit class_property( write_param_t init_value ) - : value( init_value ) {} - - // Access methods - operator read_access_t() const { return value; } - read_access_t get() const { return value; } - bool operator!() const { return !value; } - address_res_t operator&() const { return &value; } - - // Data members -#ifndef BOOST_TEST_NO_PROTECTED_USING -protected: -#endif - PropertyType value; -}; - -//____________________________________________________________________________// - -#ifdef BOOST_CLASSIC_IOSTREAMS - -template -inline std::ostream& -operator<<( std::ostream& os, class_property const& p ) - -#else - -template -inline std::basic_ostream& -operator<<( std::basic_ostream& os, class_property const& p ) - -#endif -{ - return os << p.get(); -} - -//____________________________________________________________________________// - -#define DEFINE_PROPERTY_FREE_BINARY_OPERATOR( op ) \ -template \ -inline bool \ -operator op( PropertyType const& lhs, class_property const& rhs ) \ -{ \ - return lhs op rhs.get(); \ -} \ -template \ -inline bool \ -operator op( class_property const& lhs, PropertyType const& rhs ) \ -{ \ - return lhs.get() op rhs; \ -} \ -template \ -inline bool \ -operator op( class_property const& lhs, \ - class_property const& rhs ) \ -{ \ - return lhs.get() op rhs.get(); \ -} \ -/**/ - -DEFINE_PROPERTY_FREE_BINARY_OPERATOR( == ) -DEFINE_PROPERTY_FREE_BINARY_OPERATOR( != ) - -#undef DEFINE_PROPERTY_FREE_BINARY_OPERATOR - -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - -#define DEFINE_PROPERTY_LOGICAL_OPERATOR( op ) \ -template \ -inline bool \ -operator op( bool b, class_property const& p ) \ -{ \ - return b op p.get(); \ -} \ -template \ -inline bool \ -operator op( class_property const& p, bool b ) \ -{ \ - return b op p.get(); \ -} \ -/**/ - -DEFINE_PROPERTY_LOGICAL_OPERATOR( && ) -DEFINE_PROPERTY_LOGICAL_OPERATOR( || ) - -#endif - -// ************************************************************************** // -// ************** readonly_property ************** // -// ************************************************************************** // - -template -class readonly_property : public class_property { - typedef class_property base_prop; - typedef typename base_prop::address_res_t arrow_res_t; -protected: - typedef typename base_prop::write_param_t write_param_t; -public: - // Constructor - readonly_property() {} - explicit readonly_property( write_param_t init_value ) : base_prop( init_value ) {} - - // access methods - arrow_res_t operator->() const { return autoboost::addressof( base_prop::value ); } -}; - -//____________________________________________________________________________// - -#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - -#define BOOST_READONLY_PROPERTY( property_type, friends ) autoboost::unit_test::readwrite_property - -#else - -#define BOOST_READONLY_PROPERTY_DECLARE_FRIEND(r, data, elem) friend class elem; - -#define BOOST_READONLY_PROPERTY( property_type, friends ) \ -class BOOST_JOIN( readonly_property, __LINE__ ) \ -: public autoboost::unit_test::readonly_property { \ - typedef autoboost::unit_test::readonly_property base_prop; \ - BOOST_PP_SEQ_FOR_EACH( BOOST_READONLY_PROPERTY_DECLARE_FRIEND, ' ', friends ) \ - typedef base_prop::write_param_t write_param_t; \ -public: \ - BOOST_JOIN( readonly_property, __LINE__ )() {} \ - explicit BOOST_JOIN( readonly_property, __LINE__ )( write_param_t init_v ) \ - : base_prop( init_v ) {} \ -} \ -/**/ - -#endif - -// ************************************************************************** // -// ************** readwrite_property ************** // -// ************************************************************************** // - -template -class readwrite_property : public class_property { - typedef class_property base_prop; - typedef typename add_pointer::type arrow_res_t; - typedef typename base_prop::address_res_t const_arrow_res_t; - typedef typename base_prop::write_param_t write_param_t; -public: - readwrite_property() : base_prop() {} - explicit readwrite_property( write_param_t init_value ) : base_prop( init_value ) {} - - // access methods - void set( write_param_t v ) { base_prop::value = v; } - arrow_res_t operator->() { return autoboost::addressof( base_prop::value ); } - const_arrow_res_t operator->() const { return autoboost::addressof( base_prop::value ); } - -#ifndef BOOST_TEST_NO_PROTECTED_USING - using base_prop::value; -#endif -}; - -//____________________________________________________________________________// - -} // unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#undef BOOST_TEST_NO_PROTECTED_USING - -#endif // BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/custom_manip.hpp b/contrib/autoboost/boost/test/utils/custom_manip.hpp deleted file mode 100644 index ddf3f7ee2..000000000 --- a/contrib/autoboost/boost/test/utils/custom_manip.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple helpers for creating cusom output manipulators -// *************************************************************************** - -#ifndef BOOST_TEST_CUSTOM_MANIP_HPP_071894GER -#define BOOST_TEST_CUSTOM_MANIP_HPP_071894GER - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** custom manipulators helpers ************** // -// ************************************************************************** // - -template -struct custom_printer { - explicit custom_printer( std::ostream& ostr ) : m_ostr( &ostr ) {} - - std::ostream& operator*() const { return *m_ostr; } - -private: - std::ostream* const m_ostr; -}; - -//____________________________________________________________________________// - -template struct custom_manip {}; - -//____________________________________________________________________________// - -template -inline custom_printer > -operator<<( std::ostream& ostr, custom_manip const& ) { return custom_printer >( ostr ); } - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_CUSTOM_MANIP_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/fixed_mapping.hpp b/contrib/autoboost/boost/test/utils/fixed_mapping.hpp deleted file mode 100644 index e191c804e..000000000 --- a/contrib/autoboost/boost/test/utils/fixed_mapping.hpp +++ /dev/null @@ -1,124 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2001-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : fixed sized mapping with specified invalid value -// *************************************************************************** - -#ifndef BOOST_TEST_FIXED_MAPPING_HPP_071894GER -#define BOOST_TEST_FIXED_MAPPING_HPP_071894GER - -// Boost -#include -#include -#include -#include - -// STL -#include -#include -#include -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// configurable maximum fixed sized mapping size supported by this header. -// You can redefine it before inclusion of this file. -#ifndef MAX_MAP_SIZE -#define MAX_MAP_SIZE 20 -#endif - -#define CONSTR_DECL_MID( z, i, dummy1 ) key_param_type key##i, value_param_type v##i, -#define CONSTR_BODY_MID( z, i, dummy1 ) add_pair( key##i, v##i ); - -#define CONSTR_DECL( z, n, dummy1 ) \ - fixed_mapping( BOOST_PP_REPEAT_ ## z( n, CONSTR_DECL_MID, "" ) \ - value_param_type invalid_value ) \ - : m_invalid_value( invalid_value ) \ - { \ - BOOST_PP_REPEAT_ ## z( n, CONSTR_BODY_MID, "" ) \ - init(); \ - } \ -/**/ - -#define CONTRUCTORS( n ) BOOST_PP_REPEAT( n, CONSTR_DECL, "" ) - -template > -class fixed_mapping -{ - typedef std::pair elem_type; - typedef std::vector map_type; - typedef typename std::vector::const_iterator iterator; - - typedef typename call_traits::param_type key_param_type; - typedef typename call_traits::param_type value_param_type; - typedef typename call_traits::const_reference value_ref_type; - -#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) - struct p1; friend struct p1; - struct p2; friend struct p2; -#endif - - // bind( Compare(), bind(select1st(), _1), bind(identity(), _2) ) - struct p1 : public std::binary_function - { - bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); } - }; - - // bind( Compare(), bind(select1st(), _1), bind(select1st(), _2) ) - struct p2 : public std::binary_function - { - bool operator()( elem_type const& x, elem_type const& y ) const { return Compare()( x.first, y.first ); } - }; - -public: - // Constructors - CONTRUCTORS( BOOST_PP_ADD( MAX_MAP_SIZE, 1 ) ) - - // key -> value access - value_ref_type operator[]( key_param_type key ) const - { - iterator it = autoboost::detail::lower_bound( m_map.begin(), m_map.end(), key, p1() ); - - return (it == m_map.end() || Compare()( key, it->first ) ) ? m_invalid_value : it->second; - } - -private: - // Implementation - void init() { std::sort( m_map.begin(), m_map.end(), p2() ); } - void add_pair( key_param_type key, value_param_type value ) { m_map.push_back( elem_type( key, value ) ); } - - // Data members - Value m_invalid_value; - map_type m_map; -}; - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#undef MAX_MAP_SIZE -#undef CONSTR_DECL_MID -#undef CONSTR_BODY_MID -#undef CONSTR_DECL -#undef CONTRUCTORS - -#endif // BOOST_TEST_FIXED_MAPPING_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/utils/foreach.hpp b/contrib/autoboost/boost/test/utils/foreach.hpp deleted file mode 100644 index 755bd53f8..000000000 --- a/contrib/autoboost/boost/test/utils/foreach.hpp +++ /dev/null @@ -1,281 +0,0 @@ -// (C) Copyright Eric Niebler 2004-2005 -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : this is an abridged version of an excelent BOOST_FOREACH facility -// presented by Eric Niebler. I am so fond of it so I can't wait till it -// going to be accepted into Boost. Also I need version with less number of dependencies -// and more portable. This version doesn't support rvalues and will reeveluate it's -// parameters, but should be good enough for my purposes. -// *************************************************************************** - -#ifndef BOOST_TEST_FOREACH_HPP_021005GER -#define BOOST_TEST_FOREACH_HPP_021005GER - -// Boost.Test -#include - -// Boost -#include -#include -#include - -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -namespace for_each { - -// ************************************************************************** // -// ************** static_any ************** // -// ************************************************************************** // - -struct static_any_base -{ - operator bool() const { return false; } -}; - -//____________________________________________________________________________// - -template -struct static_any : static_any_base -{ - static_any( Iter const& t ) : m_it( t ) {} - - mutable Iter m_it; -}; - -//____________________________________________________________________________// - -typedef static_any_base const& static_any_t; - -//____________________________________________________________________________// - -template -inline Iter& -static_any_cast( static_any_t a, Iter* = 0 ) -{ - return static_cast( static_cast const&>( a ).m_it ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** is_const ************** // -// ************************************************************************** // - -template -inline is_const -is_const_coll( C& ) -{ - return is_const(); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** begin ************** // -// ************************************************************************** // - -template -inline static_any -begin( C& t, mpl::false_ ) -{ - return static_any( t.begin() ); -} - -//____________________________________________________________________________// - -template -inline static_any -begin( C const& t, mpl::true_ ) -{ - return static_any( t.begin() ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** end ************** // -// ************************************************************************** // - -template -inline static_any -end( C& t, mpl::false_ ) -{ - return static_any( t.end() ); -} - -//____________________________________________________________________________// - -template -inline static_any -end( C const& t, mpl::true_ ) -{ - return static_any( t.end() ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** done ************** // -// ************************************************************************** // - -template -inline bool -done( static_any_t cur, static_any_t end, C&, mpl::false_ ) -{ - return static_any_cast( cur ) == - static_any_cast( end ); -} - -//____________________________________________________________________________// - -template -inline bool -done( static_any_t cur, static_any_t end, C const&, mpl::true_ ) -{ - return static_any_cast( cur ) == - static_any_cast( end ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** next ************** // -// ************************************************************************** // - -template -inline void -next( static_any_t cur, C&, mpl::false_ ) -{ - ++static_any_cast( cur ); -} - -//____________________________________________________________________________// - -template -inline void -next( static_any_t cur, C const&, mpl::true_ ) -{ - ++static_any_cast( cur ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** deref ************** // -// ************************************************************************** // - -template -inline RefType -deref( static_any_t cur, C&, ::autoboost::type, mpl::false_ ) -{ - return *static_any_cast( cur ); -} - -//____________________________________________________________________________// - -template -inline RefType -deref( static_any_t cur, C const&, ::autoboost::type, mpl::true_ ) -{ - return *static_any_cast( cur ); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** BOOST_TEST_FOREACH ************** // -// ************************************************************************** // - -#define BOOST_TEST_FE_ANY ::autoboost::unit_test::for_each::static_any_t -#define BOOST_TEST_FE_IS_CONST( COL ) ::autoboost::unit_test::for_each::is_const_coll( COL ) - -#define BOOST_TEST_FE_BEG( COL ) \ - ::autoboost::unit_test::for_each::begin( \ - COL, \ - BOOST_TEST_FE_IS_CONST( COL ) ) \ -/**/ - -#define BOOST_TEST_FE_END( COL ) \ - ::autoboost::unit_test::for_each::end( \ - COL, \ - BOOST_TEST_FE_IS_CONST( COL ) ) \ -/**/ - -#define BOOST_TEST_FE_DONE( COL ) \ - ::autoboost::unit_test::for_each::done( \ - BOOST_TEST_FE_CUR_VAR, \ - BOOST_TEST_FE_END_VAR, \ - COL, \ - BOOST_TEST_FE_IS_CONST( COL ) ) \ -/**/ - -#define BOOST_TEST_FE_NEXT( COL ) \ - ::autoboost::unit_test::for_each::next( \ - BOOST_TEST_FE_CUR_VAR, \ - COL, \ - BOOST_TEST_FE_IS_CONST( COL ) ) \ -/**/ - -#define BOOST_FOREACH_NOOP(COL) \ - ((void)&(COL)) - -#define BOOST_TEST_FE_DEREF( COL, RefType ) \ - ::autoboost::unit_test::for_each::deref( \ - BOOST_TEST_FE_CUR_VAR, \ - COL, \ - ::autoboost::type(), \ - BOOST_TEST_FE_IS_CONST( COL ) ) \ -/**/ - -#if BOOST_WORKAROUND( BOOST_MSVC, == 1310 ) -#define BOOST_TEST_LINE_NUM -#else -#define BOOST_TEST_LINE_NUM __LINE__ -#endif - -#define BOOST_TEST_FE_CUR_VAR BOOST_JOIN( _fe_cur_, BOOST_TEST_LINE_NUM ) -#define BOOST_TEST_FE_END_VAR BOOST_JOIN( _fe_end_, BOOST_TEST_LINE_NUM ) -#define BOOST_TEST_FE_CON_VAR BOOST_JOIN( _fe_con_, BOOST_TEST_LINE_NUM ) - -#define BOOST_TEST_FOREACH( RefType, var, COL ) \ -if( BOOST_TEST_FE_ANY BOOST_TEST_FE_CUR_VAR = BOOST_TEST_FE_BEG( COL ) ) {} else \ -if( BOOST_TEST_FE_ANY BOOST_TEST_FE_END_VAR = BOOST_TEST_FE_END( COL ) ) {} else \ -for( bool BOOST_TEST_FE_CON_VAR = true; \ - BOOST_TEST_FE_CON_VAR && !BOOST_TEST_FE_DONE( COL ); \ - BOOST_TEST_FE_CON_VAR ? BOOST_TEST_FE_NEXT( COL ) : BOOST_FOREACH_NOOP( COL )) \ - \ - if( (BOOST_TEST_FE_CON_VAR = false, false) ) {} else \ - for( RefType var = BOOST_TEST_FE_DEREF( COL, RefType ); \ - !BOOST_TEST_FE_CON_VAR; BOOST_TEST_FE_CON_VAR = true ) \ -/**/ - -//____________________________________________________________________________// - -} // namespace for_each - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_FOREACH_HPP_021005GER diff --git a/contrib/autoboost/boost/test/utils/iterator/input_iterator_facade.hpp b/contrib/autoboost/boost/test/utils/iterator/input_iterator_facade.hpp deleted file mode 100644 index f7768f4ff..000000000 --- a/contrib/autoboost/boost/test/utils/iterator/input_iterator_facade.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Input iterator facade -// *************************************************************************** - -#ifndef BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER -#define BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER - -// Boost -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** input_iterator_core_access ************** // -// ************************************************************************** // - -class input_iterator_core_access -{ -#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) -public: -#else - template friend class input_iterator_facade; -#endif - - template - static bool get( Facade& f ) - { - return f.get(); - } - -private: - // objects of this class are useless - input_iterator_core_access(); //undefined -}; - -// ************************************************************************** // -// ************** input_iterator_facade ************** // -// ************************************************************************** // - -template -class input_iterator_facade : public iterator_facade -{ -public: - // Constructor - input_iterator_facade() : m_valid( false ), m_value() {} - -protected: // provide access to the Derived - void init() - { - m_valid = true; - increment(); - } - - // Data members - mutable bool m_valid; - ValueType m_value; - -private: - friend class autoboost::iterator_core_access; - - // iterator facade interface implementation - void increment() - { - // we make post-end incrementation indefinetly safe - if( m_valid ) - m_valid = input_iterator_core_access::get( *static_cast(this) ); - } - Reference dereference() const - { - return m_value; - } - - // iterator facade interface implementation - bool equal( input_iterator_facade const& rhs ) const - { - // two invalid iterator equals, inequal otherwise - return !m_valid && !rhs.m_valid; - } -}; - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/utils/iterator/token_iterator.hpp b/contrib/autoboost/boost/test/utils/iterator/token_iterator.hpp deleted file mode 100644 index 8e2329715..000000000 --- a/contrib/autoboost/boost/test/utils/iterator/token_iterator.hpp +++ /dev/null @@ -1,418 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : token iterator for string and range tokenization -// *************************************************************************** - -#ifndef BOOST_TOKEN_ITERATOR_HPP_071894GER -#define BOOST_TOKEN_ITERATOR_HPP_071894GER - -// Boost -#include -#include - -#include -#include - -#include -#include -#include -#include - -// STL -#include -#include - -#include - -//____________________________________________________________________________// - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std{ using ::ispunct; using ::isspace; } -#endif - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** ti_delimeter_type ************** // -// ************************************************************************** // - -enum ti_delimeter_type { - dt_char, // character is delimeter if it among explicit list of some characters - dt_ispunct, // character is delimeter if it satisfies ispunct functor - dt_isspace, // character is delimeter if it satisfies isspace functor - dt_none // no character is delimeter -}; - -namespace ut_detail { - -// ************************************************************************** // -// ************** default_char_compare ************** // -// ************************************************************************** // - -template -class default_char_compare { -public: - bool operator()( CharT c1, CharT c2 ) - { -#ifdef BOOST_CLASSIC_IOSTREAMS - return std::string_char_traits::eq( c1, c2 ); -#else - return std::char_traits::eq( c1, c2 ); -#endif - } -}; - -// ************************************************************************** // -// ************** delim_policy ************** // -// ************************************************************************** // - -template -class delim_policy { - typedef basic_cstring cstring; -public: - // Constructor - explicit delim_policy( ti_delimeter_type t = dt_char, cstring d = cstring() ) - : m_type( t ) - { - set_delimeters( d ); - } - - void set_delimeters( ti_delimeter_type t ) { m_type = t; } - template - void set_delimeters( Src d ) - { - nfp::optionally_assign( m_delimeters, d ); - - if( !m_delimeters.is_empty() ) - m_type = dt_char; - } - - bool operator()( CharT c ) - { - switch( m_type ) { - case dt_char: { - BOOST_TEST_FOREACH( CharT, delim, m_delimeters ) - if( CharCompare()( delim, c ) ) - return true; - - return false; - } - case dt_ispunct: - return (std::ispunct)( c ) != 0; - case dt_isspace: - return (std::isspace)( c ) != 0; - case dt_none: - return false; - } - - return false; - } - -private: - // Data members - cstring m_delimeters; - ti_delimeter_type m_type; -}; - -// ************************************************************************** // -// ************** token_assigner ************** // -// ************************************************************************** // - -template -struct token_assigner { -#if BOOST_WORKAROUND( BOOST_DINKUMWARE_STDLIB, < 306 ) - template - static void assign( Iterator b, Iterator e, std::basic_string& t ) - { for( ; b != e; ++b ) t += *b; } - - template - static void assign( Iterator b, Iterator e, basic_cstring& t ) { t.assign( b, e ); } -#else - template - static void assign( Iterator b, Iterator e, Token& t ) { t.assign( b, e ); } -#endif - template - static void append_move( Iterator& b, Token& ) { ++b; } -}; - -//____________________________________________________________________________// - -template<> -struct token_assigner { - template - static void assign( Iterator b, Iterator e, Token& t ) {} - - template - static void append_move( Iterator& b, Token& t ) { t += *b; ++b; } -}; - -} // namespace ut_detail - -// ************************************************************************** // -// ************** modifiers ************** // -// ************************************************************************** // - -namespace { -nfp::keyword dropped_delimeters; -nfp::keyword kept_delimeters; -nfp::typed_keyword keep_empty_tokens; -nfp::typed_keyword max_tokens; -} - -// ************************************************************************** // -// ************** token_iterator_base ************** // -// ************************************************************************** // - -template, - typename ValueType = basic_cstring, - typename Reference = basic_cstring, - typename Traversal = forward_traversal_tag> -class token_iterator_base -: public input_iterator_facade { - typedef basic_cstring cstring; - typedef ut_detail::delim_policy delim_policy; - typedef input_iterator_facade base; - -protected: - // Constructor - explicit token_iterator_base() - : m_is_dropped( dt_isspace ) - , m_is_kept( dt_ispunct ) - , m_keep_empty_tokens( false ) - , m_tokens_left( static_cast(-1) ) - , m_token_produced( false ) - { - } - - template - void - apply_modifier( Modifier const& m ) - { - if( m.has( dropped_delimeters ) ) - m_is_dropped.set_delimeters( m[dropped_delimeters] ); - - if( m.has( kept_delimeters ) ) - m_is_kept.set_delimeters( m[kept_delimeters] ); - - if( m.has( keep_empty_tokens ) ) - m_keep_empty_tokens = true; - - nfp::optionally_assign( m_tokens_left, m, max_tokens ); - } - - template - bool get( Iter& begin, Iter end ) - { - typedef ut_detail::token_assigner::type> Assigner; - Iter check_point; - - this->m_value.clear(); - - if( !m_keep_empty_tokens ) { - while( begin != end && m_is_dropped( *begin ) ) - ++begin; - - if( begin == end ) - return false; - - check_point = begin; - - if( m_tokens_left == 1 ) - while( begin != end ) - Assigner::append_move( begin, this->m_value ); - else if( m_is_kept( *begin ) ) - Assigner::append_move( begin, this->m_value ); - else - while( begin != end && !m_is_dropped( *begin ) && !m_is_kept( *begin ) ) - Assigner::append_move( begin, this->m_value ); - - --m_tokens_left; - } - else { // m_keep_empty_tokens is true - check_point = begin; - - if( begin == end ) { - if( m_token_produced ) - return false; - - m_token_produced = true; - } - if( m_is_kept( *begin ) ) { - if( m_token_produced ) - Assigner::append_move( begin, this->m_value ); - - m_token_produced = !m_token_produced; - } - else if( !m_token_produced && m_is_dropped( *begin ) ) - m_token_produced = true; - else { - if( m_is_dropped( *begin ) ) - check_point = ++begin; - - while( begin != end && !m_is_dropped( *begin ) && !m_is_kept( *begin ) ) - Assigner::append_move( begin, this->m_value ); - - m_token_produced = true; - } - } - - Assigner::assign( check_point, begin, this->m_value ); - - return true; - } - -private: - // Data members - delim_policy m_is_dropped; - delim_policy m_is_kept; - bool m_keep_empty_tokens; - std::size_t m_tokens_left; - bool m_token_produced; -}; - -// ************************************************************************** // -// ************** basic_string_token_iterator ************** // -// ************************************************************************** // - -template > -class basic_string_token_iterator -: public token_iterator_base,CharT,CharCompare> { - typedef basic_cstring cstring; - typedef token_iterator_base,CharT,CharCompare> base; -public: - explicit basic_string_token_iterator() {} - explicit basic_string_token_iterator( cstring src ) - : m_src( src ) - { - this->init(); - } - - template - basic_string_token_iterator( Src src, Modifier const& m ) - : m_src( src ) - { - this->apply_modifier( m ); - - this->init(); - } - -private: - friend class input_iterator_core_access; - - // input iterator implementation - bool get() - { - typename cstring::iterator begin = m_src.begin(); - bool res = base::get( begin, m_src.end() ); - - m_src.assign( begin, m_src.end() ); - - return res; - } - - // Data members - cstring m_src; -}; - -typedef basic_string_token_iterator string_token_iterator; -typedef basic_string_token_iterator wstring_token_iterator; - -// ************************************************************************** // -// ************** range_token_iterator ************** // -// ************************************************************************** // - -template::type>, - typename ValueType = std::basic_string::type>, - typename Reference = ValueType const&> -class range_token_iterator -: public token_iterator_base, - typename iterator_value::type,CharCompare,ValueType,Reference> { - typedef basic_cstring cstring; - typedef token_iterator_base, - typename iterator_value::type,CharCompare,ValueType,Reference> base; -public: - explicit range_token_iterator() {} - explicit range_token_iterator( Iter begin, Iter end = Iter() ) - : m_begin( begin ), m_end( end ) - { - this->init(); - } - range_token_iterator( range_token_iterator const& rhs ) - : base( rhs ) - { - if( this->m_valid ) { - m_begin = rhs.m_begin; - m_end = rhs.m_end; - } - } - - template - range_token_iterator( Iter begin, Iter end, Modifier const& m ) - : m_begin( begin ), m_end( end ) - { - this->apply_modifier( m ); - - this->init(); - } - -private: - friend class input_iterator_core_access; - - // input iterator implementation - bool get() - { - return base::get( m_begin, m_end ); - } - - // Data members - Iter m_begin; - Iter m_end; -}; - -// ************************************************************************** // -// ************** make_range_token_iterator ************** // -// ************************************************************************** // - -template -inline range_token_iterator -make_range_token_iterator( Iter begin, Iter end = Iter() ) -{ - return range_token_iterator( begin, end ); -} - -//____________________________________________________________________________// - -template -inline range_token_iterator -make_range_token_iterator( Iter begin, Iter end, Modifier const& m ) -{ - return range_token_iterator( begin, end, m ); -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TOKEN_ITERATOR_HPP_071894GER - diff --git a/contrib/autoboost/boost/test/utils/lazy_ostream.hpp b/contrib/autoboost/boost/test/utils/lazy_ostream.hpp deleted file mode 100644 index f959a69dd..000000000 --- a/contrib/autoboost/boost/test/utils/lazy_ostream.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : contains definition for all test tools in test toolbox -// *************************************************************************** - -#ifndef BOOST_TEST_LAZY_OSTREAM_HPP_070708GER -#define BOOST_TEST_LAZY_OSTREAM_HPP_070708GER - -// Boost.Test -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** lazy_ostream ************** // -// ************************************************************************** // - -namespace autoboost { - -namespace unit_test { - -class lazy_ostream { -public: - static lazy_ostream& instance() { static lazy_ostream inst; return inst; } - - friend std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ) { return o( ostr ); } - - // access method - bool empty() const { return m_empty; } - - // actual printing interface; to be accessed only by this class and children - virtual std::ostream& operator()( std::ostream& ostr ) const { return ostr; } -protected: - explicit lazy_ostream( bool empty = true ) : m_empty( empty ) {} - - // protected destructor to make sure right one is called -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) -public: -#endif - BOOST_TEST_PROTECTED_VIRTUAL ~lazy_ostream() {} - -private: - // Data members - bool m_empty; -}; - -//____________________________________________________________________________// - -template -class lazy_ostream_impl : public lazy_ostream { -public: - lazy_ostream_impl( lazy_ostream const& prev, T value ) - : lazy_ostream( false ) - , m_prev( prev ) - , m_value( value ) - {} -private: - virtual std::ostream& operator()( std::ostream& ostr ) const - { - return m_prev(ostr) << m_value; - } - - // Data members - lazy_ostream const& m_prev; - T m_value; -}; - -//____________________________________________________________________________// - -template -inline lazy_ostream_impl -operator<<( lazy_ostream const& prev, T const& v ) -{ - return lazy_ostream_impl( prev, v ); -} - -//____________________________________________________________________________// - -#if BOOST_TEST_USE_STD_LOCALE - -template -inline lazy_ostream_impl -operator<<( lazy_ostream const& prev, R& (BOOST_TEST_CALL_DECL *man)(S&) ) -{ - return lazy_ostream_impl( prev, man ); -} - -//____________________________________________________________________________// - -#endif - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_LAZY_OSTREAM_HPP_070708GER diff --git a/contrib/autoboost/boost/test/utils/named_params.hpp b/contrib/autoboost/boost/test/utils/named_params.hpp deleted file mode 100644 index d655e41ca..000000000 --- a/contrib/autoboost/boost/test/utils/named_params.hpp +++ /dev/null @@ -1,329 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : facilities for named function parameters support -// *************************************************************************** - -#ifndef BOOST_TEST_NAMED_PARAM_022505GER -#define BOOST_TEST_NAMED_PARAM_022505GER - -// Boost -#include -#include - -// Boost.Test -#include -#include - -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace nfp { // named function parameters - -// ************************************************************************** // -// ************** forward declarations ************** // -// ************************************************************************** // - -template struct named_parameter; -template struct keyword; - -namespace nfp_detail { - -template struct named_parameter_combine; - -// ************************************************************************** // -// ************** access_to_invalid_parameter ************** // -// ************************************************************************** // - -struct access_to_invalid_parameter {}; - -//____________________________________________________________________________// - -inline void -report_access_to_invalid_parameter() -{ - throw access_to_invalid_parameter(); -} - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** nil ************** // -// ************************************************************************** // - -struct nil { - template -#if defined(__GNUC__) || defined(__HP_aCC) || defined(__EDG__) || defined(__SUNPRO_CC) - operator T() const -#else - operator T const&() const -#endif - { report_access_to_invalid_parameter(); static T* v = 0; return *v; } - - template - T any_cast() const - { report_access_to_invalid_parameter(); static typename remove_reference::type* v = 0; return *v; } - - template - nil operator()( Arg1 const& ) - { report_access_to_invalid_parameter(); return nil(); } - - template - nil operator()( Arg1 const&, Arg2 const& ) - { report_access_to_invalid_parameter(); return nil(); } - - template - nil operator()( Arg1 const&, Arg2 const&, Arg3 const& ) - { report_access_to_invalid_parameter(); return nil(); } - - // Visitation support - template - void apply_to( Visitor& V ) const {} - - static nil& inst() { static nil s_inst; return s_inst; } -private: - nil() {} -}; - -// ************************************************************************** // -// ************** named_parameter_base ************** // -// ************************************************************************** // - -template -struct named_parameter_base { - template - named_parameter_combine - operator,( NP const& np ) const { return named_parameter_combine( np, *static_cast(this) ); } -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** named_parameter_combine ************** // -// ************************************************************************** // - -template -struct named_parameter_combine -: Rest -, named_parameter_base > { - typedef typename NP::ref_type res_type; - typedef named_parameter_combine self_type; - - // Constructor - named_parameter_combine( NP const& np, Rest const& r ) - : Rest( r ) - , m_param( np ) - {} - - // Access methods - res_type operator[]( keyword kw ) const { return m_param[kw]; } - res_type operator[]( keyword kw ) const { return m_param[kw]; } - using Rest::operator[]; - - bool has( keyword kw ) const { return m_param.has( kw ); } - using Rest::has; - - void erase( keyword kw ) const { m_param.erase( kw ); } - using Rest::erase; - -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \ - BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0610)) - template - named_parameter_combine operator,( NP const& np ) const - { return named_parameter_combine( np, *this ); } -#else - using named_parameter_base >::operator,; -#endif - - // Visitation support - template - void apply_to( Visitor& V ) const - { - m_param.apply_to( V ); - - Rest::apply_to( V ); - } -private: - // Data members - NP m_param; -}; - -} // namespace nfp_detail - -// ************************************************************************** // -// ************** named_parameter ************** // -// ************************************************************************** // - -template -struct named_parameter -: nfp_detail::named_parameter_base > -{ - typedef nfp_detail::nil nil_t; - typedef T data_type; - typedef ReferenceType ref_type; - typedef unique_id id; - - // Constructor - explicit named_parameter( ref_type v ) - : m_value( v ) - , m_erased( false ) - {} - named_parameter( named_parameter const& np ) - : m_value( np.m_value ) - , m_erased( np.m_erased ) - {} - - // Access methods - ref_type operator[]( keyword ) const { return m_erased ? nil_t::inst().template any_cast() : m_value; } - ref_type operator[]( keyword ) const { return m_erased ? nil_t::inst().template any_cast() : m_value; } - template - nil_t operator[]( keyword ) const { return nil_t::inst(); } - - bool has( keyword ) const { return !m_erased; } - template - bool has( keyword ) const { return false; } - - void erase( keyword ) const { m_erased = true; } - template - void erase( keyword ) const {} - - // Visitation support - template - void apply_to( Visitor& V ) const - { - V.set_parameter( rtti::type_id(), m_value ); - } - -private: - // Data members - ref_type m_value; - mutable bool m_erased; -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** no_params ************** // -// ************************************************************************** // - -namespace nfp_detail { -typedef named_parameter no_params_type; -} // namespace nfp_detail - -namespace { -nfp_detail::no_params_type no_params( '\0' ); -} // local namespace - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** keyword ************** // -// ************************************************************************** // - -template -struct keyword { - typedef unique_id id; - - template - named_parameter - operator=( T const& t ) const { return named_parameter( t ); } - - template - named_parameter - operator=( T& t ) const { return named_parameter( t ); } - - named_parameter - operator=( char const* t ) const { return named_parameter( t ); } -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** typed_keyword ************** // -// ************************************************************************** // - -template -struct typed_keyword : keyword { - named_parameter - operator=( T const& t ) const { return named_parameter( t ); } - - named_parameter - operator=( T& t ) const { return named_parameter( t ); } -}; - -//____________________________________________________________________________// - -template -struct typed_keyword -: keyword -, named_parameter { - typedef unique_id id; - - typed_keyword() : named_parameter( true ) {} - - named_parameter - operator!() const { return named_parameter( false ); } -}; - -//____________________________________________________________________________// - -// ************************************************************************** // -// ************** optionally_assign ************** // -// ************************************************************************** // - -template -inline void -optionally_assign( T&, nfp_detail::nil ) -{ - nfp_detail::report_access_to_invalid_parameter(); -} - -//____________________________________________________________________________// - -template -inline void -#if BOOST_WORKAROUND( __MWERKS__, BOOST_TESTED_AT( 0x3003 ) ) \ - || BOOST_WORKAROUND( __DECCXX_VER, BOOST_TESTED_AT(60590042) ) -optionally_assign( T& target, Source src ) -#else -optionally_assign( T& target, Source const& src ) -#endif -{ - using namespace unit_test; - - assign_op( target, src, static_cast(0) ); -} - -//____________________________________________________________________________// - -template -inline void -optionally_assign( T& target, Params const& p, Keyword k ) -{ - if( p.has(k) ) - optionally_assign( target, p[k] ); -} - -//____________________________________________________________________________// - -} // namespace nfp - -} // namespace autoboost - -#include - -#endif // BOOST_TEST_NAMED_PARAM_022505GER - diff --git a/contrib/autoboost/boost/test/utils/rtti.hpp b/contrib/autoboost/boost/test/utils/rtti.hpp deleted file mode 100644 index cd5ddfd10..000000000 --- a/contrib/autoboost/boost/test/utils/rtti.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple facilities for accessing type information at runtime -// *************************************************************************** - -#ifndef BOOST_TEST_RTTI_HPP_062604GER -#define BOOST_TEST_RTTI_HPP_062604GER - -#include - -namespace autoboost { - -namespace rtti { - -// ************************************************************************** // -// ************** rtti::type_id ************** // -// ************************************************************************** // - -typedef std::ptrdiff_t id_t; - -namespace rtti_detail { - -template -struct rttid_holder { - static id_t id() { return reinterpret_cast( &inst() ); } - -private: - struct rttid {}; - - static rttid const& inst() { static rttid s_inst; return s_inst; } -}; - -} // namespace rtti_detail - -//____________________________________________________________________________// - -template -inline id_t -type_id() -{ - return rtti_detail::rttid_holder::id(); -} - -//____________________________________________________________________________// - -#define BOOST_RTTI_SWITCH( type_id_ ) if( ::autoboost::rtti::id_t switch_by_id = type_id_ ) -#define BOOST_RTTI_CASE( type ) if( switch_by_id == ::autoboost::rtti::type_id() ) - -//____________________________________________________________________________// - -} // namespace rtti - -} // namespace autoboost - -#endif // BOOST_RT_RTTI_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/argument.hpp b/contrib/autoboost/boost/test/utils/runtime/argument.hpp deleted file mode 100644 index 64e1ac149..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/argument.hpp +++ /dev/null @@ -1,112 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : model of actual argument (both typed and abstract interface) -// *************************************************************************** - -#ifndef BOOST_RT_ARGUMENT_HPP_062604GER -#define BOOST_RT_ARGUMENT_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include -#include - -// Boost.Test -#include -#include - -// STL -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -// ************************************************************************** // -// ************** runtime::argument ************** // -// ************************************************************************** // - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4244) -#endif - -class argument { -public: - // Constructor - argument( parameter const& p, rtti::id_t value_type ) - : p_formal_parameter( p ) - , p_value_type( value_type ) - {} - - // Destructor - virtual ~argument() {} - - // Public properties - unit_test::readonly_property p_formal_parameter; - unit_test::readonly_property p_value_type; -}; - -// ************************************************************************** // -// ************** runtime::typed_argument ************** // -// ************************************************************************** // - -template -class typed_argument : public argument { -public: - // Constructor - explicit typed_argument( parameter const& p ) - : argument( p, rtti::type_id() ) - {} - typed_argument( parameter const& p, T const& t ) - : argument( p, rtti::type_id() ) - , p_value( t ) - {} - - unit_test::readwrite_property p_value; -}; - -// ************************************************************************** // -// ************** runtime::arg_value ************** // -// ************************************************************************** // - -template -inline T const& -arg_value( argument const& arg_ ) -{ - assert( arg_.p_value_type == rtti::type_id() ); // detect logic error - - return static_cast const&>( arg_ ).p_value.value; -} - -//____________________________________________________________________________// - -template -inline T& -arg_value( argument& arg_ ) -{ - assert( arg_.p_value_type == rtti::type_id() ); // detect logic error - - return static_cast&>( arg_ ).p_value.value; -} - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -//____________________________________________________________________________// - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_ARGUMENT_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/argument_factory.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/argument_factory.hpp deleted file mode 100644 index a05e6160a..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/argument_factory.hpp +++ /dev/null @@ -1,218 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : generic typed_argument_factory implementation -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER -#define BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -// Boost.Test -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** default_value_interpreter ************** // -// ************************************************************************** // - -namespace rt_cla_detail { - -struct default_value_interpreter { - template - void operator()( argv_traverser& tr, autoboost::optional& value ) - { - if( interpret_argument_value( tr.token(), value, 0 ) ) - tr.next_token(); - } -}; - -} // namespace rt_cla_detail - -// ************************************************************************** // -// ************** typed_argument_factory ************** // -// ************************************************************************** // - -template -struct typed_argument_factory : public argument_factory { - // Constructor - typed_argument_factory() - : m_value_interpreter( rt_cla_detail::default_value_interpreter() ) - {} - BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~typed_argument_factory() {} - - // properties modification - template - void accept_modifier( Modifier const& m ) - { - optionally_assign( m_value_handler, m, handler ); - optionally_assign( m_value_interpreter, m, interpreter ); - - if( m.has( default_value ) ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, - BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) ); - - T const& dv_ref = m[default_value]; - m_value_generator = rt_cla_detail::const_generator( dv_ref ); - } - - if( m.has( default_refer_to ) ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, - BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) ); - - cstring ref_id = m[default_refer_to]; - m_value_generator = rt_cla_detail::ref_generator( ref_id ); - } - - if( m.has( assign_to ) ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_handler, - BOOST_RT_PARAM_LITERAL( "multiple value handlers for parameter" ) ); - - m_value_handler = rt_cla_detail::assigner( m[assign_to] ); - } - } - - // Argument factory implementation - virtual argument_ptr produce_using( parameter& p, argv_traverser& tr ); - virtual argument_ptr produce_using( parameter& p, parser const& ); - virtual void argument_usage_info( format_stream& fs ); - -// !! private? - // Data members - unit_test::callback2 m_value_handler; - unit_test::callback2&> m_value_generator; - unit_test::callback2&> m_value_interpreter; -}; - -//____________________________________________________________________________// - -template -inline argument_ptr -typed_argument_factory::produce_using( parameter& p, argv_traverser& tr ) -{ - autoboost::optional value; - - try { - m_value_interpreter( tr, value ); - } - catch( ... ) { // !! should we do that? - BOOST_RT_PARAM_TRACE( "Fail to parse argument value" ); - - if( !p.p_optional_value ) - throw; - } - - argument_ptr actual_arg = p.actual_argument(); - - BOOST_RT_CLA_VALIDATE_INPUT( !!value || p.p_optional_value, tr, - BOOST_RT_PARAM_LITERAL( "Argument value missing for parameter " ) << p.id_2_report() ); - - BOOST_RT_CLA_VALIDATE_INPUT( !actual_arg || p.p_multiplicable, tr, - BOOST_RT_PARAM_LITERAL( "Unexpected repetition of the parameter " ) << p.id_2_report() ); - - if( !!value && !!m_value_handler ) - m_value_handler( p, *value ); - - if( !p.p_multiplicable ) - actual_arg.reset( p.p_optional_value && (rtti::type_id() != rtti::type_id()) - ? static_cast(new typed_argument >( p, value )) - : static_cast(new typed_argument( p, *value )) ); - else { - typedef std::list > optional_list; - - if( !actual_arg ) - actual_arg.reset( p.p_optional_value - ? static_cast(new typed_argument( p )) - : static_cast(new typed_argument >( p )) ); - - if( p.p_optional_value ) { - optional_list& values = arg_value( *actual_arg ); - - values.push_back( value ); - } - else { - std::list& values = arg_value >( *actual_arg ); - - values.push_back( *value ); - } - } - - return actual_arg; -} - -//____________________________________________________________________________// - -template -inline argument_ptr -typed_argument_factory::produce_using( parameter& p, parser const& pa ) -{ - argument_ptr actual_arg; - - if( !m_value_generator ) - return actual_arg; - - autoboost::optional value; - m_value_generator( pa, value ); - - if( !value ) - return actual_arg; - - if( !!m_value_handler ) - m_value_handler( p, *value ); - - actual_arg.reset( new typed_argument( p, *value ) ); - - return actual_arg; -} - -//____________________________________________________________________________// - -template -inline void -typed_argument_factory::argument_usage_info( format_stream& fs ) -{ - rt_cla_detail::argument_value_usage( fs, 0, reinterpret_cast(0) ); -} - -//____________________________________________________________________________// - -} // namespace autoboost - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace cla - -#endif // BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.hpp deleted file mode 100644 index af07cca14..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines facility to hide input traversing details -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER -#define BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost.Test -#include - -// Boost -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::argv_traverser ************** // -// ************************************************************************** // - -class argv_traverser : noncopyable { - class parser; -public: - // Constructor - argv_traverser(); - - // public_properties - unit_test::readwrite_property p_ignore_mismatch; - unit_test::readwrite_property p_separator; - - // argc+argv <-> internal buffer exchange - void init( int argc, char_type** argv ); - void remainder( int& argc, char_type** argv ); - - // token based parsing - cstring token() const; - void next_token(); - - // whole input parsing - cstring input() const; - void trim( std::size_t size ); - bool match_front( cstring ); - bool match_front( char_type c ); - bool eoi() const; - - // transaction logic support - void commit(); - void rollback(); - - // current position access; used to save some reference points in input - std::size_t input_pos() const; - - // returns true if mismatch detected during input parsing handled successfully - bool handle_mismatch(); - -private: - // Data members - dstring m_buffer; - cstring m_work_buffer; - - cstring m_token; - cstring::iterator m_commited_end; - - shared_array m_remainder; - std::size_t m_remainder_size; -}; - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.ipp deleted file mode 100644 index c189d2ec9..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/argv_traverser.ipp +++ /dev/null @@ -1,209 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements facility to hide input traversing details -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER -#define BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER - -// Boost.Runtime.Parameter -#include - -#include - -// STL -#include -#include - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::memcpy; } -#endif - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::argv_traverser ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -argv_traverser::argv_traverser() -: p_ignore_mismatch( false ), p_separator( BOOST_RT_PARAM_LITERAL( ' ' ) ) -{ -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::init( int argc, char_type** argv ) -{ - for( int index = 1; index < argc; ++index ) { - m_buffer += argv[index]; - if( index != argc-1 ) - m_buffer += BOOST_RT_PARAM_LITERAL( ' ' ); - } - - m_remainder.reset( new char_type[m_buffer.size()+1] ); - m_remainder_size = 0; - m_work_buffer = m_buffer; - m_commited_end = m_work_buffer.begin(); - - BOOST_RT_PARAM_TRACE( "Input buffer: " << m_buffer ); - - next_token(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::remainder( int& argc, char_type** argv ) -{ - argc = 1; - std::size_t pos = 0; - while(pos < m_remainder_size ) { - argv[argc++] = m_remainder.get() + pos; - - pos = std::find( m_remainder.get() + pos, m_remainder.get() + m_remainder_size, - BOOST_RT_PARAM_LITERAL( ' ' ) ) - m_remainder.get(); - m_remainder[pos++] = BOOST_RT_PARAM_LITERAL( '\0' ); - } -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE cstring -argv_traverser::token() const -{ - return m_token; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::next_token() -{ - if( m_work_buffer.is_empty() ) - return; - - m_work_buffer.trim_left( m_token.size() ); // skip remainder of current token - - if( m_work_buffer.size() != m_buffer.size() ) // !! is there a better way to identify first token - m_work_buffer.trim_left( 1 ); // skip separator if not first token; - - m_token.assign( m_work_buffer.begin(), - std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE cstring -argv_traverser::input() const -{ - return m_work_buffer; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::trim( std::size_t size ) -{ - m_work_buffer.trim_left( size ); - - if( size <= m_token.size() ) - m_token.trim_left( size ); - else { - m_token.assign( m_work_buffer.begin(), - std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) ); - } -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -argv_traverser::match_front( cstring str ) -{ - return m_work_buffer.size() < str.size() ? false : m_work_buffer.substr( 0, str.size() ) == str; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -argv_traverser::match_front( char_type c ) -{ - return first_char( m_work_buffer ) == c; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -argv_traverser::eoi() const -{ - return m_work_buffer.is_empty(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::commit() -{ - m_commited_end = m_work_buffer.begin(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -argv_traverser::rollback() -{ - m_work_buffer.assign( m_commited_end, m_work_buffer.end() ); - m_token.assign( m_work_buffer.begin(), - std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) ); - -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE std::size_t -argv_traverser::input_pos() const -{ - return m_work_buffer.begin() - m_commited_end; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -argv_traverser::handle_mismatch() -{ - if( !p_ignore_mismatch ) - return false; - - std::memcpy( m_remainder.get() + m_remainder_size, token().begin(), token().size() ); - m_remainder_size += token().size(); - m_remainder[m_remainder_size++] = p_separator; - - next_token(); - commit(); - - return true; -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/basic_parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/basic_parameter.hpp deleted file mode 100644 index 6ffdf49bb..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/basic_parameter.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : generic custom parameter generator -// *************************************************************************** - -#ifndef BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include - -// Boost.Test -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::basic_parameter ************** // -// ************************************************************************** // - -template -class basic_parameter : private base_from_member, public typed_parameter { -public: - // Constructors - explicit basic_parameter( cstring n ) - : base_from_member() - , typed_parameter( base_from_member::member ) - { - this->accept_modifier( name = n ); - } - - // parameter properties modification - template - void accept_modifier( Modifier const& m ) - { - typed_parameter::accept_modifier( m ); - - base_from_member::member.accept_modifier( m ); - } -}; - -//____________________________________________________________________________// - -#define BOOST_RT_CLA_NAMED_PARAM_GENERATORS( param_type ) \ -template \ -inline shared_ptr > \ -param_type( cstring name = cstring() ) \ -{ \ - return shared_ptr >( new param_type ## _t( name ) ); \ -} \ - \ -inline shared_ptr > \ -param_type( cstring name = cstring() ) \ -{ \ - return shared_ptr >( new param_type ## _t( name ) ); \ -} \ -/**/ - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.hpp deleted file mode 100644 index 03b09e196..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines model of parameter with single char name -// *************************************************************************** - -#ifndef BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include - -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** char_name_policy ************** // -// ************************************************************************** // - -class char_name_policy : public basic_naming_policy { -public: - // Constructor - char_name_policy(); - BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {} - - // policy interface - virtual bool conflict_with( identification_policy const& ) const; - - // Accept modifier - template - void accept_modifier( Modifier const& m ) - { - basic_naming_policy::accept_modifier( m ); - - BOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name ); - } -}; - -// ************************************************************************** // -// ************** runtime::cla::char_parameter ************** // -// ************************************************************************** // - -template -class char_parameter_t : public basic_parameter { - typedef basic_parameter base; -public: - // Constructors - explicit char_parameter_t( char_type name ) : base( cstring( &name, 1 ) ) {} -}; - -//____________________________________________________________________________// - -template -inline shared_ptr > -char_parameter( char_type name ) -{ - return shared_ptr >( new char_parameter_t( name ) ); -} - -//____________________________________________________________________________// - -inline shared_ptr > -char_parameter( char_type name ) -{ - return shared_ptr >( new char_parameter_t( name ) ); -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.ipp deleted file mode 100644 index e1c457c27..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/char_parameter.ipp +++ /dev/null @@ -1,57 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements model of parameter with single char name -// *************************************************************************** - -#ifndef BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER -#define BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER - -// Boost.Runtime.Parameter -#include - -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** char_name_policy ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -char_name_policy::char_name_policy() -: basic_naming_policy( rtti::type_id() ) -{ - assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -char_name_policy::conflict_with( identification_policy const& id ) const -{ - return id.p_type_id == p_type_id && - p_name == static_cast( id ).p_name; -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp deleted file mode 100644 index b0d927ee4..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/detail/argument_value_usage.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied warranty, -// and with no claim as to its suitability for any purpose. - -// See http://www.boost.org for updates, documentation, and revision history. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : argument usage printing helpers -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER -#define BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include - -// Boost.Test -#include -#include - -#include - -// STL -// !! can we eliminate these includes? -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -namespace rt_cla_detail { - -// ************************************************************************** // -// ************** argument_value_usage ************** // -// ************************************************************************** // - -// generic case -template -inline void -argument_value_usage( format_stream& fs, long, T* = 0 ) -{ - fs << BOOST_RT_PARAM_CSTRING_LITERAL( "" ); -} - -//____________________________________________________________________________// - -// specialization for list of values -template -inline void -argument_value_usage( format_stream& fs, int, std::list* = 0 ) -{ - fs << BOOST_RT_PARAM_CSTRING_LITERAL( "(, ..., )" ); -} - -//____________________________________________________________________________// - -// specialization for type bool -inline void -argument_value_usage( format_stream& fs, int, bool* = 0 ) -{ - fs << BOOST_RT_PARAM_CSTRING_LITERAL( "yes|y|no|n" ); -} - -//____________________________________________________________________________// - -} // namespace rt_cla_detail - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.hpp deleted file mode 100644 index 0eb648e1e..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines model of generic parameter with dual naming -// *************************************************************************** - -#ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** dual_name_policy ************** // -// ************************************************************************** // - -class dual_name_policy : public dual_id_policy { -public: - dual_name_policy(); - - // Accept modifier - template - void accept_modifier( Modifier const& m ) - { - if( m.has( prefix ) ) { - set_prefix( m[prefix] ); - m.erase( prefix ); - } - - if( m.has( name ) ) { - set_name( m[name] ); - m.erase( name ); - } - - if( m.has( separator ) ) { - set_separator( m[separator] ); - m.erase( separator ); - } - - dual_id_policy::accept_modifier( m ); - } -private: - void set_prefix( cstring ); - void set_name( cstring ); - void set_separator( cstring ); -}; - -// ************************************************************************** // -// ************** runtime::cla::dual_name_parameter ************** // -// ************************************************************************** // - -template -class dual_name_parameter_t : public basic_parameter { - typedef basic_parameter base; -public: - // Constructors - explicit dual_name_parameter_t( cstring name ) : base( name ) {} -}; - -//____________________________________________________________________________// - -BOOST_RT_CLA_NAMED_PARAM_GENERATORS( dual_name_parameter ) - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.ipp deleted file mode 100644 index 1e224eebc..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/dual_name_parameter.ipp +++ /dev/null @@ -1,90 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements model of generic parameter with dual naming -// *************************************************************************** - -#ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER -#define BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER - -// Boost.Runtime.Parameter -#include -#include - -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** dual_name_policy ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -dual_name_policy::dual_name_policy() -{ - m_primary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "--" ) ); - m_secondary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "-" ) ); -} - -//____________________________________________________________________________// - -namespace { - -template -inline void -split( string_name_policy& snp, char_name_policy& cnp, cstring src, K const& k ) -{ - cstring::iterator sep = std::find( src.begin(), src.end(), BOOST_RT_PARAM_LITERAL( '|' ) ); - - if( sep != src.begin() ) - snp.accept_modifier( k = cstring( src.begin(), sep ) ); - - if( sep != src.end() ) - cnp.accept_modifier( k = cstring( sep+1, src.end() ) ); -} - -} // local namespace - -BOOST_RT_PARAM_INLINE void -dual_name_policy::set_prefix( cstring src ) -{ - split( m_primary, m_secondary, src, prefix ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -dual_name_policy::set_name( cstring src ) -{ - split( m_primary, m_secondary, src, name ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -dual_name_policy::set_separator( cstring src ) -{ - split( m_primary, m_secondary, src, separator ); -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/fwd.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/fwd.hpp deleted file mode 100644 index 71dd536aa..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/fwd.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : cla subsystem forward declarations -// *************************************************************************** - -#ifndef BOOST_RT_CLA_FWD_HPP_062604GER -#define BOOST_RT_CLA_FWD_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -class parser; -class parameter; -typedef shared_ptr parameter_ptr; -class naming_policy; -typedef shared_ptr naming_policy_ptr; -class argv_traverser; - -namespace rt_cla_detail { - -template class const_generator; -template class ref_generator; - -template class assigner; - -class named_parameter_base; -class positional_parameter_base; - -} // namespace rt_cla_detail - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_FWD_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.hpp deleted file mode 100644 index da38f1ed3..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.hpp +++ /dev/null @@ -1,145 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : some generic identification policies definition -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ID_POLICY_HPP_062604GER -#define BOOST_RT_CLA_ID_POLICY_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include -#include - -#include - -// Boost.Test -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** naming_policy_base ************** // -// ************************************************************************** // -// model: - -class basic_naming_policy : public identification_policy { -public: - // Public properties - unit_test::readwrite_property p_prefix; - unit_test::readwrite_property p_name; - unit_test::readwrite_property p_separator; - - // Policy interface - virtual bool responds_to( cstring name ) const { return p_name == name; } - virtual cstring id_2_report() const { return p_name.get(); } - virtual void usage_info( format_stream& fs ) const; - virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const; - - // Accept modifier - template - void accept_modifier( Modifier const& m ) - { - nfp::optionally_assign( p_prefix.value, m, prefix ); - nfp::optionally_assign( p_name.value, m, name ); - nfp::optionally_assign( p_separator.value, m, separator ); - } - -protected: - explicit basic_naming_policy( rtti::id_t dyn_type ) - : identification_policy( dyn_type ) - {} - BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~basic_naming_policy() {} - - // Naming policy interface - virtual bool match_prefix( argv_traverser& tr ) const; - virtual bool match_name( argv_traverser& tr ) const; - virtual bool match_separator( argv_traverser& tr, bool optional_value ) const; -}; - -// ************************************************************************** // -// ************** dual_id_policy ************** // -// ************************************************************************** // - -template -class dual_id_policy : public identification_policy { -public: - // Constructor - dual_id_policy() - : identification_policy( rtti::type_id() ) - , m_primary() - , m_secondary() - {} - - // Policy interface - virtual bool responds_to( cstring name ) const - { - return m_primary.responds_to( name ) || m_secondary.responds_to( name ); - } - virtual bool conflict_with( identification_policy const& id_p ) const - { - return id_p.conflict_with( m_primary ) || id_p.conflict_with( m_secondary ); - } - virtual cstring id_2_report() const - { - return m_primary.id_2_report(); - } - virtual void usage_info( format_stream& fs ) const - { - fs << BOOST_RT_PARAM_LITERAL( '{' ); - m_primary.usage_info( fs ); - fs << BOOST_RT_PARAM_LITERAL( '|' ); - m_secondary.usage_info( fs ); - fs << BOOST_RT_PARAM_LITERAL( '}' ); - } - virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const - { - return m_primary.matching( p, tr, primary ) || m_secondary.matching( p, tr, primary ); - } - - // Accept modifier - template - void accept_modifier( Modifier const& m ) - { - m_primary.accept_modifier( m ); - m_secondary.accept_modifier( m ); - } - -protected: - BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~dual_id_policy() {} - - // Data members - PrimaryId m_primary; - SecondId m_secondary; -}; - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_ID_POLICY_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.ipp deleted file mode 100644 index 39cf87a14..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/id_policy.ipp +++ /dev/null @@ -1,118 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : some generic identification policies implementation -// *************************************************************************** - -#ifndef BOOST_RT_CLA_ID_POLICY_IPP_062904GER -#define BOOST_RT_CLA_ID_POLICY_IPP_062904GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** basic_naming_policy ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE void -basic_naming_policy::usage_info( format_stream& fs ) const -{ - fs << p_prefix << p_name << p_separator; - - if( p_separator->empty() ) - fs << BOOST_RT_PARAM_LITERAL( ' ' ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -basic_naming_policy::match_prefix( argv_traverser& tr ) const -{ - if( !tr.match_front( p_prefix.get() ) ) - return false; - - tr.trim( p_prefix->size() ); - return true; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -basic_naming_policy::match_name( argv_traverser& tr ) const -{ - if( !tr.match_front( p_name.get() ) ) - return false; - - tr.trim( p_name->size() ); - return true; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -basic_naming_policy::match_separator( argv_traverser& tr, bool optional_value ) const -{ - if( p_separator->empty() ) { - if( !tr.token().is_empty() ) - return false; - - tr.trim( 1 ); - } - else { - if( !tr.match_front( p_separator.get() ) ) { - // if parameter has optional value separator is optional as well - if( optional_value && ( tr.eoi() || tr.match_front( ' ' ) ) ) { - return true; - } - return false; - } - - tr.trim( p_separator->size() ); - } - - return true; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -basic_naming_policy::matching( parameter const& p, argv_traverser& tr, bool ) const -{ - if( !match_prefix( tr ) ) - return false; - - if( !match_name( tr ) ) - return false; - - if( !match_separator( tr, p.p_optional_value ) ) - return false; - - return true; -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_ID_POLICY_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/iface/argument_factory.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/iface/argument_factory.hpp deleted file mode 100644 index b550770b0..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/iface/argument_factory.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines interface for argument_factory -// *************************************************************************** - -#ifndef BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER -#define BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include - -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** argument_factory ************** // -// ************************************************************************** // -// another name can be argument production policy - -class argument_factory { -public: - // Argument factory interface - virtual argument_ptr produce_using( parameter& p, argv_traverser& tr ) = 0; /// produce argument based on input - virtual argument_ptr produce_using( parameter& p, parser const& ) = 0; /// produce argument based on internal generator and/or values of other parameters - virtual void argument_usage_info( format_stream& fs ) = 0; /// argument value format information -protected: - BOOST_TEST_PROTECTED_VIRTUAL ~argument_factory() {} -}; - -} // namespace autoboost - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace cla - -#endif // BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/iface/id_policy.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/iface/id_policy.hpp deleted file mode 100644 index dc1699125..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/iface/id_policy.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines interface for identification_policy -// *************************************************************************** - -#ifndef BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER -#define BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include - -// Boost.Test -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** identification_policy ************** // -// ************************************************************************** // - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4244) -#endif - -class identification_policy { -public: - // Public properties - unit_test::readwrite_property p_type_id; - - // Policy interface - virtual bool responds_to( cstring name ) const = 0; - virtual cstring id_2_report() const = 0; - virtual void usage_info( format_stream& fs ) const = 0; - virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const = 0; - - virtual bool conflict_with( identification_policy const& ) const = 0; - -protected: - // Constructor - explicit identification_policy( rtti::id_t dyn_type ) - : p_type_id( dyn_type ) - {} - BOOST_TEST_PROTECTED_VIRTUAL ~identification_policy() {} -}; - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/modifier.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/modifier.hpp deleted file mode 100644 index 3cb233b62..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/modifier.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : parameter modifiers -// *************************************************************************** - -#ifndef BOOST_RT_CLA_MODIFIER_HPP_062604GER -#define BOOST_RT_CLA_MODIFIER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost.Test -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** environment variable modifiers ************** // -// ************************************************************************** // - -namespace { - -nfp::typed_keyword optional_m; -nfp::named_parameter optional( true ); -nfp::typed_keyword required_m; -nfp::named_parameter required( true ); -nfp::typed_keyword multiplicable_m; -nfp::named_parameter multiplicable( true ); -nfp::typed_keyword guess_name_m; -nfp::named_parameter guess_name( true ); -nfp::typed_keyword ignore_mismatch_m; -nfp::named_parameter ignore_mismatch( true ); -nfp::typed_keyword optional_value_m; -nfp::named_parameter optional_value( true ); - -nfp::typed_keyword input_separator; -nfp::typed_keyword prefix; -nfp::typed_keyword name; -nfp::typed_keyword separator; -nfp::typed_keyword description; -nfp::typed_keyword default_refer_to; - -nfp::keyword default_value; -nfp::keyword handler; -nfp::keyword interpreter; -nfp::keyword assign_to; - -} // local namespace - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_MODIFIER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.hpp deleted file mode 100644 index 0a72b14ff..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines model of named parameter -// *************************************************************************** - -#ifndef BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** string_name_policy ************** // -// ************************************************************************** // - -class string_name_policy : public basic_naming_policy { -public: - // Constructor - string_name_policy(); - BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~string_name_policy() {} - - // policy interface - virtual bool responds_to( cstring name ) const; - virtual bool conflict_with( identification_policy const& ) const; - - // Accept modifier - template - void accept_modifier( Modifier const& m ) - { - basic_naming_policy::accept_modifier( m ); - - if( m.has( guess_name_m ) ) - m_guess_name = true; - } - -private: - // Naming policy interface - virtual bool match_name( argv_traverser& tr ) const; - - // Data members - bool m_guess_name; -}; - -// ************************************************************************** // -// ************** runtime::cla::named_parameter ************** // -// ************************************************************************** // - -template -class named_parameter_t : public basic_parameter { - typedef basic_parameter base; -public: - // Constructors - explicit named_parameter_t( cstring name ) : base( name ) {} -}; - -//____________________________________________________________________________// - -BOOST_RT_CLA_NAMED_PARAM_GENERATORS( named_parameter ) - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.ipp deleted file mode 100644 index 2bf3d3120..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/named_parameter.ipp +++ /dev/null @@ -1,129 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements model of named parameter -// *************************************************************************** - -#ifndef BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER -#define BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -// Boost.Test -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** string_name_policy ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -string_name_policy::string_name_policy() -: basic_naming_policy( rtti::type_id() ) -, m_guess_name( false ) -{ - assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -string_name_policy::responds_to( cstring name ) const -{ - std::pair mm_pos; - - mm_pos = unit_test::mismatch( name.begin(), name.end(), p_name->begin(), p_name->end() ); - - return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == p_name->end()) ); -} - -//____________________________________________________________________________// - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4244) -#endif - -BOOST_RT_PARAM_INLINE bool -string_name_policy::conflict_with( identification_policy const& id ) const -{ - if( id.p_type_id == p_type_id ) { - string_name_policy const& snp = static_cast( id ); - - if( p_name->empty() || snp.p_name->empty() ) - return false; - - if( p_prefix != snp.p_prefix ) - return false; - - std::pair mm_pos = - unit_test::mismatch( p_name->begin(), p_name->end(), snp.p_name->begin(), snp.p_name->end() ); - - return mm_pos.first != p_name->begin() && // there is common substring - ((m_guess_name && (mm_pos.second == snp.p_name->end()) ) || // that match other guy and I am guessing - (snp.m_guess_name && (mm_pos.first == p_name->end()) )); // or me and the other guy is - } - - if( id.p_type_id == rtti::type_id() ) { - char_name_policy const& cnp = static_cast( id ); - - return m_guess_name && - (p_prefix == cnp.p_prefix) && - unit_test::first_char( cstring( p_name ) ) == unit_test::first_char( cstring( cnp.p_name ) ); - } - - return false; -} - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE bool -string_name_policy::match_name( argv_traverser& tr ) const -{ - if( !m_guess_name ) - return basic_naming_policy::match_name( tr ); - - cstring in = tr.input(); - - std::pair mm_pos; - - mm_pos = unit_test::mismatch( in.begin(), in.end(), p_name->begin(), p_name->end() ); - - if( mm_pos.first == in.begin() ) - return false; - - tr.trim( mm_pos.first - in.begin() ); - - return true; -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/parameter.hpp deleted file mode 100644 index 6014292b6..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/parameter.hpp +++ /dev/null @@ -1,150 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines model of formal parameter -// *************************************************************************** - -#ifndef BOOST_RT_CLA_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include -#include - -#include -#include -#include -#include - -// Boost.Test -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::parameter ************** // -// ************************************************************************** // - -class parameter : public BOOST_RT_PARAM_NAMESPACE::parameter { -public: - parameter( identification_policy& ID, argument_factory& F, bool optional_value = false ) - : p_optional( false ) - , p_multiplicable( false ) - , p_optional_value( optional_value ) - , m_id_policy( ID ) - , m_arg_factory( F ) - {} - - // Destructor - virtual ~parameter() {} - - unit_test::readwrite_property p_optional; - unit_test::readwrite_property p_multiplicable; - unit_test::readwrite_property p_optional_value; - unit_test::readwrite_property p_description; - - // parameter properties modification - template - void accept_modifier( Modifier const& m ) - { - if( m.has( optional_m ) ) - p_optional.value = true; - - if( m.has( required_m ) ) - p_optional.value = false; - - if( m.has( multiplicable_m ) ) - p_multiplicable.value = true; - - if( m.has( optional_value_m ) ) - p_optional_value.value = true; - - nfp::optionally_assign( p_description.value, m, description ); - } - - // access methods - bool has_argument() const { return m_actual_argument!=0; } - argument const& actual_argument() const { return *m_actual_argument; } - argument_ptr actual_argument() { return m_actual_argument; } - - - // identification interface - bool responds_to( cstring name ) const { return m_id_policy.responds_to( name ); } - bool conflict_with( parameter const& p ) const - { - return (id_2_report() == p.id_2_report() && !id_2_report().is_empty()) || - m_id_policy.conflict_with( p.m_id_policy ) || - ((m_id_policy.p_type_id != p.m_id_policy.p_type_id) && p.m_id_policy.conflict_with( m_id_policy )); - } - cstring id_2_report() const { return m_id_policy.id_2_report(); } - void usage_info( format_stream& fs ) const - { - m_id_policy.usage_info( fs ); - if( p_optional_value ) - fs << BOOST_RT_PARAM_LITERAL( '[' ); - - m_arg_factory.argument_usage_info( fs ); - - if( p_optional_value ) - fs << BOOST_RT_PARAM_LITERAL( ']' ); - } - - // argument match/produce based on input - bool matching( argv_traverser& tr, bool primary ) const - { - return m_id_policy.matching( *this, tr, primary ); - } - - // argument production based on different source - void produce_argument( argv_traverser& tr ) - { - m_id_policy.matching( *this, tr, true ); // !! can we save this position somehow - m_actual_argument = m_arg_factory.produce_using( *this, tr ); - } - void produce_argument( parser const& p ) - { - m_actual_argument = m_arg_factory.produce_using( *this, p ); - } - -private: - //Data members - identification_policy& m_id_policy; - argument_factory& m_arg_factory; - argument_ptr m_actual_argument; -}; - -//____________________________________________________________________________// - -template -inline shared_ptr -operator-( shared_ptr p, Modifier const& m ) -{ - p->accept_modifier( m ); - - return p; -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/parser.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/parser.hpp deleted file mode 100644 index c3057d38a..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/parser.hpp +++ /dev/null @@ -1,153 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines parser - public interface for CLA parsing and accessing -// *************************************************************************** - -#ifndef BOOST_RT_CLA_PARSER_HPP_062604GER -#define BOOST_RT_CLA_PARSER_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include -#include - -#include -#include -#include - -// Boost -#include - -// STL -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::parser ************** // -// ************************************************************************** // - -namespace cla_detail { - -template -class global_mod_parser { -public: - global_mod_parser( parser& p, Modifier const& m ) - : m_parser( p ) - , m_modifiers( m ) - {} - - template - global_mod_parser const& - operator<<( shared_ptr param ) const - { - param->accept_modifier( m_modifiers ); - - m_parser << param; - - return *this; - } - -private: - // Data members; - parser& m_parser; - Modifier const& m_modifiers; -}; - -} - -// ************************************************************************** // -// ************** runtime::cla::parser ************** // -// ************************************************************************** // - -class parser { -public: - typedef std::list::const_iterator param_iterator; - - // Constructor - explicit parser( cstring program_name = cstring() ); - - // parameter list construction interface - parser& operator<<( parameter_ptr param ); - - // parser and global parameters modifiers - template - cla_detail::global_mod_parser - operator-( Modifier const& m ) - { - nfp::optionally_assign( m_traverser.p_separator.value, m, input_separator ); - nfp::optionally_assign( m_traverser.p_ignore_mismatch.value, m, ignore_mismatch_m ); - - return cla_detail::global_mod_parser( *this, m ); - } - - // input processing method - void parse( int& argc, char_type** argv ); - - // parameters access - param_iterator first_param() const; - param_iterator last_param() const; - - // arguments access - const_argument_ptr operator[]( cstring string_id ) const; - cstring get( cstring string_id ) const; - - template - T const& get( cstring string_id ) const - { - return arg_value( valid_argument( string_id ) ); - } - - template - void get( cstring string_id, autoboost::optional& res ) const - { - const_argument_ptr actual_arg = (*this)[string_id]; - - if( actual_arg ) - res = arg_value( *actual_arg ); - else - res.reset(); - } - - // help/usage - void usage( out_stream& ostr ); - void help( out_stream& ostr ); - -private: - argument const& valid_argument( cstring string_id ) const; - - // Data members - argv_traverser m_traverser; - std::list m_parameters; - dstring m_program_name; -}; - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_PARSER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/parser.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/parser.ipp deleted file mode 100644 index 166db1d23..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/parser.ipp +++ /dev/null @@ -1,258 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements parser - public interface for CLA parsing and accessing -// *************************************************************************** - -#ifndef BOOST_RT_CLA_PARSER_IPP_062904GER -#define BOOST_RT_CLA_PARSER_IPP_062904GER - -// Boost.Runtime.Parameter -#include -#include -#include - -#include -#include -#include -#include -#include - -// Boost.Test -#include -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::parser ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -parser::parser( cstring program_name ) -{ - assign_op( m_program_name, program_name, 0 ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser::param_iterator -parser::first_param() const -{ - return m_parameters.begin(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser::param_iterator -parser::last_param() const -{ - return m_parameters.end(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE argument const& -parser::valid_argument( cstring string_id ) const -{ - const_argument_ptr arg = (*this)[string_id]; - - BOOST_RT_PARAM_VALIDATE_LOGIC( !!arg, "Actual argument for parameter " << string_id << " is not present" ); - - return *arg; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser& -parser::operator<<( parameter_ptr new_param ) -{ - BOOST_TEST_FOREACH( parameter_ptr, old_param, m_parameters ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !old_param->conflict_with( *new_param ), - BOOST_RT_PARAM_LITERAL( "Definition of parameter " ) << new_param->id_2_report() << - BOOST_RT_PARAM_LITERAL( " conflicts with defintion of parameter " ) << old_param->id_2_report() ); - } - - m_parameters.push_back( new_param ); - - return *this; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::parse( int& argc, char_type** argv ) -{ - if( m_program_name.empty() ) { - m_program_name.assign( argv[0] ); - dstring::size_type pos = m_program_name.find_last_of( BOOST_RT_PARAM_LITERAL( "/\\" ) ); - - if( pos != static_cast(cstring::npos) ) - m_program_name.erase( 0, pos+1 ); - } - - m_traverser.init( argc, argv ); - - try { - while( !m_traverser.eoi() ) { - parameter_ptr found_param; - - BOOST_RT_PARAM_TRACE( "Total " << m_parameters.size() << " parameters registered" ); - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - BOOST_RT_PARAM_TRACE( "Try parameter " << curr_param->id_2_report() ); - - if( curr_param->matching( m_traverser, !found_param ) ) { - BOOST_RT_PARAM_TRACE( "Match found" ); - BOOST_RT_CLA_VALIDATE_INPUT( !found_param, (m_traverser.rollback(),m_traverser), "Ambiguous input" ); - - found_param = curr_param; - } - - m_traverser.rollback(); - } - - if( !found_param ) { - BOOST_RT_PARAM_TRACE( "No match found" ); - BOOST_RT_CLA_VALIDATE_INPUT( m_traverser.handle_mismatch(), m_traverser, - BOOST_RT_PARAM_LITERAL( "Unexpected input" ) ); - - continue; - } - - BOOST_RT_PARAM_TRACE( "Parse argument value" ); - found_param->produce_argument( m_traverser ); - - m_traverser.commit(); - } - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( !curr_param->p_optional && !curr_param->actual_argument() ) { - curr_param->produce_argument( *this ); - - BOOST_RT_PARAM_VALIDATE_LOGIC( curr_param->actual_argument(), - BOOST_RT_PARAM_LITERAL( "Required argument for parameter " ) << curr_param->id_2_report() - << BOOST_RT_PARAM_LITERAL( " is missing" ) ); - } - } - } - catch( bad_lexical_cast const& ) { - BOOST_RT_PARAM_REPORT_LOGIC_ERROR( - BOOST_RT_PARAM_LITERAL( "String to value convertion error during input parsing" ) ); - } - - m_traverser.remainder( argc, argv ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE const_argument_ptr -parser::operator[]( cstring string_id ) const -{ - parameter_ptr found_param; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( curr_param->responds_to( string_id ) ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !found_param, - BOOST_RT_PARAM_LITERAL( "Ambiguous parameter string id: " ) << string_id ); - - found_param = curr_param; - } - } - - return found_param ? found_param->actual_argument() : argument_ptr(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE cstring -parser::get( cstring string_id ) const -{ - return get( string_id ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::usage( out_stream& ostr ) -{ - if( m_program_name.empty() ) - assign_op( m_program_name, BOOST_RT_PARAM_CSTRING_LITERAL( "" ), 0 ); - - format_stream fs; - - fs << m_program_name; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - fs << BOOST_RT_PARAM_LITERAL( ' ' ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( '[' ); - - curr_param->usage_info( fs ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( ']' ); - - if( curr_param->p_multiplicable ) { - fs << BOOST_RT_PARAM_CSTRING_LITERAL( " ... " ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( '[' ); - - curr_param->usage_info( fs ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( ']' ); - } - } - - ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "Usage:\n" ) << fs.str() << std::endl; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::help( out_stream& ostr ) -{ - usage( ostr ); - - bool need_where = true; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( curr_param->p_description->empty() ) - continue; - - if( need_where ) { - ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "where:\n" ); - need_where = false; - } - - ostr << curr_param->id_2_report() << BOOST_RT_PARAM_CSTRING_LITERAL( " - " ) << curr_param->p_description << std::endl; - } -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_PARSER_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/typed_parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/typed_parameter.hpp deleted file mode 100644 index 5e735d241..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/typed_parameter.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : generic typed parameter model -// *************************************************************************** - -#ifndef BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER -#define BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -#include -#include - -// Boost.Test -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::typed_parameter ************** // -// ************************************************************************** // - -template -class typed_parameter : public cla::parameter { -public: - explicit typed_parameter( identification_policy& ID ) - : cla::parameter( ID, m_arg_factory, rtti::type_id() == rtti::type_id() ) - {} - - // parameter properties modification - template - void accept_modifier( Modifier const& m ) - { - cla::parameter::accept_modifier( m ); - - m_arg_factory.accept_modifier( m ); - - BOOST_RT_PARAM_VALIDATE_LOGIC( !p_optional || !m_arg_factory.m_value_generator, - BOOST_RT_PARAM_LITERAL( "can't define a value generator for optional parameter " ) << id_2_report() ); - } - -private: - // Data members - typed_argument_factory m_arg_factory; -}; - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/validation.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/validation.hpp deleted file mode 100644 index 97c905530..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/validation.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : input validation helpers definition -// *************************************************************************** - -#ifndef BOOST_RT_CLA_VALIDATION_HPP_062604GER -#define BOOST_RT_CLA_VALIDATION_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::report_input_error ************** // -// ************************************************************************** // - -void report_input_error( argv_traverser const& tr, format_stream& msg ); - -//____________________________________________________________________________// - -#define BOOST_RT_CLA_VALIDATE_INPUT( b, tr, msg ) \ - if( b ) ; else ::autoboost::BOOST_RT_PARAM_NAMESPACE::cla::report_input_error( tr, format_stream().ref() << msg ) - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -# define BOOST_RT_PARAM_INLINE inline -# include - -#endif - -#endif // BOOST_RT_CLA_VALIDATION_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/validation.ipp b/contrib/autoboost/boost/test/utils/runtime/cla/validation.ipp deleted file mode 100644 index ef0de25ba..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/validation.ipp +++ /dev/null @@ -1,65 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : input validation helpers implementation -// *************************************************************************** - -#ifndef BOOST_RT_CLA_VALIDATION_IPP_070604GER -#define BOOST_RT_CLA_VALIDATION_IPP_070604GER - -// Boost.Runtime.Parameter -#include - -#include -#include -#include // BOOST_RT_PARAM_NAMESPACE::logic_error - -// Boost -#include - -// STL - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::validation ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE void -report_input_error( argv_traverser const& tr, format_stream& msg ) -{ - if( tr.eoi() ) - msg << BOOST_RT_PARAM_LITERAL( " at the end of input" ); - else { - msg << BOOST_RT_PARAM_LITERAL( " in the following position: " ); - - if( tr.input().size() > 5 ) - msg << tr.input().substr( 0, 5 ) << BOOST_RT_PARAM_LITERAL( "..." ); - else - msg << tr.input(); - } - - throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() ); -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_VALIDATION_IPP_070604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/value_generator.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/value_generator.hpp deleted file mode 100644 index 54be8505a..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/value_generator.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : specific value generators -// *************************************************************************** - -#ifndef BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER -#define BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -namespace rt_cla_detail { - -// ************************************************************************** // -// ************** runtime::cla::const_generator ************** // -// ************************************************************************** // - -template -class const_generator { -public: - // Constructor - explicit const_generator( T const& t ) : m_const_value( t ) {} - - // generator interface - void operator()( parser const&, autoboost::optional& t ) const { t = m_const_value; } - -private: - // Data members - T m_const_value; -}; - -// ************************************************************************** // -// ************** runtime::cla::ref_generator ************** // -// ************************************************************************** // - -template -class ref_generator { -public: - // Constructor - explicit ref_generator( cstring ref_id ) : m_ref_id( ref_id ) {} - - // generator interface - void operator()( parser const& p, autoboost::optional& t ) const - { - p.get( m_ref_id, t ); - } - -private: - // Data members - cstring m_ref_id; -}; - -//____________________________________________________________________________// - -} // namespace rt_cla_detail - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/cla/value_handler.hpp b/contrib/autoboost/boost/test/utils/runtime/cla/value_handler.hpp deleted file mode 100644 index 22e9e47f3..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/cla/value_handler.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : specific value handlers -// *************************************************************************** - -#ifndef BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER -#define BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -namespace rt_cla_detail { - -// ************************************************************************** // -// ************** runtime::cla::assigner ************** // -// ************************************************************************** // - -template -class assigner { -public: - // Constructor - explicit assigner( T& loc ) : m_target( loc ) {} - - // value handler implementation - void operator()( parameter const&, T& t ) { m_target = t; } - -private: - // Data members - T& m_target; -}; - -} // namespace rt_cla_detail - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/config.hpp b/contrib/autoboost/boost/test/utils/runtime/config.hpp deleted file mode 100644 index a48e60acb..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/config.hpp +++ /dev/null @@ -1,156 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : Runtime.Param library configuration -// *************************************************************************** - -#ifndef BOOST_RT_CONFIG_HPP_062604GER -#define BOOST_RT_CONFIG_HPP_062604GER - -// Boost -#include -#ifdef BOOST_MSVC -# pragma warning(disable: 4511) // copy constructor could not be generated -# pragma warning(disable: 4512) // assignment operator could not be generated -# pragma warning(disable: 4181) // qualifier applied to reference type; ignored -# pragma warning(disable: 4675) // resolved overload was found by argument-dependent lookup -#endif - -// Boost.Test -#include -#include -#include -#include // operator<<(autoboost::runtime::cstring) - -// STL -#include -#include - -//____________________________________________________________________________// - -#ifndef BOOST_RT_PARAM_CUSTOM_STRING -# ifndef BOOST_RT_PARAM_WIDE_STRING -# define BOOST_RT_PARAM_NAMESPACE runtime -# else -# define BOOST_RT_PARAM_NAMESPACE wide_runtime -# endif -#endif - -#ifdef __SUNPRO_CC -extern int putenv(char*); -#endif - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -#ifndef BOOST_RT_PARAM_CUSTOM_STRING -# ifndef BOOST_RT_PARAM_WIDE_STRING - -typedef char char_type; -typedef std::string dstring; -typedef unit_test::const_string cstring; -typedef unit_test::literal_string literal_cstring; -typedef wrap_stringstream format_stream; - -#ifdef BOOST_CLASSIC_IOSTREAMS -typedef std::ostream out_stream; -#else -typedef std::basic_ostream out_stream; -#endif - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4996) // putenv -#endif - -#ifndef UNDER_CE -#if defined(__COMO__) && 0 -inline void -putenv_impl( cstring name, cstring value ) -{ - using namespace std; - // !! this may actually fail. What should we do? - setenv( name.begin(), value.begin(), 1 ); -} -#else -inline void -putenv_impl( cstring name, cstring value ) -{ - format_stream fs; - - fs << name << '=' << value; - - // !! this may actually fail. What should we do? - // const_cast is used to satisfy putenv interface - using namespace std; - putenv( const_cast( fs.str().c_str() ) ); -} -#endif -#endif - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - -#define BOOST_RT_PARAM_LITERAL( l ) l -#define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 ) -#define BOOST_RT_PARAM_GETENV getenv -#define BOOST_RT_PARAM_PUTENV ::autoboost::BOOST_RT_PARAM_NAMESPACE::putenv_impl -#define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD - -//____________________________________________________________________________// - -# else - -typedef wchar_t char_type; -typedef std::basic_string dstring; -typedef unit_test::basic_cstring cstring; -typedef const unit_test::basic_cstring literal_cstring; -typedef wrap_wstringstream format_stream; -typedef std::wostream out_stream; - -#ifndef UNDER_CE -inline void -putenv_impl( cstring name, cstring value ) -{ - format_stream fs; - - fs << name << '=' << value; - - // !! this may actually fail. What should we do? - // const_cast is used to satisfy putenv interface - using namespace std; - wputenv( const_cast( fs.str().c_str() ) ); -} -#endif - -#define BOOST_RT_PARAM_LITERAL( l ) L ## l -#define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 ) -#define BOOST_RT_PARAM_GETENV wgetenv -#define BOOST_RT_PARAM_PUTENV putenv_impl - -# endif -#endif - -#ifdef __GNUC__ -#define BOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual -#else -#define BOOST_RT_PARAM_UNNEEDED_VIRTUAL -#endif - -//____________________________________________________________________________// - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_CONFIG_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/env/environment.hpp b/contrib/autoboost/boost/test/utils/runtime/env/environment.hpp deleted file mode 100644 index e66e38d02..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/env/environment.hpp +++ /dev/null @@ -1,172 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines and implements inline model of program environment -// *************************************************************************** - -#ifndef BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER -#define BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER - -#ifdef UNDER_CE -#error Windows CE does not support environment variables. -#endif - -// Boost.Runtime.Parameter -#include -#include -#include -#include - -#include -#include -#include - -// Boost.Test -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -// ************************************************************************** // -// ************** runtime::environment implementation ************** // -// ************************************************************************** // - -namespace environment { - -namespace rt_env_detail { - -template -variable_data& -init_new_var( cstring var_name, Modifiers m = nfp::no_params ) -{ - rt_env_detail::variable_data& new_vd = new_var_record( var_name ); - - cstring str_value = sys_read_var( new_vd.m_var_name ); - - if( !str_value.is_empty() ) { - try { - autoboost::optional value; - - if( m.has( interpreter ) ) - m[interpreter]( str_value, value ); - else - interpret_argument_value( str_value, value, 0 ); - - if( !!value ) { - new_vd.m_value.reset( new typed_argument( new_vd ) ); - - arg_value( *new_vd.m_value ) = *value; - } - } - catch( ... ) { // !! could we do that - // !! should we report an error? - } - } - - if( !new_vd.m_value && m.has( default_value ) ) { - new_vd.m_value.reset( new typed_argument( new_vd ) ); - - nfp::optionally_assign( arg_value( *new_vd.m_value ), m[default_value] ); - } - - nfp::optionally_assign( new_vd.m_global_id, m, global_id ); - - return new_vd; -} - -//____________________________________________________________________________// - -} // namespace rt_env_detail - -} // namespace environment - -// ************************************************************************** // -// ************** runtime::environment ************** // -// ************************************************************************** // - -namespace environment { - - // variable access - variable_base - var( cstring var_name ); - - //________________________________________________________________________// - - template - inline variable - var( cstring var_name ) - { - rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name ); - - return environment::variable( !vd ? rt_env_detail::init_new_var( var_name, nfp::no_params ) : *vd ); - } - - //________________________________________________________________________// - - template - inline variable - var( cstring var_name, Modifiers const& m ) - { - rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name ); - - return environment::variable( !vd ? rt_env_detail::init_new_var( var_name, m ) : *vd ); - } - - //________________________________________________________________________// - - // direct variable value access - inline cstring - get( cstring var_name ) - { - return environment::var( var_name ).value(); - } - - //________________________________________________________________________// - - template - inline T const& - get( cstring var_name ) - { - return environment::var( var_name ).value(); - } - - //________________________________________________________________________// - - template - inline void - get( cstring var_name, autoboost::optional& res ) - { - variable const& v = environment::var( var_name ); - v.value( res ); - } - - //________________________________________________________________________// - -} // namespace environment - -namespace env = environment; - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#ifndef BOOST_RT_PARAM_OFFLINE - -#define BOOST_RT_PARAM_INLINE inline -#include - -#endif - -#endif // BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/env/environment.ipp b/contrib/autoboost/boost/test/utils/runtime/env/environment.ipp deleted file mode 100644 index 8e0b573d9..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/env/environment.ipp +++ /dev/null @@ -1,125 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements model of program environment -// *************************************************************************** - -#ifndef BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER -#define BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER - -// Boost.Runtime.Parameter -#include -#include - -#include - -// Boost.Test -#include -#include - -// STL -#include -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace environment { - -// ************************************************************************** // -// ************** runtime::environment ************** // -// ************************************************************************** // - -namespace rt_env_detail { - -typedef std::map registry; -typedef std::list keys; - -BOOST_RT_PARAM_INLINE registry& s_registry() { static registry instance; return instance; } -BOOST_RT_PARAM_INLINE keys& s_keys() { static keys instance; return instance; } - -BOOST_RT_PARAM_INLINE variable_data& -new_var_record( cstring var_name ) -{ - // save the name in list of keys - s_keys().push_back( dstring() ); - dstring& key = s_keys().back(); - assign_op( key, var_name, 0 ); - - // create and return new record - variable_data& new_var_data = s_registry()[key]; - - new_var_data.m_var_name = key; - - return new_var_data; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE variable_data* -find_var_record( cstring var_name ) -{ - registry::iterator it = s_registry().find( var_name ); - - return it == s_registry().end() ? 0 : &(it->second); -} - -//____________________________________________________________________________// - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4996) // getenv -#endif - -BOOST_RT_PARAM_INLINE cstring -sys_read_var( cstring var_name ) -{ - using namespace std; - return BOOST_RT_PARAM_GETENV( var_name.begin() ); -} - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -sys_write_var( cstring var_name, format_stream& var_value ) -{ - BOOST_RT_PARAM_PUTENV( var_name, cstring( var_value.str() ) ); -} - -//____________________________________________________________________________// - -} // namespace rt_env_detail - -BOOST_RT_PARAM_INLINE variable_base -var( cstring var_name ) -{ - rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name ); - - BOOST_RT_PARAM_VALIDATE_LOGIC( !!vd, - BOOST_RT_PARAM_LITERAL( "First access to the environment variable " ) - << var_name << BOOST_RT_PARAM_LITERAL( " should be typed" ) ); - - return variable_base( *vd ); -} - -//____________________________________________________________________________// - -} // namespace environment - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER diff --git a/contrib/autoboost/boost/test/utils/runtime/env/fwd.hpp b/contrib/autoboost/boost/test/utils/runtime/env/fwd.hpp deleted file mode 100644 index f21b19dde..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/env/fwd.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : environment subsystem forward declarations -// *************************************************************************** - -#ifndef BOOST_RT_ENV_FWD_HPP_062604GER -#define BOOST_RT_ENV_FWD_HPP_062604GER - -#ifdef UNDER_CE -#error Windows CE does not support environment variables. -#endif - -// Boost.Runtime.Parameter -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace environment { - -class variable_base; -variable_base var( cstring var_name ); - -namespace rt_env_detail { - -struct variable_data; - -variable_data& new_var_record( cstring var_name ); -variable_data* find_var_record( cstring var_name ); - -cstring sys_read_var( cstring var_name ); -void sys_write_var( cstring var_name, format_stream& var_value ); - -} - -template class variable; - -} // namespace environment - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_ENV_FWD_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/env/modifier.hpp b/contrib/autoboost/boost/test/utils/runtime/env/modifier.hpp deleted file mode 100644 index a2c8dc73c..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/env/modifier.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Use, modification, and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines variable modifiers -// *************************************************************************** - -#ifndef BOOST_RT_ENV_MODIFIER_HPP_062604GER -#define BOOST_RT_ENV_MODIFIER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost.Test -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace environment { - -// ************************************************************************** // -// ************** environment variable modifiers ************** // -// ************************************************************************** // - -namespace { - -nfp::typed_keyword global_id; -nfp::keyword default_value; -nfp::keyword interpreter; - -} // local namespace -} // namespace environment - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_ENV_MODIFIER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/env/variable.hpp b/contrib/autoboost/boost/test/utils/runtime/env/variable.hpp deleted file mode 100644 index da19bb213..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/env/variable.hpp +++ /dev/null @@ -1,223 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines model of program environment variable -// *************************************************************************** - -#ifndef BOOST_RT_ENV_VARIABLE_HPP_062604GER -#define BOOST_RT_ENV_VARIABLE_HPP_062604GER - -#ifdef UNDER_CE -#error Windows CE does not support environment variables. -#endif - -// Boost.Runtime.Parameter -#include -#include -#include -#include - -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace environment { - -// ************************************************************************** // -// ************** runtime::environment::variable_data ************** // -// ************************************************************************** // - -namespace rt_env_detail { - -struct variable_data : public runtime::parameter { - cstring m_var_name; - dstring m_global_id; - argument_ptr m_value; -}; - -} // namespace rt_env_detail - -// ************************************************************************** // -// ************** runtime::environment::variable_base ************** // -// ************************************************************************** // - -class variable_base { -public: - explicit variable_base( rt_env_detail::variable_data& data ) : m_data( &data ) {} - - // arguments access - template - T const& value() const - { - return arg_value( *m_data->m_value ); - } - - template - void value( autoboost::optional& res ) const - { - if( has_value() ) - res = arg_value( *m_data->m_value ); - else - res.reset(); - } - - bool has_value() const { return m_data->m_value!=0; } - cstring name() const { return m_data->m_var_name; } - -protected: - // Data members - rt_env_detail::variable_data* m_data; -} ; - -// ************************************************************************** // -// ************** runtime::environment::variable ************** // -// ************************************************************************** // - -template -class variable : public variable_base { -public: - // Constructors - explicit variable( cstring var_name ); - - template - explicit variable( cstring var_name, Modifiers const& m ); - - explicit variable( rt_env_detail::variable_data& data ) - : variable_base( data ) {} - - // other variable assignment - void operator=( variable const& v ) { m_data = v.m_data; } - - // access methods - T const& value() const { return variable_base::value(); } - -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \ - BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0593)) - template - void value( autoboost::optional& res ) const { variable_base::value( res ); } -#else - using variable_base::value; -#endif - - // Value assignment - template - void operator=( V const& v ) - { - if( !has_value() ) - m_data->m_value.reset( new typed_argument( *m_data ) ); - - arg_value( *m_data->m_value ) = v; - - rt_env_detail::sys_write_var( m_data->m_var_name, format_stream().ref() << value() ); - } -}; // class variable - -//____________________________________________________________________________// - -template -inline std::basic_ostream& -operator<<( std::basic_ostream& os, variable const& v ) -{ - os << v.name() << '='; - - if( v.has_value() ) - os << v.value(); - - return os; -} - -//____________________________________________________________________________// - -template -inline bool -operator==( variable ev, V const& v ) -{ - return ev.has_value() && ev.value() == v; -} - -//____________________________________________________________________________// - -template -inline bool -operator==( V const& v, variable ev ) -{ - return ev.has_value() && ev.value() == v; -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( variable ev, V const& v ) -{ - return !ev.has_value() || ev.value() != v; -} - -//____________________________________________________________________________// - -template -inline bool -operator!=( V const& v, variable ev ) -{ - return !ev.has_value() || ev.value() != v; -} - -//____________________________________________________________________________// - -} // namespace environment - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -// ************************************************************************** // -// ************************************************************************** // -// Implementation - -#include - -// ************************************************************************** // -// ************** runtime::environment::variable ************** // -// ************************************************************************** // - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace environment { - -template -variable::variable( cstring var_name ) -: variable_base( environment::var( var_name ) ) -{} - -//____________________________________________________________________________// - -template -template -variable::variable( cstring var_name, Modifiers const& m ) -: variable_base( environment::var( var_name, m ) ) -{} - -//____________________________________________________________________________// - -} // namespace environment - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_ENV_VARIABLE_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/fwd.hpp b/contrib/autoboost/boost/test/utils/runtime/fwd.hpp deleted file mode 100644 index 490a16853..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/fwd.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : global framework level forward declaration -// *************************************************************************** - -#ifndef BOOST_RT_FWD_HPP_062604GER -#define BOOST_RT_FWD_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -class parameter; - -class argument; -typedef shared_ptr argument_ptr; -typedef shared_ptr const_argument_ptr; - -template class value_interpreter; -template class typed_argument; - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_FWD_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/interpret_argument_value.hpp b/contrib/autoboost/boost/test/utils/runtime/interpret_argument_value.hpp deleted file mode 100644 index f352135bc..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/interpret_argument_value.hpp +++ /dev/null @@ -1,163 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : default algorithms for string to specific type convertions -// *************************************************************************** - -#ifndef BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER -#define BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER - -// Boost.Runtime.Parameter -#include -#include - -// Boost.Test -#include -#include - -// Boost -#include -#include - -// STL -// !! could we eliminate these includes? -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -// ************************************************************************** // -// ************** runtime::interpret_argument_value ************** // -// ************************************************************************** // -// returns true if source is used false otherwise - -// generic case -template -struct interpret_argument_value_impl { - static bool _( cstring source, autoboost::optional& res ) - { - BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<" << typeid(T).name() << ">" ); - - res = lexical_cast( source ); - - BOOST_RT_PARAM_TRACE( "String " << source << " is interpreted as " << *res ); - return true; - } -}; - - -//____________________________________________________________________________// - -// dstring case -template<> -struct interpret_argument_value_impl { - static bool _( cstring source, autoboost::optional& res ) - { - BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl" ); - - res = dstring(); - assign_op( *res, source, 0 ); - - return true; - } -}; - -//____________________________________________________________________________// - -// cstring case -template<> -struct interpret_argument_value_impl { - static bool _( cstring source, autoboost::optional& res ) - { - BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl" ); - - res = source; - - return true; - } -}; - -//____________________________________________________________________________// - -// specialization for type bool -template<> -struct interpret_argument_value_impl { - static bool _( cstring source, autoboost::optional& res ) - { - BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl" ); - - static literal_cstring YES( BOOST_RT_PARAM_CSTRING_LITERAL( "YES" ) ); - static literal_cstring Y( BOOST_RT_PARAM_CSTRING_LITERAL( "Y" ) ); - static literal_cstring NO( BOOST_RT_PARAM_CSTRING_LITERAL( "NO" ) ); - static literal_cstring N( BOOST_RT_PARAM_CSTRING_LITERAL( "N" ) ); - static literal_cstring one( BOOST_RT_PARAM_CSTRING_LITERAL( "1" ) ); - static literal_cstring zero( BOOST_RT_PARAM_CSTRING_LITERAL( "0" ) ); - - source.trim(); - - if( case_ins_eq( source, YES ) || case_ins_eq( source, Y ) || case_ins_eq( source, one ) ) { - res = true; - return true; - } - else if( case_ins_eq( source, NO ) || case_ins_eq( source, N ) || case_ins_eq( source, zero ) ) { - res = false; - return true; - } - else { - res = true; - return false; - } - } -}; - -//____________________________________________________________________________// - -template -inline bool -interpret_argument_value( cstring source, autoboost::optional& res, long ) -{ - return interpret_argument_value_impl::_( source, res ); -} - -//____________________________________________________________________________// - -// specialization for list of values -template -inline bool -interpret_argument_value( cstring source, autoboost::optional >& res, int ) -{ - BOOST_RT_PARAM_TRACE( "In interpret_argument_value>" ); - - res = std::list(); - - while( !source.is_empty() ) { - // !! should we use token_iterator - cstring::iterator single_value_end = std::find( source.begin(), source.end(), BOOST_RT_PARAM_LITERAL( ',' ) ); - - autoboost::optional value; - interpret_argument_value( cstring( source.begin(), single_value_end ), value, 0 ); - - res->push_back( *value ); - - source.trim_left( single_value_end + 1 ); - } - - return true; -} - -//____________________________________________________________________________// - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/parameter.hpp b/contrib/autoboost/boost/test/utils/runtime/parameter.hpp deleted file mode 100644 index 6881b945f..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/parameter.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : abstract interface for the formal parameter -// *************************************************************************** - -#ifndef BOOST_RT_PARAMETER_HPP_062604GER -#define BOOST_RT_PARAMETER_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -// ************************************************************************** // -// ************** runtime::parameter ************** // -// ************************************************************************** // - -class parameter { -public: - virtual ~parameter() {} -}; - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_PARAMETER_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/trace.hpp b/contrib/autoboost/boost/test/utils/runtime/trace.hpp deleted file mode 100644 index 5c4e2a7c0..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/trace.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : optional internal tracing -// *************************************************************************** - -#ifndef BOOST_RT_TRACE_HPP_062604GER -#define BOOST_RT_TRACE_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -#ifdef BOOST_RT_PARAM_DEBUG - -#include - -# define BOOST_RT_PARAM_TRACE( str ) std::cerr << str << std::endl -#else -# define BOOST_RT_PARAM_TRACE( str ) -#endif - -#endif // BOOST_RT_TRACE_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/runtime/validation.hpp b/contrib/autoboost/boost/test/utils/runtime/validation.hpp deleted file mode 100644 index 4b92ae278..000000000 --- a/contrib/autoboost/boost/test/utils/runtime/validation.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines exceptions and validation tools -// *************************************************************************** - -#ifndef BOOST_RT_VALIDATION_HPP_062604GER -#define BOOST_RT_VALIDATION_HPP_062604GER - -// Boost.Runtime.Parameter -#include - -// Boost.Test -#include - -// Boost -#include - -// STL -#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD -#include -#endif - -namespace autoboost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -// ************************************************************************** // -// ************** runtime::logic_error ************** // -// ************************************************************************** // - -class logic_error -#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD -: public std::exception -#endif -{ - typedef shared_ptr dstring_ptr; -public: - // Constructor // !! could we eliminate shared_ptr - explicit logic_error( cstring msg ) : m_msg( new dstring( msg.begin(), msg.size() ) ) {} - ~logic_error() throw() {} - - dstring const& msg() const { return *m_msg; } - virtual char_type const* what() const throw() { return m_msg->c_str(); } - -private: - dstring_ptr m_msg; -}; - -// ************************************************************************** // -// ************** runtime::report_logic_error ************** // -// ************************************************************************** // - -inline void -report_logic_error( format_stream& msg ) -{ - throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() ); -} - -//____________________________________________________________________________// - -#define BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg ) \ - autoboost::BOOST_RT_PARAM_NAMESPACE::report_logic_error( format_stream().ref() << msg ) - -#define BOOST_RT_PARAM_VALIDATE_LOGIC( b, msg ) \ - if( b ) {} else BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg ) - -//____________________________________________________________________________// - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace autoboost - -#endif // BOOST_RT_VALIDATION_HPP_062604GER diff --git a/contrib/autoboost/boost/test/utils/trivial_singleton.hpp b/contrib/autoboost/boost/test/utils/trivial_singleton.hpp deleted file mode 100644 index 4bfc40c98..000000000 --- a/contrib/autoboost/boost/test/utils/trivial_singleton.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple helpers for creating cusom output manipulators -// *************************************************************************** - -#ifndef BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER -#define BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER - -#include -#include - -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** singleton ************** // -// ************************************************************************** // - -template -class singleton : private autoboost::noncopyable { -public: - static Derived& instance() { static Derived the_inst; return the_inst; } -protected: - singleton() {} - ~singleton() {} -}; - -} // namespace unit_test - -#define BOOST_TEST_SINGLETON_CONS( type ) \ -friend class autoboost::unit_test::singleton; \ -type() {} \ -/**/ - -#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4 -#define BOOST_TEST_SINGLETON_INST( inst ) \ -static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance(); - -#else - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#endif - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER diff --git a/contrib/autoboost/boost/test/utils/wrap_stringstream.hpp b/contrib/autoboost/boost/test/utils/wrap_stringstream.hpp deleted file mode 100644 index 53fd07574..000000000 --- a/contrib/autoboost/boost/test/utils/wrap_stringstream.hpp +++ /dev/null @@ -1,164 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2002-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : wraps strstream and stringstream (depends with one is present) -// to provide the unified interface -// *************************************************************************** - -#ifndef BOOST_WRAP_STRINGSTREAM_HPP_071894GER -#define BOOST_WRAP_STRINGSTREAM_HPP_071894GER - -// Boost.Test -#include - -// STL -#ifdef BOOST_NO_STRINGSTREAM -#include // for std::ostrstream -#else -#include // for std::ostringstream -#endif // BOOST_NO_STRINGSTREAM - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -// ************************************************************************** // -// ************** basic_wrap_stringstream ************** // -// ************************************************************************** // - -template -class basic_wrap_stringstream { -public: -#if defined(BOOST_CLASSIC_IOSTREAMS) - typedef std::ostringstream wrapped_stream; -#elif defined(BOOST_NO_STRINGSTREAM) - typedef std::basic_ostrstream wrapped_stream; -#else - typedef std::basic_ostringstream wrapped_stream; -#endif // BOOST_NO_STRINGSTREAM - // Access methods - basic_wrap_stringstream& ref(); - wrapped_stream& stream(); - std::basic_string const& str(); - -private: - // Data members - wrapped_stream m_stream; - std::basic_string m_str; -}; - -//____________________________________________________________________________// - -template -inline basic_wrap_stringstream& -operator<<( basic_wrap_stringstream& targ, T const& t ) -{ - targ.stream() << t; - return targ; -} - -//____________________________________________________________________________// - -template -inline typename basic_wrap_stringstream::wrapped_stream& -basic_wrap_stringstream::stream() -{ - return m_stream; -} - -//____________________________________________________________________________// - -template -inline basic_wrap_stringstream& -basic_wrap_stringstream::ref() -{ - return *this; -} - -//____________________________________________________________________________// - -template -inline std::basic_string const& -basic_wrap_stringstream::str() -{ - -#ifdef BOOST_NO_STRINGSTREAM - m_str.assign( m_stream.str(), m_stream.pcount() ); - m_stream.freeze( false ); -#else - m_str = m_stream.str(); -#endif - - return m_str; -} - -//____________________________________________________________________________// - -template -inline basic_wrap_stringstream& -operator<<( basic_wrap_stringstream& targ, basic_wrap_stringstream& src ) -{ - targ << src.str(); - return targ; -} - -//____________________________________________________________________________// - -#if BOOST_TEST_USE_STD_LOCALE - -template -inline basic_wrap_stringstream& -operator<<( basic_wrap_stringstream& targ, std::ios_base& (BOOST_TEST_CALL_DECL *man)(std::ios_base&) ) -{ - targ.stream() << man; - return targ; -} - -//____________________________________________________________________________// - -template -inline basic_wrap_stringstream& -operator<<( basic_wrap_stringstream& targ, std::basic_ostream& (BOOST_TEST_CALL_DECL *man)(std::basic_ostream&) ) -{ - targ.stream() << man; - return targ; -} - -//____________________________________________________________________________// - -template -inline basic_wrap_stringstream& -operator<<( basic_wrap_stringstream& targ, std::basic_ios& (BOOST_TEST_CALL_DECL *man)(std::basic_ios&) ) -{ - targ.stream() << man; - return targ; -} - -//____________________________________________________________________________// - -#endif - -// ************************************************************************** // -// ************** wrap_stringstream ************** // -// ************************************************************************** // - -typedef basic_wrap_stringstream wrap_stringstream; -typedef basic_wrap_stringstream wrap_wstringstream; - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_WRAP_STRINGSTREAM_HPP_071894GER diff --git a/contrib/autoboost/boost/test/utils/xml_printer.hpp b/contrib/autoboost/boost/test/utils/xml_printer.hpp deleted file mode 100644 index 27344e125..000000000 --- a/contrib/autoboost/boost/test/utils/xml_printer.hpp +++ /dev/null @@ -1,118 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : common code used by any agent serving as XML printer -// *************************************************************************** - -#ifndef BOOST_TEST_XML_PRINTER_HPP_071894GER -#define BOOST_TEST_XML_PRINTER_HPP_071894GER - -// Boost.Test -#include -#include -#include -#include -#include - -// Boost -#include - -// STL -#include - -#include - -//____________________________________________________________________________// - -namespace autoboost { - -namespace unit_test { - -// ************************************************************************** // -// ************** xml print helpers ************** // -// ************************************************************************** // - -inline void -print_escaped( std::ostream& where_to, const_string value ) -{ - static fixed_mapping char_type( - '<' , "lt", - '>' , "gt", - '&' , "amp", - '\'', "apos" , - '"' , "quot", - - 0 - ); - - BOOST_TEST_FOREACH( char, c, value ) { - char const* ref = char_type[c]; - - if( ref ) - where_to << '&' << ref << ';'; - else - where_to << c; - } -} - -//____________________________________________________________________________// - -inline void -print_escaped( std::ostream& where_to, std::string const& value ) -{ - print_escaped( where_to, const_string( value ) ); -} - -//____________________________________________________________________________// - -template -inline void -print_escaped( std::ostream& where_to, T const& value ) -{ - where_to << value; -} - -//____________________________________________________________________________// - -typedef custom_manip attr_value; - -template -inline std::ostream& -operator<<( custom_printer const& p, T const& value ) -{ - *p << "=\""; - print_escaped( *p, value ); - *p << '"'; - - return *p; -} - -//____________________________________________________________________________// - -typedef custom_manip cdata; - -inline std::ostream& -operator<<( custom_printer const& p, const_string value ) -{ - return *p << BOOST_TEST_L( "" ); -} - -//____________________________________________________________________________// - -} // namespace unit_test - -} // namespace autoboost - -//____________________________________________________________________________// - -#include - -#endif // BOOST_TEST_XML_PRINTER_HPP_071894GER diff --git a/contrib/autoboost/libs/test/src/compiler_log_formatter.cpp b/contrib/autoboost/libs/test/src/compiler_log_formatter.cpp deleted file mode 100644 index fa174fb2b..000000000 --- a/contrib/autoboost/libs/test/src/compiler_log_formatter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/cpp_main.cpp b/contrib/autoboost/libs/test/src/cpp_main.cpp deleted file mode 100644 index 805a27fd3..000000000 --- a/contrib/autoboost/libs/test/src/cpp_main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF - diff --git a/contrib/autoboost/libs/test/src/debug.cpp b/contrib/autoboost/libs/test/src/debug.cpp deleted file mode 100644 index 864d6f218..000000000 --- a/contrib/autoboost/libs/test/src/debug.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2006-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// *************************************************************************** -// Revision History : -// -// $Log$ -// *************************************************************************** - -// EOF diff --git a/contrib/autoboost/libs/test/src/exception_safety.cpp b/contrib/autoboost/libs/test/src/exception_safety.cpp deleted file mode 100644 index 6f0219636..000000000 --- a/contrib/autoboost/libs/test/src/exception_safety.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF - diff --git a/contrib/autoboost/libs/test/src/execution_monitor.cpp b/contrib/autoboost/libs/test/src/execution_monitor.cpp deleted file mode 100644 index 9702ed976..000000000 --- a/contrib/autoboost/libs/test/src/execution_monitor.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/framework.cpp b/contrib/autoboost/libs/test/src/framework.cpp deleted file mode 100644 index 986f20b99..000000000 --- a/contrib/autoboost/libs/test/src/framework.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/interaction_based.cpp b/contrib/autoboost/libs/test/src/interaction_based.cpp deleted file mode 100644 index f3dc76ff3..000000000 --- a/contrib/autoboost/libs/test/src/interaction_based.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/logged_expectations.cpp b/contrib/autoboost/libs/test/src/logged_expectations.cpp deleted file mode 100644 index c8f690f9c..000000000 --- a/contrib/autoboost/libs/test/src/logged_expectations.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/plain_report_formatter.cpp b/contrib/autoboost/libs/test/src/plain_report_formatter.cpp deleted file mode 100644 index 8ef03c361..000000000 --- a/contrib/autoboost/libs/test/src/plain_report_formatter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/progress_monitor.cpp b/contrib/autoboost/libs/test/src/progress_monitor.cpp deleted file mode 100644 index 5ee24d5d3..000000000 --- a/contrib/autoboost/libs/test/src/progress_monitor.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/results_collector.cpp b/contrib/autoboost/libs/test/src/results_collector.cpp deleted file mode 100644 index e6be408e2..000000000 --- a/contrib/autoboost/libs/test/src/results_collector.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/results_reporter.cpp b/contrib/autoboost/libs/test/src/results_reporter.cpp deleted file mode 100644 index a1790923f..000000000 --- a/contrib/autoboost/libs/test/src/results_reporter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/test_main.cpp b/contrib/autoboost/libs/test/src/test_main.cpp deleted file mode 100644 index d12dee5db..000000000 --- a/contrib/autoboost/libs/test/src/test_main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/test_tools.cpp b/contrib/autoboost/libs/test/src/test_tools.cpp deleted file mode 100644 index 905e3514b..000000000 --- a/contrib/autoboost/libs/test/src/test_tools.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/unit_test_log.cpp b/contrib/autoboost/libs/test/src/unit_test_log.cpp deleted file mode 100644 index e1da09763..000000000 --- a/contrib/autoboost/libs/test/src/unit_test_log.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/unit_test_main.cpp b/contrib/autoboost/libs/test/src/unit_test_main.cpp deleted file mode 100644 index c031c584a..000000000 --- a/contrib/autoboost/libs/test/src/unit_test_main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/unit_test_monitor.cpp b/contrib/autoboost/libs/test/src/unit_test_monitor.cpp deleted file mode 100644 index 6a94a4650..000000000 --- a/contrib/autoboost/libs/test/src/unit_test_monitor.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/unit_test_parameters.cpp b/contrib/autoboost/libs/test/src/unit_test_parameters.cpp deleted file mode 100644 index 419527b84..000000000 --- a/contrib/autoboost/libs/test/src/unit_test_parameters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/unit_test_suite.cpp b/contrib/autoboost/libs/test/src/unit_test_suite.cpp deleted file mode 100644 index 6fe2f318b..000000000 --- a/contrib/autoboost/libs/test/src/unit_test_suite.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/xml_log_formatter.cpp b/contrib/autoboost/libs/test/src/xml_log_formatter.cpp deleted file mode 100644 index e44f45888..000000000 --- a/contrib/autoboost/libs/test/src/xml_log_formatter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF diff --git a/contrib/autoboost/libs/test/src/xml_report_formatter.cpp b/contrib/autoboost/libs/test/src/xml_report_formatter.cpp deleted file mode 100644 index 4f0f59bfb..000000000 --- a/contrib/autoboost/libs/test/src/xml_report_formatter.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : forwarding source -// *************************************************************************** - -#define BOOST_TEST_SOURCE -#include - -// EOF From 9789946cc1fb13118f61e5b0ac699a354fecca83 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:21:15 -0800 Subject: [PATCH 27/57] Eliminating boost::coroutine There's nothing strictly wrong with coroutines, but we currently have no use for them in Autowiring. The current preference is to make use of OS-provided thread pooling features rather than making use of coroutines where they are used for parallelization, and in other cases where they are used to implement yield, we use explicit state. --- contrib/autoboost/boost/coroutine/all.hpp | 21 - .../boost/coroutine/asymmetric_coroutine.hpp | 2243 ----------------- .../autoboost/boost/coroutine/attributes.hpp | 94 - .../autoboost/boost/coroutine/coroutine.hpp | 13 - .../boost/coroutine/detail/config.hpp | 49 - .../coroutine/detail/coroutine_context.hpp | 62 - .../boost/coroutine/detail/flags.hpp | 48 - .../boost/coroutine/detail/parameters.hpp | 102 - .../coroutine/detail/pull_coroutine_impl.hpp | 355 --- .../detail/pull_coroutine_object.hpp | 324 --- .../detail/pull_coroutine_synthesized.hpp | 80 - .../coroutine/detail/push_coroutine_impl.hpp | 295 --- .../detail/push_coroutine_object.hpp | 336 --- .../detail/push_coroutine_synthesized.hpp | 78 - .../boost/coroutine/detail/setup.hpp | 75 - .../detail/symmetric_coroutine_call.hpp | 822 ------ .../detail/symmetric_coroutine_impl.hpp | 472 ---- .../detail/symmetric_coroutine_object.hpp | 281 --- .../detail/symmetric_coroutine_yield.hpp | 307 --- .../boost/coroutine/detail/trampoline.hpp | 67 - .../coroutine/detail/trampoline_pull.hpp | 48 - .../coroutine/detail/trampoline_push.hpp | 77 - .../autoboost/boost/coroutine/exceptions.hpp | 105 - contrib/autoboost/boost/coroutine/flags.hpp | 27 - .../posix/protected_stack_allocator.hpp | 105 - .../posix/segmented_stack_allocator.hpp | 69 - .../coroutine/protected_stack_allocator.hpp | 13 - .../coroutine/segmented_stack_allocator.hpp | 15 - .../boost/coroutine/stack_allocator.hpp | 37 - .../boost/coroutine/stack_context.hpp | 66 - .../boost/coroutine/stack_traits.hpp | 42 - .../coroutine/standard_stack_allocator.hpp | 75 - .../boost/coroutine/symmetric_coroutine.hpp | 35 - .../windows/protected_stack_allocator.hpp | 87 - 34 files changed, 6925 deletions(-) delete mode 100644 contrib/autoboost/boost/coroutine/all.hpp delete mode 100644 contrib/autoboost/boost/coroutine/asymmetric_coroutine.hpp delete mode 100644 contrib/autoboost/boost/coroutine/attributes.hpp delete mode 100644 contrib/autoboost/boost/coroutine/coroutine.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/config.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/coroutine_context.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/flags.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/parameters.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/pull_coroutine_impl.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/pull_coroutine_object.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/pull_coroutine_synthesized.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/push_coroutine_impl.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/push_coroutine_object.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/push_coroutine_synthesized.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/setup.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_call.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_impl.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_object.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_yield.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/trampoline.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/trampoline_pull.hpp delete mode 100644 contrib/autoboost/boost/coroutine/detail/trampoline_push.hpp delete mode 100644 contrib/autoboost/boost/coroutine/exceptions.hpp delete mode 100644 contrib/autoboost/boost/coroutine/flags.hpp delete mode 100644 contrib/autoboost/boost/coroutine/posix/protected_stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/posix/segmented_stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/protected_stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/segmented_stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/stack_context.hpp delete mode 100644 contrib/autoboost/boost/coroutine/stack_traits.hpp delete mode 100644 contrib/autoboost/boost/coroutine/standard_stack_allocator.hpp delete mode 100644 contrib/autoboost/boost/coroutine/symmetric_coroutine.hpp delete mode 100644 contrib/autoboost/boost/coroutine/windows/protected_stack_allocator.hpp diff --git a/contrib/autoboost/boost/coroutine/all.hpp b/contrib/autoboost/boost/coroutine/all.hpp deleted file mode 100644 index 42f63a0a7..000000000 --- a/contrib/autoboost/boost/coroutine/all.hpp +++ /dev/null @@ -1,21 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_ALL_H -#define BOOST_COROUTINES_ALL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // BOOST_COROUTINES_ALL_H diff --git a/contrib/autoboost/boost/coroutine/asymmetric_coroutine.hpp b/contrib/autoboost/boost/coroutine/asymmetric_coroutine.hpp deleted file mode 100644 index 81f05722c..000000000 --- a/contrib/autoboost/boost/coroutine/asymmetric_coroutine.hpp +++ /dev/null @@ -1,2243 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_ASYMMETRIC_COROUTINE_H -#define BOOST_COROUTINES_ASYMMETRIC_COROUTINE_H - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -template< typename R > -class pull_coroutine; - -template< typename Arg > -class push_coroutine -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::pull_coroutine_object; - - typedef detail::push_coroutine_impl< Arg > impl_type; - typedef detail::push_coroutine_synthesized< Arg > synth_type; - typedef detail::parameters< Arg > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( push_coroutine) - - explicit push_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - push_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( pull_coroutine< Arg > &); - - explicit push_coroutine( coroutine_fn, - attributes const& = attributes() ); - - template< typename StackAllocator > - explicit push_coroutine( coroutine_fn, - attributes const&, - StackAllocator); -# endif - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#else - template< typename Fn > - explicit push_coroutine( Fn fn, - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( Fn fn, - attributes const&, - StackAllocator); - - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#endif - - ~push_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - push_coroutine( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - push_coroutine & operator=( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT - { - push_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - void swap( push_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - push_coroutine & operator()( Arg arg) - { - BOOST_ASSERT( * this); - - impl_->push( arg); - return * this; - } - - class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > - { - private: - push_coroutine< Arg > * c_; - - public: - iterator() : - c_( 0) - {} - - explicit iterator( push_coroutine< Arg > * c) : - c_( c) - {} - - iterator & operator=( Arg a) - { - BOOST_ASSERT( c_); - if ( ! ( * c_)( a) ) c_ = 0; - return * this; - } - - bool operator==( iterator const& other) const - { return other.c_ == c_; } - - bool operator!=( iterator const& other) const - { return other.c_ != c_; } - - iterator & operator*() - { return * this; } - - iterator & operator++() - { return * this; } - }; - - struct const_iterator; -}; - -template< typename Arg > -class push_coroutine< Arg & > -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::pull_coroutine_object; - - typedef detail::push_coroutine_impl< Arg & > impl_type; - typedef detail::push_coroutine_synthesized< Arg & > synth_type; - typedef detail::parameters< Arg & > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( push_coroutine) - - explicit push_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - push_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( pull_coroutine< Arg & > &); - - explicit push_coroutine( coroutine_fn, - attributes const& = attributes() ); - - template< typename StackAllocator > - explicit push_coroutine( coroutine_fn, - attributes const&, - StackAllocator); -# endif - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#else - template< typename Fn > - explicit push_coroutine( Fn, - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( Fn, - attributes const&, - StackAllocator); - - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#endif - - ~push_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - push_coroutine( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - push_coroutine & operator=( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT - { - push_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - void swap( push_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - push_coroutine & operator()( Arg & arg) - { - BOOST_ASSERT( * this); - - impl_->push( arg); - return * this; - } - - class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > - { - private: - push_coroutine< Arg & > * c_; - - public: - iterator() : - c_( 0) - {} - - explicit iterator( push_coroutine< Arg & > * c) : - c_( c) - {} - - iterator & operator=( Arg & a) - { - BOOST_ASSERT( c_); - if ( ! ( * c_)( a) ) c_ = 0; - return * this; - } - - bool operator==( iterator const& other) const - { return other.c_ == c_; } - - bool operator!=( iterator const& other) const - { return other.c_ != c_; } - - iterator & operator*() - { return * this; } - - iterator & operator++() - { return * this; } - }; - - struct const_iterator; -}; - -template<> -class push_coroutine< void > -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::pull_coroutine_object; - - typedef detail::push_coroutine_impl< void > impl_type; - typedef detail::push_coroutine_synthesized< void > synth_type; - typedef detail::parameters< void > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( push_coroutine) - - explicit push_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - push_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( pull_coroutine< void > &); - - explicit push_coroutine( coroutine_fn, - attributes const& = attributes() ); - - template< typename StackAllocator > - explicit push_coroutine( coroutine_fn, - attributes const&, - StackAllocator); -# endif - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#else - template< typename Fn > - explicit push_coroutine( Fn, - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( Fn, - attributes const&, - StackAllocator); - - template< typename Fn > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const& = attributes() ); - - template< typename Fn, typename StackAllocator > - explicit push_coroutine( BOOST_RV_REF( Fn), - attributes const&, - StackAllocator); -#endif - - ~push_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - inline push_coroutine( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - inline push_coroutine & operator=( BOOST_RV_REF( push_coroutine) other) BOOST_NOEXCEPT - { - push_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - inline bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - inline void swap( push_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - inline push_coroutine & operator()() - { - BOOST_ASSERT( * this); - - impl_->push(); - return * this; - } - - struct iterator; - struct const_iterator; -}; - - - -template< typename R > -class pull_coroutine -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::push_coroutine_object; - - typedef detail::pull_coroutine_impl< R > impl_type; - typedef detail::pull_coroutine_synthesized< R > synth_type; - typedef detail::parameters< R > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( pull_coroutine) - - explicit pull_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - pull_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( push_coroutine< R > &); - - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename StackAllocator > - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -# endif - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#else - template< typename Fn > - explicit pull_coroutine( Fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R >, R, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#endif - - ~pull_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - pull_coroutine( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - pull_coroutine & operator=( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT - { - pull_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - void swap( pull_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - pull_coroutine & operator()() - { - BOOST_ASSERT( * this); - - impl_->pull(); - return * this; - } - - R get() const - { - BOOST_ASSERT( 0 != impl_); - - return impl_->get(); - } - - class iterator : public std::iterator< std::input_iterator_tag, typename remove_reference< R >::type > - { - private: - pull_coroutine< R > * c_; - R * val_; - - void fetch_() - { - BOOST_ASSERT( c_); - - if ( ! ( * c_) ) - { - c_ = 0; - val_ = 0; - return; - } - val_ = c_->impl_->get_pointer(); - } - - void increment_() - { - BOOST_ASSERT( c_); - BOOST_ASSERT( * c_); - - ( * c_)(); - fetch_(); - } - - public: - typedef typename iterator::pointer pointer_t; - typedef typename iterator::reference reference_t; - - iterator() : - c_( 0), val_( 0) - {} - - explicit iterator( pull_coroutine< R > * c) : - c_( c), val_( 0) - { fetch_(); } - - iterator( iterator const& other) : - c_( other.c_), val_( other.val_) - {} - - iterator & operator=( iterator const& other) - { - if ( this == & other) return * this; - c_ = other.c_; - val_ = other.val_; - return * this; - } - - bool operator==( iterator const& other) const - { return other.c_ == c_ && other.val_ == val_; } - - bool operator!=( iterator const& other) const - { return other.c_ != c_ || other.val_ != val_; } - - iterator & operator++() - { - increment_(); - return * this; - } - - iterator operator++( int) - { - iterator tmp( * this); - ++*this; - return tmp; - } - - reference_t operator*() const - { - if ( ! val_) - autoboost::throw_exception( - invalid_result() ); - return * val_; - } - - pointer_t operator->() const - { - if ( ! val_) - autoboost::throw_exception( - invalid_result() ); - return val_; - } - }; - - friend class iterator; - - struct const_iterator; -}; - -template< typename R > -class pull_coroutine< R & > -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::push_coroutine_object; - - typedef detail::pull_coroutine_impl< R & > impl_type; - typedef detail::pull_coroutine_synthesized< R & > synth_type; - typedef detail::parameters< R & > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( pull_coroutine) - - explicit pull_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - pull_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( push_coroutine< R & > &); - - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename StackAllocator > - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -# endif - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#else - template< typename Fn > - explicit pull_coroutine( Fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< R & >, R &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#endif - - ~pull_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - pull_coroutine( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - pull_coroutine & operator=( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT - { - pull_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - void swap( pull_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - pull_coroutine & operator()() - { - BOOST_ASSERT( * this); - - impl_->pull(); - return * this; - } - - R & get() const - { return impl_->get(); } - - class iterator : public std::iterator< std::input_iterator_tag, R > - { - private: - pull_coroutine< R & > * c_; - R * val_; - - void fetch_() - { - BOOST_ASSERT( c_); - - if ( ! ( * c_) ) - { - c_ = 0; - val_ = 0; - return; - } - val_ = c_->impl_->get_pointer(); - } - - void increment_() - { - BOOST_ASSERT( c_); - BOOST_ASSERT( * c_); - - ( * c_)(); - fetch_(); - } - - public: - typedef typename iterator::pointer pointer_t; - typedef typename iterator::reference reference_t; - - iterator() : - c_( 0), val_( 0) - {} - - explicit iterator( pull_coroutine< R & > * c) : - c_( c), val_( 0) - { fetch_(); } - - iterator( iterator const& other) : - c_( other.c_), val_( other.val_) - {} - - iterator & operator=( iterator const& other) - { - if ( this == & other) return * this; - c_ = other.c_; - val_ = other.val_; - return * this; - } - - bool operator==( iterator const& other) const - { return other.c_ == c_ && other.val_ == val_; } - - bool operator!=( iterator const& other) const - { return other.c_ != c_ || other.val_ != val_; } - - iterator & operator++() - { - increment_(); - return * this; - } - - iterator operator++( int) - { - iterator tmp( * this); - ++*this; - return tmp; - } - - reference_t operator*() const - { - if ( ! val_) - autoboost::throw_exception( - invalid_result() ); - return * val_; - } - - pointer_t operator->() const - { - if ( ! val_) - autoboost::throw_exception( - invalid_result() ); - return val_; - } - }; - - friend class iterator; - - struct const_iterator; -}; - -template<> -class pull_coroutine< void > -{ -private: - template< typename V, typename X, typename Y, typename Z > - friend class detail::push_coroutine_object; - - typedef detail::pull_coroutine_impl< void > impl_type; - typedef detail::pull_coroutine_synthesized< void > synth_type; - typedef detail::parameters< void > param_type; - - struct dummy {}; - - impl_type * impl_; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( pull_coroutine) - - explicit pull_coroutine( detail::synthesized_t::flag_t, impl_type & impl) : - impl_( & impl) - { BOOST_ASSERT( impl_); } - -public: - pull_coroutine() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( push_coroutine< void > &); - - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename StackAllocator > - explicit pull_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -# endif - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#else - template< typename Fn > - explicit pull_coroutine( Fn fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } - - template< typename Fn, typename StackAllocator > - explicit pull_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::pull_coroutine_object< - push_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - impl_->pull(); - } -#endif - - ~pull_coroutine() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - inline pull_coroutine( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - inline pull_coroutine & operator=( BOOST_RV_REF( pull_coroutine) other) BOOST_NOEXCEPT - { - pull_coroutine tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - inline bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete(); } - - inline void swap( pull_coroutine & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - inline pull_coroutine & operator()() - { - BOOST_ASSERT( * this); - - impl_->pull(); - return * this; - } - - struct iterator; - struct const_iterator; -}; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC -template< typename Arg > -push_coroutine< Arg >::push_coroutine( coroutine_fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename StackAllocator > -push_coroutine< Arg >::push_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -push_coroutine< Arg & >::push_coroutine( coroutine_fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename StackAllocator > -push_coroutine< Arg & >::push_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -inline push_coroutine< void >::push_coroutine( coroutine_fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, coroutine_fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename StackAllocator > -push_coroutine< void >::push_coroutine( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, coroutine_fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} -# endif -template< typename Arg > -template< typename Fn > -push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn > -push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn > -push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn, typename StackAllocator > -push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} -#else -template< typename Arg > -template< typename Fn > -push_coroutine< Arg >::push_coroutine( Fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg >::push_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn > -push_coroutine< Arg & >::push_coroutine( Fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg & >::push_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn > -push_coroutine< void >::push_coroutine( Fn fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn, typename StackAllocator > -push_coroutine< void >::push_coroutine( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn > -push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg >, Arg, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn > -push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Arg > -template< typename Fn, typename StackAllocator > -push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< Arg & >, Arg &, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn > -push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - stack_allocator stack_alloc; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, stack_allocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} - -template< typename Fn, typename StackAllocator > -push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) -{ - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef detail::push_coroutine_object< - pull_coroutine< void >, void, Fn, StackAllocator - > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); -} -#endif - -template< typename R > -void swap( pull_coroutine< R > & l, pull_coroutine< R > & r) BOOST_NOEXCEPT -{ l.swap( r); } - -template< typename Arg > -void swap( push_coroutine< Arg > & l, push_coroutine< Arg > & r) BOOST_NOEXCEPT -{ l.swap( r); } - -template< typename R > -typename pull_coroutine< R >::iterator -range_begin( pull_coroutine< R > & c) -{ return typename pull_coroutine< R >::iterator( & c); } - -template< typename R > -typename pull_coroutine< R >::iterator -range_end( pull_coroutine< R > &) -{ return typename pull_coroutine< R >::iterator(); } - -template< typename Arg > -typename push_coroutine< Arg >::iterator -range_begin( push_coroutine< Arg > & c) -{ return typename push_coroutine< Arg >::iterator( & c); } - -template< typename Arg > -typename push_coroutine< Arg >::iterator -range_end( push_coroutine< Arg > &) -{ return typename push_coroutine< Arg >::iterator(); } - -template< typename T > -struct asymmetric_coroutine -{ - typedef push_coroutine< T > push_type; - typedef pull_coroutine< T > pull_type; -}; - -// deprecated -template< typename T > -struct coroutine -{ - typedef push_coroutine< T > push_type; - typedef pull_coroutine< T > pull_type; -}; - -template< typename R > -typename pull_coroutine< R >::iterator -begin( pull_coroutine< R > & c) -{ return autoboost::begin( c); } - -template< typename R > -typename pull_coroutine< R >::iterator -end( pull_coroutine< R > & c) -{ return autoboost::end( c); } - -template< typename R > -typename push_coroutine< R >::iterator -begin( push_coroutine< R > & c) -{ return autoboost::begin( c); } - -template< typename R > -typename push_coroutine< R >::iterator -end( push_coroutine< R > & c) -{ return autoboost::end( c); } - -} - -template< typename Arg > -struct range_mutable_iterator< coroutines::push_coroutine< Arg > > -{ typedef typename coroutines::push_coroutine< Arg >::iterator type; }; - -template< typename R > -struct range_mutable_iterator< coroutines::pull_coroutine< R > > -{ typedef typename coroutines::pull_coroutine< R >::iterator type; }; - -} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_ASYMMETRIC_COROUTINE_H diff --git a/contrib/autoboost/boost/coroutine/attributes.hpp b/contrib/autoboost/boost/coroutine/attributes.hpp deleted file mode 100644 index e46a485e7..000000000 --- a/contrib/autoboost/boost/coroutine/attributes.hpp +++ /dev/null @@ -1,94 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_ATTRIBUTES_H -#define BOOST_COROUTINES_ATTRIBUTES_H - -#include - -#include - -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct attributes -{ - std::size_t size; - flag_unwind_t do_unwind; - flag_fpu_t preserve_fpu; - - attributes() BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( stack_unwind), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( std::size_t size_) BOOST_NOEXCEPT : - size( size_), - do_unwind( stack_unwind), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( flag_unwind_t do_unwind_) BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( do_unwind_), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( stack_unwind), - preserve_fpu( preserve_fpu_) - {} - - explicit attributes( - std::size_t size_, - flag_unwind_t do_unwind_) BOOST_NOEXCEPT : - size( size_), - do_unwind( do_unwind_), - preserve_fpu( fpu_preserved) - {} - - explicit attributes( - std::size_t size_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( size_), - do_unwind( stack_unwind), - preserve_fpu( preserve_fpu_) - {} - - explicit attributes( - flag_unwind_t do_unwind_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( stack_allocator::traits_type::default_size() ), - do_unwind( do_unwind_), - preserve_fpu( preserve_fpu_) - {} - - explicit attributes( - std::size_t size_, - flag_unwind_t do_unwind_, - flag_fpu_t preserve_fpu_) BOOST_NOEXCEPT : - size( size_), - do_unwind( do_unwind_), - preserve_fpu( preserve_fpu_) - {} -}; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_ATTRIBUTES_H diff --git a/contrib/autoboost/boost/coroutine/coroutine.hpp b/contrib/autoboost/boost/coroutine/coroutine.hpp deleted file mode 100644 index 076ffd26e..000000000 --- a/contrib/autoboost/boost/coroutine/coroutine.hpp +++ /dev/null @@ -1,13 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_COROUTINE_H -#define BOOST_COROUTINES_COROUTINE_H - -#include -#include - -#endif // BOOST_COROUTINES_COROUTINE_H diff --git a/contrib/autoboost/boost/coroutine/detail/config.hpp b/contrib/autoboost/boost/coroutine/detail/config.hpp deleted file mode 100644 index 7a88561ee..000000000 --- a/contrib/autoboost/boost/coroutine/detail/config.hpp +++ /dev/null @@ -1,49 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_CONFIG_H -#define BOOST_COROUTINES_DETAIL_CONFIG_H - -#include -#include - -#ifdef BOOST_COROUTINES_DECL -# undef BOOST_COROUTINES_DECL -#endif - -#if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_COROUTINES_DYN_LINK) ) && ! defined(BOOST_COROUTINES_STATIC_LINK) -# if defined(BOOST_COROUTINES_SOURCE) -# define BOOST_COROUTINES_DECL BOOST_SYMBOL_EXPORT -# define BOOST_COROUTINES_BUILD_DLL -# else -# define BOOST_COROUTINES_DECL BOOST_SYMBOL_IMPORT -# endif -#endif - -#if ! defined(BOOST_COROUTINES_DECL) -# define BOOST_COROUTINES_DECL -#endif - -#if ! defined(BOOST_COROUTINES_SOURCE) && ! defined(BOOST_ALL_NO_LIB) && ! defined(BOOST_COROUTINES_NO_LIB) -# define BOOST_LIB_NAME autoboost_coroutine -# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_COROUTINES_DYN_LINK) -# define BOOST_DYN_LINK -# endif -# include -#endif - -#if defined(BOOST_USE_SEGMENTED_STACKS) -# if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ - (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) -# error "compiler does not support segmented stacks" -# endif -# define BOOST_COROUTINES_SEGMENTS 10 -#endif - -#define BOOST_COROUTINES_UNIDIRECT -#define BOOST_COROUTINES_SYMMETRIC - -#endif // BOOST_COROUTINES_DETAIL_CONFIG_H diff --git a/contrib/autoboost/boost/coroutine/detail/coroutine_context.hpp b/contrib/autoboost/boost/coroutine/detail/coroutine_context.hpp deleted file mode 100644 index 7d0c0bdb0..000000000 --- a/contrib/autoboost/boost/coroutine/detail/coroutine_context.hpp +++ /dev/null @@ -1,62 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H -#define BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H - -#include - -#include -#include -#include - -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -// class hold stack-context and coroutines execution-context -class BOOST_COROUTINES_DECL coroutine_context - -{ -private: - stack_context stack_ctx_; - context::fcontext_t ctx_; - -public: - typedef void( * ctx_fn)( intptr_t); - - // default ctor represents the current execution-context - coroutine_context(); - - // ctor creates a new execution-context running coroutine-fn `fn` - // `ctx_` will be allocated on top of the stack managed by parameter - // `stack_ctx` - coroutine_context( ctx_fn fn, stack_context const& stack_ctx); - - coroutine_context( coroutine_context const&); - - coroutine_context& operator=( coroutine_context const&); - - intptr_t jump( coroutine_context &, intptr_t = 0, bool = true); - - stack_context & stack_ctx() - { return stack_ctx_; } -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_COROUTINE_CONTEXT_H diff --git a/contrib/autoboost/boost/coroutine/detail/flags.hpp b/contrib/autoboost/boost/coroutine/detail/flags.hpp deleted file mode 100644 index dd28e5938..000000000 --- a/contrib/autoboost/boost/coroutine/detail/flags.hpp +++ /dev/null @@ -1,48 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_FLAGS_H -#define BOOST_COROUTINES_DETAIL_FLAGS_H - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -enum flag_t -{ - flag_started = 1 << 1, - flag_running = 1 << 2, - flag_complete = 1 << 3, - flag_unwind_stack = 1 << 4, - flag_force_unwind = 1 << 5, - flag_preserve_fpu = 1 << 6 -}; - -struct unwind_t -{ - enum flag_t - { force_unwind = 1 }; -}; - -struct synthesized_t -{ - enum flag_t - { syntesized = 1 }; -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_FLAGS_H diff --git a/contrib/autoboost/boost/coroutine/detail/parameters.hpp b/contrib/autoboost/boost/coroutine/detail/parameters.hpp deleted file mode 100644 index acaf8c2c9..000000000 --- a/contrib/autoboost/boost/coroutine/detail/parameters.hpp +++ /dev/null @@ -1,102 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PARAMETERS_H -#define BOOST_COROUTINES_DETAIL_PARAMETERS_H - -#include -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Data > -struct parameters -{ - Data * data; - bool do_unwind; - void * coro; - - parameters() : - data( 0), do_unwind( false), coro( 0) - {} - - explicit parameters( void * coro_) : - data( 0), do_unwind( false), coro( coro_) - { BOOST_ASSERT( 0 != coro); } - - explicit parameters( Data * data_, void * coro_) : - data( data_), do_unwind( false), coro( coro_) - { - BOOST_ASSERT( 0 != data); - BOOST_ASSERT( 0 != coro); - } - - explicit parameters( unwind_t::flag_t) : - data( 0), do_unwind( true) - {} -}; - -template< typename Data > -struct parameters< Data & > -{ - Data * data; - bool do_unwind; - void * coro; - - parameters() : - data( 0), do_unwind( false), coro( 0) - {} - - explicit parameters( void * coro_) : - data( 0), do_unwind( false), coro( coro_) - { BOOST_ASSERT( 0 != coro); } - - explicit parameters( Data * data_, void * coro_) : - data( data_), do_unwind( false), coro( coro_) - { - BOOST_ASSERT( 0 != data); - BOOST_ASSERT( 0 != coro); - } - - explicit parameters( unwind_t::flag_t) : - data( 0), do_unwind( true), coro( 0) - {} -}; - -template<> -struct parameters< void > -{ - bool do_unwind; - void * coro; - - parameters() : - do_unwind( false), coro(0) - {} - - parameters( void * coro_) : - do_unwind( false), coro( coro_) - { BOOST_ASSERT( 0 != coro); } - - explicit parameters( unwind_t::flag_t) : - do_unwind( true), coro( 0) - {} -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PARAMETERS_H diff --git a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_impl.hpp b/contrib/autoboost/boost/coroutine/detail/pull_coroutine_impl.hpp deleted file mode 100644 index 77aa88f00..000000000 --- a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_impl.hpp +++ /dev/null @@ -1,355 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PULL_COROUTINE_IMPL_H -#define BOOST_COROUTINES_DETAIL_PULL_COROUTINE_IMPL_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct stack_context; - -namespace detail { - -template< typename R > -class pull_coroutine_impl : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - R * result_; - -public: - typedef parameters< R > param_type; - - pull_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee), - result_( 0) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - pull_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu, - R * result) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee), - result_( result) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~pull_coroutine_impl() {} - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void pull() - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - result_ = from->data; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - bool has_result() const - { return 0 != result_; } - - R get() const - { - if ( ! has_result() ) - autoboost::throw_exception( - invalid_result() ); - return * result_; - } - - R * get_pointer() const - { - if ( ! has_result() ) - autoboost::throw_exception( - invalid_result() ); - return result_; - } - - virtual void destroy() = 0; -}; - -template< typename R > -class pull_coroutine_impl< R & > : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - R * result_; - -public: - typedef parameters< R & > param_type; - - pull_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee), - result_( 0) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - pull_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu, - R * result) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee), - result_( result) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~pull_coroutine_impl() {} - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void pull() - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - result_ = from->data; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - bool has_result() const - { return 0 != result_; } - - R & get() const - { - if ( ! has_result() ) - autoboost::throw_exception( - invalid_result() ); - return * result_; - } - - R * get_pointer() const - { - if ( ! has_result() ) - autoboost::throw_exception( - invalid_result() ); - return result_; - } - - virtual void destroy() = 0; -}; - -template<> -class pull_coroutine_impl< void > : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - -public: - typedef parameters< void > param_type; - - pull_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~pull_coroutine_impl() {} - - inline bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - inline bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - inline bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - inline bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - inline bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - inline void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - inline void pull() - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - virtual void destroy() = 0; -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PULL_COROUTINE_IMPL_H diff --git a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_object.hpp b/contrib/autoboost/boost/coroutine/detail/pull_coroutine_object.hpp deleted file mode 100644 index 8c1ece06f..000000000 --- a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_object.hpp +++ /dev/null @@ -1,324 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PULL_COROUTINE_OBJECT_H -#define BOOST_COROUTINES_DETAIL_PULL_COROUTINE_OBJECT_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4355) -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -struct pull_coroutine_context -{ - coroutine_context caller; - coroutine_context callee; - - template< typename Coro > - pull_coroutine_context( stack_context const& stack_ctx, Coro *) : - caller(), - callee( trampoline_pull< Coro >, stack_ctx) - {} -}; - -template< typename PushCoro, typename R, typename Fn, typename StackAllocator > -class pull_coroutine_object : private pull_coroutine_context, - public pull_coroutine_impl< R > -{ -private: - typedef pull_coroutine_context ctx_t; - typedef pull_coroutine_impl< R > base_t; - typedef pull_coroutine_object< PushCoro, R, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - pull_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - pull_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run() - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); - PushCoro push_coro( synthesized_t::syntesized, b); - try - { fn_( push_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename PushCoro, typename R, typename Fn, typename StackAllocator > -class pull_coroutine_object< PushCoro, R &, Fn, StackAllocator > : private pull_coroutine_context, - public pull_coroutine_impl< R & > -{ -private: - typedef pull_coroutine_context ctx_t; - typedef pull_coroutine_impl< R & > base_t; - typedef pull_coroutine_object< PushCoro, R &, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - pull_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - pull_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run() - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); - PushCoro push_coro( synthesized_t::syntesized, b); - try - { fn_( push_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename PushCoro, typename Fn, typename StackAllocator > -class pull_coroutine_object< PushCoro, void, Fn, StackAllocator > : private pull_coroutine_context, - public pull_coroutine_impl< void > -{ -private: - typedef pull_coroutine_context ctx_t; - typedef pull_coroutine_impl< void > base_t; - typedef pull_coroutine_object< PushCoro, void, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - pull_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - pull_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run() - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PushCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); - PushCoro push_coro( synthesized_t::syntesized, b); - try - { fn_( push_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -}}} - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PULL_COROUTINE_OBJECT_H diff --git a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_synthesized.hpp b/contrib/autoboost/boost/coroutine/detail/pull_coroutine_synthesized.hpp deleted file mode 100644 index 9fb5d323b..000000000 --- a/contrib/autoboost/boost/coroutine/detail/pull_coroutine_synthesized.hpp +++ /dev/null @@ -1,80 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PULL_COROUTINE_SYNTHESIZED_H -#define BOOST_COROUTINES_DETAIL_PULL_COROUTINE_SYNTHESIZED_H - -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename R > -class pull_coroutine_synthesized : public pull_coroutine_impl< R > -{ -private: - typedef pull_coroutine_impl< R > impl_t; - -public: - pull_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu, - R * result) : - impl_t( caller, callee, unwind, preserve_fpu, result) - {} - - void destroy() {} -}; - -template< typename R > -class pull_coroutine_synthesized< R & > : public pull_coroutine_impl< R & > -{ -private: - typedef pull_coroutine_impl< R & > impl_t; - -public: - pull_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu, - R * result) : - impl_t( caller, callee, unwind, preserve_fpu, result) - {} - - void destroy() {} -}; - -template<> -class pull_coroutine_synthesized< void > : public pull_coroutine_impl< void > -{ -private: - typedef pull_coroutine_impl< void > impl_t; - -public: - pull_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) - {} - - inline void destroy() {} -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PULL_COROUTINE_SYNTHESIZED_H diff --git a/contrib/autoboost/boost/coroutine/detail/push_coroutine_impl.hpp b/contrib/autoboost/boost/coroutine/detail/push_coroutine_impl.hpp deleted file mode 100644 index 2cf31f889..000000000 --- a/contrib/autoboost/boost/coroutine/detail/push_coroutine_impl.hpp +++ /dev/null @@ -1,295 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_IMPL_H -#define BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_IMPL_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct stack_context; - -namespace detail { - -template< typename Arg > -class push_coroutine_impl : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - -public: - typedef parameters< Arg > param_type; - - push_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void push( Arg const& arg) - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( const_cast< Arg * >( & arg), this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - void push( BOOST_RV_REF( Arg) arg) - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( const_cast< Arg * >( & arg), this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - virtual void destroy() = 0; -}; - -template< typename Arg > -class push_coroutine_impl< Arg & > : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - -public: - typedef parameters< Arg & > param_type; - - push_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void push( Arg & arg) - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( & arg, this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - virtual void destroy() = 0; -}; - -template<> -class push_coroutine_impl< void > : private noncopyable -{ -protected: - int flags_; - exception_ptr except_; - coroutine_context * caller_; - coroutine_context * callee_; - -public: - typedef parameters< void > param_type; - - push_coroutine_impl( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - flags_( 0), - except_(), - caller_( caller), - callee_( callee) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - inline bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - inline bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - inline bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - inline bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - inline bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - inline void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - param_type to( unwind_t::force_unwind); - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - inline void push() - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - param_type to( this); - param_type * from( - reinterpret_cast< param_type * >( - caller_->jump( - * callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ &= ~flag_running; - if ( from->do_unwind) throw forced_unwind(); - if ( except_) rethrow_exception( except_); - } - - virtual void destroy() = 0; -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_IMPL_H diff --git a/contrib/autoboost/boost/coroutine/detail/push_coroutine_object.hpp b/contrib/autoboost/boost/coroutine/detail/push_coroutine_object.hpp deleted file mode 100644 index c23645182..000000000 --- a/contrib/autoboost/boost/coroutine/detail/push_coroutine_object.hpp +++ /dev/null @@ -1,336 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_OBJECT_H -#define BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_OBJECT_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4355) -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -struct push_coroutine_context -{ - coroutine_context caller; - coroutine_context callee; - - template< typename Coro > - push_coroutine_context( stack_context const& stack_ctx, Coro *) : - caller(), - callee( trampoline_push< Coro >, stack_ctx) - {} -}; - -struct push_coroutine_context_void -{ - coroutine_context caller; - coroutine_context callee; - - template< typename Coro > - push_coroutine_context_void( stack_context const& stack_ctx, Coro *) : - caller(), - callee( trampoline_push_void< Coro >, stack_ctx) - {} -}; - -template< typename PullCoro, typename R, typename Fn, typename StackAllocator > -class push_coroutine_object : private push_coroutine_context, - public push_coroutine_impl< R > -{ -private: - typedef push_coroutine_context ctx_t; - typedef push_coroutine_impl< R > base_t; - typedef push_coroutine_object< PullCoro, R, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - push_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - push_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run( R * result) - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu(), result); - PullCoro pull_coro( synthesized_t::syntesized, b); - try - { fn_( pull_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename PullCoro, typename R, typename Fn, typename StackAllocator > -class push_coroutine_object< PullCoro, R &, Fn, StackAllocator > : private push_coroutine_context, - public push_coroutine_impl< R & > -{ -private: - typedef push_coroutine_context ctx_t; - typedef push_coroutine_impl< R & > base_t; - typedef push_coroutine_object< PullCoro, R &, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - push_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - push_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run( R * result) - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu(), result); - PullCoro push_coro( synthesized_t::syntesized, b); - try - { fn_( push_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename PullCoro, typename Fn, typename StackAllocator > -class push_coroutine_object< PullCoro, void, Fn, StackAllocator > : private push_coroutine_context_void, - public push_coroutine_impl< void > -{ -private: - typedef push_coroutine_context_void ctx_t; - typedef push_coroutine_impl< void > base_t; - typedef push_coroutine_object< PullCoro, void, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - push_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - push_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - ctx_t( internal_stack_ctx, this), - base_t( & this->caller, - & this->callee, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run() - { - BOOST_ASSERT( ! base_t::unwind_requested() ); - - base_t::flags_ |= flag_started; - base_t::flags_ |= flag_running; - - // create push_coroutine - typename PullCoro::synth_type b( & this->callee, & this->caller, false, base_t::preserve_fpu() ); - PullCoro push_coro( synthesized_t::syntesized, b); - try - { fn_( push_coro); } - catch ( forced_unwind const&) - {} - catch (...) - { base_t::except_ = current_exception(); } - - base_t::flags_ |= flag_complete; - base_t::flags_ &= ~flag_running; - typename base_t::param_type to; - this->callee.jump( - this->caller, - reinterpret_cast< intptr_t >( & to), - base_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -}}} - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_OBJECT_H diff --git a/contrib/autoboost/boost/coroutine/detail/push_coroutine_synthesized.hpp b/contrib/autoboost/boost/coroutine/detail/push_coroutine_synthesized.hpp deleted file mode 100644 index e9415af68..000000000 --- a/contrib/autoboost/boost/coroutine/detail/push_coroutine_synthesized.hpp +++ /dev/null @@ -1,78 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_SYNTHESIZED_H -#define BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_SYNTHESIZED_H - -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename R > -class push_coroutine_synthesized : public push_coroutine_impl< R > -{ -private: - typedef push_coroutine_impl< R > impl_t; - -public: - push_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) - {} - - void destroy() {} -}; - -template< typename R > -class push_coroutine_synthesized< R & > : public push_coroutine_impl< R & > -{ -private: - typedef push_coroutine_impl< R & > impl_t; - -public: - push_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) - {} - - void destroy() {} -}; - -template<> -class push_coroutine_synthesized< void > : public push_coroutine_impl< void > -{ -private: - typedef push_coroutine_impl< void > impl_t; - -public: - push_coroutine_synthesized( coroutine_context * caller, - coroutine_context * callee, - bool unwind, bool preserve_fpu) : - impl_t( caller, callee, unwind, preserve_fpu) - {} - - inline void destroy() {} -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_PUSH_COROUTINE_SYNTHESIZED_H diff --git a/contrib/autoboost/boost/coroutine/detail/setup.hpp b/contrib/autoboost/boost/coroutine/detail/setup.hpp deleted file mode 100644 index 04a65bbc0..000000000 --- a/contrib/autoboost/boost/coroutine/detail/setup.hpp +++ /dev/null @@ -1,75 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_SETUP_H -#define BOOST_COROUTINES_DETAIL_SETUP_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Fn > -struct setup -{ - struct dummy {}; - - Fn fn; - coroutine_context * caller; - coroutine_context * callee; - attributes attr; - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - setup( Fn fn_, - coroutine_context * caller_, - coroutine_context * callee_, - attributes const& attr_) : - fn( autoboost::forward< Fn >( fn_) ), - caller( caller_), - callee( callee_), - attr( attr_) - {} -#endif - setup( BOOST_RV_REF( Fn) fn_, - coroutine_context * caller_, - coroutine_context * callee_, - attributes const& attr_, - typename disable_if< - is_same< typename decay< Fn >::type, setup >, - dummy* - >::type = 0) : -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn( fn_), -#else - fn( autoboost::forward< Fn >( fn_) ), -#endif - caller( caller_), - callee( callee_), - attr( attr_) - {} -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_SETUP_H diff --git a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_call.hpp b/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_call.hpp deleted file mode 100644 index c7042f5a2..000000000 --- a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_call.hpp +++ /dev/null @@ -1,822 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_CALL_H -#define BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_CALL_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Arg > -class symmetric_coroutine_call -{ -private: - template< typename X > - friend class symmetric_coroutine_yield; - - typedef symmetric_coroutine_impl< Arg > impl_type; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_call) - - struct dummy {}; - - impl_type * impl_; - -public: - typedef Arg value_type; - typedef symmetric_coroutine_yield< Arg > yield_type; - - symmetric_coroutine_call() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( yield_type &); - - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, coroutine_fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename StackAllocator > - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, coroutine_fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -# endif - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#else - template< typename Fn > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#endif - - ~symmetric_coroutine_call() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - symmetric_coroutine_call( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - symmetric_coroutine_call & operator=( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT - { - symmetric_coroutine_call tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete() || impl_->is_running(); } - - void swap( symmetric_coroutine_call & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - symmetric_coroutine_call & operator()( Arg arg) BOOST_NOEXCEPT - { - BOOST_ASSERT( * this); - - impl_->resume( arg); - return * this; - } -}; - -template< typename Arg > -class symmetric_coroutine_call< Arg & > -{ -private: - template< typename X > - friend class symmetric_coroutine_yield; - - typedef symmetric_coroutine_impl< Arg & > impl_type; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_call) - - struct dummy {}; - - impl_type * impl_; - -public: - typedef Arg value_type; - typedef symmetric_coroutine_yield< Arg & > yield_type; - - symmetric_coroutine_call() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( yield_type &); - - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, coroutine_fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename StackAllocator > - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, coroutine_fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -# endif - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#else - template< typename Fn > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#endif - - ~symmetric_coroutine_call() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - symmetric_coroutine_call( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - symmetric_coroutine_call & operator=( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT - { - symmetric_coroutine_call tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete() || impl_->is_running(); } - - void swap( symmetric_coroutine_call & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - symmetric_coroutine_call & operator()( Arg & arg) BOOST_NOEXCEPT - { - BOOST_ASSERT( * this); - - impl_->resume( arg); - return * this; - } -}; - -template<> -class symmetric_coroutine_call< void > -{ -private: - template< typename X > - friend class symmetric_coroutine_yield; - - typedef symmetric_coroutine_impl< void > impl_type; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_call) - - struct dummy {}; - - impl_type * impl_; - -public: - typedef void value_type; - typedef symmetric_coroutine_yield< void > yield_type; - - symmetric_coroutine_call() BOOST_NOEXCEPT : - impl_( 0) - {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -# ifdef BOOST_MSVC - typedef void ( * coroutine_fn)( yield_type &); - - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, coroutine_fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename StackAllocator > - explicit symmetric_coroutine_call( coroutine_fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, coroutine_fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< coroutine_fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -# endif - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( - autoboost::forward< Fn >( fn), attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#else - template< typename Fn > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( Fn fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs = attributes(), - stack_allocator stack_alloc = stack_allocator() ) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } - - template< typename Fn, typename StackAllocator > - explicit symmetric_coroutine_call( BOOST_RV_REF( Fn) fn, - attributes const& attrs, - StackAllocator stack_alloc) : - impl_( 0) - { - // create a stack-context - stack_context stack_ctx; - // allocate the coroutine-stack - stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); - // typedef of internal coroutine-type - typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; - // reserve space on top of coroutine-stack for internal coroutine-type - stack_context internal_stack_ctx; - internal_stack_ctx.sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.sp); - internal_stack_ctx.size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < internal_stack_ctx.size); - // placement new for internal coroutine - impl_ = new ( internal_stack_ctx.sp) object_t( fn, attrs, stack_ctx, internal_stack_ctx, stack_alloc); - BOOST_ASSERT( impl_); - } -#endif - - ~symmetric_coroutine_call() - { - if ( 0 != impl_) - { - impl_->destroy(); - impl_ = 0; - } - } - - inline symmetric_coroutine_call( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - inline symmetric_coroutine_call & operator=( BOOST_RV_REF( symmetric_coroutine_call) other) BOOST_NOEXCEPT - { - symmetric_coroutine_call tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - inline bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_ || impl_->is_complete() || impl_->is_running(); } - - inline void swap( symmetric_coroutine_call & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - inline symmetric_coroutine_call & operator()() BOOST_NOEXCEPT - { - BOOST_ASSERT( * this); - - impl_->resume(); - return * this; - } -}; - -template< typename Arg > -void swap( symmetric_coroutine_call< Arg > & l, - symmetric_coroutine_call< Arg > & r) -{ l.swap( r); } - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_CALL_H diff --git a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_impl.hpp b/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_impl.hpp deleted file mode 100644 index e869fb63e..000000000 --- a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_impl.hpp +++ /dev/null @@ -1,472 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_IMPL_H -#define BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_IMPL_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename R > -class symmetric_coroutine_impl : private noncopyable -{ -public: - typedef parameters< R > param_type; - - symmetric_coroutine_impl( stack_context const& stack_ctx, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : - flags_( 0), - caller_(), - callee_( trampoline< symmetric_coroutine_impl< R > >, stack_ctx) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~symmetric_coroutine_impl() {} - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - flags_ |= flag_running; - param_type to( unwind_t::force_unwind); - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_running; - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void resume( R r) BOOST_NOEXCEPT - { - param_type to( const_cast< R * >( & r), this); - resume_( & to); - } - - R * yield() - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ &= ~flag_running; - param_type to; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - BOOST_ASSERT( from->data); - return from->data; - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X > * other, X x) - { - typename symmetric_coroutine_impl< X >::param_type to( & x, other); - return yield_to_( other, & to); - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X & > * other, X & x) - { - typename symmetric_coroutine_impl< X & >::param_type to( & x, other); - return yield_to_( other, & to); - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X > * other) - { - typename symmetric_coroutine_impl< X >::param_type to( other); - return yield_to_( other, & to); - } - - virtual void run( R *) BOOST_NOEXCEPT = 0; - - virtual void destroy() = 0; - -protected: - template< typename X > - friend class symmetric_coroutine_impl; - - int flags_; - coroutine_context caller_; - coroutine_context callee_; - - void resume_( param_type * to) BOOST_NOEXCEPT - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ); - flags_ &= ~flag_running; - } - - template< typename Other > - R * yield_to_( Other * other, typename Other::param_type * to) - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - BOOST_ASSERT( ! other->is_running() ); - BOOST_ASSERT( ! other->is_complete() ); - - other->caller_ = caller_; - flags_ &= ~flag_running; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - BOOST_ASSERT( from->data); - return from->data; - } -}; - -template< typename R > -class symmetric_coroutine_impl< R & > : private noncopyable -{ -public: - typedef parameters< R & > param_type; - - symmetric_coroutine_impl( stack_context const& stack_ctx, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : - flags_( 0), - caller_(), - callee_( trampoline< symmetric_coroutine_impl< R > >, stack_ctx) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~symmetric_coroutine_impl() {} - - bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - flags_ |= flag_running; - param_type to( unwind_t::force_unwind); - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_running; - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - void resume( R & arg) BOOST_NOEXCEPT - { - param_type to( & arg, this); - resume_( & to); - } - - R * yield() - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ &= ~flag_running; - param_type to; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - BOOST_ASSERT( from->data); - return from->data; - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X > * other, X x) - { - typename symmetric_coroutine_impl< X >::param_type to( & x, other); - return yield_to_( other, & to); - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X & > * other, X & x) - { - typename symmetric_coroutine_impl< X & >::param_type to( & x, other); - return yield_to_( other, & to); - } - - template< typename X > - R * yield_to( symmetric_coroutine_impl< X > * other) - { - typename symmetric_coroutine_impl< X >::param_type to( other); - return yield_to_( other, & to); - } - - virtual void run( R *) BOOST_NOEXCEPT = 0; - - virtual void destroy() = 0; - -protected: - template< typename X > - friend class symmetric_coroutine_impl; - - int flags_; - coroutine_context caller_; - coroutine_context callee_; - - void resume_( param_type * to) BOOST_NOEXCEPT - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ |= flag_running; - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ); - flags_ &= ~flag_running; - } - - template< typename Other > - R * yield_to_( Other * other, typename Other::param_type * to) - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - BOOST_ASSERT( ! other->is_running() ); - BOOST_ASSERT( ! other->is_complete() ); - - other->caller_ = caller_; - flags_ &= ~flag_running; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - BOOST_ASSERT( from->data); - return from->data; - } -}; - -template<> -class symmetric_coroutine_impl< void > : private noncopyable -{ -public: - typedef parameters< void > param_type; - - symmetric_coroutine_impl( stack_context const& stack_ctx, - bool unwind, bool preserve_fpu) BOOST_NOEXCEPT : - flags_( 0), - caller_(), - callee_( trampoline_void< symmetric_coroutine_impl< void > >, stack_ctx) - { - if ( unwind) flags_ |= flag_force_unwind; - if ( preserve_fpu) flags_ |= flag_preserve_fpu; - } - - virtual ~symmetric_coroutine_impl() {} - - inline bool force_unwind() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_force_unwind); } - - inline bool unwind_requested() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_unwind_stack); } - - inline bool preserve_fpu() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_preserve_fpu); } - - inline bool is_started() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_started); } - - inline bool is_running() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_running); } - - inline bool is_complete() const BOOST_NOEXCEPT - { return 0 != ( flags_ & flag_complete); } - - inline void unwind_stack() BOOST_NOEXCEPT - { - if ( is_started() && ! is_complete() && force_unwind() ) - { - flags_ |= flag_unwind_stack; - flags_ |= flag_running; - param_type to( unwind_t::force_unwind); - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_running; - flags_ &= ~flag_unwind_stack; - - BOOST_ASSERT( is_complete() ); - } - } - - inline void resume() BOOST_NOEXCEPT - { - BOOST_ASSERT( ! is_running() ); - BOOST_ASSERT( ! is_complete() ); - - param_type to( this); - flags_ |= flag_running; - caller_.jump( - callee_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ); - flags_ &= ~flag_running; - } - - inline void yield() BOOST_NOEXCEPT - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - - flags_ &= ~flag_running; - param_type to; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - caller_, - reinterpret_cast< intptr_t >( & to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - } - - template< typename X > - void yield_to( symmetric_coroutine_impl< X > * other, X x) - { - typename symmetric_coroutine_impl< X >::param_type to( & x, other); - yield_to_( other, & to); - } - - template< typename X > - void yield_to( symmetric_coroutine_impl< X & > * other, X & x) - { - typename symmetric_coroutine_impl< X & >::param_type to( & x, other); - yield_to_( other, & to); - } - - template< typename X > - void yield_to( symmetric_coroutine_impl< X > * other) - { - typename symmetric_coroutine_impl< X >::param_type to( other); - yield_to_( other, & to); - } - - virtual void run() BOOST_NOEXCEPT = 0; - - virtual void destroy() = 0; - -protected: - template< typename X > - friend class symmetric_coroutine_impl; - - int flags_; - coroutine_context caller_; - coroutine_context callee_; - - template< typename Other > - void yield_to_( Other * other, typename Other::param_type * to) - { - BOOST_ASSERT( is_running() ); - BOOST_ASSERT( ! is_complete() ); - BOOST_ASSERT( ! other->is_running() ); - BOOST_ASSERT( ! other->is_complete() ); - - other->caller_ = caller_; - flags_ &= ~flag_running; - param_type * from( - reinterpret_cast< param_type * >( - callee_.jump( - other->callee_, - reinterpret_cast< intptr_t >( to), - preserve_fpu() ) ) ); - flags_ |= flag_running; - if ( from->do_unwind) throw forced_unwind(); - } -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_IMPL_H diff --git a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_object.hpp b/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_object.hpp deleted file mode 100644 index afa3e62ba..000000000 --- a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_object.hpp +++ /dev/null @@ -1,281 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_OBJECT_H -#define BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_OBJECT_H - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct stack_context; - -namespace detail { - -template< typename R, typename Fn, typename StackAllocator > -class symmetric_coroutine_object : public symmetric_coroutine_impl< R > -{ -private: - typedef symmetric_coroutine_impl< R > impl_t; - typedef symmetric_coroutine_object< R, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - symmetric_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - symmetric_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run( R * r) BOOST_NOEXCEPT - { - BOOST_ASSERT( ! impl_t::unwind_requested() ); - - impl_t::flags_ |= flag_started; - impl_t::flags_ |= flag_running; - try - { - symmetric_coroutine_yield< R > yc( this, r); - fn_( yc); - } - catch ( forced_unwind const&) - {} - catch (...) - { std::terminate(); } - - impl_t::flags_ |= flag_complete; - impl_t::flags_ &= ~flag_running; - typename impl_t::param_type to; - impl_t::callee_.jump( - impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename R, typename Fn, typename StackAllocator > -class symmetric_coroutine_object< R &, Fn, StackAllocator > : public symmetric_coroutine_impl< R & > -{ -private: - typedef symmetric_coroutine_impl< R & > impl_t; - typedef symmetric_coroutine_object< R &, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - symmetric_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - symmetric_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run( R * r) BOOST_NOEXCEPT - { - BOOST_ASSERT( ! impl_t::unwind_requested() ); - - impl_t::flags_ |= flag_started; - impl_t::flags_ |= flag_running; - try - { - symmetric_coroutine_yield< R & > yc( this, r); - fn_( yc); - } - catch ( forced_unwind const&) - {} - catch (...) - { std::terminate(); } - - impl_t::flags_ |= flag_complete; - impl_t::flags_ &= ~flag_running; - typename impl_t::param_type to; - impl_t::callee_.jump( - impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -template< typename Fn, typename StackAllocator > -class symmetric_coroutine_object< void, Fn, StackAllocator > : public symmetric_coroutine_impl< void > -{ -private: - typedef symmetric_coroutine_impl< void > impl_t; - typedef symmetric_coroutine_object< void, Fn, StackAllocator > obj_t; - - Fn fn_; - stack_context stack_ctx_; - StackAllocator stack_alloc_; - - static void deallocate_( obj_t * obj) - { - stack_context stack_ctx( obj->stack_ctx_); - StackAllocator stack_alloc( obj->stack_alloc_); - obj->unwind_stack(); - obj->~obj_t(); - stack_alloc.deallocate( stack_ctx); - } - -public: -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - symmetric_coroutine_object( Fn fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), - fn_( fn), - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} -#endif - - symmetric_coroutine_object( BOOST_RV_REF( Fn) fn, attributes const& attrs, - stack_context const& stack_ctx, - stack_context const& internal_stack_ctx, - StackAllocator const& stack_alloc) BOOST_NOEXCEPT : - impl_t( internal_stack_ctx, - stack_unwind == attrs.do_unwind, - fpu_preserved == attrs.preserve_fpu), -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - fn_( fn), -#else - fn_( autoboost::forward< Fn >( fn) ), -#endif - stack_ctx_( stack_ctx), - stack_alloc_( stack_alloc) - {} - - void run() BOOST_NOEXCEPT - { - BOOST_ASSERT( ! impl_t::unwind_requested() ); - - impl_t::flags_ |= flag_started; - impl_t::flags_ |= flag_running; - try - { - symmetric_coroutine_yield< void > yc( this); - fn_( yc); - } - catch ( forced_unwind const&) - {} - catch (...) - { std::terminate(); } - - impl_t::flags_ |= flag_complete; - impl_t::flags_ &= ~flag_running; - typename impl_t::param_type to; - impl_t::callee_.jump( - impl_t::caller_, - reinterpret_cast< intptr_t >( & to), - impl_t::preserve_fpu() ); - BOOST_ASSERT_MSG( false, "coroutine is complete"); - } - - void destroy() - { deallocate_( this); } -}; - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_OBJECT_H diff --git a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_yield.hpp b/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_yield.hpp deleted file mode 100644 index 6a573babb..000000000 --- a/contrib/autoboost/boost/coroutine/detail/symmetric_coroutine_yield.hpp +++ /dev/null @@ -1,307 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_YIELD_H -#define BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_YIELD_H - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename R > -class symmetric_coroutine_yield -{ -private: - template< typename X, typename Y, typename Z > - friend class symmetric_coroutine_object; - - typedef symmetric_coroutine_impl< R > impl_type; - - struct dummy {}; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_yield) - - impl_type * impl_; - R * result_; - - symmetric_coroutine_yield( impl_type * impl, R * result) BOOST_NOEXCEPT : - impl_( impl), - result_( result) - { - BOOST_ASSERT( 0 != impl_); - BOOST_ASSERT( 0 != result_); - } - -public: - symmetric_coroutine_yield() BOOST_NOEXCEPT : - impl_( 0), - result_( 0) - {} - - symmetric_coroutine_yield( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT : - impl_( 0), - result_( 0) - { swap( other); } - - symmetric_coroutine_yield & operator=( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT - { - symmetric_coroutine_yield tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_; } - - void swap( symmetric_coroutine_yield & other) BOOST_NOEXCEPT - { - std::swap( impl_, other.impl_); - std::swap( result_, other.result_); - } - - symmetric_coroutine_yield & operator()() - { - result_ = impl_->yield(); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type x, - typename disable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - result_ = impl_->yield_to( other.impl_, x); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, - typename enable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - result_ = impl_->yield_to( other.impl_); - return * this; - } - - R get() const - { - if ( 0 == result_) - autoboost::throw_exception( - invalid_result() ); - - return * result_; - } -}; - -template< typename R > -class symmetric_coroutine_yield< R & > -{ -private: - template< typename X, typename Y, typename Z > - friend class symmetric_coroutine_object; - - typedef symmetric_coroutine_impl< R & > impl_type; - - struct dummy {}; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_yield) - - impl_type * impl_; - R * result_; - - symmetric_coroutine_yield( impl_type * impl, R * result) BOOST_NOEXCEPT : - impl_( impl), - result_( result) - { - BOOST_ASSERT( 0 != impl_); - BOOST_ASSERT( 0 != result_); - } - -public: - symmetric_coroutine_yield() BOOST_NOEXCEPT : - impl_( 0), - result_( 0) - {} - - symmetric_coroutine_yield( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT : - impl_( 0), - result_( 0) - { swap( other); } - - symmetric_coroutine_yield & operator=( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT - { - symmetric_coroutine_yield tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_; } - - void swap( symmetric_coroutine_yield & other) BOOST_NOEXCEPT - { - std::swap( impl_, other.impl_); - std::swap( result_, other.result_); - } - - symmetric_coroutine_yield & operator()() - { - result_ = impl_->yield(); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type & x, - typename disable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - result_ = impl_->yield_to( other.impl_, x); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, - typename enable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - result_ = impl_->yield_to( other.impl_); - return * this; - } - - R & get() const - { - if ( 0 == result_) - autoboost::throw_exception( - invalid_result() ); - - return * result_; - } -}; - -template<> -class symmetric_coroutine_yield< void > -{ -private: - template< typename X, typename Y, typename Z > - friend class symmetric_coroutine_object; - - typedef symmetric_coroutine_impl< void > impl_type; - - struct dummy {}; - - BOOST_MOVABLE_BUT_NOT_COPYABLE( symmetric_coroutine_yield) - - impl_type * impl_; - - symmetric_coroutine_yield( impl_type * impl) BOOST_NOEXCEPT : - impl_( impl) - { BOOST_ASSERT( 0 != impl_); } - -public: - symmetric_coroutine_yield() BOOST_NOEXCEPT : - impl_( 0) - {} - - symmetric_coroutine_yield( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT : - impl_( 0) - { swap( other); } - - symmetric_coroutine_yield & operator=( BOOST_RV_REF( symmetric_coroutine_yield) other) BOOST_NOEXCEPT - { - symmetric_coroutine_yield tmp( autoboost::move( other) ); - swap( tmp); - return * this; - } - - BOOST_EXPLICIT_OPERATOR_BOOL(); - - inline bool operator!() const BOOST_NOEXCEPT - { return 0 == impl_; } - - inline void swap( symmetric_coroutine_yield & other) BOOST_NOEXCEPT - { std::swap( impl_, other.impl_); } - - inline symmetric_coroutine_yield & operator()() - { - impl_->yield(); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, typename Coro::value_type & x, - typename disable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - impl_->yield_to( other.impl_, x); - return * this; - } - - template< typename Coro > - symmetric_coroutine_yield & operator()( Coro & other, - typename enable_if< - is_same< typename Coro::value_type, void >, - dummy* - >::type = 0) - { - BOOST_ASSERT( other); - - impl_->yield_to( other.impl_); - return * this; - } -}; - -template< typename R > -void swap( symmetric_coroutine_yield< R > & l, symmetric_coroutine_yield< R > & r) -{ l.swap( r); } - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_SYMMETRIC_COROUTINE_YIELD_H diff --git a/contrib/autoboost/boost/coroutine/detail/trampoline.hpp b/contrib/autoboost/boost/coroutine/detail/trampoline.hpp deleted file mode 100644 index 7e35c6629..000000000 --- a/contrib/autoboost/boost/coroutine/detail/trampoline.hpp +++ /dev/null @@ -1,67 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_TRAMPOLINE_H -#define BOOST_COROUTINES_DETAIL_TRAMPOLINE_H - -#include -#include -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Coro > -void trampoline( intptr_t vp) -{ - typedef typename Coro::param_type param_type; - - BOOST_ASSERT( 0 != vp); - - param_type * param( - reinterpret_cast< param_type * >( vp) ); - BOOST_ASSERT( 0 != param); - BOOST_ASSERT( 0 != param->data); - - Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); - BOOST_ASSERT( 0 != coro); - - coro->run( param->data); -} - -template< typename Coro > -void trampoline_void( intptr_t vp) -{ - typedef typename Coro::param_type param_type; - - BOOST_ASSERT( 0 != vp); - - param_type * param( - reinterpret_cast< param_type * >( vp) ); - BOOST_ASSERT( 0 != param); - - Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); - BOOST_ASSERT( 0 != coro); - - coro->run(); -} - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_H diff --git a/contrib/autoboost/boost/coroutine/detail/trampoline_pull.hpp b/contrib/autoboost/boost/coroutine/detail/trampoline_pull.hpp deleted file mode 100644 index f0b85e07a..000000000 --- a/contrib/autoboost/boost/coroutine/detail/trampoline_pull.hpp +++ /dev/null @@ -1,48 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_TRAMPOLINE_PULL_H -#define BOOST_COROUTINES_DETAIL_TRAMPOLINE_PULL_H - -#include -#include -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Coro > -void trampoline_pull( intptr_t vp) -{ - typedef typename Coro::param_type param_type; - - BOOST_ASSERT( 0 != vp); - - param_type * param( - reinterpret_cast< param_type * >( vp) ); - BOOST_ASSERT( 0 != param); - - Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); - BOOST_ASSERT( 0 != coro); - - coro->run(); -} - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_PULL_H diff --git a/contrib/autoboost/boost/coroutine/detail/trampoline_push.hpp b/contrib/autoboost/boost/coroutine/detail/trampoline_push.hpp deleted file mode 100644 index ded1cccd7..000000000 --- a/contrib/autoboost/boost/coroutine/detail/trampoline_push.hpp +++ /dev/null @@ -1,77 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H -#define BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -template< typename Coro > -void trampoline_push( intptr_t vp) -{ - typedef typename Coro::param_type param_type; - - BOOST_ASSERT( vp); - - param_type * param( - reinterpret_cast< param_type * >( vp) ); - BOOST_ASSERT( 0 != param); - BOOST_ASSERT( 0 != param->data); - - Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); - BOOST_ASSERT( 0 != coro); - - coro->run( param->data); -} - -template< typename Coro > -void trampoline_push_void( intptr_t vp) -{ - typedef typename Coro::param_type param_type; - - BOOST_ASSERT( vp); - - param_type * param( - reinterpret_cast< param_type * >( vp) ); - BOOST_ASSERT( 0 != param); - - Coro * coro( - reinterpret_cast< Coro * >( param->coro) ); - BOOST_ASSERT( 0 != coro); - - coro->run(); -} - -}}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_DETAIL_TRAMPOLINE_PUSH_H diff --git a/contrib/autoboost/boost/coroutine/exceptions.hpp b/contrib/autoboost/boost/coroutine/exceptions.hpp deleted file mode 100644 index eacabfe79..000000000 --- a/contrib/autoboost/boost/coroutine/exceptions.hpp +++ /dev/null @@ -1,105 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_EXCEPTIONS_H -#define BOOST_COROUTINES_EXCEPTIONS_H - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { -namespace detail { - -struct forced_unwind {}; - -} - -BOOST_SCOPED_ENUM_DECLARE_BEGIN(coroutine_errc) -{ - no_data = 1 -} -BOOST_SCOPED_ENUM_DECLARE_END(coroutine_errc) - -BOOST_COROUTINES_DECL system::error_category const& coroutine_category() BOOST_NOEXCEPT; - -} - -namespace system { - -template<> -struct is_error_code_enum< coroutines::coroutine_errc > : public true_type -{}; - -#ifdef BOOST_NO_CXX11_SCOPED_ENUMS -template<> -struct is_error_code_enum< coroutines::coroutine_errc::enum_type > : public true_type -{}; -#endif - -inline -error_code make_error_code( coroutines::coroutine_errc e) //BOOST_NOEXCEPT -{ - return error_code( underlying_cast< int >( e), coroutines::coroutine_category() ); -} - -inline -error_condition make_error_condition( coroutines::coroutine_errc e) //BOOST_NOEXCEPT -{ - return error_condition( underlying_cast< int >( e), coroutines::coroutine_category() ); -} - -} - -namespace coroutines { - -class coroutine_error : public std::logic_error -{ -private: - system::error_code ec_; - -public: - coroutine_error( system::error_code ec) : - logic_error( ec.message() ), - ec_( ec) - {} - - system::error_code const& code() const BOOST_NOEXCEPT - { return ec_; } - - const char* what() const throw() - { return code().message().c_str(); } -}; - -class invalid_result : public coroutine_error -{ -public: - invalid_result() : - coroutine_error( - system::make_error_code( - coroutine_errc::no_data) ) - {} -}; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_EXCEPTIONS_H diff --git a/contrib/autoboost/boost/coroutine/flags.hpp b/contrib/autoboost/boost/coroutine/flags.hpp deleted file mode 100644 index 43a4c15e5..000000000 --- a/contrib/autoboost/boost/coroutine/flags.hpp +++ /dev/null @@ -1,27 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_FLAGS_H -#define BOOST_COROUTINES_FLAGS_H - -namespace autoboost { -namespace coroutines { - -enum flag_unwind_t -{ - stack_unwind = 0, - no_stack_unwind -}; - -enum flag_fpu_t -{ - fpu_preserved = 0, - fpu_not_preserved -}; - -}} - -#endif // BOOST_COROUTINES_FLAGS_H diff --git a/contrib/autoboost/boost/coroutine/posix/protected_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/posix/protected_stack_allocator.hpp deleted file mode 100644 index 4afecd6fb..000000000 --- a/contrib/autoboost/boost/coroutine/posix/protected_stack_allocator.hpp +++ /dev/null @@ -1,105 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H - -extern "C" { -#include -#include -#include -#include -} - -#if defined(BOOST_USE_VALGRIND) -#include -#endif - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -template< typename traitsT > -struct basic_protected_stack_allocator -{ - typedef traitsT traits_type; - - void allocate( stack_context & ctx, std::size_t size = traits_type::minimum_size() ) - { - BOOST_ASSERT( traits_type::minimum_size() <= size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= size) ); - - // page at bottom will be used as guard-page - const std::size_t pages( - static_cast< std::size_t >( - std::floor( - static_cast< float >( size) / traits_type::page_size() ) ) ); - BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); - const std::size_t size_( pages * traits_type::page_size() ); - BOOST_ASSERT( 0 < size && 0 < size_); - BOOST_ASSERT( size_ <= size); - - // conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L) -#if defined(MAP_ANON) - void * limit = ::mmap( 0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); -#else - void * limit = ::mmap( 0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -#endif - if ( MAP_FAILED == limit) throw std::bad_alloc(); - - // conforming to POSIX.1-2001 -#if defined(BOOST_DISABLE_ASSERTS) - ::mprotect( limit, traits_type::page_size(), PROT_NONE); -#else - const int result( ::mprotect( limit, traits_type::page_size(), PROT_NONE) ); - BOOST_ASSERT( 0 == result); -#endif - - ctx.size = size_; - ctx.sp = static_cast< char * >( limit) + ctx.size; -#if defined(BOOST_USE_VALGRIND) - ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER( ctx.sp, limit); -#endif - } - - void deallocate( stack_context & ctx) - { - BOOST_ASSERT( ctx.sp); - BOOST_ASSERT( traits_type::minimum_size() <= ctx.size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= ctx.size) ); - -#if defined(BOOST_USE_VALGRIND) - VALGRIND_STACK_DEREGISTER( ctx.valgrind_stack_id); -#endif - void * limit = static_cast< char * >( ctx.sp) - ctx.size; - // conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L) - ::munmap( limit, ctx.size); - } -}; - -typedef basic_protected_stack_allocator< stack_traits > protected_stack_allocator; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H diff --git a/contrib/autoboost/boost/coroutine/posix/segmented_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/posix/segmented_stack_allocator.hpp deleted file mode 100644 index e9280ff52..000000000 --- a/contrib/autoboost/boost/coroutine/posix/segmented_stack_allocator.hpp +++ /dev/null @@ -1,69 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_SEGMENTED_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_SEGMENTED_STACK_ALLOCATOR_H - -#include -#include - -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -// forward declaration for splitstack-functions defined in libgcc -extern "C" { -void *__splitstack_makecontext( std::size_t, - void * [BOOST_COROUTINES_SEGMENTS], - std::size_t *); - -void __splitstack_releasecontext( void * [BOOST_COROUTINES_SEGMENTS]); - -void __splitstack_resetcontext( void * [BOOST_COROUTINES_SEGMENTS]); - -void __splitstack_block_signals_context( void * [BOOST_COROUTINES_SEGMENTS], - int * new_value, int * old_value); -} - -namespace autoboost { -namespace coroutines { - -template< typename traitsT > -struct basic_segmented_stack_allocator -{ - typedef traitsT traits_type; - - void allocate( stack_context & ctx, std::size_t size = traits_type::minimum_size() ) - { - void * limit = __splitstack_makecontext( size, ctx.segments_ctx, & ctx.size); - if ( ! limit) throw std::bad_alloc(); - - // ctx.size is already filled by __splitstack_makecontext - ctx.sp = static_cast< char * >( limit) + ctx.size; - - int off = 0; - __splitstack_block_signals_context( ctx.segments_ctx, & off, 0); - } - - void deallocate( stack_context & ctx) - { __splitstack_releasecontext( ctx.segments_ctx); } -}; - -typedef basic_segmented_stack_allocator< stack_traits > segmented_stack_allocator; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_SEGMENTED_STACK_ALLOCATOR_H diff --git a/contrib/autoboost/boost/coroutine/protected_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/protected_stack_allocator.hpp deleted file mode 100644 index 268786fec..000000000 --- a/contrib/autoboost/boost/coroutine/protected_stack_allocator.hpp +++ /dev/null @@ -1,13 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined(BOOST_WINDOWS) -# include -#else -# include -#endif diff --git a/contrib/autoboost/boost/coroutine/segmented_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/segmented_stack_allocator.hpp deleted file mode 100644 index f9525a1a5..000000000 --- a/contrib/autoboost/boost/coroutine/segmented_stack_allocator.hpp +++ /dev/null @@ -1,15 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined(BOOST_USE_SEGMENTED_STACKS) -# if defined(BOOST_WINDOWS) -# error "segmented stacks are not supported by Windows" -# else -# include -# endif -#endif diff --git a/contrib/autoboost/boost/coroutine/stack_allocator.hpp b/contrib/autoboost/boost/coroutine/stack_allocator.hpp deleted file mode 100644 index c740e112c..000000000 --- a/contrib/autoboost/boost/coroutine/stack_allocator.hpp +++ /dev/null @@ -1,37 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_STACK_ALLOCATOR_H - -#include - -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -#if defined(BOOST_USE_SEGMENTED_STACKS) -typedef segmented_stack_allocator stack_allocator; -#else -typedef standard_stack_allocator stack_allocator; -#endif - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_STACK_ALLOCATOR_H diff --git a/contrib/autoboost/boost/coroutine/stack_context.hpp b/contrib/autoboost/boost/coroutine/stack_context.hpp deleted file mode 100644 index ff93bf276..000000000 --- a/contrib/autoboost/boost/coroutine/stack_context.hpp +++ /dev/null @@ -1,66 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_STACK_CONTEXT_H -#define BOOST_COROUTINES_STACK_CONTEXT_H - -#include - -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -#if defined(BOOST_USE_SEGMENTED_STACKS) -struct stack_context -{ - typedef void * segments_context[BOOST_COROUTINES_SEGMENTS]; - - std::size_t size; - void * sp; - segments_context segments_ctx; -#if defined(BOOST_USE_VALGRIND) - unsigned valgrind_stack_id; -#endif - - stack_context() : - size( 0), sp( 0), segments_ctx() -#if defined(BOOST_USE_VALGRIND) - , valgrind_stack_id( 0) -#endif - {} -}; -#else -struct stack_context -{ - std::size_t size; - void * sp; -#if defined(BOOST_USE_VALGRIND) - unsigned valgrind_stack_id; -#endif - - stack_context() : - size( 0), sp( 0) -#if defined(BOOST_USE_VALGRIND) - , valgrind_stack_id( 0) -#endif - {} -}; -#endif - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_STACK_CONTEXT_H diff --git a/contrib/autoboost/boost/coroutine/stack_traits.hpp b/contrib/autoboost/boost/coroutine/stack_traits.hpp deleted file mode 100644 index f96cc9687..000000000 --- a/contrib/autoboost/boost/coroutine/stack_traits.hpp +++ /dev/null @@ -1,42 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_STACK_TRAITS_H -#define BOOST_COROUTINES_STACK_TRAITS_H - -#include - -#include - -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct BOOST_COROUTINES_DECL stack_traits -{ - static bool is_unbounded() BOOST_NOEXCEPT; - - static std::size_t page_size() BOOST_NOEXCEPT; - - static std::size_t default_size() BOOST_NOEXCEPT; - - static std::size_t minimum_size() BOOST_NOEXCEPT; - - static std::size_t maximum_size() BOOST_NOEXCEPT; -}; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_STACK_TRAITS_H diff --git a/contrib/autoboost/boost/coroutine/standard_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/standard_stack_allocator.hpp deleted file mode 100644 index 3b387d1cf..000000000 --- a/contrib/autoboost/boost/coroutine/standard_stack_allocator.hpp +++ /dev/null @@ -1,75 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H - -#if defined(BOOST_USE_VALGRIND) -#include -#endif - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -template< typename traitsT > -struct basic_standard_stack_allocator -{ - typedef traitsT traits_type; - - void allocate( stack_context & ctx, std::size_t size = traits_type::minimum_size() ) - { - BOOST_ASSERT( traits_type::minimum_size() <= size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= size) ); - - void * limit = std::malloc( size); - if ( ! limit) throw std::bad_alloc(); - - ctx.size = size; - ctx.sp = static_cast< char * >( limit) + ctx.size; -#if defined(BOOST_USE_VALGRIND) - ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER( ctx.sp, limit); -#endif - } - - void deallocate( stack_context & ctx) - { - BOOST_ASSERT( ctx.sp); - BOOST_ASSERT( traits_type::minimum_size() <= ctx.size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= ctx.size) ); - -#if defined(BOOST_USE_VALGRIND) - VALGRIND_STACK_DEREGISTER( ctx.valgrind_stack_id); -#endif - - void * limit = static_cast< char * >( ctx.sp) - ctx.size; - std::free( limit); - } -}; - -typedef basic_standard_stack_allocator< stack_traits > standard_stack_allocator; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H diff --git a/contrib/autoboost/boost/coroutine/symmetric_coroutine.hpp b/contrib/autoboost/boost/coroutine/symmetric_coroutine.hpp deleted file mode 100644 index 53d779b8a..000000000 --- a/contrib/autoboost/boost/coroutine/symmetric_coroutine.hpp +++ /dev/null @@ -1,35 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_SYMMETRIC_COROUTINE_H -#define BOOST_COROUTINES_SYMMETRIC_COROUTINE_H - -#include - -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -template< typename T > -struct symmetric_coroutine -{ - typedef detail::symmetric_coroutine_call< T > call_type; - typedef detail::symmetric_coroutine_yield< T > yield_type; -}; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_SYMMETRIC_COROUTINE_H diff --git a/contrib/autoboost/boost/coroutine/windows/protected_stack_allocator.hpp b/contrib/autoboost/boost/coroutine/windows/protected_stack_allocator.hpp deleted file mode 100644 index a3f1d17b6..000000000 --- a/contrib/autoboost/boost/coroutine/windows/protected_stack_allocator.hpp +++ /dev/null @@ -1,87 +0,0 @@ - -// Copyright Oliver Kowalke 2009. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H - -extern "C" { -#include -} - -#include -#include -#include - -#include - -#include -#include - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -namespace autoboost { -namespace coroutines { - -struct stack_context; - -template< typename traitsT > -struct basic_protected_stack_allocator -{ - typedef traitsT traits_type; - - void allocate( stack_context & ctx, std::size_t size) - { - BOOST_ASSERT( traits_type::minimum_size() <= size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= size) ); - - // page at bottom will be used as guard-page - const std::size_t pages( - static_cast< std::size_t >( - std::floor( - static_cast< float >( size) / traits_type::page_size() ) ) ); - BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); - const std::size_t size_ = pages * traits_type::page_size(); - BOOST_ASSERT( 0 < size && 0 < size_); - - void * limit = ::VirtualAlloc( 0, size_, MEM_COMMIT, PAGE_READWRITE); - if ( ! limit) throw std::bad_alloc(); - - DWORD old_options; -#if defined(BOOST_DISABLE_ASSERTS) - ::VirtualProtect( - limit, traits_type::page_size(), PAGE_READWRITE | PAGE_GUARD /*PAGE_NOACCESS*/, & old_options); -#else - const BOOL result = ::VirtualProtect( - limit, traits_type::page_size(), PAGE_READWRITE | PAGE_GUARD /*PAGE_NOACCESS*/, & old_options); - BOOST_ASSERT( FALSE != result); -#endif - - ctx.size = size_; - ctx.sp = static_cast< char * >( limit) + ctx.size; - } - - void deallocate( stack_context & ctx) - { - BOOST_ASSERT( ctx.sp); - BOOST_ASSERT( traits_type::minimum_size() <= ctx.size); - BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= ctx.size) ); - - void * limit = static_cast< char * >( ctx.sp) - ctx.size; - ::VirtualFree( limit, 0, MEM_RELEASE); - } -}; - -typedef basic_protected_stack_allocator< stack_traits > protected_stack_allocator; - -}} - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -#endif // BOOST_COROUTINES_PROTECTED_STACK_ALLOCATOR_H From 4fb9dac82f648ece5640d0b45667b60904fe948b Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:26:26 -0800 Subject: [PATCH 28/57] Eliminating externally visible reference to std::future This is intended to make it easier to build Autowiring on platforms where std::future might not be available (IE, android) --- autowiring/CoreJob.h | 10 +++++++--- src/autowiring/CoreJob.cpp | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/autowiring/CoreJob.h b/autowiring/CoreJob.h index d04508daf..4f0765420 100644 --- a/autowiring/CoreJob.h +++ b/autowiring/CoreJob.h @@ -3,10 +3,14 @@ #include "ContextMember.h" #include "DispatchQueue.h" #include "CoreRunnable.h" -#include FUTURE_HEADER class Object; +namespace std { + template + class future; +}; + class CoreJob: public ContextMember, public DispatchQueue, @@ -14,14 +18,14 @@ class CoreJob: { public: CoreJob(const char* name = nullptr); - virtual ~CoreJob(void) {}; + virtual ~CoreJob(void); private: // Flag, set to true when it's time to start dispatching bool m_running; // The current outstanding async in the thread pool, if one exists: - std::future m_curEvent; + std::unique_ptr> m_curEvent; // Flag, indicating whether curEvent is in a teardown pathway. This // flag is highly stateful. diff --git a/src/autowiring/CoreJob.cpp b/src/autowiring/CoreJob.cpp index d987ffaef..2ff2d70a1 100644 --- a/src/autowiring/CoreJob.cpp +++ b/src/autowiring/CoreJob.cpp @@ -2,6 +2,7 @@ #include "stdafx.h" #include "CoreJob.h" #include "CoreContext.h" +#include FUTURE_HEADER CoreJob::CoreJob(const char* name) : ContextMember(name), @@ -9,6 +10,9 @@ CoreJob::CoreJob(const char* name) : m_curEventInTeardown(true) {} +CoreJob::~CoreJob(void) +{} + void CoreJob::OnPended(std::unique_lock&& lk){ if(!m_curEventInTeardown) { // Something is already outstanding, it will handle dispatching for us. @@ -34,12 +38,16 @@ void CoreJob::OnPended(std::unique_lock&& lk){ } else { // Need to ask the thread pool to handle our events again: m_curEventInTeardown = false; - m_curEvent = std::async( - std::launch::async, - [this, outstanding] () mutable { - this->DispatchAllAndClearCurrent(); - outstanding.reset(); - } + m_curEvent.reset( + new std::future( + std::async( + std::launch::async, + [this, outstanding] () mutable { + this->DispatchAllAndClearCurrent(); + outstanding.reset(); + } + ) + ) ); } } @@ -101,6 +109,8 @@ void CoreJob::OnStop(bool graceful) { } void CoreJob::DoAdditionalWait(void) { - if(m_curEvent.valid()) - m_curEvent.wait(); + if (m_curEvent) { + m_curEvent->wait(); + m_curEvent.reset(); + } } From 2a104ab7bdb5d7e538f49ac6f58d3ccd06e40c03 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 11:03:37 -0800 Subject: [PATCH 29/57] Correcting unit test namespace collision --- src/autowiring/test/MultiInheritTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/autowiring/test/MultiInheritTest.cpp b/src/autowiring/test/MultiInheritTest.cpp index 04e04874a..38b8ecc1c 100644 --- a/src/autowiring/test/MultiInheritTest.cpp +++ b/src/autowiring/test/MultiInheritTest.cpp @@ -23,11 +23,11 @@ class Base { AutoRequired m_member; }; -class Derived: +class MultiInheritDerived: public Base { public: - Derived(void) { + MultiInheritDerived(void) { EXPECT_TRUE(Base::m_member.IsAutowired()) << "Base AutoRequired member was not initialized properly"; EXPECT_EQ(100, Base::m_member->m_i) << "Autowired instance was not properly constructed"; EXPECT_TRUE(m_secondMember.IsAutowired()) << "Failed to autowire a type which should have been injected in this context"; @@ -57,7 +57,7 @@ TEST_F(MultiInheritTest, VerifyBaseInitializer) { AutoCreateContext ctxt; CurrentContextPusher pshr(ctxt); - Derived derived; + MultiInheritDerived derived; // Expect that something autowires when we're done at least: EXPECT_TRUE(derived.m_member.IsAutowired()); From 9f14290f6f658d30920cab97e7e58cd62e1f00a9 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Thu, 18 Dec 2014 11:59:40 -0800 Subject: [PATCH 30/57] Make std::future* a void* to fix forward declare problems on mac --- autowiring/CoreJob.h | 7 +------ src/autowiring/CoreJob.cpp | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/autowiring/CoreJob.h b/autowiring/CoreJob.h index 4f0765420..053b9ad26 100644 --- a/autowiring/CoreJob.h +++ b/autowiring/CoreJob.h @@ -6,11 +6,6 @@ class Object; -namespace std { - template - class future; -}; - class CoreJob: public ContextMember, public DispatchQueue, @@ -25,7 +20,7 @@ class CoreJob: bool m_running; // The current outstanding async in the thread pool, if one exists: - std::unique_ptr> m_curEvent; + void* m_curEvent; // Flag, indicating whether curEvent is in a teardown pathway. This // flag is highly stateful. diff --git a/src/autowiring/CoreJob.cpp b/src/autowiring/CoreJob.cpp index 2ff2d70a1..b1eda5e97 100644 --- a/src/autowiring/CoreJob.cpp +++ b/src/autowiring/CoreJob.cpp @@ -7,6 +7,7 @@ CoreJob::CoreJob(const char* name) : ContextMember(name), m_running(false), + m_curEvent(nullptr), m_curEventInTeardown(true) {} @@ -38,17 +39,16 @@ void CoreJob::OnPended(std::unique_lock&& lk){ } else { // Need to ask the thread pool to handle our events again: m_curEventInTeardown = false; - m_curEvent.reset( - new std::future( - std::async( - std::launch::async, - [this, outstanding] () mutable { - this->DispatchAllAndClearCurrent(); - outstanding.reset(); - } - ) - ) - ); + + if (m_curEvent) + delete static_cast*>(m_curEvent); + + m_curEvent = new std::future(std::async(std::launch::async, + [this, outstanding] () mutable { + this->DispatchAllAndClearCurrent(); + outstanding.reset(); + } + )); } } @@ -110,7 +110,9 @@ void CoreJob::OnStop(bool graceful) { void CoreJob::DoAdditionalWait(void) { if (m_curEvent) { - m_curEvent->wait(); - m_curEvent.reset(); + std::future* ptr = static_cast*>(m_curEvent); + ptr->wait(); + delete ptr; + m_curEvent = nullptr; } } From c966500312cb2d1b6963778630c23aea8658a1d4 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 10:12:06 -0800 Subject: [PATCH 31/57] Making Android build symmetric This fixes the Android build - Eliminated Android conditional dependency on `boost::thread` - Eliminated conditional build of AutoNet - Thread compatibility header uses a namespace discriminator - Adding more boost sources to be built with everything else - Adding apparently missing boost caps headers --- autowiring/C++11/boost_future.h | 12 +- autowiring/C++11/cpp11.h | 8 + .../boost/atomic/detail/caps_gcc_alpha.hpp | 34 + .../boost/atomic/detail/caps_gcc_arm.hpp | 56 + .../boost/atomic/detail/caps_gcc_atomic.hpp | 134 +++ .../boost/atomic/detail/caps_gcc_ppc.hpp | 36 + .../boost/atomic/detail/caps_gcc_sparc.hpp | 34 + .../boost/atomic/detail/caps_gcc_sync.hpp | 62 ++ .../boost/atomic/detail/caps_gcc_x86.hpp | 52 + .../boost/atomic/detail/caps_linux_arm.hpp | 35 + .../boost/atomic/detail/caps_msvc_arm.hpp | 34 + .../boost/atomic/detail/caps_msvc_x86.hpp | 50 + .../boost/atomic/detail/caps_windows.hpp | 33 + .../boost/atomic/detail/ops_cas_based.hpp | 91 ++ .../atomic/detail/ops_extending_cas_based.hpp | 65 ++ .../boost/atomic/detail/ops_gcc_alpha.hpp | 874 ++++++++++++++++ .../boost/atomic/detail/ops_gcc_arm.hpp | 971 ++++++++++++++++++ .../boost/atomic/detail/ops_gcc_atomic.hpp | 380 +++++++ .../boost/atomic/detail/ops_gcc_ppc.hpp | 775 ++++++++++++++ .../boost/atomic/detail/ops_gcc_sparc.hpp | 245 +++++ .../boost/atomic/detail/ops_gcc_sync.hpp | 237 +++++ .../boost/atomic/detail/ops_gcc_x86.hpp | 510 +++++++++ .../boost/atomic/detail/ops_gcc_x86_dcas.hpp | 308 ++++++ .../boost/atomic/detail/ops_linux_arm.hpp | 177 ++++ .../boost/atomic/detail/ops_msvc_arm.hpp | 820 +++++++++++++++ .../boost/atomic/detail/ops_msvc_common.hpp | 38 + .../boost/atomic/detail/ops_msvc_x86.hpp | 879 ++++++++++++++++ .../boost/atomic/detail/ops_windows.hpp | 215 ++++ contrib/autoboost/boost/thread/future.hpp | 4 +- src/CMakeLists.txt | 7 - src/autonet/CMakeLists.txt | 26 +- src/autonet/stdafx.h | 4 +- src/autowiring/CMakeLists.txt | 1 + src/autowiring/stdafx.h | 3 + src/autowiring/test/CMakeLists.txt | 1 + src/autowiring/test/stdafx.h | 3 + 36 files changed, 7188 insertions(+), 26 deletions(-) create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_alpha.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_atomic.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_ppc.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_sparc.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_sync.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_gcc_x86.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_linux_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_msvc_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_msvc_x86.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/caps_windows.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_cas_based.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_extending_cas_based.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_alpha.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_atomic.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_ppc.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_sparc.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_sync.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_x86.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_gcc_x86_dcas.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_linux_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_msvc_arm.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_msvc_common.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_msvc_x86.hpp create mode 100644 contrib/autoboost/boost/atomic/detail/ops_windows.hpp diff --git a/autowiring/C++11/boost_future.h b/autowiring/C++11/boost_future.h index 4d655f877..e235a759c 100644 --- a/autowiring/C++11/boost_future.h +++ b/autowiring/C++11/boost_future.h @@ -9,10 +9,10 @@ #include namespace std { - using boost::future; - using boost::future_status; - using boost::promise; - using boost::future_error; - using boost::async; - using boost::launch; + using AUTOWIRING_BOOST_NAME::future; + using AUTOWIRING_BOOST_NAME::future_status; + using AUTOWIRING_BOOST_NAME::promise; + using AUTOWIRING_BOOST_NAME::future_error; + using AUTOWIRING_BOOST_NAME::async; + using AUTOWIRING_BOOST_NAME::launch; } diff --git a/autowiring/C++11/cpp11.h b/autowiring/C++11/cpp11.h index fd79f29c4..0c7e4ea4d 100644 --- a/autowiring/C++11/cpp11.h +++ b/autowiring/C++11/cpp11.h @@ -15,6 +15,14 @@ #define STL11_ALLOWED 1 #endif +// If Autowiring is currently being built, we want to use the "autoboost" namespace in order to +// avoid requiring a dependency on Boost. +#ifdef AUTOWIRING_IS_BEING_BUILT + #define AUTOWIRING_BOOST_NAME autoboost +#else + #define AUTOWIRING_BOOST_NAME boost +#endif + #define IS_CLANG defined(__clang_major__) #define CLANG_CHECK(maj, min) (__clang_major__ == maj && __clang_minor__ >= min || __clang_major__ > maj) #define GCC_CHECK(maj, min) (__GNUC__ == maj && __GNUC_MINOR__ >= min || __GNUC__ > maj) diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_alpha.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_alpha.hpp new file mode 100644 index 000000000..861432f58 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_alpha.hpp @@ -0,0 +1,34 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_alpha.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_ALPHA_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_ALPHA_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_ALPHA_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_arm.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_arm.hpp new file mode 100644 index 000000000..b827c648d --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_arm.hpp @@ -0,0 +1,56 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2009 Phil Endecott + * Copyright (c) 2013 Tim Blechmann + * ARM Code by Phil Endecott, based on other architectures. + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_arm.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_ARM_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)) +// ARMv7 and later have dmb instruction +#define BOOST_ATOMIC_DETAIL_ARM_HAS_DMB 1 +#endif + +#if !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__)) +// ARMv6k and ARMv7 have 8 and 16 ldrex/strex variants +#define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXB_STREXB 1 +#define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXH_STREXH 1 +#if !(((defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)) && defined(__thumb__)) || defined(__ARM_ARCH_7M__)) +// ARMv6k and ARMv7 except ARMv7-M have 64-bit ldrex/strex variants. +// Unfortunately, GCC (at least 4.7.3 on Ubuntu) does not allocate register pairs properly when targeting ARMv6k Thumb, +// which is required for ldrexd/strexd instructions, so we disable 64-bit support. When targeting ARMv6k ARM +// or ARMv7 (both ARM and Thumb 2) it works as expected. +#define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD 1 +#endif +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#if defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD) +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#endif +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_atomic.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_atomic.hpp new file mode 100644 index 000000000..f4e7a7023 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_atomic.hpp @@ -0,0 +1,134 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_atomic.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1 +#endif + +#if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1 +#endif + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT)) +#define BOOST_ATOMIC_INT128_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_INT128_LOCK_FREE 0 +#endif + +#if __GCC_ATOMIC_LLONG_LOCK_FREE == 2 +#define BOOST_ATOMIC_LLONG_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE +#endif + +#if __GCC_ATOMIC_LONG_LOCK_FREE == 2 +#define BOOST_ATOMIC_LONG_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE +#endif + +#if __GCC_ATOMIC_INT_LOCK_FREE == 2 +#define BOOST_ATOMIC_INT_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE +#endif + +#if __GCC_ATOMIC_SHORT_LOCK_FREE == 2 +#define BOOST_ATOMIC_SHORT_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE +#endif + +#if __GCC_ATOMIC_CHAR_LOCK_FREE == 2 +#define BOOST_ATOMIC_CHAR_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_CHAR_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE +#endif + +#if __GCC_ATOMIC_POINTER_LOCK_FREE == 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 +#else +#define BOOST_ATOMIC_POINTER_LOCK_FREE 0 +#endif + + +#define BOOST_ATOMIC_INT8_LOCK_FREE BOOST_ATOMIC_CHAR_LOCK_FREE + +#if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE +#else +#define BOOST_ATOMIC_INT16_LOCK_FREE 0 +#endif + +#if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4 +#define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4 +#define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4 +#define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4 +#define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE +#else +#define BOOST_ATOMIC_INT32_LOCK_FREE 0 +#endif + +#if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8 +#define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8 +#define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8 +#define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8 +#define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE +#else +#define BOOST_ATOMIC_INT64_LOCK_FREE 0 +#endif + + +#if __GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2 +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2 +#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8 +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4 +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2 +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE +#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1 +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE +#else +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0 +#endif + +#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE +#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_ppc.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_ppc.hpp new file mode 100644 index 000000000..6dbdde826 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_ppc.hpp @@ -0,0 +1,36 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_ppc.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_PPC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_PPC_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#if defined(__powerpc64__) +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#endif +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_PPC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_sparc.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_sparc.hpp new file mode 100644 index 000000000..580668492 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_sparc.hpp @@ -0,0 +1,34 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2010 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_sparc.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_SPARC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_SPARC_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_SPARC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_sync.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_sync.hpp new file mode 100644 index 000000000..7fac07a13 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_sync.hpp @@ -0,0 +1,62 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2011 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_sync.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_SYNC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_SYNC_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1 +#endif + +#if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1 +#endif + +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#endif +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#endif +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#endif +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)\ + || defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#endif +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_INT128_LOCK_FREE 2 +#endif + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_SYNC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_gcc_x86.hpp b/contrib/autoboost/boost/atomic/detail/caps_gcc_x86.hpp new file mode 100644 index 000000000..0696bf1d2 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_gcc_x86.hpp @@ -0,0 +1,52 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2013 - 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_gcc_x86.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_X86_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_GCC_X86_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(__i386__) &&\ + (\ + defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\ + defined(__i586__) || defined(__i686__) || defined(__pentium4__) || defined(__nocona__) || defined(__core2__) || defined(__corei7__) ||\ + defined(__k6__) || defined(__athlon__) || defined(__k8__) || defined(__amdfam10__) || defined(__bdver1__) || defined(__bdver2__) || defined(__bdver3__) || defined(__btver1__) || defined(__btver2__)\ + ) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1 +#endif + +#if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1 +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#if defined(__x86_64__) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#endif +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT)) +#define BOOST_ATOMIC_INT128_LOCK_FREE 2 +#endif +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_X86_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_linux_arm.hpp b/contrib/autoboost/boost/atomic/detail/caps_linux_arm.hpp new file mode 100644 index 000000000..abe6fb81a --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_linux_arm.hpp @@ -0,0 +1,35 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009, 2011 Helge Bahmann + * Copyright (c) 2009 Phil Endecott + * Copyright (c) 2013 Tim Blechmann + * Linux-specific code by Phil Endecott + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_linux_arm.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_LINUX_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_LINUX_ARM_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_LINUX_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_msvc_arm.hpp b/contrib/autoboost/boost/atomic/detail/caps_msvc_arm.hpp new file mode 100644 index 000000000..6b3c61fb3 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_msvc_arm.hpp @@ -0,0 +1,34 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2012 - 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_msvc_arm.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_MSVC_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_MSVC_ARM_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_MSVC_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_msvc_x86.hpp b/contrib/autoboost/boost/atomic/detail/caps_msvc_x86.hpp new file mode 100644 index 000000000..5661a5b7a --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_msvc_x86.hpp @@ -0,0 +1,50 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2012 - 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_msvc_x86.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_MSVC_X86_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_MSVC_X86_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(_M_IX86) && _M_IX86 >= 500 +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1 +#endif + +#if _MSC_VER >= 1500 && defined(_M_AMD64) && !defined(BOOST_ATOMIC_NO_CMPXCHG16B) +#define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1 +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 + +#if defined(_M_AMD64) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) +#define BOOST_ATOMIC_INT64_LOCK_FREE 2 +#endif + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT)) +#define BOOST_ATOMIC_INT128_LOCK_FREE 2 +#endif + +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_MSVC_X86_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/caps_windows.hpp b/contrib/autoboost/boost/atomic/detail/caps_windows.hpp new file mode 100644 index 000000000..1cc0ded83 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/caps_windows.hpp @@ -0,0 +1,33 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2012 - 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/caps_windows.hpp + * + * This header defines feature capabilities macros + */ + +#ifndef BOOST_ATOMIC_DETAIL_CAPS_WINDOWS_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_CAPS_WINDOWS_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_INT8_LOCK_FREE 2 +#define BOOST_ATOMIC_INT16_LOCK_FREE 2 +#define BOOST_ATOMIC_INT32_LOCK_FREE 2 +#define BOOST_ATOMIC_POINTER_LOCK_FREE 2 + +#define BOOST_ATOMIC_THREAD_FENCE 2 +#define BOOST_ATOMIC_SIGNAL_FENCE 2 + +#endif // BOOST_ATOMIC_DETAIL_CAPS_WINDOWS_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_cas_based.hpp b/contrib/autoboost/boost/atomic/detail/ops_cas_based.hpp new file mode 100644 index 000000000..ee2ac3633 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_cas_based.hpp @@ -0,0 +1,91 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_cas_based.hpp + * + * This header contains CAS-based implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_ + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +template< typename Base > +struct cas_based_operations : + public Base +{ + typedef typename Base::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, old_val + v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, old_val - v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, old_val & v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, old_val | v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + while (!Base::compare_exchange_weak(storage, old_val, old_val ^ v, order, memory_order_relaxed)) {} + return old_val; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + Base::store(storage, (storage_type)0, order); + } +}; + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_CAS_BASED_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_extending_cas_based.hpp b/contrib/autoboost/boost/atomic/detail/ops_extending_cas_based.hpp new file mode 100644 index 000000000..0477d2014 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_extending_cas_based.hpp @@ -0,0 +1,65 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_extending_cas_based.hpp + * + * This header contains a boilerplate of the \c operations template implementation that requires sign/zero extension in arithmetic operations. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_EXTENDING_CAS_BASED_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_EXTENDING_CAS_BASED_HPP_INCLUDED_ + +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +template< typename Base, unsigned int Size, bool Signed > +struct extending_cas_based_operations : + public Base +{ + typedef typename Base::storage_type storage_type; + typedef typename make_storage_type< Size, Signed >::type emulated_storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + emulated_storage_type new_val; + do + { + new_val = static_cast< emulated_storage_type >(old_val) + static_cast< emulated_storage_type >(v); + } + while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); + return old_val; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val = Base::load(storage, memory_order_relaxed); + emulated_storage_type new_val; + do + { + new_val = static_cast< emulated_storage_type >(old_val) - static_cast< emulated_storage_type >(v); + } + while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); + return old_val; + } +}; + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_EXTENDING_CAS_BASED_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_alpha.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_alpha.hpp new file mode 100644 index 000000000..f9a352213 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_alpha.hpp @@ -0,0 +1,874 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_alpha.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_ALPHA_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_ALPHA_HPP_INCLUDED_ + +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +/* + Refer to http://h71000.www7.hp.com/doc/82final/5601/5601pro_004.html + (HP OpenVMS systems documentation) and the Alpha Architecture Reference Manual. + */ + +/* + NB: The most natural thing would be to write the increment/decrement + operators along the following lines: + + __asm__ __volatile__ + ( + "1: ldl_l %0,%1 \n" + "addl %0,1,%0 \n" + "stl_c %0,%1 \n" + "beq %0,1b\n" + : "=&b" (tmp) + : "m" (value) + : "cc" + ); + + However according to the comments on the HP website and matching + comments in the Linux kernel sources this defies branch prediction, + as the cpu assumes that backward branches are always taken; so + instead copy the trick from the Linux kernel, introduce a forward + branch and back again. + + I have, however, had a hard time measuring the difference between + the two versions in microbenchmarks -- I am leaving it in nevertheless + as it apparently does not hurt either. +*/ + +struct gcc_alpha_operations_base +{ + static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + __asm__ __volatile__ ("mb" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT + { + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + __asm__ __volatile__ ("mb" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("mb" ::: "memory"); + } +}; + + +template< bool Signed > +struct operations< 4u, Signed > : + public gcc_alpha_operations_base +{ + typedef typename make_storage_type< 4u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "mov %3, %1\n" + "ldl_l %0, %2\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (tmp) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + int success; + storage_type current; + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %2, %4\n" // current = *(&storage) + "cmpeq %2, %0, %3\n" // success = current == expected + "mov %2, %0\n" // expected = current + "beq %3, 2f\n" // if (success == 0) goto end + "stl_c %1, %4\n" // storage = desired; desired = store succeeded + "mov %1, %3\n" // success = desired + "2:\n" + : "+&r" (expected), // %0 + "+&r" (desired), // %1 + "=&r" (current), // %2 + "=&r" (success) // %3 + : "m" (storage) // %4 + : + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + storage_type current, tmp; + fence_before(success_order); + __asm__ __volatile__ + ( + "1:\n" + "mov %5, %1\n" // tmp = desired + "ldl_l %2, %4\n" // current = *(&storage) + "cmpeq %2, %0, %3\n" // success = current == expected + "mov %2, %0\n" // expected = current + "beq %3, 2f\n" // if (success == 0) goto end + "stl_c %1, %4\n" // storage = tmp; tmp = store succeeded + "beq %1, 3f\n" // if (tmp == 0) goto retry + "mov %1, %3\n" // success = tmp + "2:\n" + + ".subsection 2\n" + "3: br 1b\n" + ".previous\n" + + : "+&r" (expected), // %0 + "=&r" (tmp), // %1 + "=&r" (current), // %2 + "=&r" (success) // %3 + : "m" (storage), // %4 + "r" (desired) // %5 + : + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "addl %0, %3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "subl %0, %3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "and %0, %3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "bis %0, %3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "xor %0, %3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + + +template< > +struct operations< 1u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "addl %0, %3, %1\n" + "zapnot %1, #1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "subl %0, %3, %1\n" + "zapnot %1, #1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 1u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "addl %0, %3, %1\n" + "sextb %1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "subl %0, %3, %1\n" + "sextb %1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } +}; + + +template< > +struct operations< 2u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "addl %0, %3, %1\n" + "zapnot %1, #3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "subl %0, %3, %1\n" + "zapnot %1, #3, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 2u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "addl %0, %3, %1\n" + "sextw %1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldl_l %0, %2\n" + "subl %0, %3, %1\n" + "sextw %1, %1\n" + "stl_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } +}; + + +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_alpha_operations_base +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "mov %3, %1\n" + "ldq_l %0, %2\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (tmp) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + int success; + storage_type current; + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %2, %4\n" // current = *(&storage) + "cmpeq %2, %0, %3\n" // success = current == expected + "mov %2, %0\n" // expected = current + "beq %3, 2f\n" // if (success == 0) goto end + "stq_c %1, %4\n" // storage = desired; desired = store succeeded + "mov %1, %3\n" // success = desired + "2:\n" + : "+&r" (expected), // %0 + "+&r" (desired), // %1 + "=&r" (current), // %2 + "=&r" (success) // %3 + : "m" (storage) // %4 + : + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + storage_type current, tmp; + fence_before(success_order); + __asm__ __volatile__ + ( + "1:\n" + "mov %5, %1\n" // tmp = desired + "ldq_l %2, %4\n" // current = *(&storage) + "cmpeq %2, %0, %3\n" // success = current == expected + "mov %2, %0\n" // expected = current + "beq %3, 2f\n" // if (success == 0) goto end + "stq_c %1, %4\n" // storage = tmp; tmp = store succeeded + "beq %1, 3f\n" // if (tmp == 0) goto retry + "mov %1, %3\n" // success = tmp + "2:\n" + + ".subsection 2\n" + "3: br 1b\n" + ".previous\n" + + : "+&r" (expected), // %0 + "=&r" (tmp), // %1 + "=&r" (current), // %2 + "=&r" (success) // %3 + : "m" (storage), // %4 + "r" (desired) // %5 + : + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %0, %2\n" + "addq %0, %3, %1\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %0, %2\n" + "subq %0, %3, %1\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %0, %2\n" + "and %0, %3, %1\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %0, %2\n" + "bis %0, %3, %1\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, modified; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldq_l %0, %2\n" + "xor %0, %3, %1\n" + "stq_c %1, %2\n" + "beq %1, 2f\n" + + ".subsection 2\n" + "2: br 1b\n" + ".previous\n" + + : "=&r" (original), // %0 + "=&r" (modified) // %1 + : "m" (storage), // %2 + "r" (v) // %3 + : + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("mb" ::: "memory"); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_ALPHA_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_arm.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_arm.hpp new file mode 100644 index 000000000..e9ac0b2fb --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_arm.hpp @@ -0,0 +1,971 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_arm.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_ARM_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +// From the ARM Architecture Reference Manual for architecture v6: +// +// LDREX{} , [] +// Specifies the destination register for the memory word addressed by +// Specifies the register containing the address. +// +// STREX{} , , [] +// Specifies the destination register for the returned status value. +// 0 if the operation updates memory +// 1 if the operation fails to update memory +// Specifies the register containing the word to be stored to memory. +// Specifies the register containing the address. +// Rd must not be the same register as Rm or Rn. +// +// ARM v7 is like ARM v6 plus: +// There are half-word and byte versions of the LDREX and STREX instructions, +// LDREXH, LDREXB, STREXH and STREXB. +// There are also double-word versions, LDREXD and STREXD. +// (Actually it looks like these are available from version 6k onwards.) +// FIXME these are not yet used; should be mostly a matter of copy-and-paste. +// I think you can supply an immediate offset to the address. +// +// A memory barrier is effected using a "co-processor 15" instruction, +// though a separate assembler mnemonic is available for it in v7. +// +// "Thumb 1" is a subset of the ARM instruction set that uses a 16-bit encoding. It +// doesn't include all instructions and in particular it doesn't include the co-processor +// instruction used for the memory barrier or the load-locked/store-conditional +// instructions. So, if we're compiling in "Thumb 1" mode, we need to wrap all of our +// asm blocks with code to temporarily change to ARM mode. +// +// You can only change between ARM and Thumb modes when branching using the bx instruction. +// bx takes an address specified in a register. The least significant bit of the address +// indicates the mode, so 1 is added to indicate that the destination code is Thumb. +// A temporary register is needed for the address and is passed as an argument to these +// macros. It must be one of the "low" registers accessible to Thumb code, specified +// using the "l" attribute in the asm statement. +// +// Architecture v7 introduces "Thumb 2", which does include (almost?) all of the ARM +// instruction set. (Actually, there was an extension of v6 called v6T2 which supported +// "Thumb 2" mode, but its architecture manual is no longer available, referring to v7.) +// So in v7 we don't need to change to ARM mode; we can write "universal +// assembler" which will assemble to Thumb 2 or ARM code as appropriate. The only thing +// we need to do to make this "universal" assembler mode work is to insert "IT" instructions +// to annotate the conditional instructions. These are ignored in other modes (e.g. v6), +// so they can always be present. + +// A note about memory_order_consume. Technically, this architecture allows to avoid +// unnecessary memory barrier after consume load since it supports data dependency ordering. +// However, some compiler optimizations may break a seemingly valid code relying on data +// dependency tracking by injecting bogus branches to aid out of order execution. +// This may happen not only in Boost.Atomic code but also in user's code, which we have no +// control of. See this thread: http://lists.boost.org/Archives/boost/2014/06/213890.php. +// For this reason we promote memory_order_consume to memory_order_acquire. + +#if defined(__thumb__) && !defined(__thumb2__) +#define BOOST_ATOMIC_DETAIL_ARM_ASM_START(TMPREG) "adr " #TMPREG ", 8f\n" "bx " #TMPREG "\n" ".arm\n" ".align 4\n" "8:\n" +#define BOOST_ATOMIC_DETAIL_ARM_ASM_END(TMPREG) "adr " #TMPREG ", 9f + 1\n" "bx " #TMPREG "\n" ".thumb\n" ".align 2\n" "9:\n" +#define BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(var) "=&l" (var) +#else +// The tmpreg may be wasted in this case, which is non-optimal. +#define BOOST_ATOMIC_DETAIL_ARM_ASM_START(TMPREG) +#define BOOST_ATOMIC_DETAIL_ARM_ASM_END(TMPREG) +#define BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(var) "=&r" (var) +#endif + +struct gcc_arm_operations_base +{ + static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT + { + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_DETAIL_ARM_HAS_DMB) + // Older binutils (supposedly, older than 2.21.1) didn't support symbolic or numeric arguments of the "dmb" instruction such as "ish" or "#11". + // As a workaround we have to inject encoded bytes of the instruction. There are two encodings for the instruction: ARM and Thumb. See ARM Architecture Reference Manual, A8.8.43. + // Since we cannot detect binutils version at compile time, we'll have to always use this hack. + __asm__ __volatile__ + ( +#if defined(__thumb2__) + ".short 0xF3BF, 0x8F5B\n" // dmb ish +#else + ".word 0xF57FF05B\n" // dmb ish +#endif + : + : + : "memory" + ); +#else + int tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "mcr\tp15, 0, r0, c7, c10, 5\n" + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : "=&l" (tmp) + : + : "memory" + ); +#endif + } +}; + + +template< bool Signed > +struct operations< 4u, Signed > : + public gcc_arm_operations_base +{ + typedef typename make_storage_type< 4u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original; + fence_before(order); + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // load the original value + "strex %[tmp], %[value], %[storage]\n" // store the replacement, tmp = store failed + "teq %[tmp], #0\n" // check if store succeeded + "bne 1b\n" + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [tmp] "=&l" (tmp), [original] "=&r" (original), [storage] "+Q" (storage) + : [value] "r" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + uint32_t success; + uint32_t tmp; + storage_type original; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "mov %[success], #0\n" // success = 0 + "ldrex %[original], %[storage]\n" // original = *(&storage) + "cmp %[original], %[expected]\n" // flags = original==expected + "itt eq\n" // [hint that the following 2 instructions are conditional on flags.equal] + "strexeq %[success], %[desired], %[storage]\n" // if (flags.equal) *(&storage) = desired, success = store failed + "eoreq %[success], %[success], #1\n" // if (flags.equal) success ^= 1 (i.e. make it 1 if store succeeded) + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [success] "=&r" (success), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [expected] "r" (expected), // %4 + [desired] "r" (desired) // %5 + : "cc" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = original; + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + uint32_t success; + uint32_t tmp; + storage_type original; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "mov %[success], #0\n" // success = 0 + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "cmp %[original], %[expected]\n" // flags = original==expected + "bne 2f\n" // if (!flags.equal) goto end + "strex %[success], %[desired], %[storage]\n" // *(&storage) = desired, success = store failed + "eors %[success], %[success], #1\n" // success ^= 1 (i.e. make it 1 if store succeeded); flags.equal = success == 0 + "beq 1b\n" // if (flags.equal) goto retry + "2:\n" + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [success] "=&r" (success), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [expected] "r" (expected), // %4 + [desired] "r" (desired) // %5 + : "cc" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = original; + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "add %[result], %[original], %[value]\n" // result = original + value + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "sub %[result], %[original], %[value]\n" // result = original - value + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "and %[result], %[original], %[value]\n" // result = original & value + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "orr %[result], %[original], %[value]\n" // result = original | value + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "eor %[result], %[original], %[value]\n" // result = original ^ value + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + + +template< > +struct operations< 1u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "add %[result], %[original], %[value]\n" // result = original + value + "uxtb %[result], %[result]\n" // zero extend result from 8 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "sub %[result], %[original], %[value]\n" // result = original - value + "uxtb %[result], %[result]\n" // zero extend result from 8 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 1u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "add %[result], %[original], %[value]\n" // result = original + value + "sxtb %[result], %[result]\n" // sign extend result from 8 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "sub %[result], %[original], %[value]\n" // result = original - value + "sxtb %[result], %[result]\n" // sign extend result from 8 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } +}; + + +template< > +struct operations< 2u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "add %[result], %[original], %[value]\n" // result = original + value + "uxth %[result], %[result]\n" // zero extend result from 16 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "sub %[result], %[original], %[value]\n" // result = original - value + "uxth %[result], %[result]\n" // zero extend result from 16 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 2u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "add %[result], %[original], %[value]\n" // result = original + value + "sxth %[result], %[result]\n" // sign extend result from 16 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + uint32_t tmp; + storage_type original, result; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%[tmp]) + "1:\n" + "ldrex %[original], %[storage]\n" // original = *(&storage) + "sub %[result], %[original], %[value]\n" // result = original - value + "sxth %[result], %[result]\n" // sign extend result from 16 to 32 bits + "strex %[tmp], %[result], %[storage]\n" // *(&storage) = result, tmp = store failed + "teq %[tmp], #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%[tmp]) + : [original] "=&r" (original), // %0 + [result] "=&r" (result), // %1 + [tmp] "=&l" (tmp), // %2 + [storage] "+Q" (storage) // %3 + : [value] "r" (v) // %4 + : "cc" + ); + fence_after(order); + return original; + } +}; + + +#if defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD) + +// Unlike 32-bit operations, for 64-bit loads and stores we must use ldrexd/strexd. +// Any other instructions result in a non-atomic sequence of 32-bit accesses. +// See "ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition", +// Section A3.5.3 "Atomicity in the ARM architecture". + +// In the asm blocks below we have to use 32-bit register pairs to compose 64-bit values. +// In order to pass the 64-bit operands to/from asm blocks, we use undocumented gcc feature: +// the lower half (Rt) of the operand is accessible normally, via the numbered placeholder (e.g. %0), +// and the upper half (Rt2) - via the same placeholder with an 'H' after the '%' sign (e.g. %H0). +// See: http://hardwarebug.org/2010/07/06/arm-inline-asm-secrets/ + +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_arm_operations_base +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + exchange(storage, v, order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type original; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "ldrexd %1, %H1, [%2]\n" + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original) // %1 + : "r" (&storage) // %2 + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original; + fence_before(order); + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // load the original value + "strexd %0, %2, %H2, [%3]\n" // store the replacement, tmp = store failed + "teq %0, #0\n" // check if store succeeded + "bne 1b\n" + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original) // %1 + : "r" (v), // %2 + "r" (&storage) // %3 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + uint32_t tmp; + storage_type original, old_val = expected; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "cmp %1, %2\n" // flags = original.lo==old_val.lo + "ittt eq\n" // [hint that the following 3 instructions are conditional on flags.equal] + "cmpeq %H1, %H2\n" // if (flags.equal) flags = original.hi==old_val.hi + "strexdeq %0, %4, %H4, [%3]\n" // if (flags.equal) *(&storage) = desired, tmp = store failed + "teqeq %0, #0\n" // if (flags.equal) flags = tmp==0 + "ite eq\n" // [hint that the following 2 instructions are conditional on flags.equal] + "moveq %2, #1\n" // if (flags.equal) old_val.lo = 1 + "movne %2, #0\n" // if (!flags.equal) old_val.lo = 0 + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "+r" (old_val) // %2 + : "r" (&storage), // %3 + "r" (desired) // %4 + : "cc", "memory" + ); + const uint32_t success = (uint32_t)old_val; + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = original; + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + uint32_t tmp; + storage_type original, old_val = expected; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "cmp %1, %2\n" // flags = original.lo==old_val.lo + "it eq\n" // [hint that the following instruction is conditional on flags.equal] + "cmpeq %H1, %H2\n" // if (flags.equal) flags = original.hi==old_val.hi + "bne 2f\n" // if (!flags.equal) goto end + "strexd %0, %4, %H4, [%3]\n" // *(&storage) = desired, tmp = store failed + "teq %0, #0\n" // flags.equal = tmp == 0 + "bne 1b\n" // if (flags.equal) goto retry + "2:\n" + "ite eq\n" // [hint that the following 2 instructions are conditional on flags.equal] + "moveq %2, #1\n" // if (flags.equal) old_val.lo = 1 + "movne %2, #0\n" // if (!flags.equal) old_val.lo = 0 + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "+r" (old_val) // %2 + : "r" (&storage), // %3 + "r" (desired) // %4 + : "cc", "memory" + ); + const uint32_t success = (uint32_t)old_val; + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = original; + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage_type original, result; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "adds %2, %1, %4\n" // result = original + value + "adc %H2, %H1, %H4\n" + "strexd %0, %2, %H2, [%3]\n" // *(&storage) = result, tmp = store failed + "teq %0, #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "=&r" (result) // %2 + : "r" (&storage), // %3 + "r" (v) // %4 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage_type original, result; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "subs %2, %1, %4\n" // result = original - value + "sbc %H2, %H1, %H4\n" + "strexd %0, %2, %H2, [%3]\n" // *(&storage) = result, tmp = store failed + "teq %0, #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "=&r" (result) // %2 + : "r" (&storage), // %3 + "r" (v) // %4 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage_type original, result; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "and %2, %1, %4\n" // result = original & value + "and %H2, %H1, %H4\n" + "strexd %0, %2, %H2, [%3]\n" // *(&storage) = result, tmp = store failed + "teq %0, #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "=&r" (result) // %2 + : "r" (&storage), // %3 + "r" (v) // %4 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage_type original, result; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "orr %2, %1, %4\n" // result = original | value + "orr %H2, %H1, %H4\n" + "strexd %0, %2, %H2, [%3]\n" // *(&storage) = result, tmp = store failed + "teq %0, #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "=&r" (result) // %2 + : "r" (&storage), // %3 + "r" (v) // %4 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + storage_type original, result; + uint32_t tmp; + __asm__ __volatile__ + ( + BOOST_ATOMIC_DETAIL_ARM_ASM_START(%0) + "1:\n" + "ldrexd %1, %H1, [%3]\n" // original = *(&storage) + "eor %2, %1, %4\n" // result = original ^ value + "eor %H2, %H1, %H4\n" + "strexd %0, %2, %H2, [%3]\n" // *(&storage) = result, tmp = store failed + "teq %0, #0\n" // flags = tmp==0 + "bne 1b\n" // if (!flags.equal) goto retry + BOOST_ATOMIC_DETAIL_ARM_ASM_END(%0) + : BOOST_ATOMIC_DETAIL_ARM_ASM_TMPREG_CONSTRAINT(tmp), // %0 + "=&r" (original), // %1 + "=&r" (result) // %2 + : "r" (&storage), // %3 + "r" (v) // %4 + : "cc", "memory" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +#endif // defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD) + + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + gcc_arm_operations_base::hardware_full_fence(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_atomic.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_atomic.hpp new file mode 100644 index 000000000..90b8784d0 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_atomic.hpp @@ -0,0 +1,380 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_atomic.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#if defined(__clang__) && (defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)) +#include +#include +#endif + +#if __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE ||\ + __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE || __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE ||\ + __GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE || __GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE ||\ + __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE +// There are platforms where we need to use larger storage types +#include +#include +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(__INTEL_COMPILER) +// This is used to suppress warning #32013 described below for Intel Compiler. +// In debug builds the compiler does not inline any functions, so basically +// every atomic function call results in this warning. I don't know any other +// way to selectively disable just this one warning. +#pragma system_header +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +/*! + * The function converts \c boost::memory_order values to the compiler-specific constants. + * + * NOTE: The intention is that the function is optimized away by the compiler, and the + * compiler-specific constants are passed to the intrinsics. I know constexpr doesn't + * work in this case because the standard atomics interface require memory ordering + * constants to be passed as function arguments, at which point they stop being constexpr. + * However it is crucial that the compiler sees constants and not runtime values, + * because otherwise it just ignores the ordering value and always uses seq_cst. + * This is the case with Intel C++ Compiler 14.0.3 (Composer XE 2013 SP1, update 3) and + * gcc 4.8.2. Intel Compiler issues a warning in this case: + * + * warning #32013: Invalid memory order specified. Defaulting to seq_cst memory order. + * + * while gcc acts silently. + * + * To mitigate the problem ALL functions, including the atomic<> members must be + * declared with BOOST_FORCEINLINE. In this case the compilers are able to see that + * all functions are called with constant orderings and call intrinstcts properly. + * + * Unfortunately, this still doesn't work in debug mode as the compiler doesn't + * inline functions even when marked with BOOST_FORCEINLINE. In this case all atomic + * operaions will be executed with seq_cst semantics. + */ +BOOST_FORCEINLINE BOOST_CONSTEXPR int convert_memory_order_to_gcc(memory_order order) BOOST_NOEXCEPT +{ + return (order == memory_order_relaxed ? __ATOMIC_RELAXED : (order == memory_order_consume ? __ATOMIC_CONSUME : + (order == memory_order_acquire ? __ATOMIC_ACQUIRE : (order == memory_order_release ? __ATOMIC_RELEASE : + (order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_SEQ_CST))))); +} + +template< typename T > +struct gcc_atomic_operations +{ + typedef T storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + __atomic_store_n(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return __atomic_load_n(&storage, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_fetch_add(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_fetch_sub(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_exchange_n(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return __atomic_compare_exchange_n + ( + &storage, &expected, desired, false, + atomics::detail::convert_memory_order_to_gcc(success_order), + atomics::detail::convert_memory_order_to_gcc(failure_order) + ); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return __atomic_compare_exchange_n + ( + &storage, &expected, desired, true, + atomics::detail::convert_memory_order_to_gcc(success_order), + atomics::detail::convert_memory_order_to_gcc(failure_order) + ); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_fetch_and(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_fetch_or(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return __atomic_fetch_xor(&storage, v, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return __atomic_test_and_set(&storage, atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + __atomic_clear(const_cast< storage_type* >(&storage), atomics::detail::convert_memory_order_to_gcc(order)); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile& storage) BOOST_NOEXCEPT + { + return __atomic_is_lock_free(sizeof(storage_type), &storage); + } +}; + +#if BOOST_ATOMIC_INT128_LOCK_FREE > 0 +#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +// Workaround for clang bug: http://llvm.org/bugs/show_bug.cgi?id=19149 +// Clang 3.4 does not implement 128-bit __atomic* intrinsics even though it defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +template< bool Signed > +struct operations< 16u, Signed > : + public cas_based_operations< gcc_dcas_x86_64< Signed > > +{ +}; + +#else + +template< bool Signed > +struct operations< 16u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type > +{ +}; + +#endif +#endif + + +#if BOOST_ATOMIC_INT64_LOCK_FREE > 0 +#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) + +// Workaround for clang bug http://llvm.org/bugs/show_bug.cgi?id=19355 +template< bool Signed > +struct operations< 8u, Signed > : + public cas_based_operations< gcc_dcas_x86< Signed > > +{ +}; + +#elif (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) + +#define BOOST_ATOMIC_DETAIL_INT64_EXTENDED + +template< bool Signed > +struct operations< 8u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed > +{ +}; + +#else + +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type > +{ +}; + +#endif +#endif + +#if BOOST_ATOMIC_INT32_LOCK_FREE > 0 +#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) + +#define BOOST_ATOMIC_DETAIL_INT32_EXTENDED + +#if !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) + +template< bool Signed > +struct operations< 4u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 4u, Signed > +{ +}; + +#else // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) + +template< bool Signed > +struct operations< 4u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed > +{ +}; + +#endif // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) + +#else + +template< bool Signed > +struct operations< 4u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type > +{ +}; + +#endif +#endif + +#if BOOST_ATOMIC_INT16_LOCK_FREE > 0 +#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) + +#define BOOST_ATOMIC_DETAIL_INT16_EXTENDED + +#if !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED) + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 2u, Signed > +{ +}; + +#elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 2u, Signed > +{ +}; + +#else + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed > +{ +}; + +#endif + +#else + +template< bool Signed > +struct operations< 2u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type > +{ +}; + +#endif +#endif + +#if BOOST_ATOMIC_INT8_LOCK_FREE > 0 +#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 1 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 1 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 1 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 1 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\ + (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) ||\ + (__GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE) ||\ + (__GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE) + +#if !defined(BOOST_ATOMIC_DETAIL_INT16_EXTENDED) + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >, 1u, Signed > +{ +}; + +#elif !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED) + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 1u, Signed > +{ +}; + +#elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 1u, Signed > +{ +}; + +#else + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed > +{ +}; + +#endif + +#else + +template< bool Signed > +struct operations< 1u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 1u, Signed >::type > +{ +}; + +#endif +#endif + +#undef BOOST_ATOMIC_DETAIL_INT16_EXTENDED +#undef BOOST_ATOMIC_DETAIL_INT32_EXTENDED +#undef BOOST_ATOMIC_DETAIL_INT64_EXTENDED + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + __atomic_thread_fence(atomics::detail::convert_memory_order_to_gcc(order)); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + __atomic_signal_fence(atomics::detail::convert_memory_order_to_gcc(order)); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_ATOMIC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_ppc.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_ppc.hpp new file mode 100644 index 000000000..24cc3873c --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_ppc.hpp @@ -0,0 +1,775 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_ppc.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_PPC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_PPC_HPP_INCLUDED_ + +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +/* + Refer to: Motorola: "Programming Environments Manual for 32-Bit + Implementations of the PowerPC Architecture", Appendix E: + "Synchronization Programming Examples" for an explanation of what is + going on here (can be found on the web at various places by the + name "MPCFPE32B.pdf", Google is your friend...) + + Most of the atomic operations map to instructions in a relatively + straight-forward fashion, but "load"s may at first glance appear + a bit strange as they map to: + + lwz %rX, addr + cmpw %rX, %rX + bne- 1f + 1: + + That is, the CPU is forced to perform a branch that "formally" depends + on the value retrieved from memory. This scheme has an overhead of + about 1-2 clock cycles per load, but it allows to map "acquire" to + the "isync" instruction instead of "sync" uniformly and for all type + of atomic operations. Since "isync" has a cost of about 15 clock + cycles, while "sync" hast a cost of about 50 clock cycles, the small + penalty to atomic loads more than compensates for this. + + Byte- and halfword-sized atomic values are realized by encoding the + value to be represented into a word, performing sign/zero extension + as appropriate. This means that after add/sub operations the value + needs fixing up to accurately preserve the wrap-around semantic of + the smaller type. (Nothing special needs to be done for the bit-wise + and the "exchange type" operators as the compiler already sees to + it that values carried in registers are extended appropriately and + everything falls into place naturally). + + The register constraint "b" instructs gcc to use any register + except r0; this is sometimes required because the encoding for + r0 is used to signify "constant zero" in a number of instructions, + making r0 unusable in this place. For simplicity this constraint + is used everywhere since I am to lazy to look this up on a + per-instruction basis, and ppc has enough registers for this not + to pose a problem. +*/ + +// A note about memory_order_consume. Technically, this architecture allows to avoid +// unnecessary memory barrier after consume load since it supports data dependency ordering. +// However, some compiler optimizations may break a seemingly valid code relying on data +// dependency tracking by injecting bogus branches to aid out of order execution. +// This may happen not only in Boost.Atomic code but also in user's code, which we have no +// control of. See this thread: http://lists.boost.org/Archives/boost/2014/06/213890.php. +// For this reason we promote memory_order_consume to memory_order_acquire. + +struct gcc_ppc_operations_base +{ + static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT + { +#if defined(__powerpc64__) + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("sync" ::: "memory"); + else if ((order & memory_order_release) != 0) + __asm__ __volatile__ ("lwsync" ::: "memory"); +#else + if ((order & memory_order_release) != 0) + __asm__ __volatile__ ("sync" ::: "memory"); +#endif + } + + static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT + { + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + __asm__ __volatile__ ("isync" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("sync" ::: "memory"); + } +}; + + +template< bool Signed > +struct operations< 4u, Signed > : + public gcc_ppc_operations_base +{ + typedef typename make_storage_type< 4u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + __asm__ __volatile__ + ( + "stw %1, %0\n" + : "+m" (storage) + : "r" (v) + ); + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v; + __asm__ __volatile__ + ( + "lwz %0, %1\n" + "cmpw %0, %0\n" + "bne- 1f\n" + "1:\n" + : "=&r" (v) + : "m" (storage) + : "cr0" + ); + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y1\n" + "stwcx. %2,%y1\n" + "bne- 1b\n" + : "=&b" (original), "+Z" (storage) + : "b" (v) + : "cr0" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + fence_before(success_order); + __asm__ __volatile__ + ( + "li %1, 0\n" + "lwarx %0,%y2\n" + "cmpw %0, %3\n" + "bne- 1f\n" + "stwcx. %4,%y2\n" + "bne- 1f\n" + "li %1, 1\n" + "1:" + : "=&b" (expected), "=&b" (success), "+Z" (storage) + : "b" (expected), "b" (desired) + : "cr0" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + fence_before(success_order); + __asm__ __volatile__ + ( + "li %1, 0\n" + "0: lwarx %0,%y2\n" + "cmpw %0, %3\n" + "bne- 1f\n" + "stwcx. %4,%y2\n" + "bne- 0b\n" + "li %1, 1\n" + "1:" + : "=&b" (expected), "=&b" (success), "+Z" (storage) + : "b" (expected), "b" (desired) + : "cr0" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "add %1,%0,%3\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "sub %1,%0,%3\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "and %1,%0,%3\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "or %1,%0,%3\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "xor %1,%0,%3\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + + +template< > +struct operations< 1u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "add %1,%0,%3\n" + "rlwinm %1, %1, 0, 0xff\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "sub %1,%0,%3\n" + "rlwinm %1, %1, 0, 0xff\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 1u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "add %1,%0,%3\n" + "extsb %1, %1\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "sub %1,%0,%3\n" + "extsb %1, %1\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } +}; + + +template< > +struct operations< 2u, false > : + public operations< 4u, false > +{ + typedef operations< 4u, false > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "add %1,%0,%3\n" + "rlwinm %1, %1, 0, 0xffff\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "sub %1,%0,%3\n" + "rlwinm %1, %1, 0, 0xffff\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } +}; + +template< > +struct operations< 2u, true > : + public operations< 4u, true > +{ + typedef operations< 4u, true > base_type; + typedef base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "add %1,%0,%3\n" + "extsh %1, %1\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "lwarx %0,%y2\n" + "sub %1,%0,%3\n" + "extsh %1, %1\n" + "stwcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } +}; + + +#if defined(__powerpc64__) + +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_ppc_operations_base +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before(order); + __asm__ __volatile__ + ( + "std %1, %0\n" + : "+m" (storage) + : "r" (v) + ); + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v; + __asm__ __volatile__ + ( + "ld %0, %1\n" + "cmpd %0, %0\n" + "bne- 1f\n" + "1:\n" + : "=&b" (v) + : "m" (storage) + : "cr0" + ); + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y1\n" + "stdcx. %2,%y1\n" + "bne- 1b\n" + : "=&b" (original), "+Z" (storage) + : "b" (v) + : "cr0" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + fence_before(success_order); + __asm__ __volatile__ + ( + "li %1, 0\n" + "ldarx %0,%y2\n" + "cmpd %0, %3\n" + "bne- 1f\n" + "stdcx. %4,%y2\n" + "bne- 1f\n" + "li %1, 1\n" + "1:" + : "=&b" (expected), "=&b" (success), "+Z" (storage) + : "b" (expected), "b" (desired) + : "cr0" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + int success; + fence_before(success_order); + __asm__ __volatile__ + ( + "li %1, 0\n" + "0: ldarx %0,%y2\n" + "cmpd %0, %3\n" + "bne- 1f\n" + "stdcx. %4,%y2\n" + "bne- 0b\n" + "li %1, 1\n" + "1:" + : "=&b" (expected), "=&b" (success), "+Z" (storage) + : "b" (expected), "b" (desired) + : "cr0" + ); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + return !!success; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y2\n" + "add %1,%0,%3\n" + "stdcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y2\n" + "sub %1,%0,%3\n" + "stdcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y2\n" + "and %1,%0,%3\n" + "stdcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y2\n" + "or %1,%0,%3\n" + "stdcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type original, tmp; + fence_before(order); + __asm__ __volatile__ + ( + "1:\n" + "ldarx %0,%y2\n" + "xor %1,%0,%3\n" + "stdcx. %1,%y2\n" + "bne- 1b\n" + : "=&b" (original), "=&b" (tmp), "+Z" (storage) + : "b" (v) + : "cc" + ); + fence_after(order); + return original; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, 0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +#endif // defined(__powerpc64__) + + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + switch (order) + { + case memory_order_consume: + case memory_order_acquire: + __asm__ __volatile__ ("isync" ::: "memory"); + break; + case memory_order_release: +#if defined(__powerpc64__) + __asm__ __volatile__ ("lwsync" ::: "memory"); + break; +#endif + case memory_order_acq_rel: + case memory_order_seq_cst: + __asm__ __volatile__ ("sync" ::: "memory"); + break; + default:; + } +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_PPC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_sparc.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_sparc.hpp new file mode 100644 index 000000000..92e279066 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_sparc.hpp @@ -0,0 +1,245 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2010 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_sparc.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_SPARC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_SPARC_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +struct gcc_sparc_cas_base +{ + static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("membar #Sync" ::: "memory"); + else if ((order & memory_order_release) != 0) + __asm__ __volatile__ ("membar #StoreStore | #LoadStore" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("membar #Sync" ::: "memory"); + else if ((order & (memory_order_consume | memory_order_acquire)) != 0) + __asm__ __volatile__ ("membar #StoreStore | #LoadStore" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("membar #Sync" ::: "memory"); + } +}; + +template< bool Signed > +struct gcc_sparc_cas32 : + public gcc_sparc_cas_base +{ + typedef typename make_storage_type< 4u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before_store(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + storage_type previous = expected; + __asm__ __volatile__ + ( + "cas [%1], %2, %0" + : "+r" (desired) + : "r" (&storage), "r" (previous) + : "memory" + ); + const bool success = (desired == previous); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = desired; + return success; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public cas_based_operations< gcc_sparc_cas32< Signed > > +{ + typedef cas_based_operations< gcc_sparc_cas32< Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + __asm__ __volatile__ + ( + "swap [%1], %0" + : "+r" (v) + : "r" (&storage) + : "memory" + ); + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!exchange(storage, (storage_type)1, order); + } +}; + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 1u, Signed > +{ +}; + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 2u, Signed > +{ +}; + +template< bool Signed > +struct gcc_sparc_cas64 : + public gcc_sparc_cas_base +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before_store(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + fence_before(success_order); + storage_type previous = expected; + __asm__ __volatile__ + ( + "casx [%1], %2, %0" + : "+r" (desired) + : "r" (&storage), "r" (previous) + : "memory" + ); + const bool success = (desired == previous); + if (success) + fence_after(success_order); + else + fence_after(failure_order); + expected = desired; + return success; + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 8u, Signed > : + public cas_based_operations< gcc_sparc_cas64< Signed > > +{ +}; + + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + switch (order) + { + case memory_order_release: + __asm__ __volatile__ ("membar #StoreStore | #LoadStore" ::: "memory"); + break; + case memory_order_consume: + case memory_order_acquire: + __asm__ __volatile__ ("membar #LoadLoad | #LoadStore" ::: "memory"); + break; + case memory_order_acq_rel: + __asm__ __volatile__ ("membar #LoadLoad | #LoadStore | #StoreStore" ::: "memory"); + break; + case memory_order_seq_cst: + __asm__ __volatile__ ("membar #Sync" ::: "memory"); + break; + case memory_order_relaxed: + default: + break; + } +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_SPARC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_sync.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_sync.hpp new file mode 100644 index 000000000..3fb17f78e --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_sync.hpp @@ -0,0 +1,237 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2011 Helge Bahmann + * Copyright (c) 2013 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_sync.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_SYNC_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_SYNC_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +struct gcc_sync_operations_base +{ + static BOOST_FORCEINLINE void fence_before_store(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + __sync_synchronize(); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + __sync_synchronize(); + } + + static BOOST_FORCEINLINE void fence_after_load(memory_order order) BOOST_NOEXCEPT + { + if ((order & (memory_order_acquire | memory_order_consume)) != 0) + __sync_synchronize(); + } +}; + +template< typename T > +struct gcc_sync_operations : + public gcc_sync_operations_base +{ + typedef T storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before_store(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return __sync_fetch_and_add(&storage, v); + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return __sync_fetch_and_sub(&storage, v); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + // GCC docs mention that not all architectures may support full exchange semantics for this intrinsic. However, GCC's implementation of + // std::atomic<> uses this intrinsic unconditionally. We do so as well. In case if some architectures actually don't support this, we can always + // add a check here and fall back to a CAS loop. + if ((order & memory_order_release) != 0) + __sync_synchronize(); + return __sync_lock_test_and_set(&storage, v); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type expected2 = expected; + storage_type old_val = __sync_val_compare_and_swap(&storage, expected2, desired); + + if (old_val == expected2) + { + return true; + } + else + { + expected = old_val; + return false; + } + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return __sync_fetch_and_and(&storage, v); + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return __sync_fetch_and_or(&storage, v); + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return __sync_fetch_and_xor(&storage, v); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + __sync_synchronize(); + return !!__sync_lock_test_and_set(&storage, 1); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + __sync_lock_release(&storage); + if (order == memory_order_seq_cst) + __sync_synchronize(); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +#if BOOST_ATOMIC_INT8_LOCK_FREE > 0 +template< bool Signed > +struct operations< 1u, Signed > : +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) + public gcc_sync_operations< typename make_storage_type< 1u, Signed >::type > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 2u, Signed >::type >, 1u, Signed > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 4u, Signed >::type >, 1u, Signed > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 8u, Signed >::type >, 1u, Signed > +#else + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed > +#endif +{ +}; +#endif + +#if BOOST_ATOMIC_INT16_LOCK_FREE > 0 +template< bool Signed > +struct operations< 2u, Signed > : +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) + public gcc_sync_operations< typename make_storage_type< 2u, Signed >::type > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 4u, Signed >::type >, 2u, Signed > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 8u, Signed >::type >, 2u, Signed > +#else + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed > +#endif +{ +}; +#endif + +#if BOOST_ATOMIC_INT32_LOCK_FREE > 0 +template< bool Signed > +struct operations< 4u, Signed > : +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + public gcc_sync_operations< typename make_storage_type< 4u, Signed >::type > +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 8u, Signed >::type >, 4u, Signed > +#else + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed > +#endif +{ +}; +#endif + +#if BOOST_ATOMIC_INT64_LOCK_FREE > 0 +template< bool Signed > +struct operations< 8u, Signed > : +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + public gcc_sync_operations< typename make_storage_type< 8u, Signed >::type > +#else + public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed > +#endif +{ +}; +#endif + +#if BOOST_ATOMIC_INT128_LOCK_FREE > 0 +template< bool Signed > +struct operations< 16u, Signed > : + public gcc_sync_operations< typename make_storage_type< 16u, Signed >::type > +{ +}; +#endif + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __sync_synchronize(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_SYNC_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_x86.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_x86.hpp new file mode 100644 index 000000000..39288e0dd --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_x86.hpp @@ -0,0 +1,510 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_x86.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) +#include +#include +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(__x86_64__) +#define BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "rdx" +#else +#define BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "edx" +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +struct gcc_x86_operations_base +{ + static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + __asm__ __volatile__ ("" ::: "memory"); + } + + static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_acquire) != 0) + __asm__ __volatile__ ("" ::: "memory"); + } +}; + +template< typename T, typename Derived > +struct gcc_x86_operations : + public gcc_x86_operations_base +{ + typedef T storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + if (order != memory_order_seq_cst) + { + fence_before(order); + storage = v; + fence_after(order); + } + else + { + Derived::exchange(storage, v, order); + } + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + return Derived::fetch_add(storage, -v, order); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!Derived::exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, (storage_type)0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 1u, Signed > : + public gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > +{ + typedef gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "lock; xaddb %0, %1" + : "+q" (v), "+m" (storage) + : + : "cc", "memory" + ); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "xchgb %0, %1" + : "+q" (v), "+m" (storage) + : + : "memory" + ); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchgb %3, %1\n\t" + "sete %2" + : "+a" (previous), "+m" (storage), "=q" (success) + : "q" (desired) + : "cc", "memory" + ); + expected = previous; + return success; + } + +#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ + __asm__ __volatile__\ + (\ + "xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\ + ".align 16\n\t"\ + "1: movb %[arg], %%dl\n\t"\ + op " %%al, %%dl\n\t"\ + "lock; cmpxchgb %%dl, %[storage]\n\t"\ + "jne 1b"\ + : [res] "+a" (result), [storage] "+m" (storage)\ + : [arg] "q" (argument)\ + : "cc", BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\ + ) + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("andb", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("orb", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("xorb", v, res); + return res; + } + +#undef BOOST_ATOMIC_DETAIL_CAS_LOOP +}; + +template< bool Signed > +struct operations< 2u, Signed > : + public gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > +{ + typedef gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "lock; xaddw %0, %1" + : "+q" (v), "+m" (storage) + : + : "cc", "memory" + ); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "xchgw %0, %1" + : "+q" (v), "+m" (storage) + : + : "memory" + ); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchgw %3, %1\n\t" + "sete %2" + : "+a" (previous), "+m" (storage), "=q" (success) + : "q" (desired) + : "cc", "memory" + ); + expected = previous; + return success; + } + +#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ + __asm__ __volatile__\ + (\ + "xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\ + ".align 16\n\t"\ + "1: movw %[arg], %%dx\n\t"\ + op " %%ax, %%dx\n\t"\ + "lock; cmpxchgw %%dx, %[storage]\n\t"\ + "jne 1b"\ + : [res] "+a" (result), [storage] "+m" (storage)\ + : [arg] "q" (argument)\ + : "cc", BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\ + ) + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("andw", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("orw", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("xorw", v, res); + return res; + } + +#undef BOOST_ATOMIC_DETAIL_CAS_LOOP +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public gcc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > +{ + typedef gcc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "lock; xaddl %0, %1" + : "+r" (v), "+m" (storage) + : + : "cc", "memory" + ); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "xchgl %0, %1" + : "+r" (v), "+m" (storage) + : + : "memory" + ); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchgl %3, %1\n\t" + "sete %2" + : "+a" (previous), "+m" (storage), "=q" (success) + : "r" (desired) + : "cc", "memory" + ); + expected = previous; + return success; + } + +#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ + __asm__ __volatile__\ + (\ + "xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\ + ".align 16\n\t"\ + "1: movl %[arg], %%edx\n\t"\ + op " %%eax, %%edx\n\t"\ + "lock; cmpxchgl %%edx, %[storage]\n\t"\ + "jne 1b"\ + : [res] "+a" (result), [storage] "+m" (storage)\ + : [arg] "r" (argument)\ + : "cc", BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\ + ) + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("andl", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("orl", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("xorl", v, res); + return res; + } + +#undef BOOST_ATOMIC_DETAIL_CAS_LOOP +}; + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) + +template< bool Signed > +struct operations< 8u, Signed > : + public cas_based_operations< gcc_dcas_x86< Signed > > +{ +}; + +#elif defined(__x86_64__) + +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > +{ + typedef gcc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "lock; xaddq %0, %1" + : "+r" (v), "+m" (storage) + : + : "cc", "memory" + ); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + __asm__ __volatile__ + ( + "xchgq %0, %1" + : "+r" (v), "+m" (storage) + : + : "memory" + ); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchgq %3, %1\n\t" + "sete %2" + : "+a" (previous), "+m" (storage), "=q" (success) + : "r" (desired) + : "cc", "memory" + ); + expected = previous; + return success; + } + +#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ + __asm__ __volatile__\ + (\ + "xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\ + ".align 16\n\t"\ + "1: movq %[arg], %%rdx\n\t"\ + op " %%rax, %%rdx\n\t"\ + "lock; cmpxchgq %%rdx, %[storage]\n\t"\ + "jne 1b"\ + : [res] "+a" (result), [storage] "+m" (storage)\ + : [arg] "r" (argument)\ + : "cc", BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\ + ) + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("andq", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("orq", v, res); + return res; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type res = storage; + BOOST_ATOMIC_DETAIL_CAS_LOOP("xorq", v, res); + return res; + } + +#undef BOOST_ATOMIC_DETAIL_CAS_LOOP +}; + +#endif + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +template< bool Signed > +struct operations< 16u, Signed > : + public cas_based_operations< gcc_dcas_x86_64< Signed > > +{ +}; + +#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order == memory_order_seq_cst) + { + __asm__ __volatile__ + ( +#if defined(__x86_64__) || defined(__SSE2__) + "mfence\n" +#else + "lock; addl $0, (%%esp)\n" +#endif + ::: "memory" + ); + } + else if ((order & (memory_order_acquire | memory_order_release)) != 0) + { + __asm__ __volatile__ ("" ::: "memory"); + } +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#undef BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/contrib/autoboost/boost/atomic/detail/ops_gcc_x86_dcas.hpp new file mode 100644 index 000000000..f25a27328 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_gcc_x86_dcas.hpp @@ -0,0 +1,308 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_gcc_x86_dcas.hpp + * + * This header contains implementation of the double-width CAS primitive for x86. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_X86_DCAS_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_GCC_X86_DCAS_HPP_INCLUDED_ + +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) + +template< bool Signed > +struct gcc_dcas_x86 +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + if ((((uint32_t)&storage) & 0x00000007) == 0) + { +#if defined(__SSE2__) + __asm__ __volatile__ + ( +#if defined(__AVX__) + "vmovq %1, %%xmm4\n\t" + "vmovq %%xmm4, %0\n\t" +#else + "movq %1, %%xmm4\n\t" + "movq %%xmm4, %0\n\t" +#endif + : "=m" (storage) + : "m" (v) + : "memory", "xmm4" + ); +#else + __asm__ __volatile__ + ( + "fildll %1\n\t" + "fistpll %0\n\t" + : "=m" (storage) + : "m" (v) + : "memory" + ); +#endif + } + else + { +#if defined(__PIC__) + uint32_t scratch; + __asm__ __volatile__ + ( + "movl %%ebx, %[scratch]\n\t" + "movl %[value_lo], %%ebx\n\t" + "movl 0(%[dest]), %%eax\n\t" + "movl 4(%[dest]), %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b 0(%[dest])\n\t" + "jne 1b\n\t" + "movl %[scratch], %%ebx" + : [scratch] "=m,m" (scratch) + : [value_lo] "a,a" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage) + : "cc", "edx", "memory" + ); +#else + __asm__ __volatile__ + ( + "movl 0(%[dest]), %%eax\n\t" + "movl 4(%[dest]), %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b 0(%[dest])\n\t" + "jne 1b\n\t" + : + : [value_lo] "b,b" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage) + : "cc", "eax", "edx", "memory" + ); +#endif + } + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT + { + storage_type value; + + if ((((uint32_t)&storage) & 0x00000007) == 0) + { +#if defined(__SSE2__) + __asm__ __volatile__ + ( +#if defined(__AVX__) + "vmovq %1, %%xmm4\n\t" + "vmovq %%xmm4, %0\n\t" +#else + "movq %1, %%xmm4\n\t" + "movq %%xmm4, %0\n\t" +#endif + : "=m" (value) + : "m" (storage) + : "memory", "xmm4" + ); +#else + __asm__ __volatile__ + ( + "fildll %1\n\t" + "fistpll %0\n\t" + : "=m" (value) + : "m" (storage) + : "memory" + ); +#endif + } + else + { +#if defined(__clang__) + // Clang cannot allocate eax:edx register pairs but it has sync intrinsics + value = __sync_val_compare_and_swap(&storage, (storage_type)0, (storage_type)0); +#else + // We don't care for comparison result here; the previous value will be stored into value anyway. + // Also we don't care for ebx and ecx values, they just have to be equal to eax and edx before cmpxchg8b. + __asm__ __volatile__ + ( + "movl %%ebx, %%eax\n\t" + "movl %%ecx, %%edx\n\t" + "lock; cmpxchg8b %[storage]" + : "=&A" (value) + : [storage] "m" (storage) + : "cc", "memory" + ); +#endif + } + + return value; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { +#if defined(__clang__) + // Clang cannot allocate eax:edx register pairs but it has sync intrinsics + storage_type old_expected = expected; + expected = __sync_val_compare_and_swap(&storage, old_expected, desired); + return expected == old_expected; +#elif defined(__PIC__) + // Make sure ebx is saved and restored properly in case + // of position independent code. To make this work + // setup register constraints such that ebx can not be + // used by accident e.g. as base address for the variable + // to be modified. Accessing "scratch" should always be okay, + // as it can only be placed on the stack (and therefore + // accessed through ebp or esp only). + // + // In theory, could push/pop ebx onto/off the stack, but movs + // to a prepared stack slot turn out to be faster. + + uint32_t scratch; + bool success; + __asm__ __volatile__ + ( + "movl %%ebx, %[scratch]\n\t" + "movl %[desired_lo], %%ebx\n\t" + "lock; cmpxchg8b %[dest]\n\t" + "movl %[scratch], %%ebx\n\t" + "sete %[success]" + : "+A,A,A,A,A,A" (expected), [dest] "+m,m,m,m,m,m" (storage), [scratch] "=m,m,m,m,m,m" (scratch), [success] "=q,m,q,m,q,m" (success) + : [desired_lo] "S,S,D,D,m,m" ((uint32_t)desired), "c,c,c,c,c,c" ((uint32_t)(desired >> 32)) + : "cc", "memory" + ); + return success; +#else + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchg8b %[dest]\n\t" + "sete %[success]" + : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) + : "b,b" ((uint32_t)desired), "c,c" ((uint32_t)(desired >> 32)) + : "cc", "memory" + ); + return success; +#endif + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +template< bool Signed > +struct gcc_dcas_x86_64 +{ + typedef typename make_storage_type< 16u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + uint64_t const* p_value = (uint64_t const*)&v; + __asm__ __volatile__ + ( + "movq 0(%[dest]), %%rax\n\t" + "movq 8(%[dest]), %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b 0(%[dest])\n\t" + "jne 1b" + : + : "b" (p_value[0]), "c" (p_value[1]), [dest] "r" (&storage) + : "cc", "rax", "rdx", "memory" + ); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT + { +#if defined(__clang__) + // Clang cannot allocate rax:rdx register pairs but it has sync intrinsics + storage_type value = storage_type(); + return __sync_val_compare_and_swap(&storage, value, value); +#else + storage_type value; + + // We don't care for comparison result here; the previous value will be stored into value anyway. + // Also we don't care for rbx and rcx values, they just have to be equal to rax and rdx before cmpxchg16b. + __asm__ __volatile__ + ( + "movq %%rbx, %%rax\n\t" + "movq %%rcx, %%rdx\n\t" + "lock; cmpxchg16b %[storage]" + : "=&A" (value) + : [storage] "m" (storage) + : "cc", "memory" + ); + + return value; +#endif + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { +#if defined(__clang__) + // Clang cannot allocate rax:rdx register pairs but it has sync intrinsics + storage_type old_expected = expected; + expected = __sync_val_compare_and_swap(&storage, old_expected, desired); + return expected == old_expected; +#else + uint64_t const* p_desired = (uint64_t const*)&desired; + bool success; + __asm__ __volatile__ + ( + "lock; cmpxchg16b %[dest]\n\t" + "sete %[success]" + : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) + : "b,b" (p_desired[0]), "c,c" (p_desired[1]) + : "cc", "memory" + ); + return success; +#endif + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_X86_DCAS_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_linux_arm.hpp b/contrib/autoboost/boost/atomic/detail/ops_linux_arm.hpp new file mode 100644 index 000000000..0fa1af7f8 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_linux_arm.hpp @@ -0,0 +1,177 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009, 2011 Helge Bahmann + * Copyright (c) 2009 Phil Endecott + * Copyright (c) 2013 Tim Blechmann + * Linux-specific code by Phil Endecott + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_linux_arm.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_LINUX_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_LINUX_ARM_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +// Different ARM processors have different atomic instructions. In particular, +// architecture versions before v6 (which are still in widespread use, e.g. the +// Intel/Marvell XScale chips like the one in the NSLU2) have only atomic swap. +// On Linux the kernel provides some support that lets us abstract away from +// these differences: it provides emulated CAS and barrier functions at special +// addresses that are guaranteed not to be interrupted by the kernel. Using +// this facility is slightly slower than inline assembler would be, but much +// faster than a system call. +// +// While this emulated CAS is "strong" in the sense that it does not fail +// "spuriously" (i.e.: it never fails to perform the exchange when the value +// found equals the value expected), it does not return the found value on +// failure. To satisfy the atomic API, compare_exchange_{weak|strong} must +// return the found value on failure, and we have to manually load this value +// after the emulated CAS reports failure. This in turn introduces a race +// between the CAS failing (due to the "wrong" value being found) and subsequently +// loading (which might turn up the "right" value). From an application's +// point of view this looks like "spurious failure", and therefore the +// emulated CAS is only good enough to provide compare_exchange_weak +// semantics. + +struct linux_arm_cas_base +{ + static BOOST_FORCEINLINE void fence_before_store(memory_order order) BOOST_NOEXCEPT + { + if ((order & memory_order_release) != 0) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + if (order == memory_order_seq_cst) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void fence_after_load(memory_order order) BOOST_NOEXCEPT + { + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + hardware_full_fence(); + } + + static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT + { + typedef void (*kernel_dmb_t)(void); + ((kernel_dmb_t)0xffff0fa0)(); + } +}; + +template< bool Signed > +struct linux_arm_cas : + public linux_arm_cas_base +{ + typedef typename make_storage_type< 4u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + fence_before_store(order); + storage = v; + fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + while (true) + { + storage_type tmp = expected; + if (compare_exchange_weak(storage, tmp, desired, success_order, failure_order)) + return true; + if (tmp != expected) + { + expected = tmp; + return false; + } + } + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + typedef storage_type (*kernel_cmpxchg32_t)(storage_type oldval, storage_type newval, volatile storage_type* ptr); + + if (((kernel_cmpxchg32_t)0xffff0fc0)(expected, desired, &storage) == 0) + { + return true; + } + else + { + expected = storage; + return false; + } + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< cas_based_operations< linux_arm_cas< Signed > >, 1u, Signed > +{ +}; + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< cas_based_operations< linux_arm_cas< Signed > >, 2u, Signed > +{ +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public cas_based_operations< linux_arm_cas< Signed > > +{ +}; + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + linux_arm_cas_base::hardware_full_fence(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + __asm__ __volatile__ ("" ::: "memory"); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_LINUX_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_msvc_arm.hpp b/contrib/autoboost/boost/atomic/detail/ops_msvc_arm.hpp new file mode 100644 index 000000000..b1a92848d --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_msvc_arm.hpp @@ -0,0 +1,820 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_msvc_arm.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#define BOOST_ATOMIC_DETAIL_ARM_LOAD8(p) __iso_volatile_load8((const volatile __int8*)(p)) +#define BOOST_ATOMIC_DETAIL_ARM_LOAD16(p) __iso_volatile_load16((const volatile __int16*)(p)) +#define BOOST_ATOMIC_DETAIL_ARM_LOAD32(p) __iso_volatile_load32((const volatile __int32*)(p)) +#define BOOST_ATOMIC_DETAIL_ARM_LOAD64(p) __iso_volatile_load64((const volatile __int64*)(p)) +#define BOOST_ATOMIC_DETAIL_ARM_STORE8(p, v) __iso_volatile_store8((volatile __int8*)(p), (__int8)(v)) +#define BOOST_ATOMIC_DETAIL_ARM_STORE16(p, v) __iso_volatile_store16((volatile __int16*)(p), (__int16)(v)) +#define BOOST_ATOMIC_DETAIL_ARM_STORE32(p, v) __iso_volatile_store32((volatile __int32*)(p), (__int32)(v)) +#define BOOST_ATOMIC_DETAIL_ARM_STORE64(p, v) __iso_volatile_store64((volatile __int64*)(p), (__int64)(v)) + +namespace autoboost { +namespace atomics { +namespace detail { + +// A note about memory_order_consume. Technically, this architecture allows to avoid +// unnecessary memory barrier after consume load since it supports data dependency ordering. +// However, some compiler optimizations may break a seemingly valid code relying on data +// dependency tracking by injecting bogus branches to aid out of order execution. +// This may happen not only in Boost.Atomic code but also in user's code, which we have no +// control of. See this thread: http://lists.boost.org/Archives/boost/2014/06/213890.php. +// For this reason we promote memory_order_consume to memory_order_acquire. + +struct msvc_arm_operations_base +{ + static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT + { + __dmb(0xB); // _ARM_BARRIER_ISH, see armintr.h from MSVC 11 and later + } + + static BOOST_FORCEINLINE void fence_before_store(memory_order order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + if ((order & memory_order_release) != 0) + hardware_full_fence(); + + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + if (order == memory_order_seq_cst) + hardware_full_fence(); + + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE void fence_after_load(memory_order order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + hardware_full_fence(); + + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE BOOST_CONSTEXPR memory_order cas_common_order(memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + // Combine order flags together and promote memory_order_consume to memory_order_acquire + return static_cast< memory_order >(((failure_order | success_order) & ~memory_order_consume) | (((failure_order | success_order) & memory_order_consume) << 1u)); + } +}; + +template< typename T, typename Derived > +struct msvc_arm_operations : + public msvc_arm_operations_base +{ + typedef T storage_type; + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + typedef typename make_signed< storage_type >::type signed_storage_type; + return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!Derived::exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + Derived::store(storage, (storage_type)0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 1u, Signed > : + public msvc_arm_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > +{ + typedef msvc_arm_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before_store(order); + BOOST_ATOMIC_DETAIL_ARM_STORE8(&storage, v); + base_type::fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD8(&storage); + base_type::fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + storage_type previous = expected, old_val; + + switch (cas_common_order(success_order, failure_order)) + { + case memory_order_relaxed: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELAXED(&storage, desired, previous)); + break; + case memory_order_consume: + case memory_order_acquire: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_ACQUIRE(&storage, desired, previous)); + break; + case memory_order_release: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8_RELEASE(&storage, desired, previous)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8(&storage, desired, previous)); + break; + } + expected = old_val; + + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8(&storage, v)); + break; + } + return v; + } +}; + +template< bool Signed > +struct operations< 2u, Signed > : + public msvc_arm_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > +{ + typedef msvc_arm_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before_store(order); + BOOST_ATOMIC_DETAIL_ARM_STORE16(&storage, v); + base_type::fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD16(&storage); + base_type::fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + storage_type previous = expected, old_val; + + switch (cas_common_order(success_order, failure_order)) + { + case memory_order_relaxed: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELAXED(&storage, desired, previous)); + break; + case memory_order_consume: + case memory_order_acquire: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_ACQUIRE(&storage, desired, previous)); + break; + case memory_order_release: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16_RELEASE(&storage, desired, previous)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16(&storage, desired, previous)); + break; + } + expected = old_val; + + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16(&storage, v)); + break; + } + return v; + } +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public msvc_arm_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > +{ + typedef msvc_arm_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before_store(order); + BOOST_ATOMIC_DETAIL_ARM_STORE32(&storage, v); + base_type::fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD32(&storage); + base_type::fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + storage_type previous = expected, old_val; + + switch (cas_common_order(success_order, failure_order)) + { + case memory_order_relaxed: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELAXED(&storage, desired, previous)); + break; + case memory_order_consume: + case memory_order_acquire: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_ACQUIRE(&storage, desired, previous)); + break; + case memory_order_release: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE_RELEASE(&storage, desired, previous)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(&storage, desired, previous)); + break; + } + expected = old_val; + + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR(&storage, v)); + break; + } + return v; + } +}; + +template< bool Signed > +struct operations< 8u, Signed > : + public msvc_arm_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > +{ + typedef msvc_arm_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before_store(order); + BOOST_ATOMIC_DETAIL_ARM_STORE64(&storage, v); + base_type::fence_after_store(order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = BOOST_ATOMIC_DETAIL_ARM_LOAD64(&storage); + base_type::fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + storage_type previous = expected, old_val; + + switch (cas_common_order(success_order, failure_order)) + { + case memory_order_relaxed: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELAXED(&storage, desired, previous)); + break; + case memory_order_consume: + case memory_order_acquire: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_ACQUIRE(&storage, desired, previous)); + break; + case memory_order_release: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64_RELEASE(&storage, desired, previous)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(&storage, desired, previous)); + break; + } + expected = old_val; + + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64(&storage, v)); + break; + } + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + switch (order) + { + case memory_order_relaxed: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_RELAXED(&storage, v)); + break; + case memory_order_consume: + case memory_order_acquire: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_ACQUIRE(&storage, v)); + break; + case memory_order_release: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64_RELEASE(&storage, v)); + break; + case memory_order_acq_rel: + case memory_order_seq_cst: + default: + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64(&storage, v)); + break; + } + return v; + } +}; + + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + if (order != memory_order_relaxed) + msvc_arm_operations_base::hardware_full_fence(); + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#undef BOOST_ATOMIC_DETAIL_ARM_LOAD8 +#undef BOOST_ATOMIC_DETAIL_ARM_LOAD16 +#undef BOOST_ATOMIC_DETAIL_ARM_LOAD32 +#undef BOOST_ATOMIC_DETAIL_ARM_LOAD64 +#undef BOOST_ATOMIC_DETAIL_ARM_STORE8 +#undef BOOST_ATOMIC_DETAIL_ARM_STORE16 +#undef BOOST_ATOMIC_DETAIL_ARM_STORE32 +#undef BOOST_ATOMIC_DETAIL_ARM_STORE64 + +#endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_ARM_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_msvc_common.hpp b/contrib/autoboost/boost/atomic/detail/ops_msvc_common.hpp new file mode 100644 index 000000000..53628f360 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_msvc_common.hpp @@ -0,0 +1,38 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_msvc_common.hpp + * + * This header contains common tools for MSVC implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +// Define compiler barriers +#if defined(__INTEL_COMPILER) +#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() __memory_barrier() +#elif defined(_MSC_VER) && !defined(_WIN32_WCE) +extern "C" void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() _ReadWriteBarrier() +#endif + +#ifndef BOOST_ATOMIC_DETAIL_COMPILER_BARRIER +#define BOOST_ATOMIC_DETAIL_COMPILER_BARRIER() +#endif + +#endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_COMMON_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_msvc_x86.hpp b/contrib/autoboost/boost/atomic/detail/ops_msvc_x86.hpp new file mode 100644 index 000000000..17597d301 --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_msvc_x86.hpp @@ -0,0 +1,879 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_msvc_x86.hpp + * + * This header contains implementation of the \c operations template. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_MSVC_X86_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_MSVC_X86_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) +#include +#include +#endif +#include +#if !defined(_M_IX86) && !(defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8) && defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16)) +#include +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if defined(BOOST_MSVC) +#pragma warning(push) +// frame pointer register 'ebx' modified by inline assembly code. See the note below. +#pragma warning(disable: 4731) +#endif + +#if defined(_MSC_VER) && (defined(_M_AMD64) || (defined(_M_IX86) && defined(_M_IX86_FP) && _M_IX86_FP >= 2)) +extern "C" void _mm_mfence(void); +#if defined(BOOST_MSVC) +#pragma intrinsic(_mm_mfence) +#endif +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +/* + * Implementation note for asm blocks. + * + * http://msdn.microsoft.com/en-us/data/k1a8ss06%28v=vs.105%29 + * + * Some SSE types require eight-byte stack alignment, forcing the compiler to emit dynamic stack-alignment code. + * To be able to access both the local variables and the function parameters after the alignment, the compiler + * maintains two frame pointers. If the compiler performs frame pointer omission (FPO), it will use EBP and ESP. + * If the compiler does not perform FPO, it will use EBX and EBP. To ensure code runs correctly, do not modify EBX + * in asm code if the function requires dynamic stack alignment as it could modify the frame pointer. + * Either move the eight-byte aligned types out of the function, or avoid using EBX. + * + * Since we have no way of knowing that the compiler uses FPO, we have to always save and restore ebx + * whenever we have to clobber it. Additionally, we disable warning C4731 above so that the compiler + * doesn't spam about ebx use. + */ + +struct msvc_x86_operations_base +{ + static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT + { +#if defined(_MSC_VER) && (defined(_M_AMD64) || (defined(_M_IX86) && defined(_M_IX86_FP) && _M_IX86_FP >= 2)) + // Use mfence only if SSE2 is available + _mm_mfence(); +#else + long tmp; + BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&tmp, 0); +#endif + } + + static BOOST_FORCEINLINE void fence_before(memory_order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE void fence_after(memory_order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE void fence_after_load(memory_order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + // On x86 and x86_64 there is no need for a hardware barrier, + // even if seq_cst memory order is requested, because all + // seq_cst writes are implemented with lock-prefixed operations + // or xchg which has implied lock prefix. Therefore normal loads + // are already ordered with seq_cst stores on these architectures. + } +}; + +template< typename T, typename Derived > +struct msvc_x86_operations : + public msvc_x86_operations_base +{ + typedef T storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + if (order != memory_order_seq_cst) + { + fence_before(order); + storage = v; + fence_after(order); + } + else + { + Derived::exchange(storage, v, order); + } + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + storage_type v = storage; + fence_after_load(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + typedef typename make_signed< storage_type >::type signed_storage_type; + return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!Derived::exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, (storage_type)0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public msvc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&storage, v)); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + storage_type old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(&storage, desired, previous)); + expected = old_val; + return (previous == old_val); + } + +#if defined(BOOST_ATOMIC_INTERLOCKED_AND) + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND(&storage, v)); + } +#else + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res & v, order, memory_order_relaxed)) {} + return res; + } +#endif + +#if defined(BOOST_ATOMIC_INTERLOCKED_OR) + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR(&storage, v)); + } +#else + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res | v, order, memory_order_relaxed)) {} + return res; + } +#endif + +#if defined(BOOST_ATOMIC_INTERLOCKED_XOR) + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR(&storage, v)); + } +#else + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res ^ v, order, memory_order_relaxed)) {} + return res; + } +#endif +}; + +#if defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8) + +template< bool Signed > +struct operations< 1u, Signed > : + public msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD8(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE8(&storage, v)); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + storage_type old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE8(&storage, desired, previous)); + expected = old_val; + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND8(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR8(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR8(&storage, v)); + } +}; + +#elif defined(_M_IX86) + +template< bool Signed > +struct operations< 1u, Signed > : + public msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + __asm + { + mov edx, storage + movzx eax, v + lock xadd byte ptr [edx], al + mov v, al + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + __asm + { + mov edx, storage + movzx eax, v + xchg byte ptr [edx], al + mov v, al + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order) BOOST_NOEXCEPT + { + base_type::fence_before(success_order); + bool success; + __asm + { + mov esi, expected + mov edi, storage + movzx eax, byte ptr [esi] + movzx edx, desired + lock cmpxchg byte ptr [edi], dl + mov byte ptr [esi], al + sete success + }; + // The success and failure fences are equivalent anyway + base_type::fence_after(success_order); + return success; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, byte ptr [edi] + align 16 + again: + mov dl, al + and dl, bl + lock cmpxchg byte ptr [edi], dl + jne again + mov v, al + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, byte ptr [edi] + align 16 + again: + mov dl, al + or dl, bl + lock cmpxchg byte ptr [edi], dl + jne again + mov v, al + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, byte ptr [edi] + align 16 + again: + mov dl, al + xor dl, bl + lock cmpxchg byte ptr [edi], dl + jne again + mov v, al + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } +}; + +#else + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 1u, Signed > +{ +}; + +#endif + +#if defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16) + +template< bool Signed > +struct operations< 2u, Signed > : + public msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD16(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE16(&storage, v)); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + storage_type old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE16(&storage, desired, previous)); + expected = old_val; + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND16(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR16(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR16(&storage, v)); + } +}; + +#elif defined(_M_IX86) + +template< bool Signed > +struct operations< 2u, Signed > : + public msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + __asm + { + mov edx, storage + movzx eax, v + lock xadd word ptr [edx], ax + mov v, ax + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + __asm + { + mov edx, storage + movzx eax, v + xchg word ptr [edx], ax + mov v, ax + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order) BOOST_NOEXCEPT + { + base_type::fence_before(success_order); + bool success; + __asm + { + mov esi, expected + mov edi, storage + movzx eax, word ptr [esi] + movzx edx, desired + lock cmpxchg word ptr [edi], dx + mov word ptr [esi], ax + sete success + }; + // The success and failure fences are equivalent anyway + base_type::fence_after(success_order); + return success; + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, word ptr [edi] + align 16 + again: + mov dx, ax + and dx, bx + lock cmpxchg word ptr [edi], dx + jne again + mov v, ax + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, word ptr [edi] + align 16 + again: + mov dx, ax + or dx, bx + lock cmpxchg word ptr [edi], dx + jne again + mov v, ax + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + int backup; + __asm + { + mov backup, ebx + xor edx, edx + mov edi, storage + movzx ebx, v + movzx eax, word ptr [edi] + align 16 + again: + mov dx, ax + xor dx, bx + lock cmpxchg word ptr [edi], dx + jne again + mov v, ax + mov ebx, backup + }; + base_type::fence_after(order); + return v; + } +}; + +#else + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 2u, Signed > +{ +}; + +#endif + + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) + +template< bool Signed > +struct msvc_dcas_x86 +{ + typedef typename make_storage_type< 8u, Signed >::type storage_type; + + // Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, 8.1.1. Guaranteed Atomic Operations: + // + // The Pentium processor (and newer processors since) guarantees that the following additional memory operations will always be carried out atomically: + // * Reading or writing a quadword aligned on a 64-bit boundary + // + // Luckily, the memory is almost always 8-byte aligned in our case because atomic<> uses 64 bit native types for storage and dynamic memory allocations + // have at least 8 byte alignment. The only unfortunate case is when atomic is placeod on the stack and it is not 8-byte aligned (like on 32 bit Windows). + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type volatile* p = &storage; + if (((uint32_t)p & 0x00000007) == 0) + { +#if defined(_M_IX86_FP) && _M_IX86_FP >= 2 +#if defined(__AVX__) + __asm + { + mov edx, p + vmovq xmm4, v + vmovq qword ptr [edx], xmm4 + }; +#else + __asm + { + mov edx, p + movq xmm4, v + movq qword ptr [edx], xmm4 + }; +#endif +#else + __asm + { + mov edx, p + fild v + fistp qword ptr [edx] + }; +#endif + } + else + { + int backup; + __asm + { + mov backup, ebx + mov edi, p + mov ebx, dword ptr [v] + mov ecx, dword ptr [v + 4] + mov eax, dword ptr [edi] + mov edx, dword ptr [edi + 4] + align 16 + again: + lock cmpxchg8b qword ptr [edi] + jne again + mov ebx, backup + }; + } + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT + { + storage_type const volatile* p = &storage; + storage_type value; + + if (((uint32_t)p & 0x00000007) == 0) + { +#if defined(_M_IX86_FP) && _M_IX86_FP >= 2 +#if defined(__AVX__) + __asm + { + mov edx, p + vmovq xmm4, qword ptr [edx] + vmovq value, xmm4 + }; +#else + __asm + { + mov edx, p + movq xmm4, qword ptr [edx] + movq value, xmm4 + }; +#endif +#else + __asm + { + mov edx, p + fild qword ptr [edx] + fistp value + }; +#endif + } + else + { + // We don't care for comparison result here; the previous value will be stored into value anyway. + // Also we don't care for ebx and ecx values, they just have to be equal to eax and edx before cmpxchg8b. + __asm + { + mov edi, p + mov eax, ebx + mov edx, ecx + lock cmpxchg8b qword ptr [edi] + mov dword ptr [value], eax + mov dword ptr [value + 4], edx + }; + } + + return value; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type volatile* p = &storage; +#if defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64) + const storage_type old_val = (storage_type)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(p, desired, expected); + const bool result = (old_val == expected); + expected = old_val; + return result; +#else + bool result; + int backup; + __asm + { + mov backup, ebx + mov edi, p + mov esi, expected + mov ebx, dword ptr [desired] + mov ecx, dword ptr [desired + 4] + mov eax, dword ptr [esi] + mov edx, dword ptr [esi + 4] + lock cmpxchg8b qword ptr [edi] + mov dword ptr [esi], eax + mov dword ptr [esi + 4], edx + mov ebx, backup + sete result + }; + return result; +#endif + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 8u, Signed > : + public cas_based_operations< msvc_dcas_x86< Signed > > +{ +}; + +#elif defined(_M_AMD64) + +template< bool Signed > +struct operations< 8u, Signed > : + public msvc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > +{ + typedef msvc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE64(&storage, v)); + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + storage_type old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(&storage, desired, previous)); + expected = old_val; + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND64(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR64(&storage, v)); + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + return static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR64(&storage, v)); + } +}; + +#endif + +#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +template< bool Signed > +struct msvc_dcas_x86_64 +{ + typedef typename make_storage_type< 16u, Signed >::type storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT + { + storage_type value = const_cast< storage_type& >(storage); + while (!BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE128(&storage, v, &value)) {} + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT + { + storage_type value = storage_type(); + BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE128(&storage, value, &value); + return value; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT + { + return !!BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE128(&storage, desired, &expected); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 16u, Signed > : + public cas_based_operations< msvc_dcas_x86_64< Signed > > +{ +}; + +#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + if (order == memory_order_seq_cst) + msvc_x86_operations_base::hardware_full_fence(); + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif // BOOST_ATOMIC_DETAIL_OPS_MSVC_X86_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/atomic/detail/ops_windows.hpp b/contrib/autoboost/boost/atomic/detail/ops_windows.hpp new file mode 100644 index 000000000..2b4a36d1d --- /dev/null +++ b/contrib/autoboost/boost/atomic/detail/ops_windows.hpp @@ -0,0 +1,215 @@ +/* + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * Copyright (c) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/ops_windows.hpp + * + * This header contains implementation of the \c operations template. + * + * This implementation is the most basic version for Windows. It should + * work for any non-MSVC-like compilers as long as there are Interlocked WinAPI + * functions available. This version is also used for WinCE. + * + * Notably, this implementation is not as efficient as other + * versions based on compiler intrinsics. + */ + +#ifndef BOOST_ATOMIC_DETAIL_OPS_WINDOWS_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_OPS_WINDOWS_HPP_INCLUDED_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace autoboost { +namespace atomics { +namespace detail { + +struct windows_operations_base +{ + static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT + { + long tmp; + BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&tmp, 0); + } + + static BOOST_FORCEINLINE void fence_before(memory_order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } + + static BOOST_FORCEINLINE void fence_after(memory_order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + } +}; + +template< typename T, typename Derived > +struct windows_operations : + public windows_operations_base +{ + typedef T storage_type; + + static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + Derived::exchange(storage, v, order); + } + + static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return Derived::fetch_add(const_cast< storage_type volatile& >(storage), (storage_type)0, order); + } + + static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + typedef typename make_signed< storage_type >::type signed_storage_type; + return Derived::fetch_add(storage, static_cast< storage_type >(-static_cast< signed_storage_type >(v)), order); + } + + static BOOST_FORCEINLINE bool compare_exchange_weak( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order); + } + + static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + return !!Derived::exchange(storage, (storage_type)1, order); + } + + static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + { + store(storage, (storage_type)0, order); + } + + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT + { + return true; + } +}; + +template< bool Signed > +struct operations< 4u, Signed > : + public windows_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > +{ + typedef windows_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; + typedef typename base_type::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD(&storage, v)); + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + base_type::fence_before(order); + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_EXCHANGE(&storage, v)); + base_type::fence_after(order); + return v; + } + + static BOOST_FORCEINLINE bool compare_exchange_strong( + storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT + { + storage_type previous = expected; + base_type::fence_before(success_order); + storage_type old_val = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE(&storage, desired, previous)); + expected = old_val; + // The success and failure fences are the same anyway + base_type::fence_after(success_order); + return (previous == old_val); + } + + static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_INTERLOCKED_AND) + base_type::fence_before(order); + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_AND(&storage, v)); + base_type::fence_after(order); + return v; +#else + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res & v, order, memory_order_relaxed)) {} + return res; +#endif + } + + static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_INTERLOCKED_OR) + base_type::fence_before(order); + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_OR(&storage, v)); + base_type::fence_after(order); + return v; +#else + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res | v, order, memory_order_relaxed)) {} + return res; +#endif + } + + static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { +#if defined(BOOST_ATOMIC_INTERLOCKED_XOR) + base_type::fence_before(order); + v = static_cast< storage_type >(BOOST_ATOMIC_INTERLOCKED_XOR(&storage, v)); + base_type::fence_after(order); + return v; +#else + storage_type res = storage; + while (!compare_exchange_strong(storage, res, res ^ v, order, memory_order_relaxed)) {} + return res; +#endif + } +}; + +template< bool Signed > +struct operations< 1u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 1u, Signed > +{ +}; + +template< bool Signed > +struct operations< 2u, Signed > : + public extending_cas_based_operations< operations< 4u, Signed >, 2u, Signed > +{ +}; + +BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT +{ + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + if (order == memory_order_seq_cst) + windows_operations_base::hardware_full_fence(); + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT +{ + if (order != memory_order_relaxed) + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); +} + +} // namespace detail +} // namespace atomics +} // namespace autoboost + +#endif // BOOST_ATOMIC_DETAIL_OPS_WINDOWS_HPP_INCLUDED_ diff --git a/contrib/autoboost/boost/thread/future.hpp b/contrib/autoboost/boost/thread/future.hpp index ab826cffd..f4e7512f0 100644 --- a/contrib/autoboost/boost/thread/future.hpp +++ b/contrib/autoboost/boost/thread/future.hpp @@ -5,8 +5,8 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_THREAD_FUTURE_HPP -#define BOOST_THREAD_FUTURE_HPP +#ifndef AUTOBOOST_BOOST_THREAD_FUTURE_HPP +#define AUTOBOOST_BOOST_THREAD_FUTURE_HPP #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6b6d477f..718158e75 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,13 +22,6 @@ if(NOT autowiring_USE_LIBCXX) endif() endif() -# Android also requires boost, but a more limited subset: -if(BUILD_ANDROID) - find_package(Boost COMPONENTS thread REQUIRED) - include_directories(${Boost_INCLUDE_DIR}) - message("Include dirs are ${Boost_INCLUDE_DIR}") -endif() - add_subdirectory(autonet) add_subdirectory(autowiring) add_subdirectory(autotesting) diff --git a/src/autonet/CMakeLists.txt b/src/autonet/CMakeLists.txt index 7f60eda8a..8c885d3dd 100644 --- a/src/autonet/CMakeLists.txt +++ b/src/autonet/CMakeLists.txt @@ -1,16 +1,7 @@ -option(AUTOWIRING_BUILD_AUTONET "Build Autonet debugging server" ${AUTOWIRING_BUILD_AUTONET_DEFAULT}) -if(NOT AUTOWIRING_BUILD_AUTONET) - return() -endif() - if(NOT WIN32 AND NOT autowiring_USE_LIBCXX) message("Cannot build Autonet, requires proper C++11 supprt") endif() -if(autowiring_BUILD_ARM) - message(FATAL_ERROR "Cannot currently build Autonet for ARM processors") -endif() - add_googletest(test) include_directories( ${PROJECT_SOURCE_DIR}/contrib/autoboost @@ -23,9 +14,26 @@ set(AutoNet_SRCS AutoNetServerImpl.hpp ${PROJECT_SOURCE_DIR}/contrib/json11/json11.cpp ${PROJECT_SOURCE_DIR}/contrib/json11/json11.hpp +) + +add_conditional_sources( + AutoNet_SRCS + "ON" + GROUP_NAME "Autoboost" + FILES ${PROJECT_SOURCE_DIR}/contrib/autoboost/libs/system/src/error_code.cpp ) +add_conditional_sources( + AutoNet_SRCS + "NOT MSVC" + GROUP_NAME "Autoboost" + FILES + ${PROJECT_SOURCE_DIR}/contrib/autoboost/libs/thread/src/pthread/once_atomic.cpp + ${PROJECT_SOURCE_DIR}/contrib/autoboost/libs/thread/src/pthread/thread.cpp + ${PROJECT_SOURCE_DIR}/contrib/autoboost/libs/thread/src/future.cpp +) + # All include files are located in /autowiring from here, so prepend that to all sources rewrite_header_paths(AutoNet_SRCS) add_pch(AutoNet_SRCS "stdafx.h" "stdafx.cpp") diff --git a/src/autonet/stdafx.h b/src/autonet/stdafx.h index 87876241d..d84c2c638 100644 --- a/src/autonet/stdafx.h +++ b/src/autonet/stdafx.h @@ -7,8 +7,8 @@ #define NOMINMAX #endif -// Defined when we are exporting symbols -#define AUTOWIRING_EXPORT_AUTONET +// Defined when Autowiring is being built, as opposed to when it is being linked +#define AUTOWIRING_IS_BEING_BUILT #ifndef _MSC_VER #include diff --git a/src/autowiring/CMakeLists.txt b/src/autowiring/CMakeLists.txt index 7b4913311..80167029b 100644 --- a/src/autowiring/CMakeLists.txt +++ b/src/autowiring/CMakeLists.txt @@ -209,6 +209,7 @@ add_pch(Autowiring_SRCS "stdafx.h" "stdafx.cpp") add_library(Autowiring STATIC ${Autowiring_SRCS}) +target_include_directories(Autowiring PRIVATE "${CMAKE_SOURCE_DIR}/contrib/autoboost") target_include_directories(Autowiring INTERFACE "$" "$/include>" diff --git a/src/autowiring/stdafx.h b/src/autowiring/stdafx.h index 4ac8da63e..adacb1a4f 100644 --- a/src/autowiring/stdafx.h +++ b/src/autowiring/stdafx.h @@ -1,6 +1,9 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #pragma once +// Internal build flag for namespace discrimination +#define AUTOWIRING_IS_BEING_BUILT + // Only include these headers in cases where a pch can be generated // Currently this is only supported on MSVC #ifdef _MSC_VER diff --git a/src/autowiring/test/CMakeLists.txt b/src/autowiring/test/CMakeLists.txt index 7d4c9fd1b..7f33da50a 100644 --- a/src/autowiring/test/CMakeLists.txt +++ b/src/autowiring/test/CMakeLists.txt @@ -87,6 +87,7 @@ endif() add_pch(AutowiringTest_SRCS "stdafx.h" "stdafx.cpp") add_executable(AutowiringTest ${AutowiringTest_SRCS}) target_link_libraries(AutowiringTest Autowiring AutowiringFixture AutoTesting) +target_include_directories(AutowiringTest PRIVATE "${CMAKE_SOURCE_DIR}/contrib/autoboost") # Need boost thread on android, because of our use of std::async if(BUILD_ANDROID) diff --git a/src/autowiring/test/stdafx.h b/src/autowiring/test/stdafx.h index 0bf9972e9..a5e3db79f 100644 --- a/src/autowiring/test/stdafx.h +++ b/src/autowiring/test/stdafx.h @@ -1,6 +1,9 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #pragma once +// Internal build flag for namespace discrimination +#define AUTOWIRING_IS_BEING_BUILT + #include #include #include From 0a054468df3f10063081311fa3be688f13438413 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Thu, 18 Dec 2014 11:41:46 -0800 Subject: [PATCH 32/57] Renaming the delivery edge map and adding a getter to return a copy of the edge map --- autowiring/AutoPacketGraph.h | 9 +++++++-- src/autowiring/AutoPacketGraph.cpp | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 1dc6d97c3..bde921985 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -51,8 +51,8 @@ class AutoPacketGraph protected: // A mapping of an edge to the number of times it was delivered - typedef std::unordered_map> t_deliveryGraph; - t_deliveryGraph m_deliveryGraph; + typedef std::unordered_map> t_deliveryEdges; + t_deliveryEdges m_deliveryGraph; // A lock for this type mutable std::mutex m_lock; @@ -68,6 +68,11 @@ class AutoPacketGraph /// void AutoFilter(AutoPacket& packet); + /// + /// Get a mapping of the DeliveryEdge to the number of times the AutoFilter was called + /// + t_deliveryEdges GetEdgeCounts() const; + /// /// Write the graph to a file in graphviz format /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 36c03187e..258061464 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -45,6 +45,10 @@ void AutoPacketGraph::AutoFilter(AutoPacket& packet) { }); } +AutoPacketGraph::t_deliveryEdges AutoPacketGraph::GetEdgeCounts() const { + return m_deliveryGraph; +} + bool AutoPacketGraph::WriteGV(const std::string& filename) const { std::ofstream file(filename); From 28b95b0d8c8467822b7921b6ec8ec12314696da5 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Wed, 17 Dec 2014 10:56:08 -0800 Subject: [PATCH 33/57] Adding a true type reconciliation function This allows a user to pass an AnySharedPointer to a CoreContext, and retrieve an std::type_info corresponding to the unaliased concrete type that is known to that context. This provides diagnostics utilities to elide the TypeUnifierSimple and TypeUnifierComplex wrapper types in cases where those types are injected. --- autowiring/CoreContext.h | 68 ++++++++++++------- src/autowiring/CoreContext.cpp | 32 ++++++--- .../test/AutoFilterDiagnosticsTest.cpp | 38 +++++++++++ src/autowiring/test/CMakeLists.txt | 1 + src/autowiring/test/CoreContextTest.cpp | 2 +- 5 files changed, 109 insertions(+), 32 deletions(-) create mode 100644 src/autowiring/test/AutoFilterDiagnosticsTest.cpp diff --git a/autowiring/CoreContext.h b/autowiring/CoreContext.h index 0797f3167..f9073b237 100644 --- a/autowiring/CoreContext.h +++ b/autowiring/CoreContext.h @@ -106,6 +106,25 @@ class CoreContext: /// static std::shared_ptr GetGlobal(void); + /// + /// Represents a single entry, together with any deferred elements waiting on the satisfaction of this entry + /// + struct MemoEntry { + MemoEntry(void) : + pFirst(nullptr) + {} + + // The first deferrable autowiring which requires this type, if one exists: + DeferrableAutowiring* pFirst; + + // A back reference to the concrete type from which this memo was generated: + const ObjectTraits* pObjTraits; + + // Once this memo entry is satisfied, this will contain the AnySharedPointer instance that performs + // the satisfaction + AnySharedPointer m_value; + }; + protected: // A pointer to the parent context const std::shared_ptr m_pParent; @@ -130,22 +149,6 @@ class CoreContext: typedef std::unordered_map> t_contextNameListeners; t_contextNameListeners m_nameListeners; - /// - /// Represents a single entry, together with any deferred elements waiting on the satisfaction of this entry - /// - struct MemoEntry { - MemoEntry(void) : - pFirst(nullptr) - {} - - // The first deferrable autowiring which requires this type, if one exists: - DeferrableAutowiring* pFirst; - - // Once this memo entry is satisfied, this will contain the AnySharedPointer instance that performs - // the satisfaction - AnySharedPointer m_value; - }; - /// /// A proxy context member that knows how to create a factory for a particular type /// @@ -254,7 +257,7 @@ class CoreContext: /// /// Invokes all deferred autowiring fields, generally called after a new member has been added /// - void UpdateDeferredElements(std::unique_lock&& lk, const std::shared_ptr& entry); + void UpdateDeferredElements(std::unique_lock&& lk, const ObjectTraits& entry); /// /// Adds the named event receiver to the collection of known receivers @@ -412,6 +415,19 @@ class CoreContext: /// std::shared_ptr NextSibling(void) const; + /// + /// The type identifier of the specified type identifier + /// + /// + /// The returned type structure will be the actual type of the specified object as defined at the time of + /// injection. In the case of a static factory new or AutoFactory new, this type will be the type of the + /// interface. All other members are the concrete type actually injected, as opposed to the type unifier + /// for that type. + /// + /// This method will throw an exception if the passed shared pointer is not strictly a member of this context + /// + const std::type_info& GetAutoTypeId(const AnySharedPointer& ptr) const; + /// /// Creation helper routine /// @@ -490,15 +506,21 @@ class CoreContext: // Add this type to the TypeRegistry (void) RegType::r; - // First see if the object has already been injected: - std::shared_ptr retVal; - FindByType(retVal); - if(retVal) - return std::static_pointer_cast(retVal); + // First see if the base object type has already been injected. This is also necessary to + // ensure that a memo slot is created for the type by itself, in cases where the injected + // member does not inherit Object and this member is eventually satisfied by one that does. + { + std::shared_ptr pure; + FindByType(pure); + if (pure) + return pure; + } // We must make ourselves current for the remainder of this call: CurrentContextPusher pshr(shared_from_this()); - retVal.reset(CreationRules::New(*this, std::forward(args)...)); + std::shared_ptr retVal( + CreationRules::New(*this, std::forward(args)...) + ); // AutoInit if sensible to do so: CallAutoInit(*retVal, has_autoinit()); diff --git a/src/autowiring/CoreContext.cpp b/src/autowiring/CoreContext.cpp index 173b0140c..8b1cf31f5 100644 --- a/src/autowiring/CoreContext.cpp +++ b/src/autowiring/CoreContext.cpp @@ -156,6 +156,18 @@ std::shared_ptr CoreContext::NextSibling(void) const { return std::shared_ptr(); } +const std::type_info& CoreContext::GetAutoTypeId(const AnySharedPointer& ptr) const { + std::lock_guard lk(m_stateBlock->m_lock); + + const std::type_info& ti = ptr->type(); + auto q = m_typeMemos.find(ti); + if (q == m_typeMemos.end() || !q->second.pObjTraits) + throw autowiring_error("Attempted to obtain the true type of a shared pointer that was not a member of this context"); + + const ObjectTraits* pObjTraits = q->second.pObjTraits; + return pObjTraits->type; +} + std::shared_ptr CoreContext::IncrementOutstandingThreadCount(void) { std::shared_ptr retVal = m_outstanding.lock(); if(retVal) @@ -224,7 +236,7 @@ void CoreContext::AddInternal(const ObjectTraits& traits) { // Notify any autowiring field that is currently waiting that we have a new member // to be considered. - UpdateDeferredElements(std::move(lk), traits.pObject); + UpdateDeferredElements(std::move(lk), m_concreteTypes.back()); } // Event receivers: @@ -274,23 +286,24 @@ CoreContext::MemoEntry& CoreContext::FindByTypeUnsafe(AnySharedPointer& referenc } // Resolve based on iterated dynamic casts for each concrete type: - bool assigned = false; + const ObjectTraits* pObjTraits = nullptr; for(const auto& type : m_concreteTypes) { if(!reference->try_assign(*type.value)) // No match, try the next entry continue; - if(assigned) + if (pObjTraits) // Resolution ambiguity, cannot proceed throw autowiring_error("An attempt was made to resolve a type which has multiple possible clients"); - // Update the found-flag: - assigned = true; + // Update the object traits reference: + pObjTraits = &type; } // This entry was not formerly memoized. Memoize unconditionally. MemoEntry& retVal = m_typeMemos[type]; retVal.m_value = reference; + retVal.pObjTraits = pObjTraits; return retVal; } @@ -601,7 +614,7 @@ void CoreContext::BroadcastContextCreationNotice(const std::type_info& sigil) co m_pParent->BroadcastContextCreationNotice(sigil); } -void CoreContext::UpdateDeferredElements(std::unique_lock&& lk, const std::shared_ptr& entry) { +void CoreContext::UpdateDeferredElements(std::unique_lock&& lk, const ObjectTraits& entry) { // Collection of satisfiable lists: std::vector> satisfiable; @@ -620,7 +633,7 @@ void CoreContext::UpdateDeferredElements(std::unique_lock&& lk, cons // Each connected nonroot deferrable autowiring is referred to as a "dependant chain". std::stack stk; for(auto& cur : m_typeMemos) { - auto& value = cur.second; + MemoEntry& value = cur.second; if(value.m_value) // This entry is already satisfied, no need to process it @@ -629,9 +642,12 @@ void CoreContext::UpdateDeferredElements(std::unique_lock&& lk, cons // Determine whether the current candidate element satisfies the autowiring we are considering. // This is done internally via a dynamic cast on the interface type for which this polymorphic // base type was constructed. - if(!value.m_value->try_assign(entry)) + if(!value.m_value->try_assign(entry.pObject)) continue; + // Success, assign the traits + value.pObjTraits = &entry; + // Now we need to take on the responsibility of satisfying this deferral. We will do this by // nullifying the flink, and by ensuring that the memo is satisfied at the point where we // release the lock. diff --git a/src/autowiring/test/AutoFilterDiagnosticsTest.cpp b/src/autowiring/test/AutoFilterDiagnosticsTest.cpp new file mode 100644 index 000000000..58e2d35f6 --- /dev/null +++ b/src/autowiring/test/AutoFilterDiagnosticsTest.cpp @@ -0,0 +1,38 @@ +#include "stdafx.h" +#include +#include + +class AutoFilterDiagnosticsTest: + public testing::Test +{ +public: + AutoFilterDiagnosticsTest(void) { + AutoCurrentContext()->Initiate(); + } +}; + +class FilterMemberNotInheritingObject { +public: + void AutoFilter(const int&) {} +}; + +TEST_F(AutoFilterDiagnosticsTest, CanGetExpectedTrueType) { + AutoRequired mnio; + AutoRequired factory; + + auto packet = factory->NewPacket(); + auto dispositions = packet->GetDispositions(); + ASSERT_EQ(1UL, dispositions.size()) << "Dispositions collection contained an unexpected AutoFilter"; + + auto& disposition = dispositions.front(); + ASSERT_EQ(1UL, disposition.m_subscribers.size()) << "Expected exactly one subscriber for the sole present type"; + + const SatCounter* descriptor = disposition.m_subscribers.front(); + AnySharedPointer asp(descriptor->GetAutoFilter()); + + // Get more information about this object from the enclosing context: + AutoCurrentContext ctxt; + const std::type_info* ti; + ASSERT_NO_THROW(ti = &ctxt->GetAutoTypeId(asp)) << "Exception thrown while attempting to get true type information"; + ASSERT_EQ(typeid(FilterMemberNotInheritingObject), *ti) << "True type not correctly reported, got " << autowiring::demangle(*ti) << ", expected FilterMemberNotInheritingObject"; +} \ No newline at end of file diff --git a/src/autowiring/test/CMakeLists.txt b/src/autowiring/test/CMakeLists.txt index c631d990e..91e8e9071 100644 --- a/src/autowiring/test/CMakeLists.txt +++ b/src/autowiring/test/CMakeLists.txt @@ -4,6 +4,7 @@ set(AutowiringTest_SRCS AutoConfigTest.cpp AutoConstructTest.cpp AutoFilterCollapseRulesTest.cpp + AutoFilterDiagnosticsTest.cpp AutoInjectableTest.cpp AutoPacketFactoryTest.cpp AutoPacketGraphTest.cpp diff --git a/src/autowiring/test/CoreContextTest.cpp b/src/autowiring/test/CoreContextTest.cpp index 3e61a8dbb..63dc2cce7 100644 --- a/src/autowiring/test/CoreContextTest.cpp +++ b/src/autowiring/test/CoreContextTest.cpp @@ -214,4 +214,4 @@ TEST_F(CoreContextTest, NoEnumerateBeforeBoltReturn) { // Need to block until this thread is done t.join(); -} \ No newline at end of file +} From 5932f393cb53f40e26f2e2c208161c9a9551d245 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Thu, 18 Dec 2014 15:32:00 -0800 Subject: [PATCH 34/57] Revert "Eliminating Concept" --- contrib/autoboost/boost/concept/assert.hpp | 45 +++++++ .../concept/detail/backward_compatibility.hpp | 16 +++ .../boost/concept/detail/borland.hpp | 30 +++++ .../boost/concept/detail/concept_def.hpp | 34 +++++ .../boost/concept/detail/concept_undef.hpp | 5 + .../boost/concept/detail/general.hpp | 84 ++++++++++++ .../boost/concept/detail/has_constraints.hpp | 50 +++++++ .../autoboost/boost/concept/detail/msvc.hpp | 123 ++++++++++++++++++ contrib/autoboost/boost/concept/usage.hpp | 36 +++++ 9 files changed, 423 insertions(+) create mode 100644 contrib/autoboost/boost/concept/assert.hpp create mode 100644 contrib/autoboost/boost/concept/detail/backward_compatibility.hpp create mode 100644 contrib/autoboost/boost/concept/detail/borland.hpp create mode 100644 contrib/autoboost/boost/concept/detail/concept_def.hpp create mode 100644 contrib/autoboost/boost/concept/detail/concept_undef.hpp create mode 100644 contrib/autoboost/boost/concept/detail/general.hpp create mode 100644 contrib/autoboost/boost/concept/detail/has_constraints.hpp create mode 100644 contrib/autoboost/boost/concept/detail/msvc.hpp create mode 100644 contrib/autoboost/boost/concept/usage.hpp diff --git a/contrib/autoboost/boost/concept/assert.hpp b/contrib/autoboost/boost/concept/assert.hpp new file mode 100644 index 000000000..cf9817952 --- /dev/null +++ b/contrib/autoboost/boost/concept/assert.hpp @@ -0,0 +1,45 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_ASSERT_DWA2006430_HPP +# define BOOST_CONCEPT_ASSERT_DWA2006430_HPP + +# include +# include + +// The old protocol used a constraints() member function in concept +// checking classes. If the compiler supports SFINAE, we can detect +// that function and seamlessly support the old concept checking +// classes. In this release, backward compatibility with the old +// concept checking classes is enabled by default, where available. +// The old protocol is deprecated, though, and backward compatibility +// will no longer be the default in the next release. + +# if !defined(BOOST_NO_OLD_CONCEPT_SUPPORT) \ + && !defined(BOOST_NO_SFINAE) \ + \ + && !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4)) + +// Note: gcc-2.96 through 3.3.x have some SFINAE, but no ability to +// check for the presence of particularmember functions. + +# define BOOST_OLD_CONCEPT_SUPPORT + +# endif + +# ifdef BOOST_MSVC +# include +# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +# include +# else +# include +# endif + + // Usage, in class or function context: + // + // BOOST_CONCEPT_ASSERT((UnaryFunctionConcept)); + // +# define BOOST_CONCEPT_ASSERT(ModelInParens) \ + BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) + +#endif // BOOST_CONCEPT_ASSERT_DWA2006430_HPP diff --git a/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp b/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp new file mode 100644 index 000000000..cbb2aed09 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/backward_compatibility.hpp @@ -0,0 +1,16 @@ +// Copyright David Abrahams 2009. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP +# define BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP + +namespace autoboost +{ + namespace concepts {} + +# if defined(BOOST_HAS_CONCEPTS) && !defined(BOOST_CONCEPT_NO_BACKWARD_KEYWORD) + namespace concept = concepts; +# endif +} // namespace autoboost::concept + +#endif // BOOST_CONCEPT_BACKWARD_COMPATIBILITY_DWA200968_HPP diff --git a/contrib/autoboost/boost/concept/detail/borland.hpp b/contrib/autoboost/boost/concept/detail/borland.hpp new file mode 100644 index 000000000..05e86cbec --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/borland.hpp @@ -0,0 +1,30 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP +# define BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP + +# include +# include + +namespace autoboost { namespace concepts { + +template +struct require; + +template +struct require +{ + enum { instantiate = sizeof((((Model*)0)->~Model()), 3) }; +}; + +# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ + enum \ + { \ + BOOST_PP_CAT(boost_concept_check,__LINE__) = \ + autoboost::concepts::require::instantiate \ + } + +}} // namespace autoboost::concept + +#endif // BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/concept_def.hpp b/contrib/autoboost/boost/concept/detail/concept_def.hpp new file mode 100644 index 000000000..750561ee3 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/concept_def.hpp @@ -0,0 +1,34 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP +# define BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP +# include +# include +# include +# include +#endif // BOOST_CONCEPT_DETAIL_CONCEPT_DEF_DWA200651_HPP + +// BOOST_concept(SomeName, (p1)(p2)...(pN)) +// +// Expands to "template struct SomeName" +// +// Also defines an equivalent SomeNameConcept for backward compatibility. +// Maybe in the next release we can kill off the "Concept" suffix for good. +# define BOOST_concept(name, params) \ + template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ + struct name; /* forward declaration */ \ + \ + template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ + struct BOOST_PP_CAT(name,Concept) \ + : name< BOOST_PP_SEQ_ENUM(params) > \ + { \ + }; \ + \ + template < BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONCEPT_typename,~,params) > \ + struct name + +// Helper for BOOST_concept, above. +# define BOOST_CONCEPT_typename(r, ignored, index, t) \ + BOOST_PP_COMMA_IF(index) typename t + diff --git a/contrib/autoboost/boost/concept/detail/concept_undef.hpp b/contrib/autoboost/boost/concept/detail/concept_undef.hpp new file mode 100644 index 000000000..713db8912 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/concept_undef.hpp @@ -0,0 +1,5 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# undef BOOST_concept_typename +# undef BOOST_concept diff --git a/contrib/autoboost/boost/concept/detail/general.hpp b/contrib/autoboost/boost/concept/detail/general.hpp new file mode 100644 index 000000000..cc9d492b2 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/general.hpp @@ -0,0 +1,84 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP +# define BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP + +# include +# include + +# ifdef BOOST_OLD_CONCEPT_SUPPORT +# include +# include +# endif + +// This implementation works on Comeau and GCC, all the way back to +// 2.95 +namespace autoboost { namespace concepts { + +template +struct requirement_; + +namespace detail +{ + template struct instantiate {}; +} + +template +struct requirement +{ + static void failed() { ((Model*)0)->~Model(); } +}; + +struct failed {}; + +template +struct requirement +{ + static void failed() { ((Model*)0)->~Model(); } +}; + +# ifdef BOOST_OLD_CONCEPT_SUPPORT + +template +struct constraint +{ + static void failed() { ((Model*)0)->constraints(); } +}; + +template +struct requirement_ + : mpl::if_< + concepts::not_satisfied + , constraint + , requirement + >::type +{}; + +# else + +// For GCC-2.x, these can't have exactly the same name +template +struct requirement_ + : requirement +{}; + +# endif + +// Version check from https://svn.boost.org/trac/boost/changeset/82886 +// (boost/static_assert.hpp) +#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) +#define BOOST_CONCEPT_UNUSED_TYPEDEF __attribute__((unused)) +#else +#define BOOST_CONCEPT_UNUSED_TYPEDEF /**/ +#endif + +# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ + typedef ::autoboost::concepts::detail::instantiate< \ + &::autoboost::concepts::requirement_::failed> \ + BOOST_PP_CAT(boost_concept_check,__LINE__) \ + BOOST_CONCEPT_UNUSED_TYPEDEF + +}} + +#endif // BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/has_constraints.hpp b/contrib/autoboost/boost/concept/detail/has_constraints.hpp new file mode 100644 index 000000000..317025e25 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/has_constraints.hpp @@ -0,0 +1,50 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP +# define BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP + +# include +# include +# include + +namespace autoboost { namespace concepts { + +namespace detail +{ + +// Here we implement the metafunction that detects whether a +// constraints metafunction exists + typedef char yes; + typedef char (&no)[2]; + + template + struct wrap_constraints {}; + +#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580) || defined(__CUDACC__) + // Work around the following bogus error in Sun Studio 11, by + // turning off the has_constraints function entirely: + // Error: complex expression not allowed in dependent template + // argument expression + inline no has_constraints_(...); +#else + template + inline yes has_constraints_(Model*, wrap_constraints* = 0); + inline no has_constraints_(...); +#endif +} + +// This would be called "detail::has_constraints," but it has a strong +// tendency to show up in error messages. +template +struct not_satisfied +{ + BOOST_STATIC_CONSTANT( + bool + , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) ); + typedef mpl::bool_ type; +}; + +}} // namespace autoboost::concepts::detail + +#endif // BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/detail/msvc.hpp b/contrib/autoboost/boost/concept/detail/msvc.hpp new file mode 100644 index 000000000..29675bfc8 --- /dev/null +++ b/contrib/autoboost/boost/concept/detail/msvc.hpp @@ -0,0 +1,123 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP +# define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP + +# include +# include +# include + +# ifdef BOOST_OLD_CONCEPT_SUPPORT +# include +# include +# endif + +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4100) +# endif + +namespace autoboost { namespace concepts { + + +template +struct check +{ + virtual void failed(Model* x) + { + x->~Model(); + } +}; + +# ifndef BOOST_NO_PARTIAL_SPECIALIZATION +struct failed {}; +template +struct check +{ + virtual void failed(Model* x) + { + x->~Model(); + } +}; +# endif + +# ifdef BOOST_OLD_CONCEPT_SUPPORT + +namespace detail +{ + // No need for a virtual function here, since evaluating + // not_satisfied below will have already instantiated the + // constraints() member. + struct constraint {}; +} + +template +struct require + : mpl::if_c< + not_satisfied::value + , detail::constraint +# ifndef BOOST_NO_PARTIAL_SPECIALIZATION + , check +# else + , check +# endif + >::type +{}; + +# else + +template +struct require +# ifndef BOOST_NO_PARTIAL_SPECIALIZATION + : check +# else + : check +# endif +{}; + +# endif + +# if BOOST_WORKAROUND(BOOST_MSVC, == 1310) + +// +// The iterator library sees some really strange errors unless we +// do things this way. +// +template +struct require +{ + virtual void failed(Model*) + { + require(); + } +}; + +# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ +enum \ +{ \ + BOOST_PP_CAT(boost_concept_check,__LINE__) = \ + sizeof(::autoboost::concepts::require) \ +} + +# else // Not vc-7.1 + +template +require +require_(void(*)(Model)); + +# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ +enum \ +{ \ + BOOST_PP_CAT(boost_concept_check,__LINE__) = \ + sizeof(::autoboost::concepts::require_((ModelFnPtr)0)) \ +} + +# endif +}} + +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif + +#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP diff --git a/contrib/autoboost/boost/concept/usage.hpp b/contrib/autoboost/boost/concept/usage.hpp new file mode 100644 index 000000000..85486bacd --- /dev/null +++ b/contrib/autoboost/boost/concept/usage.hpp @@ -0,0 +1,36 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_CONCEPT_USAGE_DWA2006919_HPP +# define BOOST_CONCEPT_USAGE_DWA2006919_HPP + +# include +# include +# include + +namespace autoboost { namespace concepts { + +template +struct usage_requirements +{ + ~usage_requirements() { ((Model*)0)->~Model(); } +}; + +# if BOOST_WORKAROUND(__GNUC__, <= 3) + +# define BOOST_CONCEPT_USAGE(model) \ + model(); /* at least 2.96 and 3.4.3 both need this :( */ \ + BOOST_CONCEPT_ASSERT((autoboost::concepts::usage_requirements)); \ + ~model() + +# else + +# define BOOST_CONCEPT_USAGE(model) \ + BOOST_CONCEPT_ASSERT((autoboost::concepts::usage_requirements)); \ + ~model() + +# endif + +}} // namespace autoboost::concepts + +#endif // BOOST_CONCEPT_USAGE_DWA2006919_HPP From cfed8d0d9634465728de8dd3cc45966997bf889f Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Thu, 18 Dec 2014 16:01:58 -0800 Subject: [PATCH 35/57] =?UTF-8?q?Made=20AutoPacketFactory=20an=20member=20?= =?UTF-8?q?variable=20and=20implementing=20Jason=E2=80=99s=20true=20type?= =?UTF-8?q?=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autowiring/AutoPacketGraph.h | 5 +++++ src/autowiring/AutoPacketGraph.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index bde921985..0f8a24893 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -2,6 +2,8 @@ #pragma once #include "AutoFilterDescriptor.h" #include "AutoPacket.h" +#include "AutoPacketFactory.h" +#include "Autowired.h" #include STL_UNORDERED_MAP @@ -57,6 +59,9 @@ class AutoPacketGraph // A lock for this type mutable std::mutex m_lock; + // Reference to the AutoPacketFactory + Autowired m_factory; + /// /// Add an edge to the graph given the following parameters /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 258061464..593f3abb2 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -1,7 +1,6 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #include "stdafx.h" #include "AutoPacketGraph.h" -#include "AutoPacketProfiler.h" #include "CoreContext.h" #include "DecorationDisposition.h" #include "demangle.h" @@ -70,10 +69,13 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const auto& descriptor = edge.descriptor; auto count = itr.second; - // TODO: skip if type == AutoPacketGraph + const std::type_info& descType = m_factory->GetContext()->GetAutoTypeId(descriptor.GetAutoFilter()); + if (descType == typeid(AutoPacketGraph)) { + continue; + } std::string typeName = autowiring::demangle(type); - std::string descriptorName = autowiring::demangle(descriptor.GetType()); + std::string descriptorName = autowiring::demangle(descType); // Get a unique set of types/descriptors if (typeNames.find(typeName) == typeNames.end()) From 346c373660edfa93ade949b8154b498497f9c15e Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Thu, 18 Dec 2014 16:36:58 -0800 Subject: [PATCH 36/57] Add AutoPacket successor satisfaction test --- src/autowiring/test/AutoFilterSequencing.cpp | 35 +++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/autowiring/test/AutoFilterSequencing.cpp b/src/autowiring/test/AutoFilterSequencing.cpp index f9ae39f66..fdbfacfcb 100644 --- a/src/autowiring/test/AutoFilterSequencing.cpp +++ b/src/autowiring/test/AutoFilterSequencing.cpp @@ -97,14 +97,33 @@ TEST_F(AutoFilterSequencing, PacketReverseSuccessor) { TEST_F(AutoFilterSequencing, ManySuccessors) { AutoRequired factory; + { + auto packetA = factory->NewPacket(); + auto packet5 = packetA->Successor()->Successor()->Successor()->Successor(); + + factory->NewPacket(); + factory->NewPacket(); + factory->NewPacket(); + auto packetE = factory->NewPacket(); - auto packetA = factory->NewPacket(); - auto packet5 = packetA->Successor()->Successor()->Successor()->Successor(); - - auto packetB = factory->NewPacket(); - auto packetC = factory->NewPacket(); - auto packetD = factory->NewPacket(); - auto packetE = factory->NewPacket(); + ASSERT_EQ(packet5, packetE) << "Successor packet obtained after generation from the factory did not match as expected"; + } - ASSERT_EQ(packet5, packetE) << "Successor packet obtained after generation from the factory did not match as expected"; + AutoRequired first; + { + auto packetA = factory->NewPacket(); + packetA->Successor()->Successor()->Successor()->Successor(); + ASSERT_EQ(1, first->m_called) << "AutoFilter triggered from successor"; + + factory->NewPacket(); + ASSERT_EQ(2, first->m_called) << "AutoFilter not triggered from new packet"; + factory->NewPacket(); + ASSERT_EQ(3, first->m_called) << "AutoFilter not triggered from new packet"; + factory->NewPacket(); + ASSERT_EQ(4, first->m_called) << "AutoFilter not triggered from new packet"; + factory->NewPacket(); + ASSERT_EQ(5, first->m_called) << "AutoFilter not triggered from new packet"; + factory->NewPacket(); + ASSERT_EQ(6, first->m_called) << "AutoFilter not triggered from new packet"; + } } From 3c59ee63e99022c7416e5507082e05800f712b0a Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Thu, 18 Dec 2014 17:09:39 -0800 Subject: [PATCH 37/57] Simplifying the test receiver signatures --- src/autowiring/test/AutoPacketGraphTest.cpp | 29 +++++---------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp index bb9dfb19f..41804de02 100644 --- a/src/autowiring/test/AutoPacketGraphTest.cpp +++ b/src/autowiring/test/AutoPacketGraphTest.cpp @@ -13,44 +13,27 @@ class AutoPacketGraphTest: class APReceiver1 { public: APReceiver1(void) {} - - void AutoFilter(Decoration<0> d0) { - m_int0 = d0.i; - } - - int m_int0; + void AutoFilter(Decoration<0> d0) { } }; class APReceiver2 { public: APReceiver2(void) {} - - void AutoFilter(Decoration<0> d0, Decoration<1>& d1) { - m_int0 = d0.i; - - d1.i = m_int1; - } - - int m_int0; - int m_int1; + void AutoFilter(Decoration<0> d0, Decoration<1>& d1) { } }; class APReceiver3 { public: APReceiver3(void) {} - - void AutoFilter(Decoration<0> d0, Decoration<1> d1) { - m_int0 = d0.i; - m_int1 = d1.i; - } - - int m_int0; - int m_int1; + void AutoFilter(Decoration<0> d0, Decoration<1> d1) { } }; class APReceiver4 { public: APReceiver4(void) {} + void AutoFilter(Decoration<0> d0, Decoration<2> d2) { } +}; + void AutoFilter(Decoration<0> d0, Decoration<2> d2) { m_int0 = d0.i; From 46a1d9bf0e5001d24666483e9cdee8eaf2fe463a Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Thu, 18 Dec 2014 17:12:03 -0800 Subject: [PATCH 38/57] Slight refactor to CoreContext::Initiate() to only hold the lock for the thread list at the time of lock acquisition --- src/autowiring/CoreContext.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/autowiring/CoreContext.cpp b/src/autowiring/CoreContext.cpp index 8b1cf31f5..d4b112474 100644 --- a/src/autowiring/CoreContext.cpp +++ b/src/autowiring/CoreContext.cpp @@ -371,13 +371,20 @@ void CoreContext::Initiate(void) { // Reacquire the lock to prevent m_threads from being modified while we sit on it auto outstanding = IncrementOutstandingThreadCount(); - std::lock_guard lk(m_stateBlock->m_lock); - - // Signal our condition variable - m_stateBlock->m_stateChanged.notify_all(); + + // Get the end of the thread list that we have at the time of lock acquisition + t_threadList::iterator end; + + { + std::lock_guard lk(m_stateBlock->m_lock); + end = m_threads.end(); + + // Signal our condition variable + m_stateBlock->m_stateChanged.notify_all(); + } - for(CoreRunnable* q : m_threads) - q->Start(outstanding); + for (auto q = m_threads.begin(); q != end; ++q) + (*q)->Start(outstanding); } void CoreContext::InitiateCoreThreads(void) { From e770f9a96f13bbc92186be0564e54e851803f3d4 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Thu, 18 Dec 2014 17:47:06 -0800 Subject: [PATCH 39/57] Change to storing next packet in AutoPacketFactory Normal packet behavior is fine, but Successor functionality has regressed. --- autowiring/AutoPacket.h | 4 ++- autowiring/AutoPacketFactory.h | 9 +++---- src/autowiring/AutoPacket.cpp | 36 ++++++--------------------- src/autowiring/AutoPacketFactory.cpp | 27 ++++++++++++-------- src/autowiring/AutoPacketInternal.cpp | 24 ++++++++++++++++++ 5 files changed, 54 insertions(+), 46 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index 6bfd2cce5..2fb21d0bb 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -22,6 +22,7 @@ #include EXCEPTION_PTR_HEADER class AutoPacket; +class AutoPacketInternal; class AutoPacketFactory; class AutoPacketProfiler; struct AutoFilterDescriptor; @@ -61,7 +62,7 @@ class AutoPacket: const std::shared_ptr m_parentFactory; // The successor to this packet - std::shared_ptr m_successor; + std::shared_ptr m_successor; // Hold the time point at which this packet was last initalized. const std::chrono::high_resolution_clock::time_point m_initTime; @@ -524,6 +525,7 @@ class AutoPacket: /// /// Returns the next packet that will be issued by the packet factory in this context relative to this context /// + std::shared_ptr SuccessorInternal(void); std::shared_ptr Successor(void); /// True if the indicated type has been requested for use by some consumer diff --git a/autowiring/AutoPacketFactory.h b/autowiring/AutoPacketFactory.h index 8e5ebe78e..0016e5b86 100644 --- a/autowiring/AutoPacketFactory.h +++ b/autowiring/AutoPacketFactory.h @@ -16,6 +16,7 @@ struct AdjacencyEntry; class AutoPacketFactory; class Deferred; class DispatchQueue; +class AutoPacketInternal; /// /// A configurable factory class for pipeline packets with a built-in object pool @@ -45,7 +46,7 @@ class AutoPacketFactory: std::weak_ptr m_outstandingInternal; // The last packet issued from this factory - std::weak_ptr m_prevPacket; + std::shared_ptr m_nextPacket; // Collection of known subscribers typedef std::unordered_set> t_autoFilterSet; @@ -72,10 +73,6 @@ class AutoPacketFactory: template void AppendAutoFiltersTo(T& container) const { std::lock_guard lk(m_lock); - AppendAutoFiltersToUnsafe(container); - } - template - void AppendAutoFiltersToUnsafe(T& container) const { container.insert(container.end(), m_autoFilters.begin(), m_autoFilters.end()); } @@ -133,7 +130,7 @@ class AutoPacketFactory: /// std::shared_ptr NewPacket(void); - std::shared_ptr ConstructPacket(void); + std::shared_ptr ConstructPacket(void); /// the number of outstanding AutoPackets size_t GetOutstanding(void) const; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index a5947cd16..aac8d743c 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -3,6 +3,7 @@ #include "AutoPacket.h" #include "Autowired.h" #include "AutoPacketFactory.h" +#include "AutoPacketInternal.hpp" #include "AutoPacketProfiler.h" #include "AutoFilterDescriptor.h" #include "ContextEnumerator.h" @@ -15,34 +16,7 @@ AutoPacket::AutoPacket(AutoPacketFactory& factory, std::shared_ptr&& outst m_parentFactory(std::static_pointer_cast(factory.shared_from_this())), m_initTime(std::chrono::high_resolution_clock::now()), m_outstanding(std::move(outstanding)) -{ - // Add filters from our factory. We're holding the lock for this factory, so use unsafe - factory.AppendAutoFiltersToUnsafe(m_satCounters); - - // Traverse all descendant contexts, adding their packet subscriber vectors one at a time: - for(const auto& curContext : ContextEnumerator(factory.GetContext()->FirstChild())) { - AutowiredFast curFactory(curContext); - if(curFactory) - // Only insert if this context actually has a packet factory - curFactory->AppendAutoFiltersTo(m_satCounters); - } - - // Sort, eliminate duplicates - m_satCounters.sort(); - m_satCounters.erase(std::unique(m_satCounters.begin(), m_satCounters.end()), m_satCounters.end()); - - // Prime the satisfaction graph for each element: - for(auto& satCounter : m_satCounters) - AddSatCounter(satCounter); - - // Initialize all counters: - for (auto& satCounter : m_satCounters) - satCounter.Reset(); - - // Clear all references: - for (auto& decoration : m_decorations) - decoration.second.Reset(); -} +{} AutoPacket::~AutoPacket(void) { m_parentFactory->RecordPacketDuration( @@ -383,7 +357,7 @@ void AutoPacket::RemoveRecipient(Recipient&& recipient) { m_satCounters.erase(q); } -std::shared_ptr AutoPacket::Successor(void) { +std::shared_ptr AutoPacket::SuccessorInternal(void) { std::lock_guard lk(m_lock); // If successor doesn't already exists, create it @@ -393,3 +367,7 @@ std::shared_ptr AutoPacket::Successor(void) { return m_successor; } + +std::shared_ptr AutoPacket::Successor(void) { + return SuccessorInternal(); +} diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 8eacd49d7..41b394693 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -25,21 +25,21 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { if(!IsRunning()) throw autowiring_error("Cannot create a packet until the AutoPacketFactory is started"); - std::lock_guard lk(m_lock); + std::shared_ptr retVal; + { + std::lock_guard lk(m_lock); + retVal = m_nextPacket; - // Obtain a packet from previous packet if it still exists - auto prev = m_prevPacket.lock(); - auto retVal = prev ? prev->Successor() : ConstructPacket(); + // Create a new next packet + m_nextPacket = retVal->SuccessorInternal(); + } - // Store new packet as previous packet - m_prevPacket = retVal; + retVal->Initialize(); return retVal; } -std::shared_ptr AutoPacketFactory::ConstructPacket(void) { - auto retVal = std::make_shared(*this, GetInternalOutstanding()); - retVal->Initialize(); - return retVal; +std::shared_ptr AutoPacketFactory::ConstructPacket(void) { + return std::make_shared(*this, GetInternalOutstanding()); } bool AutoPacketFactory::IsAutoPacketType(const std::type_info& dataType) { @@ -71,6 +71,10 @@ std::shared_ptr AutoPacketFactory::GetInternalOutstanding(void) { } bool AutoPacketFactory::DoStart(void) { + // Initialize first packet + m_nextPacket = ConstructPacket(); + + // Wake us up. We're starting now m_stateCondition.notify_all(); return true; } @@ -81,6 +85,9 @@ void AutoPacketFactory::OnStop(bool graceful) { // Queue of local variables to be destroyed when leaving scope t_autoFilterSet autoFilters; + + // Reset next packet, it will never be issued + m_nextPacket.reset(); // Lock destruction precedes local variables std::lock_guard lk(m_lock); diff --git a/src/autowiring/AutoPacketInternal.cpp b/src/autowiring/AutoPacketInternal.cpp index 737f6053e..3d44da60f 100644 --- a/src/autowiring/AutoPacketInternal.cpp +++ b/src/autowiring/AutoPacketInternal.cpp @@ -11,6 +11,30 @@ AutoPacketInternal::AutoPacketInternal(AutoPacketFactory& factory, std::shared_p AutoPacketInternal::~AutoPacketInternal(void) {} void AutoPacketInternal::Initialize(void) { + // Traverse all descendant contexts, adding their packet subscriber vectors one at a time: + for(const auto& curContext : ContextEnumerator(m_parentFactory->GetContext())) { + AutowiredFast curFactory(curContext); + if(curFactory) + // Only insert if this context actually has a packet factory + curFactory->AppendAutoFiltersTo(m_satCounters); + } + + // Sort, eliminate duplicates + m_satCounters.sort(); + m_satCounters.erase(std::unique(m_satCounters.begin(), m_satCounters.end()), m_satCounters.end()); + + // Prime the satisfaction graph for each element: + for(auto& satCounter : m_satCounters) + AddSatCounter(satCounter); + + // Initialize all counters: + for (auto& satCounter : m_satCounters) + satCounter.Reset(); + + // Clear all references: + for (auto& decoration : m_decorations) + decoration.second.Reset(); + // Find all subscribers with no required or optional arguments: std::list callCounters; for (auto& satCounter : m_satCounters) From 8aa0582bd11fc8e10fd62e21a70f5ff0eb43da5e Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Thu, 18 Dec 2014 15:30:55 -0800 Subject: [PATCH 40/57] Correcting platform incompatibilities - OnStop should be invoked after Start has been called - Adding a void OnStop override for users inheriting CoreThread - Sealing OnStop(bool) to prevent odd behavior in CoreThread - Adding a protected GetOutstanding method to CoreRunnable rather than requiring direct access to its members; fixing the resulting naming collision in AutoPacketFactory --- autowiring/AutoPacketFactory.h | 4 +- autowiring/AutoRestarter.h | 6 +-- autowiring/BasicThread.h | 12 +++++- autowiring/CoreJob.h | 2 +- autowiring/CoreRunnable.h | 21 ++++++--- autowiring/CoreThread.h | 17 +++++++- src/autonet/AutoNetServerImpl.cpp | 2 +- src/autonet/AutoNetServerImpl.hpp | 2 +- src/autowiring/AutoPacketFactory.cpp | 6 +-- src/autowiring/BasicThread.cpp | 7 ++- src/autowiring/CoreJob.cpp | 18 ++++---- src/autowiring/CoreRunnable.cpp | 43 +++++++++++-------- src/autowiring/CoreThread.cpp | 6 +-- src/autowiring/test/AutoFilterTest.cpp | 10 ++--- src/autowiring/test/CoreRunnableTest.cpp | 2 +- src/autowiring/test/CoreThreadTest.cpp | 34 +++++++++++++++ .../test/TestFixtures/SimpleReceiver.hpp | 4 +- 17 files changed, 136 insertions(+), 60 deletions(-) diff --git a/autowiring/AutoPacketFactory.h b/autowiring/AutoPacketFactory.h index 8e5ebe78e..51d8b9410 100644 --- a/autowiring/AutoPacketFactory.h +++ b/autowiring/AutoPacketFactory.h @@ -80,7 +80,7 @@ class AutoPacketFactory: } // CoreRunnable overrides: - bool DoStart(void) override; + bool OnStart(void) override; void OnStop(bool graceful) override; void DoAdditionalWait(void) override; @@ -136,7 +136,7 @@ class AutoPacketFactory: std::shared_ptr ConstructPacket(void); /// the number of outstanding AutoPackets - size_t GetOutstanding(void) const; + size_t GetOutstandingPacketCount(void) const; /// /// Called by each AutoPacket's Finalize method to allow the factory diff --git a/autowiring/AutoRestarter.h b/autowiring/AutoRestarter.h index 418af1083..32cd41a34 100644 --- a/autowiring/AutoRestarter.h +++ b/autowiring/AutoRestarter.h @@ -52,12 +52,12 @@ class AutoRestarter: const AutoRestarterConfig config; // CoreRunnable overrides: - bool DoStart() override { + bool OnStart() override { // Start the enclosed context, do nothing else auto ctxt = GetContext(); if(ctxt && config.startWhenCreated) ctxt->Initiate(); - return false; + return true; } void OnStop(bool graceful) override { @@ -81,7 +81,7 @@ class AutoRestarter: // Parent restarter, we hand control here when we're stopped AutoRestarter& ar; - bool DoStart(void) override { + bool OnStart(void) override { return true; } diff --git a/autowiring/BasicThread.h b/autowiring/BasicThread.h index 37233c6ec..2a2eb6cfb 100644 --- a/autowiring/BasicThread.h +++ b/autowiring/BasicThread.h @@ -176,7 +176,7 @@ class BasicThread: /// Start will not be called from more than one place on the same object. The thread /// will be invoked from the context which was active at the time the thread was created. /// - bool DoStart() override; + bool OnStart() override; void OnStop(bool graceful) override; @@ -193,6 +193,16 @@ class BasicThread: /// virtual void Run() = 0; + /// + /// Provides derived members with a way of obtaining notification that this thread is being stopped + /// + /// + /// Callers must not perform any time-consuming operations in this callback; the method may be called + /// from a time-sensitive context and unacceptable system performance could result if long-duration + /// operations are undertaken here. + /// + virtual void OnStop(void) {} + /// /// Forces all Autowiring threads to reidentify themselves /// diff --git a/autowiring/CoreJob.h b/autowiring/CoreJob.h index 053b9ad26..12147485f 100644 --- a/autowiring/CoreJob.h +++ b/autowiring/CoreJob.h @@ -40,7 +40,7 @@ class CoreJob: public: // "CoreRunnable" overrides - bool DoStart(void) override; + bool OnStart(void) override; void OnStop(bool graceful) override; void DoAdditionalWait(void) override; }; diff --git a/autowiring/CoreRunnable.h b/autowiring/CoreRunnable.h index 0d7932066..2ca0f5761 100644 --- a/autowiring/CoreRunnable.h +++ b/autowiring/CoreRunnable.h @@ -11,27 +11,33 @@ class CoreRunnable { virtual ~CoreRunnable(void); private: - // Set to true if this runnable was ever signalled to start + // Set to true if this runnable was ever signaled to start bool m_wasStarted; // Set to true if this runnable should terminate processing bool m_shouldStop; -protected: // The outstanding count, held for as long as processing is underway std::shared_ptr m_outstanding; +protected: std::mutex m_lock; std::condition_variable m_cv; + /// + /// A reference to the current outstanding counter + /// + const std::shared_ptr& GetOutstanding(void) const; + /// /// Method invoked from Start when this class is being asked to begin processing /// /// True if processing has started, false otherwise /// - /// This method will be called at most once. + /// This method will be called at most once. Returning false from this method will result in an immediate invocation + /// of the OnStop(false). /// - virtual bool DoStart(void) { return false; }; + virtual bool OnStart(void) { return false; }; /// /// Invoked by the base class when a Stop call has been made @@ -58,13 +64,16 @@ class CoreRunnable { /// /// Causes this runnable to begin processing /// - /// True if this call resulted in a successful start the first time, false in all other cases + /// This method always returns true /// /// It is an error to call this routine more than once. The passed outstanding shared pointer /// is used to keep tracking of number of simultaneous runnables outstanding. This routine may /// be called even after Stop has been called; the caller MUST return false in this case. + /// + /// Callers should strongly prefer not to override Start if possible. Instead, override OnStart and + /// obtain an instance of the outstanding pointer via GetOutstanding /// - void Start(std::shared_ptr outstanding); + virtual bool Start(std::shared_ptr outstanding); /// /// Stops this runnable, optionally performing graceful cleanup if requested diff --git a/autowiring/CoreThread.h b/autowiring/CoreThread.h index 8938296e1..366f3796b 100644 --- a/autowiring/CoreThread.h +++ b/autowiring/CoreThread.h @@ -66,6 +66,19 @@ class CoreThread: /// void Run(void) override; + /// + /// Provides derived members with a way of obtaining notification that this thread is being stopped + /// + /// + /// This method is called before the dispatch queue is aborted or run down. Users wishing to perform + /// operations gracefully during termination should pend these operations as lambdas to the thread's + /// dispatch queue; these lambdas will be invoked if graceful termination is requested, and destroyed + /// without invocation otherwise. + /// + /// The base implementation of this method is guaranteed to do nothing. + /// + virtual void OnStop(void) {} + /// /// Event which may be used to perform custom handling when the thread is told to stop /// @@ -74,8 +87,8 @@ class CoreThread: /// This method is called when the thread should stop. When invoked, the value of /// CoreThread::ShouldStop is guaranteed to be true. /// - /// Callers are not required to call CoreThread::OnStop. This method is guaranteed to do + /// Derived classes are not required to call CoreThread::OnStop. This method is guaranteed to do /// nothing by default. /// - void OnStop(bool graceful) override; + void OnStop(bool graceful) override final; }; diff --git a/src/autonet/AutoNetServerImpl.cpp b/src/autonet/AutoNetServerImpl.cpp index a1bc0b751..82cf7e7e0 100644 --- a/src/autonet/AutoNetServerImpl.cpp +++ b/src/autonet/AutoNetServerImpl.cpp @@ -65,7 +65,7 @@ void AutoNetServerImpl::Run(void){ CoreThread::Run(); } -void AutoNetServerImpl::OnStop(bool graceful) { +void AutoNetServerImpl::OnStop(void) { if (m_Server.is_listening()) m_Server.stop_listening(); diff --git a/src/autonet/AutoNetServerImpl.hpp b/src/autonet/AutoNetServerImpl.hpp index d126836bb..108309263 100644 --- a/src/autonet/AutoNetServerImpl.hpp +++ b/src/autonet/AutoNetServerImpl.hpp @@ -31,7 +31,7 @@ class AutoNetServerImpl: // Functions from BasicThread virtual void Run(void) override; - virtual void OnStop(bool graceful) override; + virtual void OnStop(void) override; // Server Handler functions void OnOpen(websocketpp::connection_hdl hdl); diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 8eacd49d7..936c45a79 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -54,7 +54,7 @@ std::shared_ptr AutoPacketFactory::GetInternalOutstanding(void) { if (retVal) return retVal; - auto outstanding = m_outstanding; + std::shared_ptr outstanding = GetOutstanding(); retVal = std::shared_ptr( (void*)1, [this, outstanding] (void*) mutable { @@ -70,7 +70,7 @@ std::shared_ptr AutoPacketFactory::GetInternalOutstanding(void) { return retVal; } -bool AutoPacketFactory::DoStart(void) { +bool AutoPacketFactory::OnStart(void) { m_stateCondition.notify_all(); return true; } @@ -143,7 +143,7 @@ AutoFilterDescriptor AutoPacketFactory::GetTypeDescriptorUnsafe(const std::type_ return AutoFilterDescriptor(); } -size_t AutoPacketFactory::GetOutstanding(void) const { +size_t AutoPacketFactory::GetOutstandingPacketCount(void) const { return m_outstandingInternal.use_count(); } diff --git a/src/autowiring/BasicThread.cpp b/src/autowiring/BasicThread.cpp index 30c4818e7..95ee85699 100644 --- a/src/autowiring/BasicThread.cpp +++ b/src/autowiring/BasicThread.cpp @@ -114,7 +114,7 @@ bool BasicThread::ThreadSleep(std::chrono::nanoseconds timeout) { return m_state->m_stateCondition.wait_for(lk, timeout, [this] { return ShouldStop(); }); } -bool BasicThread::DoStart(void) { +bool BasicThread::OnStart(void) { std::shared_ptr context = m_context.lock(); if(!context) return false; @@ -124,7 +124,7 @@ bool BasicThread::DoStart(void) { // Place the new thread entity directly in the space where it goes to avoid // any kind of races arising from asynchronous access to this space - auto outstanding = m_outstanding; + auto outstanding = GetOutstanding(); m_state->m_thisThread.~thread(); new (&m_state->m_thisThread) std::thread( [this, outstanding] () mutable { @@ -139,6 +139,9 @@ void BasicThread::OnStop(bool graceful) { if (!m_running) { m_completed = true; } + + // Always invoke stop handler: + OnStop(); } void BasicThread::DoAdditionalWait(void) { diff --git a/src/autowiring/CoreJob.cpp b/src/autowiring/CoreJob.cpp index b1eda5e97..5c7979c01 100644 --- a/src/autowiring/CoreJob.cpp +++ b/src/autowiring/CoreJob.cpp @@ -27,7 +27,7 @@ void CoreJob::OnPended(std::unique_lock&& lk){ } // Increment outstanding count because we now have an entry out in a thread pool - auto outstanding = m_outstanding; + auto outstanding = GetOutstanding(); if(!outstanding) { // We're currently signalled to stop, we must empty the queue and then @@ -43,12 +43,14 @@ void CoreJob::OnPended(std::unique_lock&& lk){ if (m_curEvent) delete static_cast*>(m_curEvent); - m_curEvent = new std::future(std::async(std::launch::async, - [this, outstanding] () mutable { - this->DispatchAllAndClearCurrent(); - outstanding.reset(); - } - )); + m_curEvent = new std::future( + std::async( + std::launch::async, + [this, outstanding] () mutable { + this->DispatchAllAndClearCurrent(); + outstanding.reset(); + } + )); } } @@ -74,7 +76,7 @@ void CoreJob::DispatchAllAndClearCurrent(void) { } } -bool CoreJob::DoStart(void) { +bool CoreJob::OnStart(void) { std::shared_ptr context = m_context.lock(); if(!context) { return false; diff --git a/src/autowiring/CoreRunnable.cpp b/src/autowiring/CoreRunnable.cpp index adfb9354a..deaadd8b4 100644 --- a/src/autowiring/CoreRunnable.cpp +++ b/src/autowiring/CoreRunnable.cpp @@ -13,41 +13,48 @@ CoreRunnable::CoreRunnable(void): CoreRunnable::~CoreRunnable(void) {} -void CoreRunnable::Start(std::shared_ptr outstanding) { +const std::shared_ptr& CoreRunnable::GetOutstanding(void) const { + return m_outstanding; +} + +bool CoreRunnable::Start(std::shared_ptr outstanding) { std::lock_guard lk(m_lock); - if(m_wasStarted || m_outstanding || m_shouldStop) { + if(m_wasStarted || m_outstanding || m_shouldStop) // We have already been started or stopped, end here - return; - } + return true; m_wasStarted = true; m_outstanding = outstanding; - if(!DoStart()) { + if(!OnStart()) { m_shouldStop = true; m_outstanding.reset(); - return; + + // Immediately invoke a graceless stop in response + OnStop(false); } + + return true; } void CoreRunnable::Stop(bool graceful) { - if(m_shouldStop) { - // We were never started or have already stopped, end here - return; - } else if (!m_wasStarted) { - // We were never started, and now we never will be. + if (!m_shouldStop) { + // Stop flag should be pulled high m_shouldStop = true; + + // Do not call this method more than once: OnStop(graceful); - return; } - std::shared_ptr outstanding; + if (m_outstanding) { + std::shared_ptr outstanding; + std::lock_guard lk(m_lock); - m_shouldStop = true; - OnStop(graceful); + // Ensure we do not invoke the outstanding count dtor while holding a lock + outstanding.swap(m_outstanding); - std::lock_guard lk(m_lock); - outstanding.swap(m_outstanding); - m_cv.notify_all(); + // Everything looks good now + m_cv.notify_all(); + } } void CoreRunnable::Wait(void) { diff --git a/src/autowiring/CoreThread.cpp b/src/autowiring/CoreThread.cpp index 5e94a66e7..a8f8b2615 100644 --- a/src/autowiring/CoreThread.cpp +++ b/src/autowiring/CoreThread.cpp @@ -106,6 +106,9 @@ void CoreThread::Run() { } void CoreThread::OnStop(bool graceful) { + // Base class handling first: + BasicThread::OnStop(graceful); + if(graceful) { // Pend a call which will invoke Abort once the dispatch queue is done: DispatchQueue::Pend([this] { @@ -117,7 +120,4 @@ void CoreThread::OnStop(bool graceful) { } else // Abort the dispatch queue so anyone waiting will wake up DispatchQueue::Abort(); - - // Pass off to base class handling: - BasicThread::OnStop(graceful); } diff --git a/src/autowiring/test/AutoFilterTest.cpp b/src/autowiring/test/AutoFilterTest.cpp index 7039374ec..269c4287f 100644 --- a/src/autowiring/test/AutoFilterTest.cpp +++ b/src/autowiring/test/AutoFilterTest.cpp @@ -26,10 +26,10 @@ TEST_F(AutoFilterTest, GetOutstandingTest) { { auto packet = factory->NewPacket(); - ASSERT_EQ(1UL, factory->GetOutstanding()) << "Factory outstanding count mismatch"; + ASSERT_EQ(1UL, factory->GetOutstandingPacketCount()) << "Factory outstanding count mismatch"; } - ASSERT_EQ(0UL, factory->GetOutstanding()) << "Factory outstanding did not go to zero after releasing the only outstanding packet"; + ASSERT_EQ(0UL, factory->GetOutstandingPacketCount()) << "Factory outstanding did not go to zero after releasing the only outstanding packet"; } TEST_F(AutoFilterTest, VerifyDescendentAwareness) { @@ -668,11 +668,11 @@ TEST_F(AutoFilterTest, SingleImmediate) { // Verify we can't decorate this value a second time: ASSERT_ANY_THROW(packet->DecorateImmediate(val)) << "Expected an exception when a second attempt was made to attach a decoration"; } - ASSERT_EQ(0, factory->GetOutstanding()) << "Destroyed packet remains outstanding"; + ASSERT_EQ(0, factory->GetOutstandingPacketCount()) << "Destroyed packet remains outstanding"; static const int pattern = 1365; //1365 ~ 10101010101 AutoRequired>> fgp; - ASSERT_EQ(0, factory->GetOutstanding()) << "Outstanding packet count is correct after incrementing m_poolVersion due to AutoFilter addition"; + ASSERT_EQ(0, factory->GetOutstandingPacketCount()) << "Outstanding packet count is correct after incrementing m_poolVersion due to AutoFilter addition"; { auto packet = factory->NewPacket(); Decoration dec; @@ -681,7 +681,7 @@ TEST_F(AutoFilterTest, SingleImmediate) { ASSERT_TRUE(fgp->m_called == 1) << "Filter should called " << fgp->m_called << " times, expected 1"; ASSERT_TRUE(std::get<0>(fgp->m_args).i == pattern) << "Filter argument yielded " << std::get<0>(fgp->m_args).i << "expected " << pattern; } - ASSERT_EQ(0, factory->GetOutstanding()) << "Destroyed packet remains outstanding"; + ASSERT_EQ(0, factory->GetOutstandingPacketCount()) << "Destroyed packet remains outstanding"; // Terminate enclosing context AutoCurrentContext()->SignalShutdown(true); diff --git a/src/autowiring/test/CoreRunnableTest.cpp b/src/autowiring/test/CoreRunnableTest.cpp index ee66b750e..74c53aa10 100644 --- a/src/autowiring/test/CoreRunnableTest.cpp +++ b/src/autowiring/test/CoreRunnableTest.cpp @@ -13,7 +13,7 @@ class StartsSubcontextWhileStarting: public: AutoCreateContext m_myContext; - bool DoStart(void) override { + bool OnStart(void) override { m_myContext->Initiate(); return false; } diff --git a/src/autowiring/test/CoreThreadTest.cpp b/src/autowiring/test/CoreThreadTest.cpp index 2135a147e..bb55bbf08 100644 --- a/src/autowiring/test/CoreThreadTest.cpp +++ b/src/autowiring/test/CoreThreadTest.cpp @@ -443,3 +443,37 @@ TEST_F(CoreThreadTest, PendAfterShutdown) { // Verify that the lambda was destroyed more or less right away ASSERT_TRUE(v.unique()) << "Shared pointer in a lambda closure appears to have been leaked"; } + +class BTOverridesOnStopHandler: + public BasicThread +{ +public: + BTOverridesOnStopHandler(void) : got_stopped(false) {} + bool got_stopped; + + void Run(void) override {} + + void OnStop(void) override { got_stopped = true; } +}; + +class CTOverridesOnStopHandler: + public CoreThread +{ +public: + CTOverridesOnStopHandler(void) : got_stopped(false) {} + bool got_stopped; + void OnStop(void) override { got_stopped = true; } +}; + +TEST_F(CoreThreadTest, VerifyThreadGetsOnStop) { + AutoRequired bsoosh; + AutoRequired ctoosh; + + AutoCurrentContext ctxt; + ctxt->Initiate(); + ctxt->SignalShutdown(); + ctxt->Wait(); + + EXPECT_TRUE(bsoosh->got_stopped) << "BasicThread instance did not receive an OnStop notification as expected"; + EXPECT_TRUE(ctoosh->got_stopped) << "CoreThread instance did not receive an OnStop notification as expected"; +} \ No newline at end of file diff --git a/src/autowiring/test/TestFixtures/SimpleReceiver.hpp b/src/autowiring/test/TestFixtures/SimpleReceiver.hpp index 689a5fa47..0089ed519 100644 --- a/src/autowiring/test/TestFixtures/SimpleReceiver.hpp +++ b/src/autowiring/test/TestFixtures/SimpleReceiver.hpp @@ -193,10 +193,8 @@ class SimpleReceiver: } // Overridden here so we can hit the barrier if we're still waiting on it - void OnStop(bool graceful) override { + void OnStop(void) override { Proceed(); - // Allow our parent to handle the stop as well - CoreThread::OnStop(graceful); } /// From 3ba4ad4007016804e3bc7eec770985fd76eda327 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Fri, 19 Dec 2014 09:48:18 -0800 Subject: [PATCH 41/57] Bumped version number --- version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.cmake b/version.cmake index cbd770303..466dac296 100644 --- a/version.cmake +++ b/version.cmake @@ -1 +1 @@ -set(autowiring_VERSION 0.3.0) +set(autowiring_VERSION 0.3.1) From 8d210ed58ac9f5fcbb23c804fbac3bb3d2785205 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Fri, 19 Dec 2014 12:56:51 -0800 Subject: [PATCH 42/57] Making AutoPacketGraph inherit from AutowiringEvents so that it can rescan for edges on AutowiringEvents::NewObject and CoreRunnable so that it can load the system when the context has been initiated. Added more test cases (and stubs/todos) --- autowiring/AutoPacketGraph.h | 32 +++++- src/autowiring/AutoPacketGraph.cpp | 68 ++++++++++--- src/autowiring/test/AutoPacketGraphTest.cpp | 107 ++++++++++++-------- 3 files changed, 149 insertions(+), 58 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 0f8a24893..8686653f9 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -4,6 +4,8 @@ #include "AutoPacket.h" #include "AutoPacketFactory.h" #include "Autowired.h" +#include "AutowiringEvents.h" +#include "CoreRunnable.h" #include STL_UNORDERED_MAP @@ -46,26 +48,46 @@ namespace std { /// /// Graphical visualization of AutoPackets /// -class AutoPacketGraph +class AutoPacketGraph: + public AutowiringEvents, + public CoreRunnable { public: AutoPacketGraph(); + typedef std::unordered_map> t_deliveryEdges; + protected: // A mapping of an edge to the number of times it was delivered - typedef std::unordered_map> t_deliveryEdges; t_deliveryEdges m_deliveryGraph; // A lock for this type mutable std::mutex m_lock; // Reference to the AutoPacketFactory - Autowired m_factory; + AutoRequired m_factory; + + /// + /// Scan all of the objects and add any AutoFilter's from all of the objects in a system. + /// + /// + /// This function will scan all of the objects (and rescan) and only add new edges to our graph. + /// + void LoadEdges(); /// - /// Add an edge to the graph given the following parameters + /// Record the delivery of a packet and increment the number of times the packet has been delivered /// - void AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + void RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); + + /// AutowiringEvents overrides + virtual void NewContext(CoreContext&) {} + virtual void ExpiredContext(CoreContext&) {} + virtual void EventFired(CoreContext&, const std::type_info&) {} + virtual void NewObject(CoreContext&, const ObjectTraits&); + + /// CoreRunnable overrides + virtual bool DoStart(void); public: /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 593f3abb2..39eaae146 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -7,22 +7,64 @@ #include "SatCounter.h" #include #include +#include FUNCTIONAL_HEADER +AutoPacketGraph::AutoPacketGraph() { +} -AutoPacketGraph::AutoPacketGraph() -{ +void AutoPacketGraph::LoadEdges() { + std::lock_guard lk(m_lock); + + std::list descriptors; + m_factory->AppendAutoFiltersTo(descriptors); + + // Sort, eliminate duplicates + descriptors.sort(); + descriptors.erase(std::unique(descriptors.begin(), descriptors.end()), descriptors.end()); + + for (auto& descriptor : descriptors) { + for(auto pCur = descriptor.GetAutoFilterInput(); *pCur; pCur++) { + const std::type_info& type_info = *pCur->ti; + + // Skip the AutoPacketGraph + const std::type_info& descType = m_factory->GetContext()->GetAutoTypeId(descriptor.GetAutoFilter()); + if (descType == typeid(AutoPacketGraph)) { + continue; + } + + if (pCur->is_input) { + DeliveryEdge edge { &type_info, descriptor, true }; + if (m_deliveryGraph.find(edge) == m_deliveryGraph.end()) { + m_deliveryGraph[edge] = 0; + } + } + + if (pCur->is_output) { + DeliveryEdge edge { &type_info, descriptor, false }; + if (m_deliveryGraph.find(edge) == m_deliveryGraph.end()) { + m_deliveryGraph[edge] = 0; + } + } + } + } } -void AutoPacketGraph::AddEdge(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { +void AutoPacketGraph::RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input) { DeliveryEdge edge { ti, descriptor, input }; - std::lock_guard lk(m_lock); auto itr = m_deliveryGraph.find(edge); - if (itr == m_deliveryGraph.end()) { - m_deliveryGraph[edge] = 1; - } else { - itr->second++; - } + assert(itr != m_deliveryGraph.end()); + itr->second++; +} + +void AutoPacketGraph::NewObject(CoreContext&, const ObjectTraits&) { + LoadEdges(); +} + +bool AutoPacketGraph::DoStart(void) { + LoadEdges(); + + return false; } void AutoPacketGraph::AutoFilter(AutoPacket& packet) { @@ -32,12 +74,12 @@ void AutoPacketGraph::AutoFilter(AutoPacket& packet) { auto type = decoration.m_type; if (publisher && publisher->called) { - AddEdge(type, *publisher, false); + RecordDelivery(type, *publisher, false); } for (auto& subscriber : decoration.m_subscribers) { if (subscriber->called) { - AddEdge(type, *subscriber, true); + RecordDelivery(type, *subscriber, true); } } } @@ -48,8 +90,7 @@ AutoPacketGraph::t_deliveryEdges AutoPacketGraph::GetEdgeCounts() const { return m_deliveryGraph; } -bool AutoPacketGraph::WriteGV(const std::string& filename) const -{ +bool AutoPacketGraph::WriteGV(const std::string& filename) const { std::ofstream file(filename); if (!file && !file.good()) { return false; @@ -69,6 +110,7 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const auto& descriptor = edge.descriptor; auto count = itr.second; + // Skip the AutoPacketGraph const std::type_info& descType = m_factory->GetContext()->GetAutoTypeId(descriptor.GetAutoFilter()); if (descType == typeid(AutoPacketGraph)) { continue; diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp index 41804de02..62b94a7d4 100644 --- a/src/autowiring/test/AutoPacketGraphTest.cpp +++ b/src/autowiring/test/AutoPacketGraphTest.cpp @@ -34,61 +34,88 @@ class APReceiver4 { void AutoFilter(Decoration<0> d0, Decoration<2> d2) { } }; + +TEST_F(AutoPacketGraphTest, VerifyEmptyGraphBeforeCtxtInit) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); - void AutoFilter(Decoration<0> d0, Decoration<2> d2) { - m_int0 = d0.i; - m_int2 = d2.i; - } + AutoRequired graph; + ASSERT_TRUE(graph->GetEdgeCounts().empty()) + << "Graph did not start out empty before context initiation"; - int m_int0; - int m_int2; -}; + ctxt->Initiate(); + + ASSERT_TRUE(graph->GetEdgeCounts().empty()) + << "Graph did not stay empty after context initiation"; + + ctxt->SignalShutdown(); +} -TEST_F(AutoPacketGraphTest, SimpleAutoGraph) { +TEST_F(AutoPacketGraphTest, VerifyEmptyGraphAfterCtxtInit) { AutoCreateContext ctxt; CurrentContextPusher pshr(ctxt); - AutoRequired factory(ctxt); + ctxt->Initiate(); + AutoRequired graph; + ASSERT_TRUE(graph->GetEdgeCounts().empty()) + << "Graph did not start out empty"; + ctxt->SignalShutdown(); +} + +TEST_F(AutoPacketGraphTest, VerifySimpleEdgeFromObjectBeforeInit) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); + + AutoRequired graph; AutoRequired receiver1; - AutoRequired receiver2; - AutoRequired receiver3; - AutoRequired receiver4; - ctxt->Initiate(); + ASSERT_TRUE(graph->GetEdgeCounts().empty()) + << "Graph should still be empty before context is initialized"; - int int0 = 12; - int int1 = 34; - int int2 = 56; + ctxt->Initiate(); - receiver2->m_int1 = int1; + ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) + << "Graph did not detect AutoFilter from object after being initiated"; - { - // decorate 1 - auto packet = factory->NewPacket(); - packet->Decorate(Decoration<0>(int0)); + ctxt->SignalShutdown(); +} - // TODO: add some real test cases -// ASSERT_EQ(int0, receiver1->m_int0); -// -// ASSERT_EQ(int0, receiver2->m_int0); -// -// ASSERT_EQ(int0, receiver3->m_int0); -// ASSERT_EQ(int1, receiver3->m_int1); - - // decorate 2 - packet->Decorate(Decoration<2>(int2)); +TEST_F(AutoPacketGraphTest, VerifySimpleInputFilter) { + // TODO +} - // TODO: add some real test cases -// ASSERT_EQ(int0, receiver4->m_int0); -// ASSERT_EQ(int2, receiver4->m_int2); - } +TEST_F(AutoPacketGraphTest, VerifySimpleOutputFilter) { + // TODO +} + +TEST_F(AutoPacketGraphTest, VerifyPacketDecorationIncrementingCount) { + // TODO +} + +TEST_F(AutoPacketGraphTest, VerifyLoadAutoFilterSystem) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); - graph->WriteGV("/Users/jnguyen/Desktop/graph.gv"); + AutoRequired factory(ctxt); + AutoRequired graph; - // Shutdown our context, and rundown our factory - ctxt->SignalShutdown(); - factory->Wait(); + ctxt->Initiate(); + + AutoRequired receiver1; + AutoRequired receiver2; + AutoRequired receiver3; + AutoRequired receiver4; + + AutoPacketGraph::t_deliveryEdges edges = graph->GetEdgeCounts(); + + ASSERT_EQ(7UL, edges.size()) + << "Graph could not load the edges from new objects"; -} \ No newline at end of file + for (auto& itr : edges) { + ASSERT_EQ(0UL, itr.second) + << "Coutn should be 0 since packets have not been delivered yet"; + } +} + From 63dd34634b628c02572e962d55884085903fdfcf Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Fri, 19 Dec 2014 12:55:01 -0800 Subject: [PATCH 43/57] Fix tests with new AutoPacket guarantees --- src/autowiring/AutoPacketFactory.cpp | 9 ++++++--- src/autowiring/AutoPacketInternal.cpp | 1 + src/autowiring/test/AutoFilterSequencing.cpp | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/autowiring/AutoPacketFactory.cpp b/src/autowiring/AutoPacketFactory.cpp index 41b394693..cae4f0903 100644 --- a/src/autowiring/AutoPacketFactory.cpp +++ b/src/autowiring/AutoPacketFactory.cpp @@ -28,9 +28,12 @@ std::shared_ptr AutoPacketFactory::NewPacket(void) { std::shared_ptr retVal; { std::lock_guard lk(m_lock); - retVal = m_nextPacket; + + // New packet issued + ++m_packetCount; // Create a new next packet + retVal = m_nextPacket; m_nextPacket = retVal->SuccessorInternal(); } @@ -151,12 +154,12 @@ AutoFilterDescriptor AutoPacketFactory::GetTypeDescriptorUnsafe(const std::type_ } size_t AutoPacketFactory::GetOutstanding(void) const { - return m_outstandingInternal.use_count(); + // Next packet is stored internally, don't count that packet + return m_outstandingInternal.use_count() - 1; } void AutoPacketFactory::RecordPacketDuration(std::chrono::nanoseconds duration) { std::unique_lock lk(m_lock); - ++m_packetCount; m_packetDurationSum += duration.count(); m_packetDurationSqSum += duration.count() * duration.count(); } diff --git a/src/autowiring/AutoPacketInternal.cpp b/src/autowiring/AutoPacketInternal.cpp index 3d44da60f..0cfa48117 100644 --- a/src/autowiring/AutoPacketInternal.cpp +++ b/src/autowiring/AutoPacketInternal.cpp @@ -3,6 +3,7 @@ #include "AutoPacketInternal.hpp" #include "AutoPacketFactory.h" #include "SatCounter.h" +#include AutoPacketInternal::AutoPacketInternal(AutoPacketFactory& factory, std::shared_ptr&& outstanding) : AutoPacket(factory, std::move(outstanding)) diff --git a/src/autowiring/test/AutoFilterSequencing.cpp b/src/autowiring/test/AutoFilterSequencing.cpp index fdbfacfcb..c92b3a5ea 100644 --- a/src/autowiring/test/AutoFilterSequencing.cpp +++ b/src/autowiring/test/AutoFilterSequencing.cpp @@ -82,6 +82,7 @@ TEST_F(AutoFilterSequencing, SuccessorHoldViolationCheck) { ASSERT_TRUE(packet1.unique()) << "Expected that the first issued packet shared pointer not to be aliased anywhere"; packet1.reset(); + factory->NewPacket(); ASSERT_TRUE(packet2.unique()) << "Expected that a successor packet would be unique when the principal was destroyed"; } From 42637f743b3d885db89ed688a8d9cd373bb198eb Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Fri, 19 Dec 2014 13:54:36 -0800 Subject: [PATCH 44/57] Fixing issue where finding the iterator to the beginning of the list instead of the front since we push to the front of m_threads --- src/autowiring/CoreContext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/autowiring/CoreContext.cpp b/src/autowiring/CoreContext.cpp index d4b112474..71557bb3b 100644 --- a/src/autowiring/CoreContext.cpp +++ b/src/autowiring/CoreContext.cpp @@ -372,18 +372,18 @@ void CoreContext::Initiate(void) { // Reacquire the lock to prevent m_threads from being modified while we sit on it auto outstanding = IncrementOutstandingThreadCount(); - // Get the end of the thread list that we have at the time of lock acquisition - t_threadList::iterator end; + // Get the beginning of the thread list that we have at the time of lock acquisition + t_threadList::iterator beginning; { std::lock_guard lk(m_stateBlock->m_lock); - end = m_threads.end(); + beginning = m_threads.begin(); // Signal our condition variable m_stateBlock->m_stateChanged.notify_all(); } - for (auto q = m_threads.begin(); q != end; ++q) + for (auto q = beginning; q != m_threads.end(); ++q) (*q)->Start(outstanding); } From 854fb59b43ceab02740c9d06926ce3356ec7886a Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Fri, 19 Dec 2014 14:14:30 -0800 Subject: [PATCH 45/57] Updating the override methods from the CoreRunnable refactor --- autowiring/AutoPacketGraph.h | 10 +++++----- src/autowiring/AutoPacketGraph.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 8686653f9..e7b2c5444 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -81,13 +81,13 @@ class AutoPacketGraph: void RecordDelivery(const std::type_info* ti, const AutoFilterDescriptor& descriptor, bool input); /// AutowiringEvents overrides - virtual void NewContext(CoreContext&) {} - virtual void ExpiredContext(CoreContext&) {} - virtual void EventFired(CoreContext&, const std::type_info&) {} - virtual void NewObject(CoreContext&, const ObjectTraits&); + virtual void NewContext(CoreContext&) override {} + virtual void ExpiredContext(CoreContext&) override {} + virtual void EventFired(CoreContext&, const std::type_info&) override {} + virtual void NewObject(CoreContext&, const ObjectTraits&) override; /// CoreRunnable overrides - virtual bool DoStart(void); + virtual bool OnStart(void) override; public: /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 39eaae146..cf30d1c5c 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -61,7 +61,7 @@ void AutoPacketGraph::NewObject(CoreContext&, const ObjectTraits&) { LoadEdges(); } -bool AutoPacketGraph::DoStart(void) { +bool AutoPacketGraph::OnStart(void) { LoadEdges(); return false; From 0886e24d454eac8c76b583c0093426fdebc30934 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Fri, 19 Dec 2014 14:19:53 -0800 Subject: [PATCH 46/57] Move m_initTime initialization to Initialize call --- autowiring/AutoPacket.h | 2 +- src/autowiring/AutoPacket.cpp | 1 - src/autowiring/AutoPacketInternal.cpp | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/autowiring/AutoPacket.h b/autowiring/AutoPacket.h index 2fb21d0bb..5b3acebcb 100644 --- a/autowiring/AutoPacket.h +++ b/autowiring/AutoPacket.h @@ -65,7 +65,7 @@ class AutoPacket: std::shared_ptr m_successor; // Hold the time point at which this packet was last initalized. - const std::chrono::high_resolution_clock::time_point m_initTime; + std::chrono::high_resolution_clock::time_point m_initTime; // Outstanding count local and remote holds: const std::shared_ptr m_outstanding; diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index aac8d743c..0573bac49 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -14,7 +14,6 @@ using namespace autowiring; AutoPacket::AutoPacket(AutoPacketFactory& factory, std::shared_ptr&& outstanding): m_parentFactory(std::static_pointer_cast(factory.shared_from_this())), - m_initTime(std::chrono::high_resolution_clock::now()), m_outstanding(std::move(outstanding)) {} diff --git a/src/autowiring/AutoPacketInternal.cpp b/src/autowiring/AutoPacketInternal.cpp index 0cfa48117..28aa7cc03 100644 --- a/src/autowiring/AutoPacketInternal.cpp +++ b/src/autowiring/AutoPacketInternal.cpp @@ -12,6 +12,9 @@ AutoPacketInternal::AutoPacketInternal(AutoPacketFactory& factory, std::shared_p AutoPacketInternal::~AutoPacketInternal(void) {} void AutoPacketInternal::Initialize(void) { + // Mark init time of packet + this->m_initTime = std::chrono::high_resolution_clock::now(); + // Traverse all descendant contexts, adding their packet subscriber vectors one at a time: for(const auto& curContext : ContextEnumerator(m_parentFactory->GetContext())) { AutowiredFast curFactory(curContext); From 621bf01882bdd71389398146bbf6a69069a1e820 Mon Sep 17 00:00:00 2001 From: Graham Tremper Date: Fri, 19 Dec 2014 14:54:32 -0800 Subject: [PATCH 47/57] Avoid recursive AutoPacket destructor calls --- src/autowiring/AutoPacket.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/autowiring/AutoPacket.cpp b/src/autowiring/AutoPacket.cpp index 0573bac49..74d60d9dc 100644 --- a/src/autowiring/AutoPacket.cpp +++ b/src/autowiring/AutoPacket.cpp @@ -23,6 +23,20 @@ AutoPacket::~AutoPacket(void) { std::chrono::high_resolution_clock::now() - m_initTime ) ); + + // Create vector of all successor packets that will be destroyed + // This prevents recursive AutoPacket destructor calls + std::vector> packets; + + // Recurse through unique successors, storing them in our vector + for (AutoPacket* current = this; current->m_successor.unique();) { + packets.push_back(current->m_successor); + + // Reset and continue to next successor + AutoPacket* prev_current = current; + current = current->m_successor.get(); + prev_current->m_successor.reset(); + } } DecorationDisposition& AutoPacket::CheckoutImmediateUnsafe(const std::type_info& ti, const void* pvImmed) From de806e3454399872186b475231e76f26343baaa2 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Fri, 19 Dec 2014 16:10:31 -0800 Subject: [PATCH 48/57] =?UTF-8?q?Adding=20a=20=E2=80=9Crunning=E2=80=9D=20?= =?UTF-8?q?state=20using=20a=20=E2=80=9CbeforeRunning=E2=80=9D=20boolean?= =?UTF-8?q?=20to=20allow=20a=20CoreRunnable=20to=20safely=20access=20its?= =?UTF-8?q?=20context=20without=20deadlocking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autowiring/CoreContext.h | 3 ++ src/autowiring/CoreContext.cpp | 59 +++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/autowiring/CoreContext.h b/autowiring/CoreContext.h index 0797f3167..df2ad32e8 100644 --- a/autowiring/CoreContext.h +++ b/autowiring/CoreContext.h @@ -115,6 +115,9 @@ class CoreContext: // State block for this context: std::unique_ptr m_stateBlock; + + // Set if a thread is added and needs to be run + bool m_beforeRunning; // Set if threads in this context should be started when they are added bool m_initiated; diff --git a/src/autowiring/CoreContext.cpp b/src/autowiring/CoreContext.cpp index 173b0140c..40b33f41f 100644 --- a/src/autowiring/CoreContext.cpp +++ b/src/autowiring/CoreContext.cpp @@ -31,6 +31,7 @@ CoreContext::CoreContext(std::shared_ptr pParent, t_childList::iter m_pParent(pParent), m_backReference(backReference), m_stateBlock(new CoreContextStateBlock), + m_beforeRunning(false), m_initiated(false), m_isShutdown(false), m_junctionBoxManager( @@ -213,9 +214,6 @@ void CoreContext::AddInternal(const ObjectTraits& traits) { if(traits.pContextMember) AddContextMember(traits.pContextMember); - if(traits.pCoreRunnable) - AddCoreRunnable(traits.pCoreRunnable); - if(traits.pFilter) m_filters.push_back(traits.pFilter.get()); @@ -226,6 +224,10 @@ void CoreContext::AddInternal(const ObjectTraits& traits) { // to be considered. UpdateDeferredElements(std::move(lk), traits.pObject); } + + // Moving this outside the lock because AddCoreRunnable will perform the checks inside its function + if(traits.pCoreRunnable) + AddCoreRunnable(traits.pCoreRunnable); // Event receivers: if(traits.receivesEvents) { @@ -372,11 +374,20 @@ void CoreContext::InitiateCoreThreads(void) { } void CoreContext::SignalShutdown(bool wait, ShutdownMode shutdownMode) { + // As we signal shutdown, there may be a CoreRunnable that is in the "running" state. If so, + // then we will skip that thread as we signal the list of threads to shutdown. + t_threadList::iterator firstThreadToStop; + // Wipe out the junction box manager, notify anyone waiting on the state condition: { std::lock_guard lk(m_stateBlock->m_lock); UnregisterEventReceiversUnsafe(); m_isShutdown = true; + + firstThreadToStop = m_threads.begin(); + if (m_beforeRunning) + ++firstThreadToStop; + m_stateBlock->m_stateChanged.notify_all(); } @@ -418,8 +429,8 @@ void CoreContext::SignalShutdown(bool wait, ShutdownMode shutdownMode) { // Pass notice to all child threads: bool graceful = (shutdownMode == ShutdownMode::Graceful); - for(CoreRunnable* runnable : m_threads) - runnable->Stop(graceful); + for (auto itr = firstThreadToStop; itr != m_threads.end(); ++itr) + (*itr)->Stop(graceful); // Signal our condition variable m_stateBlock->m_stateChanged.notify_all(); @@ -460,16 +471,40 @@ std::shared_ptr CoreContext::CurrentContext(void) { } void CoreContext::AddCoreRunnable(const std::shared_ptr& ptr) { - // Insert into the linked list of threads first: - m_threads.push_front(ptr.get()); + // Performing a double check. + bool shouldRun; + { + std::unique_lock lk(m_stateBlock->m_lock); + + // Insert into the linked list of threads first: + m_threads.push_front(ptr.get()); + + // Check if we're already running, this means we're late to the party and need to start _now_. + shouldRun = m_initiated; + + // Signal that we are in the "running" + m_beforeRunning = true; + } - if(m_initiated) - // We're already running, this means we're late to the party and need to start _now_. + // Run this thread without the lock + if(shouldRun) ptr->Start(IncrementOutstandingThreadCount()); + - if(m_isShutdown) - // We're really late to the party, it's already over. Make sure the thread's stop - // overrides are called and that it transitions to a stopped state. + // Check if the stop signal was sent between the time we started running until now. If so, then + // we will stop the thread manually here. + bool shouldStopHere; + { + std::unique_lock lk(m_stateBlock->m_lock); + + // Signal that we have stopped "running" + m_beforeRunning = false; + + // If SignalShutdown() was invoked while we were "running", then we will need to stop this thread ourselves + shouldStopHere = m_isShutdown; + } + + if(shouldStopHere) ptr->Stop(false); } From 738bf9e3e0453106d654b452cf807535602b9cf6 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Mon, 22 Dec 2014 14:36:14 -0800 Subject: [PATCH 49/57] AutowiredFast should be allowed to work with a pointer type as its ctor arg This allows us to use AutowiredFast in cases where a shared pointer might not be avilable, such as early CoreContext construction and in teardown notifiers --- autowiring/Autowired.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autowiring/Autowired.h b/autowiring/Autowired.h index e80e7da05..f5c8f0887 100644 --- a/autowiring/Autowired.h +++ b/autowiring/Autowired.h @@ -261,10 +261,14 @@ class AutowiredFast: // !!!!! Read comment in AutoRequired if you get a compiler error here !!!!! AutowiredFast(const std::shared_ptr& ctxt = CoreContext::CurrentContext()) { - if(ctxt) + if (ctxt) ctxt->FindByTypeRecursive(*this); } + AutowiredFast(const CoreContext* pCtxt) { + pCtxt->FindByTypeRecursive(*this); + } + operator bool(void) const { return IsAutowired(); } From c468fbd5e4ab74f43e194b75390b4b2b84e6482d Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Mon, 22 Dec 2014 13:53:31 -0800 Subject: [PATCH 50/57] Allow autowiring to take place even in teardown --- autowiring/CoreContext.h | 20 ++++++++++++++++++++ src/autowiring/test/TeardownNotifierTest.cpp | 20 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/autowiring/CoreContext.h b/autowiring/CoreContext.h index 0797f3167..d47be8df0 100644 --- a/autowiring/CoreContext.h +++ b/autowiring/CoreContext.h @@ -387,6 +387,18 @@ class CoreContext: template void RegisterFactory(const Factory&, autowiring::member_new_type) {} + // Internal resolvers, used to determine which teardown style the user would like to use + template + void AddTeardownListener2(Fx&& fx, void (Fx::*)(void)) { TeardownNotifier::AddTeardownListener(fx); } + + template + void AddTeardownListener2(Fx&& fx, void (Fx::*)(const CoreContext&)) { TeardownNotifier::AddTeardownListener([fx, this] () mutable { fx(*this); }); } + template + void AddTeardownListener2(Fx&& fx, void (Fx::*)(void) const) { TeardownNotifier::AddTeardownListener(fx); } + + template + void AddTeardownListener2(Fx&& fx, void (Fx::*)(const CoreContext&) const) { TeardownNotifier::AddTeardownListener([fx, this] () mutable { fx(*this); }); } + public: // Accessor methods: bool IsGlobalContext(void) const { return !m_pParent; } @@ -911,6 +923,14 @@ class CoreContext: return searchFn.resultSlot; } + /// + /// Adds a teardown notifier which receives a pointer to this context on destruction + /// + template + void AddTeardownListener(Fx&& fx) { + AddTeardownListener2(std::forward(fx), &Fx::operator()); + } + /// /// Unregisters a slot as a recipient of potential autowiring /// diff --git a/src/autowiring/test/TeardownNotifierTest.cpp b/src/autowiring/test/TeardownNotifierTest.cpp index a009304e6..827a9521f 100644 --- a/src/autowiring/test/TeardownNotifierTest.cpp +++ b/src/autowiring/test/TeardownNotifierTest.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #include "stdafx.h" -#include +#include class TeardownNotifierTest: public testing::Test @@ -45,4 +45,20 @@ TEST_F(TeardownNotifierTest, ReferenceMemberInTeardown) { } EXPECT_TRUE(hit) << "Failed to reference a member of a context in it's teardown listener"; -} \ No newline at end of file +} + +TEST_F(TeardownNotifierTest, CanAutowireInTeardown) { + bool foundSimpleMember = false; + bool calledNotifier = false; + { + AutoCreateContext ctxt; + AutoRequired sm(ctxt); + ctxt->AddTeardownListener([&foundSimpleMember, &calledNotifier](const CoreContext& ctxt) { + foundSimpleMember = AutowiredFast(&ctxt).IsAutowired(); + calledNotifier = true; + }); + } + + ASSERT_TRUE(foundSimpleMember) << "Failed to find a context member in teardown with AutowiredFast"; + ASSERT_TRUE(calledNotifier) << "Teardown notifier not called as expected"; +} From 2de9b58cb649e19368ddc7757c83632abcc37276 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Mon, 22 Dec 2014 16:36:17 -0800 Subject: [PATCH 51/57] =?UTF-8?q?Stripping=20the=20=E2=80=9Cauto=5Fin<=20>?= =?UTF-8?q?=E2=80=9D=20from=20the=20demangled=20type=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autowiring/AutoPacketGraph.h | 14 ++++++++++++++ src/autowiring/AutoPacketGraph.cpp | 14 +++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index e7b2c5444..ed4fae3a0 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -67,6 +67,20 @@ class AutoPacketGraph: // Reference to the AutoPacketFactory AutoRequired m_factory; + /// + /// Demangle a type name as well as stripping "auto_in< >" + /// + /// + /// The ">" that encloses the templates will have extra spaces between them, for instance + /// + /// auto_in + /// auto_in > + /// auto_in > > + /// + /// All we care about is matching "^auto_in<(.*)>$" + /// + std::string DemangleTypeName(const std::type_info* type_info) const; + /// /// Scan all of the objects and add any AutoFilter's from all of the objects in a system. /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index cf30d1c5c..b8132d837 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -12,6 +12,18 @@ AutoPacketGraph::AutoPacketGraph() { } +std::string AutoPacketGraph::DemangleTypeName(const std::type_info* type_info) const { + std::string demangled = autowiring::demangle(type_info); + + size_t demangledLength = demangled.length(); + size_t newLength = + demangled[demangledLength - 2] == ' ' ? + demangledLength - 10 : + demangledLength - 9; + + return demangled.substr(demangled.find("<") + 1, newLength); +} + void AutoPacketGraph::LoadEdges() { std::lock_guard lk(m_lock); @@ -116,7 +128,7 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const { continue; } - std::string typeName = autowiring::demangle(type); + std::string typeName = DemangleTypeName(type); std::string descriptorName = autowiring::demangle(descType); // Get a unique set of types/descriptors From f9a12da9475a640235a9fc817c8d215fd517acba Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Mon, 22 Dec 2014 16:45:47 -0800 Subject: [PATCH 52/57] Adding an optional parameter to add the number of times a packet was delivered --- autowiring/AutoPacketGraph.h | 8 +++++++- src/autowiring/AutoPacketGraph.cpp | 12 +++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index ed4fae3a0..1edbdd02b 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -117,5 +117,11 @@ class AutoPacketGraph: /// /// Write the graph to a file in graphviz format /// - bool WriteGV(const std::string& filename) const; + /// + /// The name of the file to write the graph to + /// + /// + /// Include the number of times the packet was delivered + /// + bool WriteGV(const std::string& filename, bool numPackets = false) const; }; diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index b8132d837..9aa43183b 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -102,7 +102,7 @@ AutoPacketGraph::t_deliveryEdges AutoPacketGraph::GetEdgeCounts() const { return m_deliveryGraph; } -bool AutoPacketGraph::WriteGV(const std::string& filename) const { +bool AutoPacketGraph::WriteGV(const std::string& filename, bool numPackets) const { std::ofstream file(filename); if (!file && !file.good()) { return false; @@ -142,13 +142,15 @@ bool AutoPacketGraph::WriteGV(const std::string& filename) const { std::stringstream ss; ss << " \""; if (edge.input) { - ss << typeName << "\" -> \"" << descriptorName; + ss << typeName << "\" -> \"" << descriptorName << "\""; } else { - ss << descriptorName << "\" -> \"" << typeName; + ss << descriptorName << "\" -> \"" << typeName << "\""; } - // TODO: count should probably be optional - ss << "\" [label=\"" << count << "\"];" << std::endl; + if (numPackets) + ss << "[label=\"" << count << "\"];"; + + ss << std::endl; file << ss.str(); } From ac79d4e87f292885699b0f5f1eb0879bcf35a392 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Mon, 22 Dec 2014 17:53:38 -0800 Subject: [PATCH 53/57] More tests --- src/autowiring/AutoPacketGraph.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index 9aa43183b..cec5111e8 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -90,6 +90,12 @@ void AutoPacketGraph::AutoFilter(AutoPacket& packet) { } for (auto& subscriber : decoration.m_subscribers) { + // Skip the AutoPacketGraph + const std::type_info& descType = m_factory->GetContext()->GetAutoTypeId(subscriber->GetAutoFilter()); + if (descType == typeid(AutoPacketGraph)) { + continue; + } + if (subscriber->called) { RecordDelivery(type, *subscriber, true); } From a7d451915a42f89fb76e9999624aaa696f97098b Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 23 Dec 2014 00:25:13 -0800 Subject: [PATCH 54/57] adding 2 quick tests --- src/autowiring/test/AutoPacketGraphTest.cpp | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp index 62b94a7d4..dfb43a7ee 100644 --- a/src/autowiring/test/AutoPacketGraphTest.cpp +++ b/src/autowiring/test/AutoPacketGraphTest.cpp @@ -82,6 +82,41 @@ TEST_F(AutoPacketGraphTest, VerifySimpleEdgeFromObjectBeforeInit) { ctxt->SignalShutdown(); } +TEST_F(AutoPacketGraphTest, VerifySimpleEdgeFromNewObject) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); + + AutoRequired graph; + + ctxt->Initiate(); + + ASSERT_TRUE(graph->GetEdgeCounts().empty()) + << "Graph should still be empty before context is initialized"; + + AutoRequired receiver1; + + ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) + << "Graph did not detect AutoFilter from object after being initiated"; + + ctxt->SignalShutdown(); +} + +TEST_F(AutoPacketGraphTest, VerifyLoadGraphAfterInitAndObject) { + AutoCreateContext ctxt; + CurrentContextPusher pshr(ctxt); + + AutoRequired receiver1; + + ctxt->Initiate(); + + AutoRequired graph; + + ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) + << "Graph did not detect AutoFilter from object after being initiated"; + + ctxt->SignalShutdown(); +} + TEST_F(AutoPacketGraphTest, VerifySimpleInputFilter) { // TODO } @@ -110,6 +145,12 @@ TEST_F(AutoPacketGraphTest, VerifyLoadAutoFilterSystem) { AutoPacketGraph::t_deliveryEdges edges = graph->GetEdgeCounts(); + { + auto packet = factory->NewPacket(); + packet->Decorate(Decoration<0>(0)); + packet->Decorate(Decoration<2>(2)); + } + ASSERT_EQ(7UL, edges.size()) << "Graph could not load the edges from new objects"; @@ -117,5 +158,7 @@ TEST_F(AutoPacketGraphTest, VerifyLoadAutoFilterSystem) { ASSERT_EQ(0UL, itr.second) << "Coutn should be 0 since packets have not been delivered yet"; } + + ctxt->SignalShutdown(); } From fff21daefbaeeb1fe43564f9283e0506effa71de Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 23 Dec 2014 00:27:08 -0800 Subject: [PATCH 55/57] Removing the GetEdges() API until the feature is more defined. As a result, removing the unit tests as well. --- autowiring/AutoPacketGraph.h | 5 - src/autowiring/AutoPacketGraph.cpp | 4 - src/autowiring/test/AutoPacketGraphTest.cpp | 164 -------------------- src/autowiring/test/CMakeLists.txt | 1 - 4 files changed, 174 deletions(-) delete mode 100644 src/autowiring/test/AutoPacketGraphTest.cpp diff --git a/autowiring/AutoPacketGraph.h b/autowiring/AutoPacketGraph.h index 1edbdd02b..cc29f67ce 100644 --- a/autowiring/AutoPacketGraph.h +++ b/autowiring/AutoPacketGraph.h @@ -109,11 +109,6 @@ class AutoPacketGraph: /// void AutoFilter(AutoPacket& packet); - /// - /// Get a mapping of the DeliveryEdge to the number of times the AutoFilter was called - /// - t_deliveryEdges GetEdgeCounts() const; - /// /// Write the graph to a file in graphviz format /// diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index cec5111e8..b3820eea9 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -104,10 +104,6 @@ void AutoPacketGraph::AutoFilter(AutoPacket& packet) { }); } -AutoPacketGraph::t_deliveryEdges AutoPacketGraph::GetEdgeCounts() const { - return m_deliveryGraph; -} - bool AutoPacketGraph::WriteGV(const std::string& filename, bool numPackets) const { std::ofstream file(filename); if (!file && !file.good()) { diff --git a/src/autowiring/test/AutoPacketGraphTest.cpp b/src/autowiring/test/AutoPacketGraphTest.cpp deleted file mode 100644 index dfb43a7ee..000000000 --- a/src/autowiring/test/AutoPacketGraphTest.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. -#include "stdafx.h" -#include "TestFixtures/Decoration.hpp" -#include -#include -#include CHRONO_HEADER -#include THREAD_HEADER - -class AutoPacketGraphTest: - public testing::Test -{}; - -class APReceiver1 { -public: - APReceiver1(void) {} - void AutoFilter(Decoration<0> d0) { } -}; - -class APReceiver2 { -public: - APReceiver2(void) {} - void AutoFilter(Decoration<0> d0, Decoration<1>& d1) { } -}; - -class APReceiver3 { -public: - APReceiver3(void) {} - void AutoFilter(Decoration<0> d0, Decoration<1> d1) { } -}; - -class APReceiver4 { -public: - APReceiver4(void) {} - void AutoFilter(Decoration<0> d0, Decoration<2> d2) { } -}; - - -TEST_F(AutoPacketGraphTest, VerifyEmptyGraphBeforeCtxtInit) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - AutoRequired graph; - ASSERT_TRUE(graph->GetEdgeCounts().empty()) - << "Graph did not start out empty before context initiation"; - - ctxt->Initiate(); - - ASSERT_TRUE(graph->GetEdgeCounts().empty()) - << "Graph did not stay empty after context initiation"; - - ctxt->SignalShutdown(); -} - -TEST_F(AutoPacketGraphTest, VerifyEmptyGraphAfterCtxtInit) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - ctxt->Initiate(); - - AutoRequired graph; - ASSERT_TRUE(graph->GetEdgeCounts().empty()) - << "Graph did not start out empty"; - - ctxt->SignalShutdown(); -} - -TEST_F(AutoPacketGraphTest, VerifySimpleEdgeFromObjectBeforeInit) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - AutoRequired graph; - AutoRequired receiver1; - - ASSERT_TRUE(graph->GetEdgeCounts().empty()) - << "Graph should still be empty before context is initialized"; - - ctxt->Initiate(); - - ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) - << "Graph did not detect AutoFilter from object after being initiated"; - - ctxt->SignalShutdown(); -} - -TEST_F(AutoPacketGraphTest, VerifySimpleEdgeFromNewObject) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - AutoRequired graph; - - ctxt->Initiate(); - - ASSERT_TRUE(graph->GetEdgeCounts().empty()) - << "Graph should still be empty before context is initialized"; - - AutoRequired receiver1; - - ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) - << "Graph did not detect AutoFilter from object after being initiated"; - - ctxt->SignalShutdown(); -} - -TEST_F(AutoPacketGraphTest, VerifyLoadGraphAfterInitAndObject) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - AutoRequired receiver1; - - ctxt->Initiate(); - - AutoRequired graph; - - ASSERT_EQ(1UL, graph->GetEdgeCounts().size()) - << "Graph did not detect AutoFilter from object after being initiated"; - - ctxt->SignalShutdown(); -} - -TEST_F(AutoPacketGraphTest, VerifySimpleInputFilter) { - // TODO -} - -TEST_F(AutoPacketGraphTest, VerifySimpleOutputFilter) { - // TODO -} - -TEST_F(AutoPacketGraphTest, VerifyPacketDecorationIncrementingCount) { - // TODO -} - -TEST_F(AutoPacketGraphTest, VerifyLoadAutoFilterSystem) { - AutoCreateContext ctxt; - CurrentContextPusher pshr(ctxt); - - AutoRequired factory(ctxt); - AutoRequired graph; - - ctxt->Initiate(); - - AutoRequired receiver1; - AutoRequired receiver2; - AutoRequired receiver3; - AutoRequired receiver4; - - AutoPacketGraph::t_deliveryEdges edges = graph->GetEdgeCounts(); - - { - auto packet = factory->NewPacket(); - packet->Decorate(Decoration<0>(0)); - packet->Decorate(Decoration<2>(2)); - } - - ASSERT_EQ(7UL, edges.size()) - << "Graph could not load the edges from new objects"; - - for (auto& itr : edges) { - ASSERT_EQ(0UL, itr.second) - << "Coutn should be 0 since packets have not been delivered yet"; - } - - ctxt->SignalShutdown(); -} - diff --git a/src/autowiring/test/CMakeLists.txt b/src/autowiring/test/CMakeLists.txt index 91e8e9071..d7223e1eb 100644 --- a/src/autowiring/test/CMakeLists.txt +++ b/src/autowiring/test/CMakeLists.txt @@ -7,7 +7,6 @@ set(AutowiringTest_SRCS AutoFilterDiagnosticsTest.cpp AutoInjectableTest.cpp AutoPacketFactoryTest.cpp - AutoPacketGraphTest.cpp AutoParameterTest.cpp AutoRestarterTest.cpp AutowiringTest.cpp From e10f2959b19cd0cc43e441c4e16edb5a7e129113 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Tue, 23 Dec 2014 07:02:58 -0800 Subject: [PATCH 56/57] Added missing copyright notice --- src/autowiring/test/AutoFilterDiagnosticsTest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autowiring/test/AutoFilterDiagnosticsTest.cpp b/src/autowiring/test/AutoFilterDiagnosticsTest.cpp index 58e2d35f6..e4e190656 100644 --- a/src/autowiring/test/AutoFilterDiagnosticsTest.cpp +++ b/src/autowiring/test/AutoFilterDiagnosticsTest.cpp @@ -1,3 +1,4 @@ +// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. #include "stdafx.h" #include #include From 5a94dc54667cc6b397a324357286639b100a2820 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Tue, 23 Dec 2014 07:08:57 -0800 Subject: [PATCH 57/57] Added missing header file reference --- src/autowiring/AutoPacketGraph.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autowiring/AutoPacketGraph.cpp b/src/autowiring/AutoPacketGraph.cpp index b3820eea9..e92ed348e 100644 --- a/src/autowiring/AutoPacketGraph.cpp +++ b/src/autowiring/AutoPacketGraph.cpp @@ -5,6 +5,7 @@ #include "DecorationDisposition.h" #include "demangle.h" #include "SatCounter.h" +#include #include #include #include FUNCTIONAL_HEADER