From e7923af18500bfbe19415ce979455d2e87ca7efb Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 10 May 2017 09:37:37 +0100 Subject: [PATCH] Got rid of the old PARAMETER_TYPE macro - this isn't needed as the same thing can be done directly with the TypeHelpers::ParameterType helper class --- modules/juce_core/containers/juce_Array.h | 2 +- .../containers/juce_ElementComparator.h | 2 +- modules/juce_core/containers/juce_HashMap.h | 4 ++-- modules/juce_core/maths/juce_MathsFunctions.h | 24 ++++++++++--------- .../mouse/juce_SelectedItemSet.h | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index aaa6a1330b..ca024a9c2c 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -53,7 +53,7 @@ template ::type ParameterType; public: //============================================================================== diff --git a/modules/juce_core/containers/juce_ElementComparator.h b/modules/juce_core/containers/juce_ElementComparator.h index f319b5552b..3f5881c1d1 100644 --- a/modules/juce_core/containers/juce_ElementComparator.h +++ b/modules/juce_core/containers/juce_ElementComparator.h @@ -175,7 +175,7 @@ template class DefaultElementComparator { private: - typedef PARAMETER_TYPE (ElementType) ParameterType; + typedef typename TypeHelpers::ParameterType::type ParameterType; public: static int compareElements (ParameterType first, ParameterType second) diff --git a/modules/juce_core/containers/juce_HashMap.h b/modules/juce_core/containers/juce_HashMap.h index 892851193e..350944a192 100644 --- a/modules/juce_core/containers/juce_HashMap.h +++ b/modules/juce_core/containers/juce_HashMap.h @@ -93,8 +93,8 @@ template ::type KeyTypeParameter; + typedef typename TypeHelpers::ParameterType::type ValueTypeParameter; public: //============================================================================== diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 0a54c96fe3..27458c5fe3 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -585,10 +585,7 @@ namespace TypeHelpers Of course, this is only likely to be useful in certain esoteric template situations. - Because "typename TypeHelpers::ParameterType::type" is a bit of a mouthful, there's - a PARAMETER_TYPE(SomeClass) macro that you can use to get the same effect. - - E.g. "myFunction (PARAMETER_TYPE (int), PARAMETER_TYPE (MyObject))" + E.g. "myFunction (typename TypeHelpers::ParameterType::type, typename TypeHelpers::ParameterType::type)" would evaluate to "myfunction (int, const MyObject&)", keeping any primitive types as pass-by-value, but passing objects as a const reference, to avoid copying. */ @@ -612,16 +609,21 @@ namespace TypeHelpers template <> struct ParameterType { typedef double type; }; #endif - /** A helpful macro to simplify the use of the ParameterType template. - @see ParameterType - */ - #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType::type - /** These templates are designed to take a type, and if it's a double, they return a double type; for anything else, they return a float type. */ - template struct SmallestFloatType { typedef float type; }; - template <> struct SmallestFloatType { typedef double type; }; + template struct SmallestFloatType { typedef float type; }; + template <> struct SmallestFloatType { typedef double type; }; + + + /** These templates are designed to take an integer type, and return an unsigned int + version with the same size. + */ + template struct UnsignedTypeWithSize {}; + template <> struct UnsignedTypeWithSize<1> { typedef uint8 type; }; + template <> struct UnsignedTypeWithSize<2> { typedef uint16 type; }; + template <> struct UnsignedTypeWithSize<4> { typedef uint32 type; }; + template <> struct UnsignedTypeWithSize<8> { typedef uint64 type; }; } diff --git a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index c7d50833cd..c78c970727 100644 --- a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -47,7 +47,7 @@ public: //============================================================================== typedef SelectableItemType ItemType; typedef Array ItemArray; - typedef PARAMETER_TYPE (SelectableItemType) ParameterType; + typedef typename TypeHelpers::ParameterType::type ParameterType; //============================================================================== /** Creates an empty set. */