From c17a72e5b13f46788198766cc08dbe0a58382ae4 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 27 Apr 2015 12:18:22 +0100 Subject: [PATCH] Minor clean-ups. --- .../components/jucer_TabbedComponentHandler.h | 108 +++++++++--------- modules/juce_core/memory/juce_HeapBlock.h | 26 ++--- .../windows/juce_ComponentPeer.cpp | 6 +- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h b/extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h index f1a09da8df..88c626dca3 100644 --- a/extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h +++ b/extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h @@ -42,7 +42,7 @@ public: XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) { - TabbedComponent* const t = dynamic_cast (comp); + TabbedComponent* const t = dynamic_cast (comp); XmlElement* const e = ComponentTypeHandler::createXmlFor (comp, layout); if (t->getOrientation() == TabbedButtonBar::TabsAtTop) e->setAttribute ("orientation", "top"); @@ -64,7 +64,7 @@ public: if (! ComponentTypeHandler::restoreFromXml (xml, comp, layout)) return false; - TabbedComponent* const t = dynamic_cast (comp); + TabbedComponent* const t = dynamic_cast (comp); if (xml.getStringAttribute ("orientation") == "top") t->setOrientation (TabbedButtonBar::TabsAtTop); else if (xml.getStringAttribute ("orientation") == "bottom") t->setOrientation (TabbedButtonBar::TabsAtBottom); @@ -92,7 +92,7 @@ public: { ComponentTypeHandler::getEditableProperties (component, doc, props); - TabbedComponent* const t = dynamic_cast (component); + TabbedComponent* const t = dynamic_cast (component); props.add (new TabOrientationProperty (t, doc)); props.add (new TabDepthProperty (t, doc)); @@ -110,11 +110,11 @@ public: { ComponentTypeHandler::addPropertiesToPropertyPanel (comp, doc, panel); - TabbedComponent* const t = dynamic_cast (comp); + TabbedComponent* const t = dynamic_cast (comp); for (int i = 0; i < t->getNumTabs(); ++i) { - Array properties; + Array properties; properties.add (new TabNameProperty (t, doc, i)); properties.add (new TabColourProperty (t, doc, i)); @@ -136,7 +136,7 @@ public: String getCreationParameters (GeneratedCode&, Component* comp) { - TabbedComponent* const t = dynamic_cast (comp); + TabbedComponent* const t = dynamic_cast (comp); switch (t->getOrientation()) { @@ -152,7 +152,7 @@ public: void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) { - TabbedComponent* const t = dynamic_cast (component); + TabbedComponent* const t = dynamic_cast (component); ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); @@ -223,7 +223,7 @@ public: xml->setAttribute ("name", tc->getTabNames() [tabIndex]); xml->setAttribute ("colour", tc->getTabBackgroundColour (tabIndex).toString()); - if (TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex))) + if (TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex))) { xml->setAttribute ("useJucerComp", tdc->isUsingJucerComp); xml->setAttribute ("contentClassName", tdc->contentClassName); @@ -239,11 +239,11 @@ public: tc->setTabName (tabIndex, xml.getStringAttribute ("name", "Tab")); tc->setTabBackgroundColour (tabIndex, Colour::fromString (xml.getStringAttribute ("colour", Colours::lightgrey.toString()))); - if (TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex))) + if (TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex))) { - tdc->isUsingJucerComp = xml.getBoolAttribute ("useJucerComp", false); - tdc->contentClassName = xml.getStringAttribute ("contentClassName"); - tdc->constructorParams = xml.getStringAttribute ("constructorParams"); + tdc->isUsingJucerComp = xml.getBoolAttribute ("useJucerComp", false); + tdc->contentClassName = xml.getStringAttribute ("contentClassName"); + tdc->constructorParams = xml.getStringAttribute ("constructorParams"); tdc->jucerComponentFile = xml.getStringAttribute ("jucerComponentFile"); tdc->updateContent(); @@ -253,7 +253,7 @@ public: //============================================================================== static bool isTabUsingJucerComp (TabbedComponent* tc, int tabIndex) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); return tdc != 0 && tdc->isUsingJucerComp; @@ -261,7 +261,7 @@ public: static void setTabUsingJucerComp (TabbedComponent* tc, int tabIndex, const bool b) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); if (tdc != nullptr) @@ -273,7 +273,7 @@ public: static String getTabClassName (TabbedComponent* tc, int tabIndex) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); return tdc != 0 ? tdc->contentClassName : String::empty; @@ -281,7 +281,7 @@ public: static void setTabClassName (TabbedComponent* tc, int tabIndex, const String& newName) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); if (tdc != nullptr) @@ -293,7 +293,7 @@ public: static String getTabConstructorParams (TabbedComponent* tc, int tabIndex) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); return tdc != 0 ? tdc->constructorParams : String::empty; @@ -301,7 +301,7 @@ public: static void setTabConstructorParams (TabbedComponent* tc, int tabIndex, const String& newParams) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); if (tdc != nullptr) @@ -313,7 +313,7 @@ public: static String getTabJucerFile (TabbedComponent* tc, int tabIndex) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); return tdc != 0 ? tdc->jucerComponentFile : String::empty; @@ -321,7 +321,7 @@ public: static void setTabJucerFile (TabbedComponent* tc, int tabIndex, const String& newFile) { - TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); + TabDemoContentComp* const tdc = dynamic_cast (tc->getTabContentComponent (tabIndex)); jassert (tdc != nullptr); if (tdc != nullptr) @@ -396,11 +396,11 @@ private: }; //============================================================================== - class TabOrientationProperty : public ComponentChoiceProperty + class TabOrientationProperty : public ComponentChoiceProperty { public: TabOrientationProperty (TabbedComponent* comp, JucerDocument& doc) - : ComponentChoiceProperty ("tab position", comp, doc) + : ComponentChoiceProperty ("tab position", comp, doc) { choices.add ("Tabs at top"); choices.add ("Tabs at bottom"); @@ -434,11 +434,11 @@ private: } private: - class TabOrienationChangeAction : public ComponentUndoableAction + class TabOrienationChangeAction : public ComponentUndoableAction { public: TabOrienationChangeAction (TabbedComponent* const comp, ComponentLayout& l, const TabbedButtonBar::Orientation newState_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), newState (newState_) { oldState = comp->getOrientation(); @@ -465,11 +465,11 @@ private: }; //============================================================================== - class TabInitialTabProperty : public ComponentChoiceProperty + class TabInitialTabProperty : public ComponentChoiceProperty { public: TabInitialTabProperty (TabbedComponent* comp, JucerDocument& doc) - : ComponentChoiceProperty ("initial tab", comp, doc) + : ComponentChoiceProperty ("initial tab", comp, doc) { for (int i = 0; i < comp->getNumTabs(); ++i) choices.add ("Tab " + String (i) + ": \"" + comp->getTabNames() [i] + "\""); @@ -487,11 +487,11 @@ private: } private: - class InitialTabChangeAction : public ComponentUndoableAction + class InitialTabChangeAction : public ComponentUndoableAction { public: InitialTabChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), newValue (newValue_) { oldValue = comp->getCurrentTabIndex(); @@ -558,11 +558,11 @@ private: JucerDocument& document; private: - class TabDepthChangeAction : public ComponentUndoableAction + class TabDepthChangeAction : public ComponentUndoableAction { public: TabDepthChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int newState_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), newState (newState_) { oldState = comp->getTabBarDepth(); @@ -614,7 +614,7 @@ private: JucerDocument& document; private: - class AddTabAction : public ComponentUndoableAction + class AddTabAction : public ComponentUndoableAction { public: AddTabAction (TabbedComponent* const comp, ComponentLayout& l) @@ -680,7 +680,7 @@ private: JucerDocument& document; private: - class RemoveTabAction : public ComponentUndoableAction + class RemoveTabAction : public ComponentUndoableAction { public: RemoveTabAction (TabbedComponent* const comp, ComponentLayout& l, int indexToRemove_) @@ -717,11 +717,11 @@ private: }; //============================================================================== - class TabNameProperty : public ComponentTextProperty + class TabNameProperty : public ComponentTextProperty { public: TabNameProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_) - : ComponentTextProperty ("name", 200, false, comp, doc), + : ComponentTextProperty ("name", 200, false, comp, doc), tabIndex (tabIndex_) { } @@ -740,11 +740,11 @@ private: private: int tabIndex; - class TabNameChangeAction : public ComponentUndoableAction + class TabNameChangeAction : public ComponentUndoableAction { public: TabNameChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newValue (newValue_) { @@ -817,12 +817,12 @@ private: JucerDocument& document; int tabIndex; - class TabColourChangeAction : public ComponentUndoableAction + class TabColourChangeAction : public ComponentUndoableAction { public: TabColourChangeAction (TabbedComponent* comp, ComponentLayout& l, int tabIndex_, Colour newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newValue (newValue_) { @@ -852,11 +852,11 @@ private: }; //============================================================================== - class TabContentTypeProperty : public ComponentChoiceProperty + class TabContentTypeProperty : public ComponentChoiceProperty { public: TabContentTypeProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_) - : ComponentChoiceProperty ("content type", comp, doc), + : ComponentChoiceProperty ("content type", comp, doc), tabIndex (tabIndex_) { choices.add ("Jucer content component"); @@ -877,11 +877,11 @@ private: private: int tabIndex; - class TabContentTypeChangeAction : public ComponentUndoableAction + class TabContentTypeChangeAction : public ComponentUndoableAction { public: TabContentTypeChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const bool newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newValue (newValue_) { @@ -952,11 +952,11 @@ private: JucerDocument& document; int tabIndex; - class JucerCompFileChangeAction : public ComponentUndoableAction + class JucerCompFileChangeAction : public ComponentUndoableAction { public: JucerCompFileChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newState_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newState (newState_) { @@ -985,11 +985,11 @@ private: }; //============================================================================== - class TabContentClassProperty : public ComponentTextProperty + class TabContentClassProperty : public ComponentTextProperty { public: TabContentClassProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_) - : ComponentTextProperty ("content class", 256, false, comp, doc), + : ComponentTextProperty ("content class", 256, false, comp, doc), tabIndex (tabIndex_) { } @@ -1008,11 +1008,11 @@ private: private: int tabIndex; - class TabClassNameChangeAction : public ComponentUndoableAction + class TabClassNameChangeAction : public ComponentUndoableAction { public: TabClassNameChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newValue (newValue_) { @@ -1043,11 +1043,11 @@ private: }; //============================================================================== - class TabContentConstructorParamsProperty : public ComponentTextProperty + class TabContentConstructorParamsProperty : public ComponentTextProperty { public: TabContentConstructorParamsProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_) - : ComponentTextProperty ("constructor params", 512, false, comp, doc), + : ComponentTextProperty ("constructor params", 512, false, comp, doc), tabIndex (tabIndex_) { } @@ -1066,11 +1066,11 @@ private: private: int tabIndex; - class TabConstructorParamChangeAction : public ComponentUndoableAction + class TabConstructorParamChangeAction : public ComponentUndoableAction { public: TabConstructorParamChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), tabIndex (tabIndex_), newValue (newValue_) { @@ -1138,12 +1138,12 @@ private: const int tabIndex, totalNumTabs; private: - class MoveTabAction : public ComponentUndoableAction + class MoveTabAction : public ComponentUndoableAction { public: MoveTabAction (TabbedComponent* const comp, ComponentLayout& l, const int oldIndex_, const int newIndex_) - : ComponentUndoableAction (comp, l), + : ComponentUndoableAction (comp, l), oldIndex (oldIndex_), newIndex (newIndex_) { diff --git a/modules/juce_core/memory/juce_HeapBlock.h b/modules/juce_core/memory/juce_HeapBlock.h index 3731f0b302..402b6173aa 100644 --- a/modules/juce_core/memory/juce_HeapBlock.h +++ b/modules/juce_core/memory/juce_HeapBlock.h @@ -36,7 +36,7 @@ namespace HeapBlockHelper struct ThrowOnFail { static void check (void*) {} }; template<> - struct ThrowOnFail { static void check (void* data) { if (data == nullptr) throw std::bad_alloc(); } }; + struct ThrowOnFail { static void check (void* data) { if (data == nullptr) throw std::bad_alloc(); } }; } #endif @@ -67,7 +67,7 @@ namespace HeapBlockHelper ..you could just write this: @code - HeapBlock temp (1024); + HeapBlock temp (1024); memcpy (temp, xyz, 1024 * sizeof (int)); temp.calloc (2048); temp[0] = 1234; @@ -109,7 +109,7 @@ public: other constructor that takes an InitialisationState parameter. */ explicit HeapBlock (const size_t numElements) - : data (static_cast (std::malloc (numElements * sizeof (ElementType)))) + : data (static_cast (std::malloc (numElements * sizeof (ElementType)))) { throwOnAllocationFailure(); } @@ -120,7 +120,7 @@ public: or left uninitialised. */ HeapBlock (const size_t numElements, const bool initialiseToZero) - : data (static_cast (initialiseToZero + : data (static_cast (initialiseToZero ? std::calloc (numElements, sizeof (ElementType)) : std::malloc (numElements * sizeof (ElementType)))) { @@ -166,13 +166,13 @@ public: This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator void*() const noexcept { return static_cast (data); } + inline operator void*() const noexcept { return static_cast (data); } /** Returns a void pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator const void*() const noexcept { return static_cast (data); } + inline operator const void*() const noexcept { return static_cast (data); } /** Lets you use indirect calls to the first element in the array. Obviously this will cause problems if the array hasn't been initialised, because it'll @@ -220,7 +220,7 @@ public: void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::malloc (newNumElements * elementSize)); + data = static_cast (std::malloc (newNumElements * elementSize)); throwOnAllocationFailure(); } @@ -230,7 +230,7 @@ public: void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::calloc (newNumElements, elementSize)); + data = static_cast (std::calloc (newNumElements, elementSize)); throwOnAllocationFailure(); } @@ -241,7 +241,7 @@ public: void allocate (const size_t newNumElements, bool initialiseToZero) { std::free (data); - data = static_cast (initialiseToZero + data = static_cast (initialiseToZero ? std::calloc (newNumElements, sizeof (ElementType)) : std::malloc (newNumElements * sizeof (ElementType))); throwOnAllocationFailure(); @@ -254,15 +254,15 @@ public: */ void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { - data = static_cast (data == nullptr ? std::malloc (newNumElements * elementSize) - : std::realloc (data, newNumElements * elementSize)); + data = static_cast (data == nullptr ? std::malloc (newNumElements * elementSize) + : std::realloc (data, newNumElements * elementSize)); throwOnAllocationFailure(); } /** Frees any currently-allocated data. This will free the data and reset this object to be a null pointer. */ - void free() + void free() noexcept { std::free (data); data = nullptr; @@ -272,7 +272,7 @@ public: The two objects simply exchange their data pointers. */ template - void swapWith (HeapBlock & other) noexcept + void swapWith (HeapBlock& other) noexcept { std::swap (data, other.data); } diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index c27692bb0e..52563768ce 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -187,7 +187,7 @@ bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textChar { const WeakReference deletionChecker (target); - if (const Array * const keyListeners = target->keyListeners) + if (const Array* const keyListeners = target->keyListeners) { for (int i = keyListeners->size(); --i >= 0;) { @@ -238,7 +238,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown) if (keyWasUsed || deletionChecker == nullptr) break; - if (const Array * const keyListeners = target->keyListeners) + if (const Array* const keyListeners = target->keyListeners) { for (int i = keyListeners->size(); --i >= 0;) { @@ -276,7 +276,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget() Component* const c = Component::getCurrentlyFocusedComponent(); if (c == &component || component.isParentOf (c)) - if (TextInputTarget* const ti = dynamic_cast (c)) + if (TextInputTarget* const ti = dynamic_cast (c)) if (ti->isTextInputActive()) return ti;