From 8ccbf63f28efe0cd8672dfc1d0b993027cb02ab3 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 25 Apr 2017 21:51:44 +0100 Subject: [PATCH] Removed Ptr, Shared and SharedImpl --- CMakeLists.txt | 4 - include/internal/catch_context.h | 2 +- include/internal/catch_impl.hpp | 1 - include/internal/catch_interfaces_config.h | 5 +- .../internal/catch_interfaces_registry_hub.h | 3 +- include/internal/catch_interfaces_reporter.h | 1 - include/internal/catch_interfaces_testcase.h | 3 +- include/internal/catch_ptr.hpp | 93 ------------------- include/internal/catch_test_case_info.h | 2 +- .../catch_test_case_registry_impl.hpp | 2 +- include/internal/catch_test_case_tracker.hpp | 2 +- include/internal/catch_test_registry.hpp | 2 +- include/reporters/catch_reporter_bases.hpp | 4 +- include/reporters/catch_reporter_multi.hpp | 2 +- projects/SelfTest/SurrogateCpps/catch_ptr.cpp | 3 - 15 files changed, 14 insertions(+), 115 deletions(-) delete mode 100644 include/internal/catch_ptr.hpp delete mode 100644 projects/SelfTest/SurrogateCpps/catch_ptr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 61cdc09c..dfea23cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,6 @@ set(IMPL_SOURCES ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp - ${SELF_TEST_DIR}/SurrogateCpps/catch_ptr.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp @@ -152,8 +151,6 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_interfaces_runner.h ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h ${HEADER_DIR}/internal/catch_interfaces_testcase.h - ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.h - ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.hpp ${HEADER_DIR}/internal/catch_list.hpp ${HEADER_DIR}/internal/catch_matchers.hpp ${HEADER_DIR}/internal/catch_matchers_string.h @@ -167,7 +164,6 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_objc_arc.hpp ${HEADER_DIR}/internal/catch_option.hpp ${HEADER_DIR}/internal/catch_platform.h - ${HEADER_DIR}/internal/catch_ptr.hpp ${HEADER_DIR}/internal/catch_reenable_warnings.h ${HEADER_DIR}/internal/catch_registry_hub.hpp ${HEADER_DIR}/internal/catch_reporter_registrars.hpp diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index 77a7d3ac..4dd48a2f 100644 --- a/include/internal/catch_context.h +++ b/include/internal/catch_context.h @@ -9,8 +9,8 @@ #define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED #include "catch_interfaces_generators.h" -#include "catch_ptr.hpp" +#include namespace Catch { diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 9dca5084..978ca1a4 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -47,7 +47,6 @@ namespace Catch { // These are all here to avoid warnings about not having any out of line // virtual methods NonCopyable::~NonCopyable() {} - IShared::~IShared() {} IStream::~IStream() noexcept {} FileStream::~FileStream() noexcept {} CoutStream::~CoutStream() noexcept {} diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h index d9479e07..4f64f4e3 100644 --- a/include/internal/catch_interfaces_config.h +++ b/include/internal/catch_interfaces_config.h @@ -8,11 +8,12 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED +#include "catch_common.h" + #include #include #include - -#include "catch_ptr.hpp" +#include namespace Catch { diff --git a/include/internal/catch_interfaces_registry_hub.h b/include/internal/catch_interfaces_registry_hub.h index 9a42fbad..fb7d87cf 100644 --- a/include/internal/catch_interfaces_registry_hub.h +++ b/include/internal/catch_interfaces_registry_hub.h @@ -8,9 +8,10 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED -#include "catch_ptr.hpp" +#include "catch_common.h" #include +#include namespace Catch { diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index b0af150f..7679c07a 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -11,7 +11,6 @@ #include "catch_section_info.h" #include "catch_common.h" #include "catch_totals.hpp" -#include "catch_ptr.hpp" #include "catch_config.hpp" #include "catch_test_case_info.h" #include "catch_assertionresult.h" diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h index 0c759166..c9ab3238 100644 --- a/include/internal/catch_interfaces_testcase.h +++ b/include/internal/catch_interfaces_testcase.h @@ -8,9 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED -#include "catch_ptr.hpp" - #include +#include namespace Catch { diff --git a/include/internal/catch_ptr.hpp b/include/internal/catch_ptr.hpp deleted file mode 100644 index 4197cf79..00000000 --- a/include/internal/catch_ptr.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Created by Phil on 02/05/2012. - * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. - * - * 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 TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED - -#include "catch_common.h" - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - // An intrusive reference counting smart pointer. - // T must implement addRef() and release() methods - // typically implementing the IShared interface - template - class Ptr { - public: - Ptr() : m_p( nullptr ){} - Ptr( T* p ) : m_p( p ){ - if( m_p ) - m_p->addRef(); - } - Ptr( Ptr const& other ) : m_p( other.m_p ){ - if( m_p ) - m_p->addRef(); - } - ~Ptr(){ - if( m_p ) - m_p->release(); - } - void reset() { - if( m_p ) - m_p->release(); - m_p = nullptr; - } - Ptr& operator = ( T* p ){ - Ptr temp( p ); - swap( temp ); - return *this; - } - Ptr& operator = ( Ptr const& other ){ - Ptr temp( other ); - swap( temp ); - return *this; - } - void swap( Ptr& other ) { std::swap( m_p, other.m_p ); } - T* get() const{ return m_p; } - T& operator*() const { return *m_p; } - T* operator->() const { return m_p; } - bool operator !() const { return m_p == nullptr; } - explicit operator bool() const { return m_p != nullptr; } - - private: - T* m_p; - }; - - struct IShared : NonCopyable { - virtual ~IShared(); - virtual void addRef() const = 0; - virtual void release() const = 0; - }; - - template - struct SharedImpl : T { - - SharedImpl() : m_rc( 0 ){} - - virtual void addRef() const { - ++m_rc; - } - virtual void release() const { - if( --m_rc == 0 ) - delete this; - } - - mutable unsigned int m_rc; - }; - -} // end namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif // TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h index ac83cb3f..1ff0c819 100644 --- a/include/internal/catch_test_case_info.h +++ b/include/internal/catch_test_case_info.h @@ -9,10 +9,10 @@ #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED #include "catch_common.h" -#include "catch_ptr.hpp" #include #include +#include #ifdef __clang__ #pragma clang diagnostic push diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index e5b1f281..cecbc253 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -127,7 +127,7 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////// - class FreeFunctionTestCase : public SharedImpl { + class FreeFunctionTestCase : public ITestCase { public: FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index 8b74e249..c7631384 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -9,7 +9,7 @@ #define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED #include "catch_compiler_capabilities.h" -#include "catch_ptr.hpp" +#include "catch_common.h" #include #include diff --git a/include/internal/catch_test_registry.hpp b/include/internal/catch_test_registry.hpp index b6d423c8..5be6f6d7 100644 --- a/include/internal/catch_test_registry.hpp +++ b/include/internal/catch_test_registry.hpp @@ -15,7 +15,7 @@ namespace Catch { template -class MethodTestCase : public SharedImpl { +class MethodTestCase : public ITestCase { public: MethodTestCase( void (C::*method)() ) : m_method( method ) {} diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index 371f9624..6782e8b3 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -41,7 +41,7 @@ namespace Catch { } - struct StreamingReporterBase : SharedImpl { + struct StreamingReporterBase : IStreamingReporter { StreamingReporterBase( ReporterConfig const& _config ) : m_config( _config.fullConfig() ), @@ -103,7 +103,7 @@ namespace Catch { ReporterPreferences m_reporterPrefs; }; - struct CumulativeReporterBase : SharedImpl { + struct CumulativeReporterBase : IStreamingReporter { template struct Node { explicit Node( T const& _value ) : value( _value ) {} diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp index 0fbba771..859e3f83 100644 --- a/include/reporters/catch_reporter_multi.hpp +++ b/include/reporters/catch_reporter_multi.hpp @@ -12,7 +12,7 @@ namespace Catch { -class MultipleReporters : public SharedImpl { +class MultipleReporters : public IStreamingReporter { typedef std::vector Reporters; Reporters m_reporters; diff --git a/projects/SelfTest/SurrogateCpps/catch_ptr.cpp b/projects/SelfTest/SurrogateCpps/catch_ptr.cpp deleted file mode 100644 index 90796ca1..00000000 --- a/projects/SelfTest/SurrogateCpps/catch_ptr.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "internal/catch_suppress_warnings.h" -#include "internal/catch_ptr.hpp"