1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Removed some defunct code from the C++1 feature detection macros, and simplified code which no longer needs to test for feature availability

This commit is contained in:
jules 2018-01-10 11:43:18 +00:00
parent e5ddf29bf9
commit 8d09eaadb6
25 changed files with 76 additions and 148 deletions

View file

@ -94,7 +94,7 @@ public:
private:
//==============================================================================
Target& operator= (const Target&) JUCE_DELETED_FUNCTION;
Target& operator= (const Target&) = delete;
};
virtual bool supportsTargetType (Target::Type /*targetType*/) const { return false; }

View file

@ -1675,7 +1675,7 @@ public:
//==============================================================================
const XcodeProjectExporter& owner;
Target& operator= (const Target&) JUCE_DELETED_FUNCTION;
Target& operator= (const Target&) = delete;
};
mutable StringArray xcodeFrameworks;

View file

@ -68,10 +68,6 @@
#define JUCE_VIEWCONTROLLER_OBJC_NAME(x) JUCE_JOIN_MACRO (x, FactoryAUv3)
#if ! JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
#error AUv3 wrapper requires variadic template support
#endif
#if JUCE_IOS
#define JUCE_IOS_MAC_VIEW UIView
#else
@ -122,9 +118,9 @@ struct AudioProcessorHolder : public ReferenceCountedObject
private:
ScopedPointer<AudioProcessor> processor;
AudioProcessorHolder& operator= (AudioProcessor*) JUCE_DELETED_FUNCTION;
AudioProcessorHolder (AudioProcessorHolder&) JUCE_DELETED_FUNCTION;
AudioProcessorHolder& operator= (AudioProcessorHolder&) JUCE_DELETED_FUNCTION;
AudioProcessorHolder& operator= (AudioProcessor*) = delete;
AudioProcessorHolder (AudioProcessorHolder&) = delete;
AudioProcessorHolder& operator= (AudioProcessorHolder&) = delete;
};
//==============================================================================

View file

@ -106,7 +106,7 @@ private:
ScopedPointer<AudioProcessor> audioProcessor;
ScopedJuceInitialiser_GUI libraryInitialiser;
JuceAudioProcessor() JUCE_DELETED_FUNCTION;
JuceAudioProcessor() = delete;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceAudioProcessor)
};

View file

@ -39,7 +39,7 @@
#endif
#ifndef JUCE_SUPPORTS_AUv3
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES && __OBJC2__ \
#if __OBJC2__ \
&& ((defined (MAC_OS_X_VERSION_MIN_REQUIRED) && defined (MAC_OS_X_VERSION_10_11) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11)) \
|| (defined (__IPHONE_OS_VERSION_MIN_REQUIRED) && defined (__IPHONE_9_0) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0)))
#define JUCE_SUPPORTS_AUv3 1

View file

@ -39,7 +39,7 @@ struct SortFunctionConverter
private:
ElementComparator& comparator;
SortFunctionConverter& operator= (const SortFunctionConverter&) JUCE_DELETED_FUNCTION;
SortFunctionConverter& operator= (const SortFunctionConverter&) = delete;
};
#endif

View file

@ -455,7 +455,7 @@ public:
int index;
// using the copy constructor is ok, but you cannot assign iterators
Iterator& operator= (const Iterator&) JUCE_DELETED_FUNCTION;
Iterator& operator= (const Iterator&) = delete;
JUCE_LEAK_DETECTOR (Iterator)
};

View file

@ -126,7 +126,7 @@ public:
private:
//==============================================================================
JSON() JUCE_DELETED_FUNCTION; // This class can't be instantiated - just use its static methods.
JSON() = delete; // This class can't be instantiated - just use its static methods.
};
} // namespace juce

View file

@ -129,7 +129,7 @@ public:
JUCE_CONSTEXPR static bool isBigEndian() noexcept;
private:
ByteOrder() JUCE_DELETED_FUNCTION;
ByteOrder() = delete;
JUCE_DECLARE_NON_COPYABLE (ByteOrder)
};

View file

@ -181,7 +181,7 @@ private:
// a scoped pointer, which is almost certainly not what you intended to do!
// If you hit a problem with this, you probably meant to say
// myPointer.setOwned (myScopedPointer.release())
void setOwned (const ScopedPointer<ObjectType>&) JUCE_DELETED_FUNCTION;
void setOwned (const ScopedPointer<ObjectType>&) = delete;
};
} // namespace juce

View file

@ -127,7 +127,7 @@ public:
JUCE_DEPRECATED (static bool keyExistsWow64 (const String&));
private:
WindowsRegistry() JUCE_DELETED_FUNCTION;
WindowsRegistry() = delete;
JUCE_DECLARE_NON_COPYABLE (WindowsRegistry)
};

View file

@ -204,7 +204,6 @@ static NSRect makeNSRect (const RectangleType& r) noexcept
}
#endif
#if JUCE_MAC || JUCE_IOS
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
// This is necessary as on iOS builds, some arguments may be passed on registers
// depending on the argument type. The re-cast objc_msgSendSuper to a function
@ -217,8 +216,6 @@ static inline ReturnValue ObjCMsgSendSuper (struct objc_super* s, SEL sel, Param
return fn (s, sel, params...);
}
#endif
// These hacks are a workaround for newer Xcode builds which by default prevent calls to these objc functions..
typedef id (*MsgSendSuperFn) (struct objc_super*, SEL, ...);
static inline MsgSendSuperFn getMsgSendSuperFn() noexcept { return (MsgSendSuperFn) (void*) objc_msgSendSuper; }
@ -399,8 +396,6 @@ Class* getJuceClassFromNSObject (NSObject* obj)
return obj != nullptr ? ObjCLifetimeManagedClass<Class>:: template getIvar<Class*> (obj, "cppObject") : nullptr;
}
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
template <typename ReturnT, class Class, typename... Params>
ReturnT (^CreateObjCBlock(Class* object, ReturnT (Class::*fn)(Params...))) (Params...)
{
@ -429,6 +424,5 @@ private:
BlockType block;
};
#endif
} // namespace juce

View file

@ -22,29 +22,25 @@
#pragma once
/* This file has some checks to see whether the compiler supports various C++11/14 features,
When these aren't available, the code defines a few workarounds, so that we can still use
some of the newer language features like nullptr and noexcept, even on old compilers.
/*
This file provides flags for compiler features that aren't supported on all platforms.
*/
//==============================================================================
// GCC
#if (__cplusplus >= 201103L || defined (__GXX_EXPERIMENTAL_CXX0X__)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
#if JUCE_GCC
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
#error "JUCE requires GCC 4.7 or later"
#endif
#if ! (__cplusplus >= 201103L || defined (__GXX_EXPERIMENTAL_CXX0X__))
#error "JUCE requires that GCC has C++11 compatibility enabled"
#endif
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1
#define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL)
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#endif
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_DELETED_FUNCTION)
#define JUCE_DELETED_FUNCTION = delete
#endif
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
#define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1
#endif
#define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1
#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500
#define JUCE_HAS_CONSTEXPR 1
@ -59,36 +55,20 @@
//==============================================================================
// Clang
#if JUCE_CLANG && defined (__has_feature)
#if JUCE_CLANG
#if __has_feature (cxx_noexcept)
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#if __clang_major__ < 5
#error "JUCE requires Clang 5.0 or later"
#endif
#if __has_feature (cxx_deleted_functions)
#define JUCE_DELETED_FUNCTION = delete
#endif
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#define JUCE_HAS_CONSTEXPR 1
#if (defined (_LIBCPP_VERSION) || ! (JUCE_MAC || JUCE_IOS))
#if defined (_LIBCPP_VERSION) || ! (JUCE_MAC || JUCE_IOS)
#define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1
#endif
#if __has_feature (cxx_generalized_initializers) && (defined (_LIBCPP_VERSION) || ! (JUCE_MAC || JUCE_IOS))
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1
#endif
#if __has_feature (cxx_variadic_templates)
#define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1
#endif
#if __has_feature (cxx_override_control) && (! defined (JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL))
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#endif
#if __has_feature(cxx_constexpr)
#define JUCE_HAS_CONSTEXPR 1
#endif
#ifndef JUCE_COMPILER_SUPPORTS_ARC
#define JUCE_COMPILER_SUPPORTS_ARC 1
#endif
@ -103,22 +83,22 @@
//==============================================================================
// MSVC
#ifdef _MSC_VER
#if JUCE_MSVC
#if _MSC_VER >= 1700
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#if _MSC_VER < 1800 // VS2013
#error "JUCE requires Visual Studio 2013 or later"
#endif
#if _MSC_VER >= 1800
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1
#define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1
#define JUCE_DELETED_FUNCTION = delete
#define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1
#endif
#define JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS 1
#define JUCE_STDLIB_HAS_STD_FUNCTION_SUPPORT 1
#if _MSC_VER >= 1900
#if _MSC_VER >= 1900 // VS2015
#define JUCE_COMPILER_SUPPORTS_NOEXCEPT 1
#define JUCE_HAS_CONSTEXPR 1
#else
#define _ALLOW_KEYWORD_MACROS 1 // prevent a warning
#undef noexcept
#define noexcept throw()
#endif
#ifndef JUCE_EXCEPTIONS_DISABLED
@ -129,17 +109,6 @@
#endif
//==============================================================================
// Declare some fake versions of nullptr and noexcept, for older compilers:
#ifndef JUCE_DELETED_FUNCTION
/** This macro can be placed after a method declaration to allow the use of
the C++11 feature "= delete" on all compilers.
On newer compilers that support it, it does the C++11 "= delete", but on
older ones it's just an empty definition.
*/
#define JUCE_DELETED_FUNCTION
#endif
#if JUCE_HAS_CONSTEXPR
#define JUCE_CONSTEXPR constexpr
#else
@ -147,20 +116,10 @@
#endif
#if ! DOXYGEN
#if ! JUCE_COMPILER_SUPPORTS_NOEXCEPT
#ifdef noexcept
#undef noexcept
#endif
#define noexcept throw()
#if defined (_MSC_VER) && _MSC_VER > 1600
#define _ALLOW_KEYWORD_MACROS 1 // (to stop VC2012 complaining)
#endif
#endif
#if ! JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL
#undef override
#define override
#endif
// These are old flags that are now supported on all compatible build targets
#define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#define JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES 1
#define JUCE_DELETED_FUNCTION = delete
#endif
//==============================================================================

View file

@ -191,8 +191,8 @@ namespace juce
};@endcode
*/
#define JUCE_DECLARE_NON_COPYABLE(className) \
className (const className&) JUCE_DELETED_FUNCTION;\
className& operator= (const className&) JUCE_DELETED_FUNCTION;
className (const className&) = delete;\
className& operator= (const className&) = delete;
/** This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and
JUCE_LEAK_DETECTOR macro for a class.
@ -206,8 +206,8 @@ namespace juce
*/
#define JUCE_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new (size_t) JUCE_DELETED_FUNCTION; \
static void operator delete (void*) JUCE_DELETED_FUNCTION;
static void* operator new (size_t) = delete; \
static void operator delete (void*) = delete;
//==============================================================================
#if JUCE_MSVC && ! defined (DOXYGEN)

View file

@ -185,21 +185,12 @@
#ifdef __clang__
#define JUCE_CLANG 1
#if ((! __has_feature (cxx_nullptr)) || (! __has_feature (cxx_rvalue_references)) || (! __has_feature (cxx_static_assert)))
#error "Clang 3.2 and earlier are no longer supported!"
#endif
#elif defined (__GNUC__)
#define JUCE_GCC 1
#if (__cplusplus < 201103L && (! defined (__GXX_EXPERIMENTAL_CXX0X__))) || ((__GNUC__ * 100 + __GNUC_MINOR__) < 406)
#error "GCC 4.5 and earlier are no longer supported!"
#endif
#elif defined (_MSC_VER)
#define JUCE_MSVC 1
#if _MSC_VER < 1600
#error "Visual Studio 2008 and earlier are no longer supported!"
#endif
#else
#error unknown compiler
#endif

View file

@ -62,7 +62,7 @@ static const EmptyString emptyString = { 0x3fffffff, sizeof (String::CharPointer
class StringHolder
{
public:
StringHolder() JUCE_DELETED_FUNCTION;
StringHolder() = delete;
typedef String::CharPointerType CharPointerType;
typedef String::CharPointerType::CharType CharType;

View file

@ -734,7 +734,7 @@ private:
String value;
private:
XmlAttributeNode& operator= (const XmlAttributeNode&) JUCE_DELETED_FUNCTION;
XmlAttributeNode& operator= (const XmlAttributeNode&) = delete;
};
friend class XmlDocument;
@ -758,7 +758,7 @@ private:
// Sigh.. L"" or _T("") string literals are problematic in general, and really inappropriate
// for XML tags. Use a UTF-8 encoded literal instead, or if you're really determined to use
// UTF-16, cast it to a String and use the other constructor.
XmlElement (const wchar_t*) JUCE_DELETED_FUNCTION;
XmlElement (const wchar_t*) = delete;
JUCE_LEAK_DETECTOR (XmlElement)
};

View file

@ -111,7 +111,7 @@ private:
// This private constructor is declared here to prevent you accidentally passing a
// String and having it unexpectedly call the constructor that takes a File.
explicit MD5 (const String&) JUCE_DELETED_FUNCTION;
explicit MD5 (const String&) = delete;
JUCE_LEAK_DETECTOR (MD5)
};

View file

@ -227,11 +227,11 @@ private:
// This is disallowed to avoid confusion about whether it should
// do a by-value or by-reference copy.
Value& operator= (const Value&) JUCE_DELETED_FUNCTION;
Value& operator= (const Value&) = delete;
// This declaration prevents accidental construction from an integer of 0,
// which is possible in some compilers via an implicit cast to a pointer.
explicit Value (void*) JUCE_DELETED_FUNCTION;
explicit Value (void*) = delete;
};
/** Writes a Value to an OutputStream as a UTF8 string. */

View file

@ -2374,7 +2374,7 @@ private:
// This is included here to cause an error if you use or overload it - it has been deprecated in
// favour of contains (Point<int>)
void contains (int, int) JUCE_DELETED_FUNCTION;
void contains (int, int) = delete;
#endif
protected:

View file

@ -1686,7 +1686,7 @@ private:
deltaAngle = fmod (deltaAngle, MathConstants<double>::twoPi);
}
SVGState& operator= (const SVGState&) JUCE_DELETED_FUNCTION;
SVGState& operator= (const SVGState&) = delete;
};

View file

@ -213,7 +213,7 @@ public:
#endif
private:
NativeMessageBox() JUCE_DELETED_FUNCTION;
NativeMessageBox() = delete;
JUCE_DECLARE_NON_COPYABLE (NativeMessageBox)
};

View file

@ -152,7 +152,6 @@ public:
}
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
beginTest ("Initialisation with argument list (C++11 only)");
{
int testInt = 42;
@ -197,7 +196,6 @@ public:
expectEquals (msg[4].getInt32(), testInt);
}
}
#endif
}
};

View file

@ -53,7 +53,6 @@ public:
OSCMessage (const OSCAddressPattern& ap) noexcept;
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
/** Constructs an OSCMessage object with the given address pattern and list
of arguments.
@ -68,7 +67,6 @@ public:
*/
template <typename Arg1, typename... Args>
OSCMessage (const OSCAddressPattern& ap, Arg1&& arg1, Args&&... args);
#endif
/** Sets the address pattern of the OSCMessage.
@ -143,7 +141,6 @@ public:
private:
//==============================================================================
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
template <typename Arg1, typename... Args>
void addArguments (Arg1&& arg1, Args&&... args)
{
@ -152,7 +149,6 @@ private:
}
void addArguments() {}
#endif
//==============================================================================
OSCAddressPattern addressPattern;
@ -161,13 +157,11 @@ private:
//==============================================================================
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
template <typename Arg1, typename... Args>
OSCMessage::OSCMessage (const OSCAddressPattern& ap, Arg1&& arg1, Args&&... args)
: addressPattern (ap)
{
addArguments (std::forward<Arg1> (arg1), std::forward<Args> (args)...);
}
#endif
template <typename Arg1, typename... Args>
OSCMessage::OSCMessage (const OSCAddressPattern& ap, Arg1&& arg1, Args&&... args)
: addressPattern (ap)
{
addArguments (std::forward<Arg1> (arg1), std::forward<Args> (args)...);
}
} // namespace juce

View file

@ -113,7 +113,6 @@ public:
bool sendToIPAddress (const String& targetIPAddress, int targetPortNumber,
const OSCBundle& bundle);
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
/** Creates a new OSC message with the specified address pattern and list
of arguments, and sends it to the target.
@ -136,7 +135,6 @@ public:
template <typename... Args>
bool sendToIPAddress (const String& targetIPAddress, int targetPortNumber,
const OSCAddressPattern& address, Args&&... args);
#endif
private:
//==============================================================================
@ -150,19 +148,17 @@ private:
//==============================================================================
#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
template <typename... Args>
bool OSCSender::send (const OSCAddressPattern& address, Args&&... args)
{
return send (OSCMessage (address, std::forward<Args> (args)...));
}
template <typename... Args>
bool OSCSender::send (const OSCAddressPattern& address, Args&&... args)
{
return send (OSCMessage (address, std::forward<Args> (args)...));
}
template <typename... Args>
bool OSCSender::sendToIPAddress (const String& targetIPAddress, int targetPortNumber,
const OSCAddressPattern& address, Args&&... args)
{
return sendToIPAddress (targetIPAddress, targetPortNumber, OSCMessage (address, std::forward<Args> (args)...));
}
#endif // JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES
template <typename... Args>
bool OSCSender::sendToIPAddress (const String& targetIPAddress, int targetPortNumber,
const OSCAddressPattern& address, Args&&... args)
{
return sendToIPAddress (targetIPAddress, targetPortNumber, OSCMessage (address, std::forward<Args> (args)...));
}
} // namespace juce