From c6efba534e5c6cc0803e3a43642966b5cf9f06d8 Mon Sep 17 00:00:00 2001 From: David Braun <2096055+DBraun@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:48:21 -0500 Subject: [PATCH] update JUCE to 7.0.8 --- Builds/LinuxMakefile/Makefile | 76 +- .../DawDreamer.xcodeproj/project.pbxproj | 15 +- .../DawDreamer_DynamicLibrary.vcxproj | 30 +- .../DawDreamer_DynamicLibrary.vcxproj.filters | 48 +- JuceLibraryCode/AppConfig.h | 2 +- .../buffers/juce_AudioChannelSet.cpp | 204 ++--- .../buffers/juce_AudioDataConverters.cpp | 2 +- .../buffers/juce_AudioDataConverters.h | 2 +- .../buffers/juce_FloatVectorOperations.cpp | 2 +- .../juce_audio_basics/juce_audio_basics.cpp | 19 +- .../juce_audio_basics/juce_audio_basics.h | 3 +- .../midi/juce_MidiBuffer.cpp | 2 +- .../juce_audio_basics/midi/juce_MidiBuffer.h | 2 +- .../juce_audio_basics/midi/juce_MidiFile.cpp | 8 +- .../midi/juce_MidiMessage.cpp | 144 ++-- .../midi/juce_MidiMessageSequence.cpp | 22 +- .../juce_audio_basics/midi/juce_MidiRPN.cpp | 4 +- .../midi/ump/juce_UMPConversion.h | 7 +- .../midi/ump/juce_UMPConverters.h | 7 +- .../midi/ump/juce_UMPDispatcher.h | 7 +- .../midi/ump/juce_UMPFactory.h | 7 +- .../midi/ump/juce_UMPIterator.cpp | 7 +- .../midi/ump/juce_UMPIterator.h | 7 +- .../ump/juce_UMPMidi1ToBytestreamTranslator.h | 7 +- .../juce_UMPMidi1ToMidi2DefaultTranslator.cpp | 7 +- .../juce_UMPMidi1ToMidi2DefaultTranslator.h | 19 +- .../midi/ump/juce_UMPProtocols.h | 7 +- .../midi/ump/juce_UMPReceiver.h | 7 +- .../midi/ump/juce_UMPSysEx7.cpp | 7 +- .../midi/ump/juce_UMPSysEx7.h | 7 +- .../midi/ump/juce_UMPUtils.cpp | 7 +- .../midi/ump/juce_UMPUtils.h | 7 +- .../midi/ump/juce_UMPView.cpp | 7 +- .../juce_audio_basics/midi/ump/juce_UMPView.h | 9 +- .../midi/ump/juce_UMP_test.cpp | 9 +- .../midi/ump/juce_UMPacket.h | 7 +- .../midi/ump/juce_UMPackets.h | 7 +- .../mpe/juce_MPEInstrument.cpp | 6 +- .../mpe/juce_MPEMessages.cpp | 2 +- .../juce_audio_basics/mpe/juce_MPENote.cpp | 2 +- .../mpe/juce_MPESynthesiserBase.cpp | 4 +- .../juce_audio_basics/mpe/juce_MPEUtils.cpp | 2 +- .../juce_audio_basics/mpe/juce_MPEValue.cpp | 2 +- .../mpe/juce_MPEZoneLayout.cpp | 2 +- .../native/juce_AudioWorkgroup_mac.h | 35 + .../sources/juce_BufferingAudioSource.h | 2 +- .../juce_ChannelRemappingAudioSource.cpp | 4 +- .../sources/juce_IIRFilterAudioSource.cpp | 8 +- .../sources/juce_MemoryAudioSource.cpp | 2 +- .../sources/juce_MixerAudioSource.cpp | 12 +- .../utilities/juce_ADSR_test.cpp | 2 +- .../utilities/juce_AudioWorkgroup.cpp | 221 ++++++ .../utilities/juce_AudioWorkgroup.h | 214 ++++++ .../utilities/juce_IIRFilter.cpp | 2 +- .../utilities/juce_Interpolators.cpp | 2 +- .../juce_audio_basics/utilities/juce_Reverb.h | 1 + .../utilities/juce_SmoothedValue.cpp | 2 +- .../audio_io/juce_AudioDeviceManager.cpp | 55 +- .../audio_io/juce_AudioDeviceManager.h | 3 + .../audio_io/juce_AudioIODevice.h | 17 + .../audio_io/juce_SampleRateHelpers.cpp | 7 +- .../juce_audio_devices/juce_audio_devices.cpp | 6 + .../juce_audio_devices/juce_audio_devices.h | 2 +- .../midi_io/juce_MidiDevices.cpp | 2 +- .../ump/juce_UMPBytestreamInputHandler.h | 7 +- .../midi_io/ump/juce_UMPU32InputHandler.h | 8 +- .../native/juce_ALSA_linux.cpp | 8 +- .../native/juce_ASIO_windows.cpp | 16 +- .../native/juce_Audio_android.cpp | 24 +- .../native/juce_Audio_ios.cpp | 95 +-- .../native/juce_Audio_ios.h | 2 + .../native/juce_Bela_linux.cpp | 4 +- .../native/juce_CoreAudio_mac.cpp | 88 ++- .../native/juce_CoreMidi_mac.mm | 4 +- .../native/juce_DirectSound_windows.cpp | 174 ++--- ...juce_HighPerformanceAudioHelpers_android.h | 8 +- .../native/juce_JackAudio_linux.cpp | 21 +- .../native/juce_Midi_android.cpp | 2 +- .../native/juce_Midi_linux.cpp | 8 +- .../native/juce_Midi_windows.cpp | 40 +- .../native/juce_Oboe_android.cpp | 14 +- .../native/juce_OpenSL_android.cpp | 26 +- .../native/juce_WASAPI_windows.cpp | 60 +- .../native/oboe/.clang-tidy | 3 + .../codecs/juce_AiffAudioFormat.cpp | 6 +- .../codecs/juce_AiffAudioFormat.h | 2 +- .../codecs/juce_CoreAudioFormat.cpp | 6 +- .../codecs/juce_FlacAudioFormat.cpp | 4 +- .../codecs/juce_LAMEEncoderAudioFormat.cpp | 2 +- .../codecs/juce_MP3AudioFormat.cpp | 2 +- .../codecs/juce_OggVorbisAudioFormat.cpp | 4 +- .../codecs/juce_WavAudioFormat.cpp | 8 +- .../codecs/juce_WindowsMediaAudioFormat.cpp | 4 +- .../format/juce_ARAAudioReaders.cpp | 24 +- .../format/juce_AudioFormatWriter.cpp | 4 +- .../juce_BufferingAudioFormatReader.cpp | 57 +- .../juce_audio_formats/juce_audio_formats.h | 2 +- .../format/juce_AudioPluginFormat.cpp | 2 +- .../format/juce_AudioPluginFormatManager.cpp | 2 +- .../public.sdk/source/common/pluginview.cpp | 1 + .../format_types/juce_ARAHosting.cpp | 6 +- .../juce_AudioUnitPluginFormat.mm | 45 +- .../format_types/juce_LADSPAPluginFormat.cpp | 21 +- .../format_types/juce_LV2Common.h | 7 +- .../format_types/juce_LV2PluginFormat.cpp | 75 +- .../juce_LV2PluginFormat_test.cpp | 2 +- .../format_types/juce_LV2Resources.h | 7 +- .../juce_LegacyAudioParameter.cpp | 2 +- .../format_types/juce_VST3Common.h | 63 +- .../format_types/juce_VST3PluginFormat.cpp | 233 +++--- .../juce_VST3PluginFormat_test.cpp | 2 +- .../format_types/juce_VSTCommon.h | 2 +- .../format_types/juce_VSTPluginFormat.cpp | 46 +- .../juce_audio_processors.cpp | 29 +- .../juce_audio_processors.h | 2 +- .../processors/juce_AudioPluginInstance.cpp | 2 +- .../processors/juce_AudioProcessor.cpp | 14 +- .../processors/juce_AudioProcessor.h | 10 + .../processors/juce_AudioProcessorGraph.cpp | 41 +- .../processors/juce_AudioProcessorGraph.h | 2 +- .../processors/juce_AudioProcessorParameter.h | 2 +- .../juce_AudioProcessorParameterGroup.cpp | 4 +- .../juce_GenericAudioProcessorEditor.cpp | 24 +- .../scanning/juce_KnownPluginList.cpp | 2 +- .../scanning/juce_KnownPluginList.h | 2 +- .../scanning/juce_PluginListComponent.cpp | 4 +- .../ARA/juce_ARADocumentControllerCommon.cpp | 2 +- .../utilities/ARA/juce_ARAModelObjects.h | 2 +- .../utilities/ARA/juce_ARA_utils.cpp | 2 +- .../utilities/juce_AAXClientExtensions.cpp | 2 +- .../utilities/juce_AudioParameterBool.cpp | 2 +- .../utilities/juce_AudioParameterChoice.cpp | 2 +- .../utilities/juce_AudioParameterInt.cpp | 2 +- .../juce_AudioProcessorParameterWithID.h | 4 +- .../juce_AudioProcessorValueTreeState.cpp | 10 +- .../juce_AudioProcessorValueTreeState.h | 2 +- .../utilities/juce_ExtensionsVisitor.h | 9 +- .../utilities/juce_ParameterAttachments.cpp | 3 +- .../containers/juce_AbstractFifo.cpp | 4 +- .../juce_core/containers/juce_AbstractFifo.h | 2 +- .../juce_core/containers/juce_ArrayBase.cpp | 6 +- .../juce_core/containers/juce_ArrayBase.h | 6 +- .../containers/juce_DynamicObject.cpp | 8 +- .../juce_core/containers/juce_DynamicObject.h | 7 +- .../containers/juce_FixedSizeFunction.h | 478 ++++++------ .../juce_FixedSizeFunction_test.cpp | 719 +++++++++--------- .../juce_core/containers/juce_HashMap.h | 8 +- .../containers/juce_HashMap_test.cpp | 2 +- .../containers/juce_ListenerList.cpp | 2 +- .../juce_core/containers/juce_ListenerList.h | 20 +- .../containers/juce_NamedValueSet.cpp | 12 +- .../containers/juce_Optional_test.cpp | 4 +- .../juce_core/containers/juce_OwnedArray.cpp | 2 +- .../containers/juce_ReferenceCountedArray.cpp | 6 +- .../juce_core/containers/juce_SparseSet.cpp | 2 +- .../juce_core/containers/juce_SparseSet.h | 2 +- .../juce_core/containers/juce_Variant.cpp | 4 +- .../juce_core/containers/juce_Variant.h | 22 - .../modules/juce_core/files/juce_File.cpp | 4 +- .../juce_core/files/juce_FileInputStream.cpp | 2 +- .../juce_core/files/juce_FileSearchPath.cpp | 2 +- .../juce_core/javascript/juce_JSON.cpp | 4 +- .../javascript/juce_JSONSerialisation.h | 532 +++++++++++++ .../juce_JSONSerialisation_test.cpp | 614 +++++++++++++++ .../juce_core/javascript/juce_JSONUtils.cpp | 215 ++++++ .../juce_core/javascript/juce_JSONUtils.h | 67 ++ .../juce_core/javascript/juce_Javascript.cpp | 118 +-- .../modules/juce_core/juce_core.cpp | 7 + JuceLibraryCode/modules/juce_core/juce_core.h | 8 +- .../juce_core/maths/juce_BigInteger.cpp | 12 +- .../modules/juce_core/maths/juce_BigInteger.h | 2 +- .../juce_core/maths/juce_Expression.cpp | 42 +- .../juce_core/maths/juce_MathsFunctions.h | 6 +- .../maths/juce_MathsFunctions_test.cpp | 8 +- .../modules/juce_core/maths/juce_Random.cpp | 2 +- .../modules/juce_core/memory/juce_ByteOrder.h | 4 - .../modules/juce_core/memory/juce_HeapBlock.h | 61 +- .../memory/juce_LeakedObjectDetector.h | 2 +- .../juce_core/memory/juce_MemoryBlock.h | 6 +- .../memory/juce_SharedResourcePointer.h | 2 +- .../modules/juce_core/memory/juce_Singleton.h | 4 +- .../misc/juce_ConsoleApplication.cpp | 4 +- .../juce_core/misc/juce_EnumHelpers_test.cpp | 4 +- .../modules/juce_core/misc/juce_Functional.h | 29 - .../juce_core/misc/juce_ScopeGuard.cpp | 55 ++ .../modules/juce_core/misc/juce_ScopeGuard.h | 113 +++ .../native/juce_AndroidDocument_android.cpp | 2 +- .../juce_core/native/juce_Files_android.cpp | 6 +- .../juce_core/native/juce_Files_windows.cpp | 2 +- .../native/juce_JNIHelpers_android.cpp | 8 +- .../juce_core/native/juce_Network_curl.cpp | 2 +- .../juce_core/native/juce_Network_linux.cpp | 6 +- .../juce_core/native/juce_Network_mac.mm | 14 +- .../juce_core/native/juce_Network_windows.cpp | 4 +- .../juce_core/native/juce_ObjCHelpers_mac.h | 155 ++-- .../native/juce_ObjCHelpers_mac_test.mm | 72 ++ .../juce_RuntimePermissions_android.cpp | 8 +- .../native/juce_SystemStats_android.cpp | 2 +- .../juce_core/native/juce_SystemStats_mac.mm | 4 +- .../native/juce_SystemStats_windows.cpp | 4 +- .../juce_core/native/juce_Threads_android.cpp | 4 +- .../juce_core/native/juce_Threads_mac.mm | 2 +- .../juce_core/native/juce_Threads_windows.cpp | 2 +- .../juce_core/network/juce_IPAddress.cpp | 2 +- .../juce_core/network/juce_NamedPipe.cpp | 8 +- .../modules/juce_core/network/juce_Socket.cpp | 2 +- .../modules/juce_core/network/juce_Socket.h | 4 +- .../modules/juce_core/network/juce_URL.cpp | 14 +- .../juce_core/network/juce_WebInputStream.cpp | 2 +- .../serialisation/juce_Serialisation.h | 576 ++++++++++++++ .../streams/juce_BufferedInputStream.cpp | 2 +- .../streams/juce_MemoryInputStream.cpp | 2 +- .../streams/juce_SubregionStream.cpp | 2 +- .../juce_core/streams/juce_URLInputSource.cpp | 2 +- .../juce_core/system/juce_CompilerSupport.h | 33 + .../juce_core/system/juce_CompilerWarnings.h | 4 +- .../juce_core/system/juce_PlatformDefs.h | 14 +- .../juce_core/system/juce_StandardHeader.h | 6 +- .../juce_core/system/juce_SystemStats.cpp | 8 +- .../modules/juce_core/text/juce_Base64.cpp | 6 +- .../text/juce_CharacterFunctions.cpp | 2 +- .../juce_core/text/juce_LocalisedStrings.h | 4 +- .../modules/juce_core/text/juce_String.cpp | 20 +- .../modules/juce_core/text/juce_String.h | 2 +- .../juce_core/text/juce_StringArray.cpp | 14 +- .../juce_core/text/juce_StringPairArray.cpp | 2 +- .../juce_core/text/juce_StringPool.cpp | 2 +- .../modules/juce_core/text/juce_TextDiff.cpp | 2 +- .../juce_core/threads/juce_ChildProcess.cpp | 2 +- .../threads/juce_HighResolutionTimer.cpp | 16 +- .../modules/juce_core/threads/juce_Thread.cpp | 14 +- .../modules/juce_core/threads/juce_Thread.h | 19 + .../juce_core/threads/juce_ThreadPool.cpp | 8 +- .../juce_core/time/juce_RelativeTime.cpp | 14 +- .../modules/juce_core/time/juce_Time.cpp | 5 +- .../modules/juce_core/time/juce_Time.h | 2 +- .../unit_tests/juce_UnitTestCategories.h | 8 +- .../modules/juce_core/xml/juce_XmlElement.cpp | 2 +- .../modules/juce_core/xml/juce_XmlElement.h | 8 +- .../zip/juce_GZIPCompressorOutputStream.cpp | 2 +- .../zip/juce_GZIPDecompressorInputStream.cpp | 2 +- .../modules/juce_core/zip/juce_ZipFile.cpp | 4 +- .../encryption/juce_BlowFish.cpp | 16 +- .../juce_cryptography/hashing/juce_MD5.cpp | 4 +- .../juce_cryptography/hashing/juce_SHA256.cpp | 2 +- .../hashing/juce_Whirlpool.cpp | 2 +- .../juce_cryptography/juce_cryptography.h | 2 +- .../juce_data_structures.h | 2 +- .../undomanager/juce_UndoManager.cpp | 2 +- .../values/juce_CachedValue.cpp | 2 +- .../values/juce_Value.cpp | 2 +- .../values/juce_ValueTree.cpp | 14 +- .../juce_ValueTreePropertyWithDefault.h | 3 +- ...juce_ValueTreePropertyWithDefault_test.cpp | 2 +- .../values/juce_ValueTreeSynchroniser.cpp | 2 +- .../juce_dsp/containers/juce_AudioBlock.h | 7 +- .../containers/juce_AudioBlock_test.cpp | 11 +- .../juce_dsp/containers/juce_SIMDRegister.h | 11 +- .../containers/juce_SIMDRegister_test.cpp | 17 +- .../filter_design/juce_FilterDesign.cpp | 9 +- .../filter_design/juce_FilterDesign.h | 7 +- .../juce_dsp/frequency/juce_Convolution.cpp | 11 +- .../juce_dsp/frequency/juce_Convolution.h | 7 +- .../frequency/juce_Convolution_test.cpp | 9 +- .../modules/juce_dsp/frequency/juce_FFT.cpp | 19 +- .../modules/juce_dsp/frequency/juce_FFT.h | 7 +- .../juce_dsp/frequency/juce_FFT_test.cpp | 15 +- .../juce_dsp/frequency/juce_Windowing.cpp | 7 +- .../juce_dsp/frequency/juce_Windowing.h | 7 +- JuceLibraryCode/modules/juce_dsp/juce_dsp.cpp | 1 - JuceLibraryCode/modules/juce_dsp/juce_dsp.h | 69 +- .../maths/juce_FastMathApproximations.h | 7 +- .../juce_dsp/maths/juce_LogRampedValue.h | 7 +- .../maths/juce_LogRampedValue_test.cpp | 9 +- .../juce_dsp/maths/juce_LookupTable.cpp | 7 +- .../modules/juce_dsp/maths/juce_LookupTable.h | 7 +- .../modules/juce_dsp/maths/juce_Matrix.cpp | 13 +- .../modules/juce_dsp/maths/juce_Matrix.h | 7 +- .../juce_dsp/maths/juce_Matrix_test.cpp | 15 +- .../modules/juce_dsp/maths/juce_Phase.h | 7 +- .../modules/juce_dsp/maths/juce_Polynomial.h | 9 +- .../juce_dsp/maths/juce_SpecialFunctions.cpp | 7 +- .../juce_dsp/maths/juce_SpecialFunctions.h | 8 +- .../native/juce_SIMDNativeOps_avx.cpp | 41 +- .../juce_dsp/native/juce_SIMDNativeOps_avx.h | 15 +- .../native/juce_SIMDNativeOps_fallback.h | 7 +- .../native/juce_SIMDNativeOps_neon.cpp | 39 +- .../juce_dsp/native/juce_SIMDNativeOps_neon.h | 15 +- .../native/juce_SIMDNativeOps_sse.cpp | 41 +- .../juce_dsp/native/juce_SIMDNativeOps_sse.h | 55 +- .../processors/juce_BallisticsFilter.cpp | 7 +- .../processors/juce_BallisticsFilter.h | 7 +- .../juce_dsp/processors/juce_DelayLine.cpp | 9 +- .../juce_dsp/processors/juce_DelayLine.h | 7 +- .../juce_dsp/processors/juce_DryWetMixer.cpp | 9 +- .../juce_dsp/processors/juce_DryWetMixer.h | 7 +- .../juce_dsp/processors/juce_FIRFilter.cpp | 7 +- .../juce_dsp/processors/juce_FIRFilter.h | 15 +- .../processors/juce_FIRFilter_test.cpp | 9 +- .../processors/juce_FirstOrderTPTFilter.cpp | 7 +- .../processors/juce_FirstOrderTPTFilter.h | 7 +- .../juce_dsp/processors/juce_IIRFilter.cpp | 12 +- .../juce_dsp/processors/juce_IIRFilter.h | 13 +- .../juce_dsp/processors/juce_IIRFilter_Impl.h | 10 +- .../processors/juce_LinkwitzRileyFilter.cpp | 7 +- .../processors/juce_LinkwitzRileyFilter.h | 7 +- .../juce_dsp/processors/juce_Oversampling.cpp | 17 +- .../juce_dsp/processors/juce_Oversampling.h | 7 +- .../juce_dsp/processors/juce_Panner.cpp | 7 +- .../modules/juce_dsp/processors/juce_Panner.h | 11 +- .../juce_dsp/processors/juce_ProcessContext.h | 7 +- .../juce_dsp/processors/juce_ProcessorChain.h | 9 +- .../processors/juce_ProcessorChain_test.cpp | 9 +- .../processors/juce_ProcessorDuplicator.h | 7 +- .../processors/juce_ProcessorWrapper.h | 7 +- .../processors/juce_StateVariableFilter.h | 13 +- .../juce_StateVariableTPTFilter.cpp | 7 +- .../processors/juce_StateVariableTPTFilter.h | 9 +- .../modules/juce_dsp/widgets/juce_Bias.h | 7 +- .../modules/juce_dsp/widgets/juce_Chorus.cpp | 7 +- .../modules/juce_dsp/widgets/juce_Chorus.h | 9 +- .../juce_dsp/widgets/juce_Compressor.cpp | 7 +- .../juce_dsp/widgets/juce_Compressor.h | 7 +- .../modules/juce_dsp/widgets/juce_Gain.h | 7 +- .../juce_dsp/widgets/juce_LadderFilter.cpp | 7 +- .../juce_dsp/widgets/juce_LadderFilter.h | 7 +- .../modules/juce_dsp/widgets/juce_Limiter.cpp | 7 +- .../modules/juce_dsp/widgets/juce_Limiter.h | 7 +- .../juce_dsp/widgets/juce_NoiseGate.cpp | 7 +- .../modules/juce_dsp/widgets/juce_NoiseGate.h | 7 +- .../juce_dsp/widgets/juce_Oscillator.h | 7 +- .../modules/juce_dsp/widgets/juce_Phaser.cpp | 7 +- .../modules/juce_dsp/widgets/juce_Phaser.h | 9 +- .../modules/juce_dsp/widgets/juce_Reverb.h | 7 +- .../juce_dsp/widgets/juce_WaveShaper.h | 7 +- .../broadcasters/juce_ActionBroadcaster.cpp | 4 +- .../broadcasters/juce_AsyncUpdater.cpp | 2 +- .../juce_ConnectedChildProcess.cpp | 12 +- .../juce_InterprocessConnection.cpp | 8 +- .../juce_NetworkServiceDiscovery.cpp | 3 +- .../modules/juce_events/juce_events.h | 2 +- .../messages/juce_ApplicationBase.cpp | 10 +- .../messages/juce_DeletedAtShutdown.cpp | 2 +- .../messages/juce_MessageManager.cpp | 65 +- .../messages/juce_MessageManager.h | 12 +- .../juce_events/native/juce_EventLoop_linux.h | 7 +- .../native/juce_MessageManager_mac.mm | 12 +- .../native/juce_Messaging_android.cpp | 8 +- .../native/juce_Messaging_linux.cpp | 4 +- .../native/juce_Messaging_windows.cpp | 5 +- .../juce_events/timers/juce_MultiTimer.cpp | 4 +- .../modules/juce_events/timers/juce_Timer.cpp | 10 +- .../juce_graphics/colour/juce_Colour.cpp | 2 +- .../colour/juce_ColourGradient.cpp | 8 +- .../juce_graphics/colour/juce_Colours.h | 9 +- .../contexts/juce_GraphicsContext.cpp | 8 +- .../contexts/juce_GraphicsContext.h | 2 +- .../juce_LowLevelGraphicsPostScriptRenderer.h | 2 +- .../juce_graphics/fonts/juce_CustomTypeface.h | 2 +- .../modules/juce_graphics/fonts/juce_Font.cpp | 9 +- .../fonts/juce_GlyphArrangement.cpp | 8 +- .../geometry/juce_AffineTransform.cpp | 2 +- .../juce_graphics/geometry/juce_Path.h | 6 +- .../juce_graphics/geometry/juce_Rectangle.h | 18 +- .../geometry/juce_Rectangle_test.cpp | 2 +- .../image_formats/juce_JPEGLoader.cpp | 2 +- .../image_formats/juce_PNGLoader.cpp | 2 +- .../juce_graphics/images/juce_Image.cpp | 4 +- .../juce_graphics/images/juce_ImageCache.cpp | 4 +- .../modules/juce_graphics/juce_graphics.h | 2 +- .../native/juce_CoreGraphicsContext_mac.mm | 12 +- .../juce_Direct2DGraphicsContext_windows.cpp | 4 +- .../juce_DirectWriteTypeLayout_windows.cpp | 4 +- .../juce_DirectWriteTypeface_windows.cpp | 12 +- .../native/juce_Fonts_android.cpp | 42 +- .../native/juce_Fonts_freetype.cpp | 8 +- .../juce_graphics/native/juce_Fonts_mac.mm | 2 +- .../native/juce_Fonts_windows.cpp | 2 +- .../native/juce_GraphicsContext_android.cpp | 4 +- .../native/juce_IconHelpers_mac.cpp | 4 +- .../native/juce_RenderingHelpers.h | 9 +- .../application/juce_Application.cpp | 4 +- .../juce_gui_basics/buttons/juce_Button.cpp | 16 +- .../buttons/juce_ShapeButton.cpp | 2 +- .../juce_ApplicationCommandManager.cpp | 12 +- .../commands/juce_ApplicationCommandManager.h | 2 +- .../juce_ApplicationCommandTarget.cpp | 2 +- .../commands/juce_ApplicationCommandTarget.h | 12 +- .../commands/juce_KeyPressMappingSet.cpp | 32 +- .../commands/juce_KeyPressMappingSet.h | 4 +- .../components/juce_Component.cpp | 6 +- .../components/juce_Component.h | 2 +- .../components/juce_FocusTraverser.cpp | 4 +- .../components/juce_ModalComponentManager.cpp | 2 +- .../juce_gui_basics/desktop/juce_Desktop.cpp | 4 +- .../detail/juce_ComponentHelpers.h | 2 +- .../juce_ScopedContentSharerInterface.h | 8 +- .../drawables/juce_Drawable.cpp | 6 +- .../juce_gui_basics/drawables/juce_Drawable.h | 34 +- .../drawables/juce_DrawableText.cpp | 4 +- .../drawables/juce_SVGParser.cpp | 62 +- .../juce_DirectoryContentsList.cpp | 4 +- .../filebrowser/juce_FileBrowserComponent.cpp | 34 +- .../filebrowser/juce_FileChooser.cpp | 4 +- .../filebrowser/juce_FileChooserDialogBox.cpp | 14 +- .../filebrowser/juce_FileListComponent.cpp | 8 +- .../juce_FileSearchPathListComponent.cpp | 4 +- .../filebrowser/juce_FileTreeComponent.cpp | 12 +- .../juce_gui_basics/juce_gui_basics.cpp | 5 +- .../modules/juce_gui_basics/juce_gui_basics.h | 2 +- .../keyboard/juce_KeyboardFocusTraverser.cpp | 4 +- .../layout/juce_AnimatedPositionBehaviours.h | 9 +- .../layout/juce_ComponentAnimator.cpp | 8 +- .../layout/juce_ComponentBuilder.cpp | 4 +- .../layout/juce_ConcertinaPanel.cpp | 28 +- .../juce_gui_basics/layout/juce_FlexBox.cpp | 2 +- .../juce_gui_basics/layout/juce_Grid.cpp | 14 +- .../juce_gui_basics/layout/juce_Grid.h | 12 +- .../layout/juce_MultiDocumentPanel.cpp | 18 +- .../juce_gui_basics/layout/juce_ScrollBar.cpp | 4 +- .../juce_gui_basics/layout/juce_SidePanel.cpp | 6 +- .../layout/juce_StretchableLayoutManager.cpp | 4 +- .../layout/juce_StretchableObjectResizer.cpp | 6 +- .../layout/juce_TabbedButtonBar.cpp | 12 +- .../layout/juce_TabbedComponent.cpp | 2 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 4 +- .../lookandfeel/juce_LookAndFeel.cpp | 2 +- .../lookandfeel/juce_LookAndFeel_V1.h | 2 +- .../lookandfeel/juce_LookAndFeel_V2.cpp | 8 +- .../lookandfeel/juce_LookAndFeel_V2.h | 8 +- .../lookandfeel/juce_LookAndFeel_V3.cpp | 4 +- .../lookandfeel/juce_LookAndFeel_V3.h | 4 +- .../lookandfeel/juce_LookAndFeel_V4.cpp | 2 +- .../lookandfeel/juce_LookAndFeel_V4.h | 2 +- .../menus/juce_BurgerMenuComponent.cpp | 2 +- .../menus/juce_MenuBarComponent.cpp | 6 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 14 +- .../misc/juce_DropShadower.cpp | 4 +- .../misc/juce_FocusOutline.cpp | 2 +- .../mouse/juce_DragAndDropContainer.cpp | 4 +- .../mouse/juce_SelectedItemSet.h | 4 +- .../accessibility/juce_Accessibility.cpp | 6 +- .../juce_AccessibilityElement_windows.cpp | 8 +- .../juce_AccessibilitySharedCode_mac.mm | 2 +- .../juce_AccessibilityTextHelpers_test.cpp | 4 +- .../accessibility/juce_Accessibility_ios.mm | 72 +- .../accessibility/juce_Accessibility_mac.mm | 16 +- .../juce_Accessibility_windows.cpp | 6 +- .../juce_ComInterfaces_windows.h | 7 +- .../native/juce_CGMetalLayerRenderer_mac.h | 2 +- .../native/juce_ContentSharer_android.cpp | 6 +- .../native/juce_ContentSharer_ios.cpp | 4 +- .../native/juce_DragAndDrop_linux.cpp | 3 +- .../native/juce_DragAndDrop_windows.cpp | 10 +- .../native/juce_FileChooser_android.cpp | 4 +- .../native/juce_FileChooser_ios.mm | 8 +- .../native/juce_FileChooser_linux.cpp | 4 +- .../native/juce_FileChooser_mac.mm | 6 +- .../native/juce_FileChooser_windows.cpp | 14 +- .../native/juce_MainMenu_mac.mm | 24 +- .../native/juce_NSViewComponentPeer_mac.mm | 26 +- .../native/juce_NativeMessageBox_android.cpp | 2 +- .../native/juce_NativeMessageBox_ios.mm | 2 +- .../native/juce_NativeMessageBox_linux.cpp | 2 +- .../native/juce_NativeMessageBox_mac.mm | 2 +- .../native/juce_NativeMessageBox_windows.cpp | 6 +- .../juce_NativeModalWrapperComponent_ios.h | 2 +- .../native/juce_PerScreenDisplayLinks_mac.h | 18 +- .../native/juce_UIViewComponentPeer_ios.mm | 24 +- .../native/juce_Windowing_android.cpp | 22 +- .../native/juce_Windowing_ios.mm | 6 +- .../native/juce_Windowing_linux.cpp | 6 +- .../native/juce_Windowing_mac.mm | 11 +- .../native/juce_Windowing_windows.cpp | 123 +-- .../native/juce_WindowsHooks_windows.cpp | 9 +- .../native/juce_XWindowSystem_linux.cpp | 5 +- .../positioning/juce_MarkerList.cpp | 8 +- .../juce_RelativeCoordinatePositioner.cpp | 8 +- .../positioning/juce_RelativePointPath.cpp | 8 +- .../positioning/juce_RelativeRectangle.cpp | 6 +- .../juce_ChoicePropertyComponent.cpp | 12 +- .../juce_MultiChoicePropertyComponent.cpp | 15 +- .../properties/juce_PropertyComponent.cpp | 2 +- .../properties/juce_PropertyPanel.cpp | 6 +- .../properties/juce_TextPropertyComponent.cpp | 6 +- .../juce_gui_basics/widgets/juce_ComboBox.cpp | 9 +- .../widgets/juce_ImageComponent.cpp | 2 +- .../juce_gui_basics/widgets/juce_Label.cpp | 19 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 18 +- .../widgets/juce_ProgressBar.cpp | 4 +- .../juce_gui_basics/widgets/juce_Slider.cpp | 17 +- .../juce_gui_basics/widgets/juce_Slider.h | 8 +- .../widgets/juce_TableHeaderComponent.cpp | 18 +- .../widgets/juce_TableListBox.cpp | 16 +- .../widgets/juce_TextEditor.cpp | 44 +- .../juce_gui_basics/widgets/juce_Toolbar.cpp | 18 +- .../widgets/juce_ToolbarItemComponent.h | 2 +- .../juce_gui_basics/widgets/juce_TreeView.cpp | 24 +- .../windows/juce_AlertWindow.cpp | 10 +- .../windows/juce_CallOutBox.cpp | 4 +- .../windows/juce_DialogWindow.cpp | 2 +- .../windows/juce_DocumentWindow.cpp | 2 +- .../windows/juce_NativeMessageBox.cpp | 4 +- .../windows/juce_ThreadWithProgressWindow.cpp | 2 +- .../code_editor/juce_CodeDocument.cpp | 8 +- .../code_editor/juce_CodeEditorComponent.cpp | 12 +- .../documents/juce_FileBasedDocument.cpp | 110 ++- .../modules/juce_gui_extra/juce_gui_extra.cpp | 13 +- .../modules/juce_gui_extra/juce_gui_extra.h | 2 +- .../misc/juce_ColourSelector.cpp | 20 +- .../juce_gui_extra/misc/juce_ColourSelector.h | 7 +- .../misc/juce_KeyMappingEditorComponent.cpp | 52 +- .../misc/juce_LiveConstantEditor.cpp | 37 +- .../misc/juce_LiveConstantEditor.h | 12 +- .../misc/juce_PreferencesPanel.cpp | 2 +- .../misc/juce_RecentlyOpenedFilesList.cpp | 4 +- .../misc/juce_WebBrowserComponent.h | 2 +- .../native/juce_ActiveXComponent_windows.cpp | 12 +- .../native/juce_AndroidViewComponent.cpp | 2 +- .../native/juce_AppleRemote_mac.mm | 2 +- .../native/juce_NSViewComponent_mac.mm | 12 +- .../native/juce_PushNotifications_android.cpp | 32 +- .../native/juce_PushNotifications_ios.cpp | 4 +- .../native/juce_PushNotifications_mac.cpp | 8 +- .../native/juce_SystemTrayIcon_mac.cpp | 10 +- .../juce_WebBrowserComponent_android.cpp | 2 +- .../native/juce_WebBrowserComponent_linux.cpp | 12 +- .../native/juce_WebBrowserComponent_mac.mm | 12 +- .../juce_WebBrowserComponent_windows.cpp | 30 +- .../native/juce_XEmbedComponent_linux.cpp | 2 +- .../modules/juce_opengl/juce_opengl.h | 2 +- .../juce_opengl/native/juce_OpenGL_android.h | 10 +- .../juce_opengl/native/juce_OpenGL_ios.h | 6 +- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 27 +- .../opengl/juce_OpenGLGraphicsContext.cpp | 52 +- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 4 +- .../opengl/juce_OpenGLShaderProgram.cpp | 2 +- .../modules/juce_opengl/opengl/juce_gl.h | 7 +- .../modules/juce_opengl/opengl/juce_gles2.h | 7 +- .../modules/juce_opengl/opengl/juce_wgl.h | 7 +- .../modules/juce_video/juce_video.h | 2 +- .../native/juce_CameraDevice_android.h | 15 +- .../juce_video/native/juce_CameraDevice_ios.h | 22 +- .../juce_video/native/juce_CameraDevice_mac.h | 21 +- .../native/juce_CameraDevice_windows.h | 20 +- .../juce_video/native/juce_Video_android.h | 12 +- .../juce_video/native/juce_Video_mac.h | 19 +- .../juce_video/native/juce_Video_windows.h | 9 +- 548 files changed, 6511 insertions(+), 3931 deletions(-) create mode 100644 JuceLibraryCode/modules/juce_audio_basics/native/juce_AudioWorkgroup_mac.h create mode 100644 JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.cpp create mode 100644 JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.h create mode 100644 JuceLibraryCode/modules/juce_audio_devices/native/oboe/.clang-tidy rename JuceLibraryCode/modules/{juce_dsp => juce_core}/containers/juce_FixedSizeFunction.h (94%) rename JuceLibraryCode/modules/{juce_dsp => juce_core}/containers/juce_FixedSizeFunction_test.cpp (93%) create mode 100644 JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation.h create mode 100644 JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation_test.cpp create mode 100644 JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.cpp create mode 100644 JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.h create mode 100644 JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.cpp create mode 100644 JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.h create mode 100644 JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac_test.mm create mode 100644 JuceLibraryCode/modules/juce_core/serialisation/juce_Serialisation.h diff --git a/Builds/LinuxMakefile/Makefile b/Builds/LinuxMakefile/Makefile index 2e36f747..6ecc69ec 100644 --- a/Builds/LinuxMakefile/Makefile +++ b/Builds/LinuxMakefile/Makefile @@ -112,170 +112,180 @@ OBJECTS_DYNAMIC_LIBRARY := \ all : $(JUCE_OUTDIR)/$(JUCE_TARGET_DYNAMIC_LIBRARY) -$(JUCE_OUTDIR)/$(JUCE_TARGET_DYNAMIC_LIBRARY) : $(OBJECTS_DYNAMIC_LIBRARY) $(RESOURCES) +$(JUCE_OUTDIR)/$(JUCE_TARGET_DYNAMIC_LIBRARY) : $(OBJECTS_DYNAMIC_LIBRARY) $(JUCE_OBJDIR)/execinfo.cmd $(RESOURCES) @command -v $(PKG_CONFIG) >/dev/null 2>&1 || { echo >&2 "pkg-config not installed. Please, install it."; exit 1; } @$(PKG_CONFIG) --print-errors alsa freetype2 gl @echo Linking "DawDreamer - Dynamic Library" -$(V_AT)mkdir -p $(JUCE_BINDIR) -$(V_AT)mkdir -p $(JUCE_LIBDIR) -$(V_AT)mkdir -p $(JUCE_OUTDIR) - $(V_AT)$(CXX) -o $(JUCE_OUTDIR)/$(JUCE_TARGET_DYNAMIC_LIBRARY) $(OBJECTS_DYNAMIC_LIBRARY) $(JUCE_LDFLAGS) $(JUCE_LDFLAGS_DYNAMIC_LIBRARY) $(RESOURCES) $(TARGET_ARCH) + $(V_AT)$(CXX) -o $(JUCE_OUTDIR)/$(JUCE_TARGET_DYNAMIC_LIBRARY) $(OBJECTS_DYNAMIC_LIBRARY) $(JUCE_LDFLAGS) $(shell cat $(JUCE_OBJDIR)/execinfo.cmd) $(JUCE_LDFLAGS_DYNAMIC_LIBRARY) $(RESOURCES) $(TARGET_ARCH) $(JUCE_OBJDIR)/DataModel_e101b2.o: ../../Source/Sampler/Source/DataModels/DataModel.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling DataModel.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/MPESettingsDataModel_aeb1f3d1.o: ../../Source/Sampler/Source/DataModels/MPESettingsDataModel.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling MPESettingsDataModel.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/SamplerAudioProcessor_298eea40.o: ../../Source/Sampler/Source/SamplerAudioProcessor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling SamplerAudioProcessor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/SamplerAudioProcessorEditor_39db550d.o: ../../Source/Sampler/Source/SamplerAudioProcessorEditor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling SamplerAudioProcessorEditor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/FaustProcessor_2056a3e0.o: ../../Source/FaustProcessor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling FaustProcessor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/FaustBoxAPI_5f675c8b.o: ../../Source/FaustBoxAPI.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling FaustBoxAPI.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/FaustSignalAPI_ca49a5a0.o: ../../Source/FaustSignalAPI.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling FaustSignalAPI.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/FilterProcessor_8755f5b.o: ../../Source/FilterProcessor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling FilterProcessor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/PlaybackWarpProcessor_eedba470.o: ../../Source/PlaybackWarpProcessor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling PlaybackWarpProcessor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/PluginProcessor_a059e380.o: ../../Source/PluginProcessor.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling PluginProcessor.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/ProcessorBase_65bf9464.o: ../../Source/ProcessorBase.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling ProcessorBase.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/CustomParameters_5970e144.o: ../../Source/CustomParameters.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling CustomParameters.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/custom_pybind_wrappers_ac32b5b4.o: ../../Source/custom_pybind_wrappers.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling custom_pybind_wrappers.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/RenderEngine_d1c4d401.o: ../../Source/RenderEngine.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling RenderEngine.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/source_704c2604.o: ../../Source/source.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling source.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_basics_8a4e984a.o: ../../JuceLibraryCode/include_juce_audio_basics.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_basics.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_devices_63111d02.o: ../../JuceLibraryCode/include_juce_audio_devices.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_devices.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_formats_15f82001.o: ../../JuceLibraryCode/include_juce_audio_formats.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_formats.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_processors_10c03666.o: ../../JuceLibraryCode/include_juce_audio_processors.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_processors.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_processors_ara_2a4c6ef7.o: ../../JuceLibraryCode/include_juce_audio_processors_ara.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_processors_ara.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_audio_processors_lv2_libs_12bdca08.o: ../../JuceLibraryCode/include_juce_audio_processors_lv2_libs.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_audio_processors_lv2_libs.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_core_f26d17db.o: ../../JuceLibraryCode/include_juce_core.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_core.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_cryptography_8cb807a8.o: ../../JuceLibraryCode/include_juce_cryptography.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_cryptography.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_data_structures_7471b1e3.o: ../../JuceLibraryCode/include_juce_data_structures.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_data_structures.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_dsp_aeb2060f.o: ../../JuceLibraryCode/include_juce_dsp.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_dsp.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_events_fd7d695.o: ../../JuceLibraryCode/include_juce_events.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_events.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_graphics_f817e147.o: ../../JuceLibraryCode/include_juce_graphics.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_graphics.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_gui_basics_e3f79785.o: ../../JuceLibraryCode/include_juce_gui_basics.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_gui_basics.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_gui_extra_6dee1c1a.o: ../../JuceLibraryCode/include_juce_gui_extra.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_gui_extra.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_opengl_a8a032b.o: ../../JuceLibraryCode/include_juce_opengl.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_opengl.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" $(JUCE_OBJDIR)/include_juce_video_be78589.o: ../../JuceLibraryCode/include_juce_video.cpp - -$(V_AT)mkdir -p $(JUCE_OBJDIR) + -$(V_AT)mkdir -p $(@D) @echo "Compiling include_juce_video.cpp" $(V_AT)$(CXX) $(JUCE_CXXFLAGS) $(JUCE_CPPFLAGS_DYNAMIC_LIBRARY) $(JUCE_CFLAGS_DYNAMIC_LIBRARY) -o "$@" -c "$<" +$(JUCE_OBJDIR)/execinfo.cmd: + -$(V_AT)mkdir -p $(@D) + -@if [ -z "$(V_AT)" ]; then echo "Checking if we need to link libexecinfo"; fi + $(V_AT)printf "int main() { return 0; }" | $(CXX) -x c++ -o $(@D)/execinfo.x -lexecinfo - >/dev/null 2>&1 && printf -- "-lexecinfo" > "$@" || touch "$@" + +$(JUCE_OBJDIR)/cxxfs.cmd: + -$(V_AT)mkdir -p $(@D) + -@if [ -z "$(V_AT)" ]; then echo "Checking if we need to link stdc++fs"; fi + $(V_AT)printf "int main() { return 0; }" | $(CXX) -x c++ -o $(@D)/cxxfs.x -lstdc++fs - >/dev/null 2>&1 && printf -- "-lstdc++fs" > "$@" || touch "$@" + clean: @echo Cleaning DawDreamer $(V_AT)$(CLEANCMD) diff --git a/Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj b/Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj index 7b60ab51..8b0b24cf 100644 --- a/Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj @@ -28,10 +28,12 @@ 7F31E8E6BCA6C4D063D57689 /* include_juce_gui_basics.mm */ = {isa = PBXBuildFile; fileRef = 9FDB1268E8AD800788F80B72; }; 8CB86F722980F4262C64B7D7 /* QuartzCore.framework */ = {isa = PBXBuildFile; fileRef = D2350C56CE13419F5D6CF40E; }; 911FCAF5D38B28CA617932B9 /* DataModel.cpp */ = {isa = PBXBuildFile; fileRef = 5691FDBCADAAE7C01869F756; }; + 9220E9F1E4B8AE7DA6C45322 /* Metal.framework */ = {isa = PBXBuildFile; fileRef = 862E281E065C481F1DD68ABE; settings = { ATTRIBUTES = (Weak, ); }; }; 92F6A21BA484A258A4EF5F23 /* PluginProcessor.cpp */ = {isa = PBXBuildFile; fileRef = 2F962B6F6EA479E59F083A16; }; 969FB6089449B8EF662494AE /* CoreAudio.framework */ = {isa = PBXBuildFile; fileRef = 2AFB20E3BF20B006326ADE78; }; 972909F8E3C96F724A1E69AE /* SamplerAudioProcessor.cpp */ = {isa = PBXBuildFile; fileRef = 9A5A5CF18A53538DC4C811D1; }; 9D34C1F40CAD6A7617F1B60B /* custom_pybind_wrappers.cpp */ = {isa = PBXBuildFile; fileRef = A2CE988FDEA16DA46477FB4B; }; + A216E35DCCBFEEC04D4A7E45 /* MetalKit.framework */ = {isa = PBXBuildFile; fileRef = 023080B0911E6794DD8D4D14; settings = { ATTRIBUTES = (Weak, ); }; }; A36633FC72AA916869FA8B33 /* source.cpp */ = {isa = PBXBuildFile; fileRef = 4B4337E31892157AAFCBD879; }; A376ADE2384A37361A90737F /* AVFoundation.framework */ = {isa = PBXBuildFile; fileRef = 4C016F8E9E5EB85EF51350D2; }; A57AA5B8EA2A23EF5E99E0D2 /* include_juce_opengl.mm */ = {isa = PBXBuildFile; fileRef = 066AA4F18B1578FAE9DEF375; }; @@ -61,6 +63,7 @@ /* Begin PBXFileReference section */ 0144F71788C0BA26D2427CEA /* ProcessorState.h */ /* ProcessorState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ProcessorState.h; path = ../../Source/Sampler/Source/ProcessorState.h; sourceTree = SOURCE_ROOT; }; + 023080B0911E6794DD8D4D14 /* MetalKit.framework */ /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 03A685E6693EE1741A43DE6D /* AppConfig.h */ /* AppConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AppConfig.h; path = ../../JuceLibraryCode/AppConfig.h; sourceTree = SOURCE_ROOT; }; 03BD258F06159505E43073E1 /* include_juce_audio_formats.mm */ /* include_juce_audio_formats.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = include_juce_audio_formats.mm; path = ../../JuceLibraryCode/include_juce_audio_formats.mm; sourceTree = SOURCE_ROOT; }; 0437FDFA6CF09192A01A9F89 /* SamplerAudioProcessorEditor.cpp */ /* SamplerAudioProcessorEditor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SamplerAudioProcessorEditor.cpp; path = ../../Source/Sampler/Source/SamplerAudioProcessorEditor.cpp; sourceTree = SOURCE_ROOT; }; @@ -125,6 +128,7 @@ 813727514E7E0F4593240E30 /* WaveformView.h */ /* WaveformView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WaveformView.h; path = ../../Source/Sampler/Source/Components/WaveformView.h; sourceTree = SOURCE_ROOT; }; 81E1E946E734ED2D5F139566 /* AudioToolbox.framework */ /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 845C73442A853AAC5FB09A34 /* SamplerAudioProcessor.h */ /* SamplerAudioProcessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SamplerAudioProcessor.h; path = ../../Source/Sampler/Source/SamplerAudioProcessor.h; sourceTree = SOURCE_ROOT; }; + 862E281E065C481F1DD68ABE /* Metal.framework */ /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; 8F78B14DAA164DE1331AD3FD /* Main.cpp */ /* Main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Main.cpp; path = ../../Source/Sampler/Source/Main.cpp; sourceTree = SOURCE_ROOT; }; 950B050EA948807CC56423AA /* Sample.h */ /* Sample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Sample.h; path = ../../Source/Sampler/Source/Sample.h; sourceTree = SOURCE_ROOT; }; 9A5A5CF18A53538DC4C811D1 /* SamplerAudioProcessor.cpp */ /* SamplerAudioProcessor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SamplerAudioProcessor.cpp; path = ../../Source/Sampler/Source/SamplerAudioProcessor.cpp; sourceTree = SOURCE_ROOT; }; @@ -196,6 +200,8 @@ 8CB86F722980F4262C64B7D7, DF5374E67F8812D79694279E, 31D395DB17463EFA64FFF6EE, + 9220E9F1E4B8AE7DA6C45322, + A216E35DCCBFEEC04D4A7E45, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -317,6 +323,8 @@ D2350C56CE13419F5D6CF40E, B243F8F5ADFF280683E55EE1, 7FC28740B3DC997941439C94, + 862E281E065C481F1DD68ABE, + 023080B0911E6794DD8D4D14, ); name = Frameworks; sourceTree = ""; @@ -436,6 +444,7 @@ 4A73310BAAAEBD94149F5709 = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1340; ORGANIZATIONNAME = ""; }; @@ -690,7 +699,7 @@ MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sratom $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/serd $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lv2 $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JuceLibraryCode/modules $(pythonLocation)/include/python$(PYTHONMAJOR) $(SRCROOT)/../../thirdparty $(SRCROOT)/../../thirdparty/pybind11/include $(SRCROOT)/../../thirdparty/faust/architecture $(SRCROOT)/../../thirdparty/faust/compiler $(SRCROOT)/../../thirdparty/faust/compiler/boxes $(SRCROOT)/../../thirdparty/faust/compiler/documentator $(SRCROOT)/../../thirdparty/faust/compiler/draw $(SRCROOT)/../../thirdparty/faust/compiler/draw/device $(SRCROOT)/../../thirdparty/faust/compiler/draw/schema $(SRCROOT)/../../thirdparty/faust/compiler/errors $(SRCROOT)/../../thirdparty/faust/compiler/evaluate $(SRCROOT)/../../thirdparty/faust/compiler/extended $(SRCROOT)/../../thirdparty/faust/compiler/generator $(SRCROOT)/../../thirdparty/faust/compiler/generator/interpreter $(SRCROOT)/../../thirdparty/faust/compiler/normalize $(SRCROOT)/../../thirdparty/faust/compiler/parallelize $(SRCROOT)/../../thirdparty/faust/compiler/parser $(SRCROOT)/../../thirdparty/faust/compiler/patternmatcher $(SRCROOT)/../../thirdparty/faust/compiler/propagate $(SRCROOT)/../../thirdparty/faust/compiler/signals $(SRCROOT)/../../thirdparty/faust/compiler/tlib $(SRCROOT)/../../thirdparty/faust/compiler/transform $(SRCROOT)/../../thirdparty/faust/compiler/utils $(SRCROOT)/../../thirdparty/libsamplerate/src $(SRCROOT)/../../thirdparty/libsamplerate/include"; OTHER_CFLAGS = "-fPIC"; OTHER_CPLUSPLUSFLAGS = "-fPIC"; - OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup -weak_framework Metal -weak_framework MetalKit"; + OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup"; PRODUCT_BUNDLE_IDENTIFIER = design.dirt.DawDreamer; PRODUCT_NAME = "dawdreamer.so"; USE_HEADERMAP = NO; @@ -787,7 +796,7 @@ MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sratom $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/serd $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lv2 $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JuceLibraryCode/modules $(pythonLocation)/include/python$(PYTHONMAJOR) $(SRCROOT)/../../thirdparty $(SRCROOT)/../../thirdparty/pybind11/include $(SRCROOT)/../../thirdparty/faust/architecture $(SRCROOT)/../../thirdparty/faust/compiler $(SRCROOT)/../../thirdparty/faust/compiler/boxes $(SRCROOT)/../../thirdparty/faust/compiler/documentator $(SRCROOT)/../../thirdparty/faust/compiler/draw $(SRCROOT)/../../thirdparty/faust/compiler/draw/device $(SRCROOT)/../../thirdparty/faust/compiler/draw/schema $(SRCROOT)/../../thirdparty/faust/compiler/errors $(SRCROOT)/../../thirdparty/faust/compiler/evaluate $(SRCROOT)/../../thirdparty/faust/compiler/extended $(SRCROOT)/../../thirdparty/faust/compiler/generator $(SRCROOT)/../../thirdparty/faust/compiler/generator/interpreter $(SRCROOT)/../../thirdparty/faust/compiler/normalize $(SRCROOT)/../../thirdparty/faust/compiler/parallelize $(SRCROOT)/../../thirdparty/faust/compiler/parser $(SRCROOT)/../../thirdparty/faust/compiler/patternmatcher $(SRCROOT)/../../thirdparty/faust/compiler/propagate $(SRCROOT)/../../thirdparty/faust/compiler/signals $(SRCROOT)/../../thirdparty/faust/compiler/tlib $(SRCROOT)/../../thirdparty/faust/compiler/transform $(SRCROOT)/../../thirdparty/faust/compiler/utils $(SRCROOT)/../../thirdparty/libsamplerate/src $(SRCROOT)/../../thirdparty/libsamplerate/include"; OTHER_CFLAGS = "-fPIC"; OTHER_CPLUSPLUSFLAGS = "-fPIC"; - OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup -weak_framework Metal -weak_framework MetalKit"; + OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup"; PRODUCT_BUNDLE_IDENTIFIER = design.dirt.DawDreamer; PRODUCT_NAME = "dawdreamer.so"; USE_HEADERMAP = NO; @@ -884,7 +893,7 @@ MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lilv $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sratom $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord/src $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/sord $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/serd $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK/lv2 $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/LV2_SDK $(SRCROOT)/../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JuceLibraryCode/modules $(pythonLocation)/include/python$(PYTHONMAJOR) $(SRCROOT)/../../thirdparty $(SRCROOT)/../../thirdparty/pybind11/include $(SRCROOT)/../../thirdparty/faust/architecture $(SRCROOT)/../../thirdparty/faust/compiler $(SRCROOT)/../../thirdparty/faust/compiler/boxes $(SRCROOT)/../../thirdparty/faust/compiler/documentator $(SRCROOT)/../../thirdparty/faust/compiler/draw $(SRCROOT)/../../thirdparty/faust/compiler/draw/device $(SRCROOT)/../../thirdparty/faust/compiler/draw/schema $(SRCROOT)/../../thirdparty/faust/compiler/errors $(SRCROOT)/../../thirdparty/faust/compiler/evaluate $(SRCROOT)/../../thirdparty/faust/compiler/extended $(SRCROOT)/../../thirdparty/faust/compiler/generator $(SRCROOT)/../../thirdparty/faust/compiler/generator/interpreter $(SRCROOT)/../../thirdparty/faust/compiler/normalize $(SRCROOT)/../../thirdparty/faust/compiler/parallelize $(SRCROOT)/../../thirdparty/faust/compiler/parser $(SRCROOT)/../../thirdparty/faust/compiler/patternmatcher $(SRCROOT)/../../thirdparty/faust/compiler/propagate $(SRCROOT)/../../thirdparty/faust/compiler/signals $(SRCROOT)/../../thirdparty/faust/compiler/tlib $(SRCROOT)/../../thirdparty/faust/compiler/transform $(SRCROOT)/../../thirdparty/faust/compiler/utils $(SRCROOT)/../../thirdparty/libsamplerate/src $(SRCROOT)/../../thirdparty/libsamplerate/include"; OTHER_CFLAGS = "-fPIC"; OTHER_CPLUSPLUSFLAGS = "-fPIC"; - OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup -weak_framework Metal -weak_framework MetalKit"; + OTHER_LDFLAGS = "-lsamplerate -lfaustwithllvm -shared -Wl,-undefined,dynamic_lookup"; PRODUCT_BUNDLE_IDENTIFIER = design.dirt.DawDreamer; PRODUCT_NAME = "dawdreamer.so"; USE_HEADERMAP = NO; diff --git a/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj b/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj index 90235e49..b209a7a3 100644 --- a/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj +++ b/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj @@ -285,6 +285,9 @@ true + + true + true @@ -1059,6 +1062,9 @@ true + + true + true @@ -1122,6 +1128,12 @@ true + + true + + + true + true @@ -1158,6 +1170,9 @@ true + + true + true @@ -1440,9 +1455,6 @@ true - - true - true @@ -2525,7 +2537,9 @@ - + + /bigobj %(AdditionalOptions) + @@ -2623,6 +2637,7 @@ + @@ -2637,6 +2652,7 @@ + @@ -3028,6 +3044,7 @@ + @@ -3056,6 +3073,8 @@ + + @@ -3086,6 +3105,7 @@ + @@ -3104,6 +3124,7 @@ + @@ -3191,7 +3212,6 @@ - diff --git a/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj.filters b/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj.filters index d188c42b..ef041931 100644 --- a/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj.filters +++ b/Builds/VisualStudio2022/DawDreamer_DynamicLibrary.vcxproj.filters @@ -389,6 +389,9 @@ {0F70B1A9-BB50-23F5-2AE7-F95E51A00389} + + {D4D9BC01-0DED-2577-4B99-2FF7B9C7EF8A} + {D4C8DC40-2CD2-04B6-05D0-1E7A88841390} @@ -802,6 +805,9 @@ JUCE Modules\juce_audio_basics\utilities + + JUCE Modules\juce_audio_basics\utilities + JUCE Modules\juce_audio_basics\utilities @@ -1597,6 +1603,9 @@ JUCE Modules\juce_core\containers + + JUCE Modules\juce_core\containers + JUCE Modules\juce_core\containers @@ -1660,6 +1669,12 @@ JUCE Modules\juce_core\javascript + + JUCE Modules\juce_core\javascript + + + JUCE Modules\juce_core\javascript + JUCE Modules\juce_core\logging @@ -1696,6 +1711,9 @@ JUCE Modules\juce_core\misc + + JUCE Modules\juce_core\misc + JUCE Modules\juce_core\misc @@ -1741,6 +1759,9 @@ JUCE Modules\juce_core\native + + JUCE Modules\juce_core\native + JUCE Modules\juce_core\native @@ -2002,9 +2023,6 @@ JUCE Modules\juce_dsp\containers - - JUCE Modules\juce_dsp\containers - JUCE Modules\juce_dsp\containers @@ -3471,6 +3489,9 @@ JUCE Modules\juce_audio_basics\mpe + + JUCE Modules\juce_audio_basics\native + JUCE Modules\juce_audio_basics\native @@ -3513,6 +3534,9 @@ JUCE Modules\juce_audio_basics\utilities + + JUCE Modules\juce_audio_basics\utilities + JUCE Modules\juce_audio_basics\utilities @@ -4686,6 +4710,9 @@ JUCE Modules\juce_core\containers + + JUCE Modules\juce_core\containers + JUCE Modules\juce_core\containers @@ -4770,6 +4797,12 @@ JUCE Modules\juce_core\javascript + + JUCE Modules\juce_core\javascript + + + JUCE Modules\juce_core\javascript + JUCE Modules\juce_core\logging @@ -4860,6 +4893,9 @@ JUCE Modules\juce_core\misc + + JUCE Modules\juce_core\misc + JUCE Modules\juce_core\misc @@ -4914,6 +4950,9 @@ JUCE Modules\juce_core\network + + JUCE Modules\juce_core\serialisation + JUCE Modules\juce_core\streams @@ -5175,9 +5214,6 @@ JUCE Modules\juce_dsp\containers - - JUCE Modules\juce_dsp\containers - JUCE Modules\juce_dsp\containers diff --git a/JuceLibraryCode/AppConfig.h b/JuceLibraryCode/AppConfig.h index b6baecc9..00853270 100644 --- a/JuceLibraryCode/AppConfig.h +++ b/JuceLibraryCode/AppConfig.h @@ -43,7 +43,7 @@ #define JUCE_USE_DARK_SPLASH_SCREEN 1 -#define JUCE_PROJUCER_VERSION 0x70005 +#define JUCE_PROJUCER_VERSION 0x70008 //============================================================================== #define JUCE_MODULE_AVAILABLE_juce_audio_basics 1 diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp index 7f053d31..2507ea98 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp @@ -46,105 +46,105 @@ String AudioChannelSet::getChannelTypeName (AudioChannelSet::ChannelType type) switch (type) { - case left: return NEEDS_TRANS("Left"); - case right: return NEEDS_TRANS("Right"); - case centre: return NEEDS_TRANS("Centre"); - case LFE: return NEEDS_TRANS("LFE"); - case leftSurround: return NEEDS_TRANS("Left Surround"); - case rightSurround: return NEEDS_TRANS("Right Surround"); - case leftCentre: return NEEDS_TRANS("Left Centre"); - case rightCentre: return NEEDS_TRANS("Right Centre"); - case centreSurround: return NEEDS_TRANS("Centre Surround"); - case leftSurroundRear: return NEEDS_TRANS("Left Surround Rear"); - case rightSurroundRear: return NEEDS_TRANS("Right Surround Rear"); - case topMiddle: return NEEDS_TRANS("Top Middle"); - case topFrontLeft: return NEEDS_TRANS("Top Front Left"); - case topFrontCentre: return NEEDS_TRANS("Top Front Centre"); - case topFrontRight: return NEEDS_TRANS("Top Front Right"); - case topRearLeft: return NEEDS_TRANS("Top Rear Left"); - case topRearCentre: return NEEDS_TRANS("Top Rear Centre"); - case topRearRight: return NEEDS_TRANS("Top Rear Right"); - case wideLeft: return NEEDS_TRANS("Wide Left"); - case wideRight: return NEEDS_TRANS("Wide Right"); - case LFE2: return NEEDS_TRANS("LFE 2"); - case leftSurroundSide: return NEEDS_TRANS("Left Surround Side"); - case rightSurroundSide: return NEEDS_TRANS("Right Surround Side"); - case ambisonicW: return NEEDS_TRANS("Ambisonic W"); - case ambisonicX: return NEEDS_TRANS("Ambisonic X"); - case ambisonicY: return NEEDS_TRANS("Ambisonic Y"); - case ambisonicZ: return NEEDS_TRANS("Ambisonic Z"); - case topSideLeft: return NEEDS_TRANS("Top Side Left"); - case topSideRight: return NEEDS_TRANS("Top Side Right"); - case ambisonicACN4: return NEEDS_TRANS("Ambisonic 4"); - case ambisonicACN5: return NEEDS_TRANS("Ambisonic 5"); - case ambisonicACN6: return NEEDS_TRANS("Ambisonic 6"); - case ambisonicACN7: return NEEDS_TRANS("Ambisonic 7"); - case ambisonicACN8: return NEEDS_TRANS("Ambisonic 8"); - case ambisonicACN9: return NEEDS_TRANS("Ambisonic 9"); - case ambisonicACN10: return NEEDS_TRANS("Ambisonic 10"); - case ambisonicACN11: return NEEDS_TRANS("Ambisonic 11"); - case ambisonicACN12: return NEEDS_TRANS("Ambisonic 12"); - case ambisonicACN13: return NEEDS_TRANS("Ambisonic 13"); - case ambisonicACN14: return NEEDS_TRANS("Ambisonic 14"); - case ambisonicACN15: return NEEDS_TRANS("Ambisonic 15"); - case ambisonicACN16: return NEEDS_TRANS("Ambisonic 16"); - case ambisonicACN17: return NEEDS_TRANS("Ambisonic 17"); - case ambisonicACN18: return NEEDS_TRANS("Ambisonic 18"); - case ambisonicACN19: return NEEDS_TRANS("Ambisonic 19"); - case ambisonicACN20: return NEEDS_TRANS("Ambisonic 20"); - case ambisonicACN21: return NEEDS_TRANS("Ambisonic 21"); - case ambisonicACN22: return NEEDS_TRANS("Ambisonic 22"); - case ambisonicACN23: return NEEDS_TRANS("Ambisonic 23"); - case ambisonicACN24: return NEEDS_TRANS("Ambisonic 24"); - case ambisonicACN25: return NEEDS_TRANS("Ambisonic 25"); - case ambisonicACN26: return NEEDS_TRANS("Ambisonic 26"); - case ambisonicACN27: return NEEDS_TRANS("Ambisonic 27"); - case ambisonicACN28: return NEEDS_TRANS("Ambisonic 28"); - case ambisonicACN29: return NEEDS_TRANS("Ambisonic 29"); - case ambisonicACN30: return NEEDS_TRANS("Ambisonic 30"); - case ambisonicACN31: return NEEDS_TRANS("Ambisonic 31"); - case ambisonicACN32: return NEEDS_TRANS("Ambisonic 32"); - case ambisonicACN33: return NEEDS_TRANS("Ambisonic 33"); - case ambisonicACN34: return NEEDS_TRANS("Ambisonic 34"); - case ambisonicACN35: return NEEDS_TRANS("Ambisonic 35"); - case ambisonicACN36: return NEEDS_TRANS("Ambisonic 36"); - case ambisonicACN37: return NEEDS_TRANS("Ambisonic 37"); - case ambisonicACN38: return NEEDS_TRANS("Ambisonic 38"); - case ambisonicACN39: return NEEDS_TRANS("Ambisonic 39"); - case ambisonicACN40: return NEEDS_TRANS("Ambisonic 40"); - case ambisonicACN41: return NEEDS_TRANS("Ambisonic 41"); - case ambisonicACN42: return NEEDS_TRANS("Ambisonic 42"); - case ambisonicACN43: return NEEDS_TRANS("Ambisonic 43"); - case ambisonicACN44: return NEEDS_TRANS("Ambisonic 44"); - case ambisonicACN45: return NEEDS_TRANS("Ambisonic 45"); - case ambisonicACN46: return NEEDS_TRANS("Ambisonic 46"); - case ambisonicACN47: return NEEDS_TRANS("Ambisonic 47"); - case ambisonicACN48: return NEEDS_TRANS("Ambisonic 48"); - case ambisonicACN49: return NEEDS_TRANS("Ambisonic 49"); - case ambisonicACN50: return NEEDS_TRANS("Ambisonic 50"); - case ambisonicACN51: return NEEDS_TRANS("Ambisonic 51"); - case ambisonicACN52: return NEEDS_TRANS("Ambisonic 52"); - case ambisonicACN53: return NEEDS_TRANS("Ambisonic 53"); - case ambisonicACN54: return NEEDS_TRANS("Ambisonic 54"); - case ambisonicACN55: return NEEDS_TRANS("Ambisonic 55"); - case ambisonicACN56: return NEEDS_TRANS("Ambisonic 56"); - case ambisonicACN57: return NEEDS_TRANS("Ambisonic 57"); - case ambisonicACN58: return NEEDS_TRANS("Ambisonic 58"); - case ambisonicACN59: return NEEDS_TRANS("Ambisonic 59"); - case ambisonicACN60: return NEEDS_TRANS("Ambisonic 60"); - case ambisonicACN61: return NEEDS_TRANS("Ambisonic 61"); - case ambisonicACN62: return NEEDS_TRANS("Ambisonic 62"); - case ambisonicACN63: return NEEDS_TRANS("Ambisonic 63"); - case bottomFrontLeft: return NEEDS_TRANS("Bottom Front Left"); - case bottomFrontCentre: return NEEDS_TRANS("Bottom Front Centre"); - case bottomFrontRight: return NEEDS_TRANS("Bottom Front Right"); - case proximityLeft: return NEEDS_TRANS("Proximity Left"); - case proximityRight: return NEEDS_TRANS("Proximity Right"); - case bottomSideLeft: return NEEDS_TRANS("Bottom Side Left"); - case bottomSideRight: return NEEDS_TRANS("Bottom Side Right"); - case bottomRearLeft: return NEEDS_TRANS("Bottom Rear Left"); - case bottomRearCentre: return NEEDS_TRANS("Bottom Rear Centre"); - case bottomRearRight: return NEEDS_TRANS("Bottom Rear Right"); + case left: return NEEDS_TRANS ("Left"); + case right: return NEEDS_TRANS ("Right"); + case centre: return NEEDS_TRANS ("Centre"); + case LFE: return NEEDS_TRANS ("LFE"); + case leftSurround: return NEEDS_TRANS ("Left Surround"); + case rightSurround: return NEEDS_TRANS ("Right Surround"); + case leftCentre: return NEEDS_TRANS ("Left Centre"); + case rightCentre: return NEEDS_TRANS ("Right Centre"); + case centreSurround: return NEEDS_TRANS ("Centre Surround"); + case leftSurroundRear: return NEEDS_TRANS ("Left Surround Rear"); + case rightSurroundRear: return NEEDS_TRANS ("Right Surround Rear"); + case topMiddle: return NEEDS_TRANS ("Top Middle"); + case topFrontLeft: return NEEDS_TRANS ("Top Front Left"); + case topFrontCentre: return NEEDS_TRANS ("Top Front Centre"); + case topFrontRight: return NEEDS_TRANS ("Top Front Right"); + case topRearLeft: return NEEDS_TRANS ("Top Rear Left"); + case topRearCentre: return NEEDS_TRANS ("Top Rear Centre"); + case topRearRight: return NEEDS_TRANS ("Top Rear Right"); + case wideLeft: return NEEDS_TRANS ("Wide Left"); + case wideRight: return NEEDS_TRANS ("Wide Right"); + case LFE2: return NEEDS_TRANS ("LFE 2"); + case leftSurroundSide: return NEEDS_TRANS ("Left Surround Side"); + case rightSurroundSide: return NEEDS_TRANS ("Right Surround Side"); + case ambisonicW: return NEEDS_TRANS ("Ambisonic W"); + case ambisonicX: return NEEDS_TRANS ("Ambisonic X"); + case ambisonicY: return NEEDS_TRANS ("Ambisonic Y"); + case ambisonicZ: return NEEDS_TRANS ("Ambisonic Z"); + case topSideLeft: return NEEDS_TRANS ("Top Side Left"); + case topSideRight: return NEEDS_TRANS ("Top Side Right"); + case ambisonicACN4: return NEEDS_TRANS ("Ambisonic 4"); + case ambisonicACN5: return NEEDS_TRANS ("Ambisonic 5"); + case ambisonicACN6: return NEEDS_TRANS ("Ambisonic 6"); + case ambisonicACN7: return NEEDS_TRANS ("Ambisonic 7"); + case ambisonicACN8: return NEEDS_TRANS ("Ambisonic 8"); + case ambisonicACN9: return NEEDS_TRANS ("Ambisonic 9"); + case ambisonicACN10: return NEEDS_TRANS ("Ambisonic 10"); + case ambisonicACN11: return NEEDS_TRANS ("Ambisonic 11"); + case ambisonicACN12: return NEEDS_TRANS ("Ambisonic 12"); + case ambisonicACN13: return NEEDS_TRANS ("Ambisonic 13"); + case ambisonicACN14: return NEEDS_TRANS ("Ambisonic 14"); + case ambisonicACN15: return NEEDS_TRANS ("Ambisonic 15"); + case ambisonicACN16: return NEEDS_TRANS ("Ambisonic 16"); + case ambisonicACN17: return NEEDS_TRANS ("Ambisonic 17"); + case ambisonicACN18: return NEEDS_TRANS ("Ambisonic 18"); + case ambisonicACN19: return NEEDS_TRANS ("Ambisonic 19"); + case ambisonicACN20: return NEEDS_TRANS ("Ambisonic 20"); + case ambisonicACN21: return NEEDS_TRANS ("Ambisonic 21"); + case ambisonicACN22: return NEEDS_TRANS ("Ambisonic 22"); + case ambisonicACN23: return NEEDS_TRANS ("Ambisonic 23"); + case ambisonicACN24: return NEEDS_TRANS ("Ambisonic 24"); + case ambisonicACN25: return NEEDS_TRANS ("Ambisonic 25"); + case ambisonicACN26: return NEEDS_TRANS ("Ambisonic 26"); + case ambisonicACN27: return NEEDS_TRANS ("Ambisonic 27"); + case ambisonicACN28: return NEEDS_TRANS ("Ambisonic 28"); + case ambisonicACN29: return NEEDS_TRANS ("Ambisonic 29"); + case ambisonicACN30: return NEEDS_TRANS ("Ambisonic 30"); + case ambisonicACN31: return NEEDS_TRANS ("Ambisonic 31"); + case ambisonicACN32: return NEEDS_TRANS ("Ambisonic 32"); + case ambisonicACN33: return NEEDS_TRANS ("Ambisonic 33"); + case ambisonicACN34: return NEEDS_TRANS ("Ambisonic 34"); + case ambisonicACN35: return NEEDS_TRANS ("Ambisonic 35"); + case ambisonicACN36: return NEEDS_TRANS ("Ambisonic 36"); + case ambisonicACN37: return NEEDS_TRANS ("Ambisonic 37"); + case ambisonicACN38: return NEEDS_TRANS ("Ambisonic 38"); + case ambisonicACN39: return NEEDS_TRANS ("Ambisonic 39"); + case ambisonicACN40: return NEEDS_TRANS ("Ambisonic 40"); + case ambisonicACN41: return NEEDS_TRANS ("Ambisonic 41"); + case ambisonicACN42: return NEEDS_TRANS ("Ambisonic 42"); + case ambisonicACN43: return NEEDS_TRANS ("Ambisonic 43"); + case ambisonicACN44: return NEEDS_TRANS ("Ambisonic 44"); + case ambisonicACN45: return NEEDS_TRANS ("Ambisonic 45"); + case ambisonicACN46: return NEEDS_TRANS ("Ambisonic 46"); + case ambisonicACN47: return NEEDS_TRANS ("Ambisonic 47"); + case ambisonicACN48: return NEEDS_TRANS ("Ambisonic 48"); + case ambisonicACN49: return NEEDS_TRANS ("Ambisonic 49"); + case ambisonicACN50: return NEEDS_TRANS ("Ambisonic 50"); + case ambisonicACN51: return NEEDS_TRANS ("Ambisonic 51"); + case ambisonicACN52: return NEEDS_TRANS ("Ambisonic 52"); + case ambisonicACN53: return NEEDS_TRANS ("Ambisonic 53"); + case ambisonicACN54: return NEEDS_TRANS ("Ambisonic 54"); + case ambisonicACN55: return NEEDS_TRANS ("Ambisonic 55"); + case ambisonicACN56: return NEEDS_TRANS ("Ambisonic 56"); + case ambisonicACN57: return NEEDS_TRANS ("Ambisonic 57"); + case ambisonicACN58: return NEEDS_TRANS ("Ambisonic 58"); + case ambisonicACN59: return NEEDS_TRANS ("Ambisonic 59"); + case ambisonicACN60: return NEEDS_TRANS ("Ambisonic 60"); + case ambisonicACN61: return NEEDS_TRANS ("Ambisonic 61"); + case ambisonicACN62: return NEEDS_TRANS ("Ambisonic 62"); + case ambisonicACN63: return NEEDS_TRANS ("Ambisonic 63"); + case bottomFrontLeft: return NEEDS_TRANS ("Bottom Front Left"); + case bottomFrontCentre: return NEEDS_TRANS ("Bottom Front Centre"); + case bottomFrontRight: return NEEDS_TRANS ("Bottom Front Right"); + case proximityLeft: return NEEDS_TRANS ("Proximity Left"); + case proximityRight: return NEEDS_TRANS ("Proximity Right"); + case bottomSideLeft: return NEEDS_TRANS ("Bottom Side Left"); + case bottomSideRight: return NEEDS_TRANS ("Bottom Side Right"); + case bottomRearLeft: return NEEDS_TRANS ("Bottom Rear Left"); + case bottomRearCentre: return NEEDS_TRANS ("Bottom Rear Centre"); + case bottomRearRight: return NEEDS_TRANS ("Bottom Rear Right"); case discreteChannel0: case unknown: default: break; @@ -487,7 +487,7 @@ int AudioChannelSet::size() const noexcept AudioChannelSet::ChannelType AudioChannelSet::getTypeOfChannel (int index) const noexcept { - int bit = channels.findNextSetBit(0); + int bit = channels.findNextSetBit (0); for (int i = 0; i < index && bit >= 0; ++i) bit = channels.findNextSetBit (bit + 1); @@ -514,7 +514,7 @@ Array AudioChannelSet::getChannelTypes() const { Array result; - for (int bit = channels.findNextSetBit(0); bit >= 0; bit = channels.findNextSetBit (bit + 1)) + for (int bit = channels.findNextSetBit (0); bit >= 0; bit = channels.findNextSetBit (bit + 1)) result.add (static_cast (bit)); return result; @@ -750,7 +750,7 @@ int AudioChannelSet::getAmbisonicOrderForNumChannels (int numChannels, int maxOr //============================================================================== #if JUCE_UNIT_TESTS -class AudioChannelSetUnitTest : public UnitTest +class AudioChannelSetUnitTest final : public UnitTest { public: AudioChannelSetUnitTest() diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index f5e9c668..89aba5a3 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -454,7 +454,7 @@ void AudioDataConverters::deinterleaveSamples (const float* source, float** dest //============================================================================== #if JUCE_UNIT_TESTS -class AudioConversionTests : public UnitTest +class AudioConversionTests final : public UnitTest { public: AudioConversionTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h index c5907447..d3699f8e 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h @@ -279,7 +279,7 @@ class JUCE_API AudioData public: inline NonInterleaved() = default; inline NonInterleaved (const NonInterleaved&) = default; - inline NonInterleaved (const int) noexcept {} + inline NonInterleaved (int) noexcept {} inline void copyFrom (const NonInterleaved&) noexcept {} template inline void advanceData (SampleFormatType& s) noexcept { s.advance(); } template inline void advanceDataBy (SampleFormatType& s, int numSamples) noexcept { s.skip (numSamples); } diff --git a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index 1079e872..6ead8545 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -1555,7 +1555,7 @@ ScopedNoDenormals::~ScopedNoDenormals() noexcept //============================================================================== #if JUCE_UNIT_TESTS -class FloatVectorOperationsTests : public UnitTest +class FloatVectorOperationsTests final : public UnitTest { public: FloatVectorOperationsTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp index 260635fa..32335130 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.cpp @@ -39,13 +39,18 @@ #include #endif -#ifndef JUCE_USE_VDSP_FRAMEWORK - #define JUCE_USE_VDSP_FRAMEWORK 1 -#endif +#if JUCE_MAC || JUCE_IOS + #ifndef JUCE_USE_VDSP_FRAMEWORK + #define JUCE_USE_VDSP_FRAMEWORK 1 + #endif + + #if JUCE_USE_VDSP_FRAMEWORK + #include + #endif -#if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK - #include -#else + #include "native/juce_AudioWorkgroup_mac.h" + +#elif JUCE_USE_VDSP_FRAMEWORK #undef JUCE_USE_VDSP_FRAMEWORK #endif @@ -89,13 +94,13 @@ #include "synthesisers/juce_Synthesiser.cpp" #include "audio_play_head/juce_AudioPlayHead.cpp" #include "midi/juce_MidiDataConcatenator.h" - #include "midi/ump/juce_UMP.h" #include "midi/ump/juce_UMPUtils.cpp" #include "midi/ump/juce_UMPView.cpp" #include "midi/ump/juce_UMPSysEx7.cpp" #include "midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.cpp" #include "midi/ump/juce_UMPIterator.cpp" +#include "utilities/juce_AudioWorkgroup.cpp" #if JUCE_UNIT_TESTS #include "utilities/juce_ADSR_test.cpp" diff --git a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h index 6a8c999d..f2fd112b 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h +++ b/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h @@ -32,7 +32,7 @@ ID: juce_audio_basics vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE audio and MIDI data classes description: Classes for audio buffer manipulation, midi message handling, synthesis, etc. website: http://www.juce.com/juce @@ -123,3 +123,4 @@ JUCE_END_IGNORE_WARNINGS_MSVC #include "sources/juce_ToneGeneratorAudioSource.h" #include "synthesisers/juce_Synthesiser.h" #include "audio_play_head/juce_AudioPlayHead.h" +#include "utilities/juce_AudioWorkgroup.h" diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp index f3bdd2cd..7ae0068a 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp @@ -252,7 +252,7 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE //============================================================================== #if JUCE_UNIT_TESTS -struct MidiBufferTest : public UnitTest +struct MidiBufferTest final : public UnitTest { MidiBufferTest() : UnitTest ("MidiBuffer", UnitTestCategories::midi) diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.h index 6a2a5413..404ccf17 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -33,7 +33,7 @@ namespace juce @tags{Audio} */ -struct MidiMessageMetadata final +struct MidiMessageMetadata { MidiMessageMetadata() noexcept = default; diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiFile.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiFile.cpp index 51bfcdda..5d220352 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiFile.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiFile.cpp @@ -200,7 +200,7 @@ namespace MidiFileHelpers for (int j = 0; j < numEvents; ++j) { - auto& m = track->getEventPointer(j)->message; + auto& m = track->getEventPointer (j)->message; if ((m.*method)()) results.addEvent (m); @@ -439,7 +439,7 @@ void MidiFile::convertTimestampTicksToSeconds() { for (int j = ms->getNumEvents(); --j >= 0;) { - auto& m = ms->getEventPointer(j)->message; + auto& m = ms->getEventPointer (j)->message; m.setTimeStamp (MidiFileHelpers::convertTicksToSeconds (m.getTimeStamp(), tempoEvents, timeFormat)); } } @@ -475,7 +475,7 @@ bool MidiFile::writeTrack (OutputStream& mainOut, const MidiMessageSequence& ms) for (int i = 0; i < ms.getNumEvents(); ++i) { - auto& mm = ms.getEventPointer(i)->message; + auto& mm = ms.getEventPointer (i)->message; if (mm.isEndOfTrackMetaEvent()) endOfTrackEventWritten = true; @@ -530,7 +530,7 @@ bool MidiFile::writeTrack (OutputStream& mainOut, const MidiMessageSequence& ms) //============================================================================== #if JUCE_UNIT_TESTS -struct MidiFileTest : public UnitTest +struct MidiFileTest final : public UnitTest { MidiFileTest() : UnitTest ("MidiFile", UnitTestCategories::midi) diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index 062262b0..876760c5 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -404,7 +404,7 @@ void MidiMessage::setChannel (const int channel) noexcept if ((data[0] & 0xf0) != (uint8) 0xf0) data[0] = (uint8) ((data[0] & (uint8) 0xf0) - | (uint8)(channel - 1)); + | (uint8) (channel - 1)); } bool MidiMessage::isNoteOn (const bool returnTrueForVelocity0) const noexcept @@ -1048,38 +1048,38 @@ const char* MidiMessage::getGMInstrumentName (const int n) { static const char* names[] = { - NEEDS_TRANS("Acoustic Grand Piano"), NEEDS_TRANS("Bright Acoustic Piano"), NEEDS_TRANS("Electric Grand Piano"), NEEDS_TRANS("Honky-tonk Piano"), - NEEDS_TRANS("Electric Piano 1"), NEEDS_TRANS("Electric Piano 2"), NEEDS_TRANS("Harpsichord"), NEEDS_TRANS("Clavinet"), - NEEDS_TRANS("Celesta"), NEEDS_TRANS("Glockenspiel"), NEEDS_TRANS("Music Box"), NEEDS_TRANS("Vibraphone"), - NEEDS_TRANS("Marimba"), NEEDS_TRANS("Xylophone"), NEEDS_TRANS("Tubular Bells"), NEEDS_TRANS("Dulcimer"), - NEEDS_TRANS("Drawbar Organ"), NEEDS_TRANS("Percussive Organ"), NEEDS_TRANS("Rock Organ"), NEEDS_TRANS("Church Organ"), - NEEDS_TRANS("Reed Organ"), NEEDS_TRANS("Accordion"), NEEDS_TRANS("Harmonica"), NEEDS_TRANS("Tango Accordion"), - NEEDS_TRANS("Acoustic Guitar (nylon)"), NEEDS_TRANS("Acoustic Guitar (steel)"), NEEDS_TRANS("Electric Guitar (jazz)"), NEEDS_TRANS("Electric Guitar (clean)"), - NEEDS_TRANS("Electric Guitar (mute)"), NEEDS_TRANS("Overdriven Guitar"), NEEDS_TRANS("Distortion Guitar"), NEEDS_TRANS("Guitar Harmonics"), - NEEDS_TRANS("Acoustic Bass"), NEEDS_TRANS("Electric Bass (finger)"), NEEDS_TRANS("Electric Bass (pick)"), NEEDS_TRANS("Fretless Bass"), - NEEDS_TRANS("Slap Bass 1"), NEEDS_TRANS("Slap Bass 2"), NEEDS_TRANS("Synth Bass 1"), NEEDS_TRANS("Synth Bass 2"), - NEEDS_TRANS("Violin"), NEEDS_TRANS("Viola"), NEEDS_TRANS("Cello"), NEEDS_TRANS("Contrabass"), - NEEDS_TRANS("Tremolo Strings"), NEEDS_TRANS("Pizzicato Strings"), NEEDS_TRANS("Orchestral Harp"), NEEDS_TRANS("Timpani"), - NEEDS_TRANS("String Ensemble 1"), NEEDS_TRANS("String Ensemble 2"), NEEDS_TRANS("SynthStrings 1"), NEEDS_TRANS("SynthStrings 2"), - NEEDS_TRANS("Choir Aahs"), NEEDS_TRANS("Voice Oohs"), NEEDS_TRANS("Synth Voice"), NEEDS_TRANS("Orchestra Hit"), - NEEDS_TRANS("Trumpet"), NEEDS_TRANS("Trombone"), NEEDS_TRANS("Tuba"), NEEDS_TRANS("Muted Trumpet"), - NEEDS_TRANS("French Horn"), NEEDS_TRANS("Brass Section"), NEEDS_TRANS("SynthBrass 1"), NEEDS_TRANS("SynthBrass 2"), - NEEDS_TRANS("Soprano Sax"), NEEDS_TRANS("Alto Sax"), NEEDS_TRANS("Tenor Sax"), NEEDS_TRANS("Baritone Sax"), - NEEDS_TRANS("Oboe"), NEEDS_TRANS("English Horn"), NEEDS_TRANS("Bassoon"), NEEDS_TRANS("Clarinet"), - NEEDS_TRANS("Piccolo"), NEEDS_TRANS("Flute"), NEEDS_TRANS("Recorder"), NEEDS_TRANS("Pan Flute"), - NEEDS_TRANS("Blown Bottle"), NEEDS_TRANS("Shakuhachi"), NEEDS_TRANS("Whistle"), NEEDS_TRANS("Ocarina"), - NEEDS_TRANS("Lead 1 (square)"), NEEDS_TRANS("Lead 2 (sawtooth)"), NEEDS_TRANS("Lead 3 (calliope)"), NEEDS_TRANS("Lead 4 (chiff)"), - NEEDS_TRANS("Lead 5 (charang)"), NEEDS_TRANS("Lead 6 (voice)"), NEEDS_TRANS("Lead 7 (fifths)"), NEEDS_TRANS("Lead 8 (bass+lead)"), - NEEDS_TRANS("Pad 1 (new age)"), NEEDS_TRANS("Pad 2 (warm)"), NEEDS_TRANS("Pad 3 (polysynth)"), NEEDS_TRANS("Pad 4 (choir)"), - NEEDS_TRANS("Pad 5 (bowed)"), NEEDS_TRANS("Pad 6 (metallic)"), NEEDS_TRANS("Pad 7 (halo)"), NEEDS_TRANS("Pad 8 (sweep)"), - NEEDS_TRANS("FX 1 (rain)"), NEEDS_TRANS("FX 2 (soundtrack)"), NEEDS_TRANS("FX 3 (crystal)"), NEEDS_TRANS("FX 4 (atmosphere)"), - NEEDS_TRANS("FX 5 (brightness)"), NEEDS_TRANS("FX 6 (goblins)"), NEEDS_TRANS("FX 7 (echoes)"), NEEDS_TRANS("FX 8 (sci-fi)"), - NEEDS_TRANS("Sitar"), NEEDS_TRANS("Banjo"), NEEDS_TRANS("Shamisen"), NEEDS_TRANS("Koto"), - NEEDS_TRANS("Kalimba"), NEEDS_TRANS("Bag pipe"), NEEDS_TRANS("Fiddle"), NEEDS_TRANS("Shanai"), - NEEDS_TRANS("Tinkle Bell"), NEEDS_TRANS("Agogo"), NEEDS_TRANS("Steel Drums"), NEEDS_TRANS("Woodblock"), - NEEDS_TRANS("Taiko Drum"), NEEDS_TRANS("Melodic Tom"), NEEDS_TRANS("Synth Drum"), NEEDS_TRANS("Reverse Cymbal"), - NEEDS_TRANS("Guitar Fret Noise"), NEEDS_TRANS("Breath Noise"), NEEDS_TRANS("Seashore"), NEEDS_TRANS("Bird Tweet"), - NEEDS_TRANS("Telephone Ring"), NEEDS_TRANS("Helicopter"), NEEDS_TRANS("Applause"), NEEDS_TRANS("Gunshot") + NEEDS_TRANS ("Acoustic Grand Piano"), NEEDS_TRANS ("Bright Acoustic Piano"), NEEDS_TRANS ("Electric Grand Piano"), NEEDS_TRANS ("Honky-tonk Piano"), + NEEDS_TRANS ("Electric Piano 1"), NEEDS_TRANS ("Electric Piano 2"), NEEDS_TRANS ("Harpsichord"), NEEDS_TRANS ("Clavinet"), + NEEDS_TRANS ("Celesta"), NEEDS_TRANS ("Glockenspiel"), NEEDS_TRANS ("Music Box"), NEEDS_TRANS ("Vibraphone"), + NEEDS_TRANS ("Marimba"), NEEDS_TRANS ("Xylophone"), NEEDS_TRANS ("Tubular Bells"), NEEDS_TRANS ("Dulcimer"), + NEEDS_TRANS ("Drawbar Organ"), NEEDS_TRANS ("Percussive Organ"), NEEDS_TRANS ("Rock Organ"), NEEDS_TRANS ("Church Organ"), + NEEDS_TRANS ("Reed Organ"), NEEDS_TRANS ("Accordion"), NEEDS_TRANS ("Harmonica"), NEEDS_TRANS ("Tango Accordion"), + NEEDS_TRANS ("Acoustic Guitar (nylon)"), NEEDS_TRANS ("Acoustic Guitar (steel)"), NEEDS_TRANS ("Electric Guitar (jazz)"), NEEDS_TRANS ("Electric Guitar (clean)"), + NEEDS_TRANS ("Electric Guitar (mute)"), NEEDS_TRANS ("Overdriven Guitar"), NEEDS_TRANS ("Distortion Guitar"), NEEDS_TRANS ("Guitar Harmonics"), + NEEDS_TRANS ("Acoustic Bass"), NEEDS_TRANS ("Electric Bass (finger)"), NEEDS_TRANS ("Electric Bass (pick)"), NEEDS_TRANS ("Fretless Bass"), + NEEDS_TRANS ("Slap Bass 1"), NEEDS_TRANS ("Slap Bass 2"), NEEDS_TRANS ("Synth Bass 1"), NEEDS_TRANS ("Synth Bass 2"), + NEEDS_TRANS ("Violin"), NEEDS_TRANS ("Viola"), NEEDS_TRANS ("Cello"), NEEDS_TRANS ("Contrabass"), + NEEDS_TRANS ("Tremolo Strings"), NEEDS_TRANS ("Pizzicato Strings"), NEEDS_TRANS ("Orchestral Harp"), NEEDS_TRANS ("Timpani"), + NEEDS_TRANS ("String Ensemble 1"), NEEDS_TRANS ("String Ensemble 2"), NEEDS_TRANS ("SynthStrings 1"), NEEDS_TRANS ("SynthStrings 2"), + NEEDS_TRANS ("Choir Aahs"), NEEDS_TRANS ("Voice Oohs"), NEEDS_TRANS ("Synth Voice"), NEEDS_TRANS ("Orchestra Hit"), + NEEDS_TRANS ("Trumpet"), NEEDS_TRANS ("Trombone"), NEEDS_TRANS ("Tuba"), NEEDS_TRANS ("Muted Trumpet"), + NEEDS_TRANS ("French Horn"), NEEDS_TRANS ("Brass Section"), NEEDS_TRANS ("SynthBrass 1"), NEEDS_TRANS ("SynthBrass 2"), + NEEDS_TRANS ("Soprano Sax"), NEEDS_TRANS ("Alto Sax"), NEEDS_TRANS ("Tenor Sax"), NEEDS_TRANS ("Baritone Sax"), + NEEDS_TRANS ("Oboe"), NEEDS_TRANS ("English Horn"), NEEDS_TRANS ("Bassoon"), NEEDS_TRANS ("Clarinet"), + NEEDS_TRANS ("Piccolo"), NEEDS_TRANS ("Flute"), NEEDS_TRANS ("Recorder"), NEEDS_TRANS ("Pan Flute"), + NEEDS_TRANS ("Blown Bottle"), NEEDS_TRANS ("Shakuhachi"), NEEDS_TRANS ("Whistle"), NEEDS_TRANS ("Ocarina"), + NEEDS_TRANS ("Lead 1 (square)"), NEEDS_TRANS ("Lead 2 (sawtooth)"), NEEDS_TRANS ("Lead 3 (calliope)"), NEEDS_TRANS ("Lead 4 (chiff)"), + NEEDS_TRANS ("Lead 5 (charang)"), NEEDS_TRANS ("Lead 6 (voice)"), NEEDS_TRANS ("Lead 7 (fifths)"), NEEDS_TRANS ("Lead 8 (bass+lead)"), + NEEDS_TRANS ("Pad 1 (new age)"), NEEDS_TRANS ("Pad 2 (warm)"), NEEDS_TRANS ("Pad 3 (polysynth)"), NEEDS_TRANS ("Pad 4 (choir)"), + NEEDS_TRANS ("Pad 5 (bowed)"), NEEDS_TRANS ("Pad 6 (metallic)"), NEEDS_TRANS ("Pad 7 (halo)"), NEEDS_TRANS ("Pad 8 (sweep)"), + NEEDS_TRANS ("FX 1 (rain)"), NEEDS_TRANS ("FX 2 (soundtrack)"), NEEDS_TRANS ("FX 3 (crystal)"), NEEDS_TRANS ("FX 4 (atmosphere)"), + NEEDS_TRANS ("FX 5 (brightness)"), NEEDS_TRANS ("FX 6 (goblins)"), NEEDS_TRANS ("FX 7 (echoes)"), NEEDS_TRANS ("FX 8 (sci-fi)"), + NEEDS_TRANS ("Sitar"), NEEDS_TRANS ("Banjo"), NEEDS_TRANS ("Shamisen"), NEEDS_TRANS ("Koto"), + NEEDS_TRANS ("Kalimba"), NEEDS_TRANS ("Bag pipe"), NEEDS_TRANS ("Fiddle"), NEEDS_TRANS ("Shanai"), + NEEDS_TRANS ("Tinkle Bell"), NEEDS_TRANS ("Agogo"), NEEDS_TRANS ("Steel Drums"), NEEDS_TRANS ("Woodblock"), + NEEDS_TRANS ("Taiko Drum"), NEEDS_TRANS ("Melodic Tom"), NEEDS_TRANS ("Synth Drum"), NEEDS_TRANS ("Reverse Cymbal"), + NEEDS_TRANS ("Guitar Fret Noise"), NEEDS_TRANS ("Breath Noise"), NEEDS_TRANS ("Seashore"), NEEDS_TRANS ("Bird Tweet"), + NEEDS_TRANS ("Telephone Ring"), NEEDS_TRANS ("Helicopter"), NEEDS_TRANS ("Applause"), NEEDS_TRANS ("Gunshot") }; return isPositiveAndBelow (n, numElementsInArray (names)) ? names[n] : nullptr; @@ -1089,10 +1089,10 @@ const char* MidiMessage::getGMInstrumentBankName (const int n) { static const char* names[] = { - NEEDS_TRANS("Piano"), NEEDS_TRANS("Chromatic Percussion"), NEEDS_TRANS("Organ"), NEEDS_TRANS("Guitar"), - NEEDS_TRANS("Bass"), NEEDS_TRANS("Strings"), NEEDS_TRANS("Ensemble"), NEEDS_TRANS("Brass"), - NEEDS_TRANS("Reed"), NEEDS_TRANS("Pipe"), NEEDS_TRANS("Synth Lead"), NEEDS_TRANS("Synth Pad"), - NEEDS_TRANS("Synth Effects"), NEEDS_TRANS("Ethnic"), NEEDS_TRANS("Percussive"), NEEDS_TRANS("Sound Effects") + NEEDS_TRANS ("Piano"), NEEDS_TRANS ("Chromatic Percussion"), NEEDS_TRANS ("Organ"), NEEDS_TRANS ("Guitar"), + NEEDS_TRANS ("Bass"), NEEDS_TRANS ("Strings"), NEEDS_TRANS ("Ensemble"), NEEDS_TRANS ("Brass"), + NEEDS_TRANS ("Reed"), NEEDS_TRANS ("Pipe"), NEEDS_TRANS ("Synth Lead"), NEEDS_TRANS ("Synth Pad"), + NEEDS_TRANS ("Synth Effects"), NEEDS_TRANS ("Ethnic"), NEEDS_TRANS ("Percussive"), NEEDS_TRANS ("Sound Effects") }; return isPositiveAndBelow (n, numElementsInArray (names)) ? names[n] : nullptr; @@ -1102,18 +1102,18 @@ const char* MidiMessage::getRhythmInstrumentName (const int n) { static const char* names[] = { - NEEDS_TRANS("Acoustic Bass Drum"), NEEDS_TRANS("Bass Drum 1"), NEEDS_TRANS("Side Stick"), NEEDS_TRANS("Acoustic Snare"), - NEEDS_TRANS("Hand Clap"), NEEDS_TRANS("Electric Snare"), NEEDS_TRANS("Low Floor Tom"), NEEDS_TRANS("Closed Hi-Hat"), - NEEDS_TRANS("High Floor Tom"), NEEDS_TRANS("Pedal Hi-Hat"), NEEDS_TRANS("Low Tom"), NEEDS_TRANS("Open Hi-Hat"), - NEEDS_TRANS("Low-Mid Tom"), NEEDS_TRANS("Hi-Mid Tom"), NEEDS_TRANS("Crash Cymbal 1"), NEEDS_TRANS("High Tom"), - NEEDS_TRANS("Ride Cymbal 1"), NEEDS_TRANS("Chinese Cymbal"), NEEDS_TRANS("Ride Bell"), NEEDS_TRANS("Tambourine"), - NEEDS_TRANS("Splash Cymbal"), NEEDS_TRANS("Cowbell"), NEEDS_TRANS("Crash Cymbal 2"), NEEDS_TRANS("Vibraslap"), - NEEDS_TRANS("Ride Cymbal 2"), NEEDS_TRANS("Hi Bongo"), NEEDS_TRANS("Low Bongo"), NEEDS_TRANS("Mute Hi Conga"), - NEEDS_TRANS("Open Hi Conga"), NEEDS_TRANS("Low Conga"), NEEDS_TRANS("High Timbale"), NEEDS_TRANS("Low Timbale"), - NEEDS_TRANS("High Agogo"), NEEDS_TRANS("Low Agogo"), NEEDS_TRANS("Cabasa"), NEEDS_TRANS("Maracas"), - NEEDS_TRANS("Short Whistle"), NEEDS_TRANS("Long Whistle"), NEEDS_TRANS("Short Guiro"), NEEDS_TRANS("Long Guiro"), - NEEDS_TRANS("Claves"), NEEDS_TRANS("Hi Wood Block"), NEEDS_TRANS("Low Wood Block"), NEEDS_TRANS("Mute Cuica"), - NEEDS_TRANS("Open Cuica"), NEEDS_TRANS("Mute Triangle"), NEEDS_TRANS("Open Triangle") + NEEDS_TRANS ("Acoustic Bass Drum"), NEEDS_TRANS ("Bass Drum 1"), NEEDS_TRANS ("Side Stick"), NEEDS_TRANS ("Acoustic Snare"), + NEEDS_TRANS ("Hand Clap"), NEEDS_TRANS ("Electric Snare"), NEEDS_TRANS ("Low Floor Tom"), NEEDS_TRANS ("Closed Hi-Hat"), + NEEDS_TRANS ("High Floor Tom"), NEEDS_TRANS ("Pedal Hi-Hat"), NEEDS_TRANS ("Low Tom"), NEEDS_TRANS ("Open Hi-Hat"), + NEEDS_TRANS ("Low-Mid Tom"), NEEDS_TRANS ("Hi-Mid Tom"), NEEDS_TRANS ("Crash Cymbal 1"), NEEDS_TRANS ("High Tom"), + NEEDS_TRANS ("Ride Cymbal 1"), NEEDS_TRANS ("Chinese Cymbal"), NEEDS_TRANS ("Ride Bell"), NEEDS_TRANS ("Tambourine"), + NEEDS_TRANS ("Splash Cymbal"), NEEDS_TRANS ("Cowbell"), NEEDS_TRANS ("Crash Cymbal 2"), NEEDS_TRANS ("Vibraslap"), + NEEDS_TRANS ("Ride Cymbal 2"), NEEDS_TRANS ("Hi Bongo"), NEEDS_TRANS ("Low Bongo"), NEEDS_TRANS ("Mute Hi Conga"), + NEEDS_TRANS ("Open Hi Conga"), NEEDS_TRANS ("Low Conga"), NEEDS_TRANS ("High Timbale"), NEEDS_TRANS ("Low Timbale"), + NEEDS_TRANS ("High Agogo"), NEEDS_TRANS ("Low Agogo"), NEEDS_TRANS ("Cabasa"), NEEDS_TRANS ("Maracas"), + NEEDS_TRANS ("Short Whistle"), NEEDS_TRANS ("Long Whistle"), NEEDS_TRANS ("Short Guiro"), NEEDS_TRANS ("Long Guiro"), + NEEDS_TRANS ("Claves"), NEEDS_TRANS ("Hi Wood Block"), NEEDS_TRANS ("Low Wood Block"), NEEDS_TRANS ("Mute Cuica"), + NEEDS_TRANS ("Open Cuica"), NEEDS_TRANS ("Mute Triangle"), NEEDS_TRANS ("Open Triangle") }; return (n >= 35 && n <= 81) ? names[n - 35] : nullptr; @@ -1123,38 +1123,38 @@ const char* MidiMessage::getControllerName (const int n) { static const char* names[] = { - NEEDS_TRANS("Bank Select"), NEEDS_TRANS("Modulation Wheel (coarse)"), NEEDS_TRANS("Breath controller (coarse)"), + NEEDS_TRANS ("Bank Select"), NEEDS_TRANS ("Modulation Wheel (coarse)"), NEEDS_TRANS ("Breath controller (coarse)"), nullptr, - NEEDS_TRANS("Foot Pedal (coarse)"), NEEDS_TRANS("Portamento Time (coarse)"), NEEDS_TRANS("Data Entry (coarse)"), - NEEDS_TRANS("Volume (coarse)"), NEEDS_TRANS("Balance (coarse)"), + NEEDS_TRANS ("Foot Pedal (coarse)"), NEEDS_TRANS ("Portamento Time (coarse)"), NEEDS_TRANS ("Data Entry (coarse)"), + NEEDS_TRANS ("Volume (coarse)"), NEEDS_TRANS ("Balance (coarse)"), nullptr, - NEEDS_TRANS("Pan position (coarse)"), NEEDS_TRANS("Expression (coarse)"), NEEDS_TRANS("Effect Control 1 (coarse)"), - NEEDS_TRANS("Effect Control 2 (coarse)"), + NEEDS_TRANS ("Pan position (coarse)"), NEEDS_TRANS ("Expression (coarse)"), NEEDS_TRANS ("Effect Control 1 (coarse)"), + NEEDS_TRANS ("Effect Control 2 (coarse)"), nullptr, nullptr, - NEEDS_TRANS("General Purpose Slider 1"), NEEDS_TRANS("General Purpose Slider 2"), - NEEDS_TRANS("General Purpose Slider 3"), NEEDS_TRANS("General Purpose Slider 4"), + NEEDS_TRANS ("General Purpose Slider 1"), NEEDS_TRANS ("General Purpose Slider 2"), + NEEDS_TRANS ("General Purpose Slider 3"), NEEDS_TRANS ("General Purpose Slider 4"), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - NEEDS_TRANS("Bank Select (fine)"), NEEDS_TRANS("Modulation Wheel (fine)"), NEEDS_TRANS("Breath controller (fine)"), + NEEDS_TRANS ("Bank Select (fine)"), NEEDS_TRANS ("Modulation Wheel (fine)"), NEEDS_TRANS ("Breath controller (fine)"), nullptr, - NEEDS_TRANS("Foot Pedal (fine)"), NEEDS_TRANS("Portamento Time (fine)"), NEEDS_TRANS("Data Entry (fine)"), NEEDS_TRANS("Volume (fine)"), - NEEDS_TRANS("Balance (fine)"), nullptr, NEEDS_TRANS("Pan position (fine)"), NEEDS_TRANS("Expression (fine)"), - NEEDS_TRANS("Effect Control 1 (fine)"), NEEDS_TRANS("Effect Control 2 (fine)"), + NEEDS_TRANS ("Foot Pedal (fine)"), NEEDS_TRANS ("Portamento Time (fine)"), NEEDS_TRANS ("Data Entry (fine)"), NEEDS_TRANS ("Volume (fine)"), + NEEDS_TRANS ("Balance (fine)"), nullptr, NEEDS_TRANS ("Pan position (fine)"), NEEDS_TRANS ("Expression (fine)"), + NEEDS_TRANS ("Effect Control 1 (fine)"), NEEDS_TRANS ("Effect Control 2 (fine)"), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - NEEDS_TRANS("Hold Pedal (on/off)"), NEEDS_TRANS("Portamento (on/off)"), NEEDS_TRANS("Sustenuto Pedal (on/off)"), NEEDS_TRANS("Soft Pedal (on/off)"), - NEEDS_TRANS("Legato Pedal (on/off)"), NEEDS_TRANS("Hold 2 Pedal (on/off)"), NEEDS_TRANS("Sound Variation"), NEEDS_TRANS("Sound Timbre"), - NEEDS_TRANS("Sound Release Time"), NEEDS_TRANS("Sound Attack Time"), NEEDS_TRANS("Sound Brightness"), NEEDS_TRANS("Sound Control 6"), - NEEDS_TRANS("Sound Control 7"), NEEDS_TRANS("Sound Control 8"), NEEDS_TRANS("Sound Control 9"), NEEDS_TRANS("Sound Control 10"), - NEEDS_TRANS("General Purpose Button 1 (on/off)"), NEEDS_TRANS("General Purpose Button 2 (on/off)"), - NEEDS_TRANS("General Purpose Button 3 (on/off)"), NEEDS_TRANS("General Purpose Button 4 (on/off)"), + NEEDS_TRANS ("Hold Pedal (on/off)"), NEEDS_TRANS ("Portamento (on/off)"), NEEDS_TRANS ("Sustenuto Pedal (on/off)"), NEEDS_TRANS ("Soft Pedal (on/off)"), + NEEDS_TRANS ("Legato Pedal (on/off)"), NEEDS_TRANS ("Hold 2 Pedal (on/off)"), NEEDS_TRANS ("Sound Variation"), NEEDS_TRANS ("Sound Timbre"), + NEEDS_TRANS ("Sound Release Time"), NEEDS_TRANS ("Sound Attack Time"), NEEDS_TRANS ("Sound Brightness"), NEEDS_TRANS ("Sound Control 6"), + NEEDS_TRANS ("Sound Control 7"), NEEDS_TRANS ("Sound Control 8"), NEEDS_TRANS ("Sound Control 9"), NEEDS_TRANS ("Sound Control 10"), + NEEDS_TRANS ("General Purpose Button 1 (on/off)"), NEEDS_TRANS ("General Purpose Button 2 (on/off)"), + NEEDS_TRANS ("General Purpose Button 3 (on/off)"), NEEDS_TRANS ("General Purpose Button 4 (on/off)"), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - NEEDS_TRANS("Reverb Level"), NEEDS_TRANS("Tremolo Level"), NEEDS_TRANS("Chorus Level"), NEEDS_TRANS("Celeste Level"), - NEEDS_TRANS("Phaser Level"), NEEDS_TRANS("Data Button increment"), NEEDS_TRANS("Data Button decrement"), NEEDS_TRANS("Non-registered Parameter (fine)"), - NEEDS_TRANS("Non-registered Parameter (coarse)"), NEEDS_TRANS("Registered Parameter (fine)"), NEEDS_TRANS("Registered Parameter (coarse)"), + NEEDS_TRANS ("Reverb Level"), NEEDS_TRANS ("Tremolo Level"), NEEDS_TRANS ("Chorus Level"), NEEDS_TRANS ("Celeste Level"), + NEEDS_TRANS ("Phaser Level"), NEEDS_TRANS ("Data Button increment"), NEEDS_TRANS ("Data Button decrement"), NEEDS_TRANS ("Non-registered Parameter (fine)"), + NEEDS_TRANS ("Non-registered Parameter (coarse)"), NEEDS_TRANS ("Registered Parameter (fine)"), NEEDS_TRANS ("Registered Parameter (coarse)"), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - NEEDS_TRANS("All Sound Off"), NEEDS_TRANS("All Controllers Off"), NEEDS_TRANS("Local Keyboard (on/off)"), NEEDS_TRANS("All Notes Off"), - NEEDS_TRANS("Omni Mode Off"), NEEDS_TRANS("Omni Mode On"), NEEDS_TRANS("Mono Operation"), NEEDS_TRANS("Poly Operation") + NEEDS_TRANS ("All Sound Off"), NEEDS_TRANS ("All Controllers Off"), NEEDS_TRANS ("Local Keyboard (on/off)"), NEEDS_TRANS ("All Notes Off"), + NEEDS_TRANS ("Omni Mode Off"), NEEDS_TRANS ("Omni Mode On"), NEEDS_TRANS ("Mono Operation"), NEEDS_TRANS ("Poly Operation") }; return isPositiveAndBelow (n, numElementsInArray (names)) ? names[n] : nullptr; @@ -1164,7 +1164,7 @@ const char* MidiMessage::getControllerName (const int n) //============================================================================== #if JUCE_UNIT_TESTS -struct MidiMessageTest : public UnitTest +struct MidiMessageTest final : public UnitTest { MidiMessageTest() : UnitTest ("MidiMessage", UnitTestCategories::midi) diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index 95d01222..3eec1847 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -40,7 +40,7 @@ MidiMessageSequence::MidiMessageSequence (const MidiMessageSequence& other) auto noteOffIndex = other.getIndexOfMatchingKeyUp (i); if (noteOffIndex >= 0) - list.getUnchecked(i)->noteOffObject = list.getUnchecked (noteOffIndex); + list.getUnchecked (i)->noteOffObject = list.getUnchecked (noteOffIndex); } } @@ -103,7 +103,7 @@ int MidiMessageSequence::getIndexOfMatchingKeyUp (int index) const noexcept if (auto* noteOff = meh->noteOffObject) { for (int i = index; i < list.size(); ++i) - if (list.getUnchecked(i) == noteOff) + if (list.getUnchecked (i) == noteOff) return i; jassertfalse; // we've somehow got a pointer to a note-off object that isn't in the sequence @@ -124,7 +124,7 @@ int MidiMessageSequence::getNextIndexAtTime (double timeStamp) const noexcept int i; for (i = 0; i < numEvents; ++i) - if (list.getUnchecked(i)->message.getTimeStamp() >= timeStamp) + if (list.getUnchecked (i)->message.getTimeStamp() >= timeStamp) break; return i; @@ -157,7 +157,7 @@ MidiMessageSequence::MidiEventHolder* MidiMessageSequence::addEvent (MidiEventHo int i; for (i = list.size(); --i >= 0;) - if (list.getUnchecked(i)->message.getTimeStamp() <= time) + if (list.getUnchecked (i)->message.getTimeStamp() <= time) break; list.insert (i + 1, newEvent); @@ -227,7 +227,7 @@ void MidiMessageSequence::updateMatchedPairs() noexcept { for (int i = 0; i < list.size(); ++i) { - auto* meh = list.getUnchecked(i); + auto* meh = list.getUnchecked (i); auto& m1 = meh->message; if (m1.isNoteOn()) @@ -239,7 +239,7 @@ void MidiMessageSequence::updateMatchedPairs() noexcept for (int j = i + 1; j < len; ++j) { - auto* meh2 = list.getUnchecked(j); + auto* meh2 = list.getUnchecked (j); auto& m = meh2->message; if (m.getNoteNumber() == note && m.getChannel() == chan) @@ -292,15 +292,15 @@ void MidiMessageSequence::extractSysExMessages (MidiMessageSequence& destSequenc void MidiMessageSequence::deleteMidiChannelMessages (const int channelNumberToRemove) { for (int i = list.size(); --i >= 0;) - if (list.getUnchecked(i)->message.isForChannel (channelNumberToRemove)) - list.remove(i); + if (list.getUnchecked (i)->message.isForChannel (channelNumberToRemove)) + list.remove (i); } void MidiMessageSequence::deleteSysExMessages() { for (int i = list.size(); --i >= 0;) - if (list.getUnchecked(i)->message.isSysEx()) - list.remove(i); + if (list.getUnchecked (i)->message.isSysEx()) + list.remove (i); } //============================================================================== @@ -477,7 +477,7 @@ void MidiMessageSequence::createControllerUpdatesForTime (int channel, double ti //============================================================================== #if JUCE_UNIT_TESTS -struct MidiMessageSequenceTest : public UnitTest +struct MidiMessageSequenceTest final : public UnitTest { MidiMessageSequenceTest() : UnitTest ("MidiMessageSequence", UnitTestCategories::midi) diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiRPN.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiRPN.cpp index f16e73a7..00c9536a 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiRPN.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiRPN.cpp @@ -158,7 +158,7 @@ MidiBuffer MidiRPNGenerator::generate (int midiChannel, //============================================================================== #if JUCE_UNIT_TESTS -class MidiRPNDetectorTests : public UnitTest +class MidiRPNDetectorTests final : public UnitTest { public: MidiRPNDetectorTests() @@ -364,7 +364,7 @@ class MidiRPNDetectorTests : public UnitTest static MidiRPNDetectorTests MidiRPNDetectorUnitTests; //============================================================================== -class MidiRPNGeneratorTests : public UnitTest +class MidiRPNGeneratorTests final : public UnitTest { public: MidiRPNGeneratorTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConversion.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConversion.h index f28cc765..7001d878 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConversion.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConversion.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** Represents a MIDI message that happened at a particular time. @@ -352,7 +350,6 @@ struct Conversion } }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConverters.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConverters.h index 8f51f13a..0893bc71 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConverters.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPConverters.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** Allows conversion from bytestream- or Universal MIDI Packet-formatted @@ -182,7 +180,6 @@ namespace universal_midi_packets Midi1ToBytestreamTranslator translator; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h index f5eb8873..38068699 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -196,7 +194,6 @@ class ToBytestreamDispatcher ToBytestreamConverter converter; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPFactory.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPFactory.h index 9f1e2656..dbc239b6 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPFactory.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPFactory.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -532,7 +530,6 @@ struct Factory } }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.cpp index cb875256..b86ffac3 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { Iterator::Iterator (const uint32_t* ptr, [[maybe_unused]] size_t bytes) noexcept @@ -33,5 +31,4 @@ Iterator::Iterator (const uint32_t* ptr, [[maybe_unused]] size_t bytes) noexcept { } -} // namespace universal_midi_packets -} // namespace juce +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.h index eba62029..6087b412 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPIterator.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -117,7 +115,6 @@ class Iterator #endif }; -} // namespace universal_midi_packets -} // namespace juce +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToBytestreamTranslator.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToBytestreamTranslator.h index e1b268b5..ca41919c 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToBytestreamTranslator.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToBytestreamTranslator.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -212,7 +210,6 @@ class Midi1ToBytestreamTranslator double pendingSysExTime = 0.0; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.cpp index 69648092..7508893c 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { PacketX2 Midi1ToMidi2DefaultTranslator::processNoteOnOrOff (const HelperValues helpers) @@ -197,5 +195,4 @@ bool Midi1ToMidi2DefaultTranslator::PnAccumulator::addByte (uint8_t cc, std::byt return true; } -} -} +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.h index b644b839..d71e4919 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPMidi1ToMidi2DefaultTranslator.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -134,15 +132,15 @@ class Midi1ToMidi2DefaultTranslator std::byte byte2; }; - static PacketX2 processNoteOnOrOff (const HelperValues helpers); - static PacketX2 processPolyPressure (const HelperValues helpers); + static PacketX2 processNoteOnOrOff (HelperValues helpers); + static PacketX2 processPolyPressure (HelperValues helpers); - bool processControlChange (const HelperValues helpers, PacketX2& packet); + bool processControlChange (HelperValues helpers, PacketX2& packet); - PacketX2 processProgramChange (const HelperValues helpers) const; + PacketX2 processProgramChange (HelperValues helpers) const; - static PacketX2 processChannelPressure (const HelperValues helpers); - static PacketX2 processPitchBend (const HelperValues helpers); + static PacketX2 processChannelPressure (HelperValues helpers); + static PacketX2 processPitchBend (HelperValues helpers); class PnAccumulator { @@ -185,7 +183,6 @@ class Midi1ToMidi2DefaultTranslator std::array groupBanks; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPProtocols.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPProtocols.h index 78792bbf..c0df33bb 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPProtocols.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPProtocols.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** The kinds of MIDI protocol that can be formatted into Universal MIDI Packets. */ @@ -42,7 +40,6 @@ enum class MidiProtocol UMP_MIDI_2_0, }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPReceiver.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPReceiver.h index 6f2cac67..5705ed65 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPReceiver.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPReceiver.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -40,7 +38,6 @@ struct Receiver virtual void packetReceived (const View& packet, double time) = 0; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.cpp index eaea29f1..45ba0c97 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { uint32_t SysEx7::getNumPacketsRequiredForDataSize (uint32_t size) @@ -49,5 +47,4 @@ SysEx7::PacketBytes SysEx7::getDataBytes (const PacketX2& packet) }; } -} -} +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.h index c08313c0..c061a4e0 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPSysEx7.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -71,7 +69,6 @@ struct SysEx7 static PacketBytes getDataBytes (const PacketX2& packet); }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.cpp index 353672f8..556e2638 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { uint32_t Utils::getNumWordsForMessageType (uint32_t mt) @@ -55,5 +53,4 @@ uint32_t Utils::getNumWordsForMessageType (uint32_t mt) return 1; } -} -} +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.h index 53b097b9..ad93823c 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPUtils.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -114,7 +112,6 @@ struct Utils static constexpr uint8_t getChannel (uint32_t w) noexcept { return U4<3>::get (w); } }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.cpp index 37dc324d..219e88a8 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { uint32_t View::size() const noexcept @@ -31,5 +29,4 @@ uint32_t View::size() const noexcept return Utils::getNumWordsForMessageType (*ptr); } -} -} +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.h index e9f70d6d..9be4c258 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPView.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -33,7 +31,7 @@ namespace universal_midi_packets The packet must be well-formed for member functions to work correctly. Specifically, the constructor argument must be the beginning of a region of - uint32_t that contains at least `getNumWordsForMessageType(*data)` items, + uint32_t that contains at least `getNumWordsForMessageType (*data)` items, where `data` is the constructor argument. NOTE: Instances of this class do not own the memory that they point to! @@ -86,7 +84,6 @@ class View const uint32_t* ptr = nullptr; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMP_test.cpp b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMP_test.cpp index b34ed0fb..732bf0e3 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMP_test.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMP_test.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { constexpr uint8_t operator""_u8 (unsigned long long int i) { return static_cast (i); } @@ -30,7 +28,7 @@ constexpr uint16_t operator""_u16 (unsigned long long int i) { return static_cas constexpr uint32_t operator""_u32 (unsigned long long int i) { return static_cast (i); } constexpr uint64_t operator""_u64 (unsigned long long int i) { return static_cast (i); } -class UniversalMidiPacketTests : public UnitTest +class UniversalMidiPacketTests final : public UnitTest { public: UniversalMidiPacketTests() @@ -1015,5 +1013,4 @@ class UniversalMidiPacketTests : public UnitTest static UniversalMidiPacketTests universalMidiPacketTests; -} -} +} // namespace juce::universal_midi_packets diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPacket.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPacket.h index ef811510..197f0f7b 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPacket.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPacket.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -187,7 +185,6 @@ using PacketX2 = Packet<2>; using PacketX3 = Packet<3>; using PacketX4 = Packet<4>; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPackets.h b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPackets.h index 14dcb44a..fba4966c 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPackets.h +++ b/JuceLibraryCode/modules/juce_audio_basics/midi/ump/juce_UMPackets.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -90,7 +88,6 @@ class Packets std::vector storage; }; -} -} +} // namespace juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 87f3df39..0622e27d 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -866,7 +866,7 @@ void MPEInstrument::Listener::zoneLayoutChanged() //============================================================================== #if JUCE_UNIT_TESTS -class MPEInstrumentTests : public UnitTest +class MPEInstrumentTests final : public UnitTest { public: MPEInstrumentTests() @@ -2201,8 +2201,8 @@ class MPEInstrumentTests : public UnitTest /* This mock class is used for unit testing whether the methods of MPEInstrument are called correctly. */ - class UnitTestInstrument : public MPEInstrument, - private MPEInstrument::Listener + class UnitTestInstrument final : public MPEInstrument, + private MPEInstrument::Listener { using Base = MPEInstrument; diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp index c9109bfa..463345de 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp @@ -111,7 +111,7 @@ MidiBuffer MPEMessages::setZoneLayout (MPEZoneLayout layout) //============================================================================== #if JUCE_UNIT_TESTS -class MPEMessagesTests : public UnitTest +class MPEMessagesTests final : public UnitTest { public: MPEMessagesTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPENote.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPENote.cpp index ed4414b7..0a82efe3 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPENote.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPENote.cpp @@ -89,7 +89,7 @@ bool MPENote::operator!= (const MPENote& other) const noexcept //============================================================================== #if JUCE_UNIT_TESTS -class MPENoteTests : public UnitTest +class MPENoteTests final : public UnitTest { public: MPENoteTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp index 45555558..048ef183 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp @@ -164,7 +164,7 @@ void MPESynthesiserBase::setMinimumRenderingSubdivisionSize (int numSamples, boo namespace { - class MpeSynthesiserBaseTests : public UnitTest + class MpeSynthesiserBaseTests final : public UnitTest { enum class CallbackKind { process, midi }; @@ -190,7 +190,7 @@ namespace std::vector order; }; - class MockSynthesiser : public MPESynthesiserBase + class MockSynthesiser final : public MPESynthesiserBase { public: Events events; diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEUtils.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEUtils.cpp index bb3d48c3..8d0c1f16 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEUtils.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEUtils.cpp @@ -284,7 +284,7 @@ void MPEChannelRemapper::zeroArrays() //============================================================================== #if JUCE_UNIT_TESTS -struct MPEUtilsUnitTests : public UnitTest +struct MPEUtilsUnitTests final : public UnitTest { MPEUtilsUnitTests() : UnitTest ("MPE Utilities", UnitTestCategories::midi) diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEValue.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEValue.cpp index 5efd7ac4..3ece4bb2 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEValue.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEValue.cpp @@ -99,7 +99,7 @@ bool MPEValue::operator!= (const MPEValue& other) const noexcept //============================================================================== #if JUCE_UNIT_TESTS -class MPEValueTests : public UnitTest +class MPEValueTests final : public UnitTest { public: MPEValueTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp index b86e179b..7ce29b60 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp @@ -213,7 +213,7 @@ void MPEZoneLayout::checkAndLimitZoneParameters (int minValue, int maxValue, //============================================================================== #if JUCE_UNIT_TESTS -class MPEZoneLayoutTests : public UnitTest +class MPEZoneLayoutTests final : public UnitTest { public: MPEZoneLayoutTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/native/juce_AudioWorkgroup_mac.h b/JuceLibraryCode/modules/juce_audio_basics/native/juce_AudioWorkgroup_mac.h new file mode 100644 index 00000000..710bd735 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_basics/native/juce_AudioWorkgroup_mac.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ +#if (defined (MAC_OS_VERSION_11_0) || defined (__IPHONE_14_0)) + #define JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE 1 +#else + #define JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE 0 +#endif + +#if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + AudioWorkgroup makeRealAudioWorkgroup (os_workgroup_t handle); +#endif + +} diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index d751ad7a..f11448c8 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -95,7 +95,7 @@ class JUCE_API BufferingAudioSource : public PositionableAudioSource, This is useful for offline rendering. */ - bool waitForNextAudioBlockReady (const AudioSourceChannelInfo& info, const uint32 timeout); + bool waitForNextAudioBlockReady (const AudioSourceChannelInfo& info, uint32 timeout); private: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp index c7f48543..aef4b0ff 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp @@ -153,10 +153,10 @@ std::unique_ptr ChannelRemappingAudioSource::createXml() const const ScopedLock sl (lock); for (int i = 0; i < remappedInputs.size(); ++i) - ins << remappedInputs.getUnchecked(i) << ' '; + ins << remappedInputs.getUnchecked (i) << ' '; for (int i = 0; i < remappedOutputs.size(); ++i) - outs << remappedOutputs.getUnchecked(i) << ' '; + outs << remappedOutputs.getUnchecked (i) << ' '; e->setAttribute ("inputs", ins.trimEnd()); e->setAttribute ("outputs", outs.trimEnd()); diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp index a784c048..1a598228 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp @@ -39,13 +39,13 @@ IIRFilterAudioSource::~IIRFilterAudioSource() {} void IIRFilterAudioSource::setCoefficients (const IIRCoefficients& newCoefficients) { for (int i = iirFilters.size(); --i >= 0;) - iirFilters.getUnchecked(i)->setCoefficients (newCoefficients); + iirFilters.getUnchecked (i)->setCoefficients (newCoefficients); } void IIRFilterAudioSource::makeInactive() { for (int i = iirFilters.size(); --i >= 0;) - iirFilters.getUnchecked(i)->makeInactive(); + iirFilters.getUnchecked (i)->makeInactive(); } //============================================================================== @@ -54,7 +54,7 @@ void IIRFilterAudioSource::prepareToPlay (int samplesPerBlockExpected, double sa input->prepareToPlay (samplesPerBlockExpected, sampleRate); for (int i = iirFilters.size(); --i >= 0;) - iirFilters.getUnchecked(i)->reset(); + iirFilters.getUnchecked (i)->reset(); } void IIRFilterAudioSource::releaseResources() @@ -72,7 +72,7 @@ void IIRFilterAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& buff iirFilters.add (new IIRFilter (*iirFilters.getUnchecked (0))); for (int i = 0; i < numChannels; ++i) - iirFilters.getUnchecked(i) + iirFilters.getUnchecked (i) ->processSamples (bufferToFill.buffer->getWritePointer (i, bufferToFill.startSample), bufferToFill.numSamples); } diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp index db30a341..c5351075 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp @@ -108,7 +108,7 @@ void MemoryAudioSource::setLooping (bool shouldLoop) //============================================================================== #if JUCE_UNIT_TESTS -struct MemoryAudioSourceTests : public UnitTest +struct MemoryAudioSourceTests final : public UnitTest { MemoryAudioSourceTests() : UnitTest ("MemoryAudioSource", UnitTestCategories::audio) {} diff --git a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index 79d60e62..666ed105 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp @@ -90,13 +90,13 @@ void MixerAudioSource::removeAllInputs() for (int i = inputs.size(); --i >= 0;) if (inputsToDelete[i]) - toDelete.add (inputs.getUnchecked(i)); + toDelete.add (inputs.getUnchecked (i)); inputs.clear(); } for (int i = toDelete.size(); --i >= 0;) - toDelete.getUnchecked(i)->releaseResources(); + toDelete.getUnchecked (i)->releaseResources(); } void MixerAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate) @@ -109,7 +109,7 @@ void MixerAudioSource::prepareToPlay (int samplesPerBlockExpected, double sample bufferSizeExpected = samplesPerBlockExpected; for (int i = inputs.size(); --i >= 0;) - inputs.getUnchecked(i)->prepareToPlay (samplesPerBlockExpected, sampleRate); + inputs.getUnchecked (i)->prepareToPlay (samplesPerBlockExpected, sampleRate); } void MixerAudioSource::releaseResources() @@ -117,7 +117,7 @@ void MixerAudioSource::releaseResources() const ScopedLock sl (lock); for (int i = inputs.size(); --i >= 0;) - inputs.getUnchecked(i)->releaseResources(); + inputs.getUnchecked (i)->releaseResources(); tempBuffer.setSize (2, 0); @@ -131,7 +131,7 @@ void MixerAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info) if (inputs.size() > 0) { - inputs.getUnchecked(0)->getNextAudioBlock (info); + inputs.getUnchecked (0)->getNextAudioBlock (info); if (inputs.size() > 1) { @@ -142,7 +142,7 @@ void MixerAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info) for (int i = 1; i < inputs.size(); ++i) { - inputs.getUnchecked(i)->getNextAudioBlock (info2); + inputs.getUnchecked (i)->getNextAudioBlock (info2); for (int chan = 0; chan < info.buffer->getNumChannels(); ++chan) info.buffer->addFrom (chan, info.startSample, tempBuffer, chan, 0, info.numSamples); diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_ADSR_test.cpp b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_ADSR_test.cpp index 94189b9e..e26dd6ce 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_ADSR_test.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_ADSR_test.cpp @@ -23,7 +23,7 @@ namespace juce { -struct ADSRTests : public UnitTest +struct ADSRTests final : public UnitTest { ADSRTests() : UnitTest ("ADSR", UnitTestCategories::audio) {} diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.cpp b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.cpp new file mode 100644 index 00000000..c44a11c5 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.cpp @@ -0,0 +1,221 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + +class WorkgroupToken::TokenProvider +{ +public: + explicit TokenProvider (os_workgroup_t wg) + : workgroup (wg), attached (attach (wg, token)) {} + + ~TokenProvider() + { + if (attached) + detach (workgroup, token); + } + + TokenProvider (const TokenProvider&) = delete; + TokenProvider (TokenProvider&& other) noexcept + : workgroup (std::exchange (other.workgroup, os_workgroup_t{})), + token (std::exchange (other.token, os_workgroup_join_token_s{})), + attached (std::exchange (other.attached, false)) {} + + TokenProvider& operator= (const TokenProvider&) = delete; + TokenProvider& operator= (TokenProvider&& other) noexcept + { + TokenProvider { std::move (other) }.swap (*this); + return *this; + } + + bool isAttached() const { return attached; } + os_workgroup_t getHandle() const { return workgroup; } + +private: + static void detach (os_workgroup_t wg, os_workgroup_join_token_s token) + { + if (@available (macos 11.0, ios 14.0, *)) + os_workgroup_leave (wg, &token); + } + + static bool attach (os_workgroup_t wg, os_workgroup_join_token_s& tokenOut) + { + if (@available (macos 11.0, ios 14.0, *)) + { + if (wg != nullptr && os_workgroup_join (wg, &tokenOut) == 0) + return true; + } + + return false; + } + + void swap (TokenProvider& other) noexcept + { + std::swap (other.workgroup, workgroup); + std::swap (other.token, token); + std::swap (other.attached, attached); + } + + os_workgroup_t workgroup; + os_workgroup_join_token_s token; + bool attached; +}; + +class AudioWorkgroup::WorkgroupProvider +{ +public: + explicit WorkgroupProvider (os_workgroup_t ptr) : handle { ptr } {} + + void join (WorkgroupToken& token) const + { + if (const auto* tokenProvider = token.getTokenProvider()) + if (tokenProvider->isAttached() && tokenProvider->getHandle() == handle.get()) + return; + + // Explicit reset before constructing the new workgroup to ensure that the old workgroup + // is left before the new one is joined. + token.reset(); + + if (handle.get() != nullptr) + token = WorkgroupToken { [provider = WorkgroupToken::TokenProvider { handle.get() }] { return &provider; } }; + } + + static os_workgroup_t getWorkgroup (const AudioWorkgroup& wg) + { + if (auto* provider = wg.getWorkgroupProvider()) + return provider->handle.get(); + + return nullptr; + } + +private: + struct ScopedWorkgroupRetainer + { + ScopedWorkgroupRetainer (os_workgroup_t wg) : handle { wg } + { + if (handle != nullptr) + os_retain (handle); + } + + ~ScopedWorkgroupRetainer() + { + if (handle != nullptr) + os_release (handle); + } + + ScopedWorkgroupRetainer (const ScopedWorkgroupRetainer& other) + : ScopedWorkgroupRetainer { other.handle } {} + + ScopedWorkgroupRetainer& operator= (const ScopedWorkgroupRetainer& other) + { + ScopedWorkgroupRetainer { other }.swap (*this); + return *this; + } + + ScopedWorkgroupRetainer (ScopedWorkgroupRetainer&& other) noexcept + { + swap (other); + } + + ScopedWorkgroupRetainer& operator= (ScopedWorkgroupRetainer&& other) noexcept + { + swap (other); + return *this; + } + + void swap (ScopedWorkgroupRetainer& other) noexcept + { + std::swap (handle, other.handle); + } + + os_workgroup_t get() const noexcept { return handle; } + + private: + os_workgroup_t handle { nullptr }; + }; + + ScopedWorkgroupRetainer handle; +}; + +#else + +class WorkgroupToken::TokenProvider {}; + +class AudioWorkgroup::WorkgroupProvider +{ +public: + explicit WorkgroupProvider() = default; + + void join (WorkgroupToken& t) const { t.reset(); } + + static void* getWorkgroup (const AudioWorkgroup&) { return nullptr; } +}; + +#endif + +AudioWorkgroup::AudioWorkgroup (const AudioWorkgroup& other) + : erased ([&]() -> Erased + { + if (auto* p = other.getWorkgroupProvider()) + return [provider = *p] { return &provider; }; + + return nullptr; + }()) {} + +bool AudioWorkgroup::operator== (const AudioWorkgroup& other) const +{ + return WorkgroupProvider::getWorkgroup (*this) == WorkgroupProvider::getWorkgroup (other); +} + +void AudioWorkgroup::join (WorkgroupToken& token) const +{ + #if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + + if (const auto* p = getWorkgroupProvider()) + { + p->join (token); + return; + } + + #endif + + token.reset(); +} + +AudioWorkgroup::operator bool() const { return WorkgroupProvider::getWorkgroup (*this) != nullptr; } + +#if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + +AudioWorkgroup makeRealAudioWorkgroup (os_workgroup_t handle) +{ + if (handle == nullptr) + return AudioWorkgroup{}; + + return AudioWorkgroup { [provider = AudioWorkgroup::WorkgroupProvider { handle }] { return &provider; } }; +} + +#endif + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.h b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.h new file mode 100644 index 00000000..7ccb4265 --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_AudioWorkgroup.h @@ -0,0 +1,214 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +//============================================================================== +/** + Created by AudioWorkgroup to join the calling thread to a workgroup. + To leave the workgroup again, destroy the WorkgroupToken. + + @see AudioWorkgroup + + @tags{Audio} +*/ +class WorkgroupToken +{ +public: + /** @internal */ + class TokenProvider; + + /** @internal */ + using Erased = FixedSizeFunction<64, const TokenProvider*()>; + + /** @internal + + Creates a WorkgroupToken from a function returning a TokenProvider. + */ + explicit WorkgroupToken (Erased e) : erased (std::move (e)) {} + + /** @internal + + Creates a disengaged WorkgroupToken, i.e. create a token without joining the thread to a + workgroup. + */ + WorkgroupToken() = default; + + /** If the token joined the calling thread to a workgroup during construction, the destructor + will cause the calling thread to leave that workgroup. + */ + ~WorkgroupToken() = default; + + /** @internal */ + WorkgroupToken (const WorkgroupToken&) = delete; + + WorkgroupToken (WorkgroupToken&&) noexcept = default; + + /** @internal */ + WorkgroupToken& operator= (const WorkgroupToken&) = delete; + + WorkgroupToken& operator= (WorkgroupToken&&) = default; + + /** Returns true if and only if getTokenProvider() returns non-null. */ + explicit operator bool() const { return getTokenProvider() != nullptr; } + + /** The result of this function can be compared to nullptr to check whether the token + successfully joined the calling thread to a workgroup. + + Used in the implementation to provide platform-specific information about this token. + */ + [[nodiscard]] const TokenProvider* getTokenProvider() const { return erased != nullptr ? erased() : nullptr; } + + /** If this token was engaged by joining a workgroup, leaves that workgroup and disengages the token. + + After this call, getTokenProvider() will return nullptr. + */ + void reset() { erased = nullptr; } + +private: + Erased erased; +}; + +//============================================================================== +/** + A handle to an audio workgroup, which is a collection of realtime threads + working together to produce audio by a common deadline. + + You can use this class to join a real-time worker thread to a workgroup. + Rather than constructing instances of this class directly, you should use + functions like AudioProcessor::audioWorkgroupContextChanged() and + AudioIODevice::getWorkgroup() to fetch an engaged workgroup from the system. + + The class contains a single method, join(). Call this from your real-time + thread to with register this workgroup. + + Here's an example of how you might use this class: + + @code + Constructor() + { + startRealtimeThread (RealtimeThreadOptions{}.withApproximateAudioProcessingTime (samplesPerFrame, sampleRate)); + or + startRealtimeThread (RealtimeThreadOptions{}.withProcessingTimeMs (10)); + } + + void Thread::run() override + { + WorkgroupToken token; + + getWorkgroup().join (token); + + while (wait (-1) && ! threadShouldExit()) + { + // If the workgroup has changed, rejoin the workgroup with the same token. + if (workgroupChanged()) + getWorkgroup().join (token); + + // Perform the work here + } + } + + void AudioProcessor::processBlock() + { + workerThread->notify(); + } + @endcode + + @see Thread, AudioProcessor, WorkgroupToken + + @tags{Audio} +*/ +class AudioWorkgroup +{ +public: + /** @internal */ + class WorkgroupProvider; + + /** @internal */ + using Erased = FixedSizeFunction<64, const WorkgroupProvider*()>; + + /** @internal + + Creates an AudioWorkgroup from a function returning a WorkgroupProvider. + */ + explicit AudioWorkgroup (Erased e) : erased (std::move (e)) {} + + /** Move constructor. */ + AudioWorkgroup (AudioWorkgroup&&) = default; + + /** Move assignment operator. */ + AudioWorkgroup& operator= (AudioWorkgroup&&) = default; + + /** Copy constructor. */ + AudioWorkgroup (const AudioWorkgroup&); + + /** Copy assignment operator. */ + AudioWorkgroup& operator= (const AudioWorkgroup& other) + { + AudioWorkgroup { other }.swap (*this); + return *this; + } + + /** Constructs a disengaged handle that does not represent any workgroup. */ + AudioWorkgroup() = default; + + /** + This method attempts to join the calling thread to this workgroup. + + If the join operation is successful, the token will be engaged, i.e. its + getTokenProvider() function will return non-null. + + If the token is already engaged and represents a join to another workgroup, + the thread will leave that workgroup before joining the workgroup represented by this + object. If the 'token' is already engaged and is passed to the same workgroup, the method + will not perform any action. + + It's important to note that the lifetime of the token should not exceed the lifetime + of the associated thread and must be destroyed on the same thread. + */ + void join (WorkgroupToken& token) const; + + /** Equality operator. */ + bool operator== (const AudioWorkgroup& other) const; + + /** Inequality operator. */ + bool operator!= (const AudioWorkgroup& other) const { return ! operator== (other); } + + /** Returns true if and only if this object represents a workgroup. */ + explicit operator bool() const; + + /** Disengages this instance so that it no longer represents a workgroup. + + After this call, operator bool() will return false. + */ + void reset() { erased = nullptr; } + +private: + const WorkgroupProvider* getWorkgroupProvider() const { return erased != nullptr ? erased() : nullptr; } + + void swap (AudioWorkgroup& other) noexcept { std::swap (other.erased, erased); } + + Erased erased; +}; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_IIRFilter.cpp b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_IIRFilter.cpp index c1e32254..3c129cb0 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_IIRFilter.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_IIRFilter.cpp @@ -84,7 +84,7 @@ IIRCoefficients IIRCoefficients::makeLowPass (double sampleRate, IIRCoefficients IIRCoefficients::makeHighPass (double sampleRate, double frequency) noexcept { - return makeHighPass (sampleRate, frequency, 1.0 / std::sqrt(2.0)); + return makeHighPass (sampleRate, frequency, 1.0 / std::sqrt (2.0)); } IIRCoefficients IIRCoefficients::makeHighPass (double sampleRate, diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Interpolators.cpp b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Interpolators.cpp index 9ddaf18b..3e16a8e1 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Interpolators.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Interpolators.cpp @@ -25,7 +25,7 @@ namespace juce #if JUCE_UNIT_TESTS -class InterpolatorTests : public UnitTest +class InterpolatorTests final : public UnitTest { public: InterpolatorTests() diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Reverb.h b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Reverb.h index 8a7ad092..8f539d0e 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Reverb.h +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_Reverb.h @@ -136,6 +136,7 @@ class Reverb for (int i = 0; i < numSamples; ++i) { + // NOLINTNEXTLINE(clang-analyzer-core.NullDereference) const float input = (left[i] + right[i]) * gain; float outL = 0, outR = 0; diff --git a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_SmoothedValue.cpp b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_SmoothedValue.cpp index e65e06cc..9dbda5c5 100644 --- a/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_SmoothedValue.cpp +++ b/JuceLibraryCode/modules/juce_audio_basics/utilities/juce_SmoothedValue.cpp @@ -28,7 +28,7 @@ namespace juce static CommonSmoothedValueTests > commonLinearSmoothedValueTests; static CommonSmoothedValueTests > commonMultiplicativeSmoothedValueTests; -class SmoothedValueTests : public UnitTest +class SmoothedValueTests final : public UnitTest { public: SmoothedValueTests() diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 4a1a9aed..447a240a 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -61,9 +61,9 @@ bool AudioDeviceManager::AudioDeviceSetup::operator!= (const AudioDeviceManager: } //============================================================================== -class AudioDeviceManager::CallbackHandler : public AudioIODeviceCallback, - public MidiInputCallback, - public AudioIODeviceType::Listener +class AudioDeviceManager::CallbackHandler final : public AudioIODeviceCallback, + public MidiInputCallback, + public AudioIODeviceType::Listener { public: CallbackHandler (AudioDeviceManager& adm) noexcept : owner (adm) {} @@ -659,7 +659,7 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, bool tre { for (int i = 0; i < availableDeviceTypes.size(); ++i) { - if (availableDeviceTypes.getUnchecked(i)->getTypeName() == type + if (availableDeviceTypes.getUnchecked (i)->getTypeName() == type && currentDeviceType != type) { if (currentAudioDevice != nullptr) @@ -671,7 +671,7 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, bool tre currentDeviceType = type; - AudioDeviceSetup s (*lastDeviceTypeConfigs.getUnchecked(i)); + AudioDeviceSetup s (*lastDeviceTypeConfigs.getUnchecked (i)); insertDefaultDeviceNames (s); setAudioDeviceSetup (s, treatAsChosenDevice); @@ -682,6 +682,11 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, bool tre } } +AudioWorkgroup AudioDeviceManager::getDeviceAudioWorkgroup() const +{ + return currentAudioDevice != nullptr ? currentAudioDevice->getWorkgroup() : AudioWorkgroup{}; +} + AudioIODeviceType* AudioDeviceManager::getCurrentDeviceTypeObject() const { for (auto* type : availableDeviceTypes) @@ -1002,23 +1007,23 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float* const* inputChan tempBuffer.setSize (jmax (1, numOutputChannels), jmax (1, numSamples), false, false, true); - callbacks.getUnchecked(0)->audioDeviceIOCallbackWithContext (inputChannelData, - numInputChannels, - outputChannelData, - numOutputChannels, - numSamples, - context); + callbacks.getUnchecked (0)->audioDeviceIOCallbackWithContext (inputChannelData, + numInputChannels, + outputChannelData, + numOutputChannels, + numSamples, + context); auto* const* tempChans = tempBuffer.getArrayOfWritePointers(); for (int i = callbacks.size(); --i > 0;) { - callbacks.getUnchecked(i)->audioDeviceIOCallbackWithContext (inputChannelData, - numInputChannels, - tempChans, - numOutputChannels, - numSamples, - context); + callbacks.getUnchecked (i)->audioDeviceIOCallbackWithContext (inputChannelData, + numInputChannels, + tempChans, + numOutputChannels, + numSamples, + context); for (int chan = 0; chan < numOutputChannels; ++chan) { @@ -1065,7 +1070,7 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device const ScopedLock sl (audioCallbackLock); for (int i = callbacks.size(); --i >= 0;) - callbacks.getUnchecked(i)->audioDeviceAboutToStart (device); + callbacks.getUnchecked (i)->audioDeviceAboutToStart (device); } sendChangeMessage(); @@ -1080,7 +1085,7 @@ void AudioDeviceManager::audioDeviceStoppedInt() loadMeasurer.reset(); for (int i = callbacks.size(); --i >= 0;) - callbacks.getUnchecked(i)->audioDeviceStopped(); + callbacks.getUnchecked (i)->audioDeviceStopped(); } void AudioDeviceManager::audioDeviceErrorInt (const String& message) @@ -1088,7 +1093,7 @@ void AudioDeviceManager::audioDeviceErrorInt (const String& message) const ScopedLock sl (audioCallbackLock); for (int i = callbacks.size(); --i >= 0;) - callbacks.getUnchecked(i)->audioDeviceError (message); + callbacks.getUnchecked (i)->audioDeviceError (message); } double AudioDeviceManager::getCpuUsage() const @@ -1374,7 +1379,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& name) //============================================================================== #if JUCE_UNIT_TESTS -class AudioDeviceManagerTests : public UnitTest +class AudioDeviceManagerTests final : public UnitTest { public: AudioDeviceManagerTests() : UnitTest ("AudioDeviceManager", UnitTestCategories::audio) {} @@ -1752,8 +1757,8 @@ class AudioDeviceManagerTests : public UnitTest virtual void restart (double newSr, int newBs) = 0; }; - class MockDevice : public AudioIODevice, - private Restartable + class MockDevice final : public AudioIODevice, + private Restartable { public: MockDevice (ListenerList& l, String typeNameIn, String outNameIn, String inNameIn) @@ -1831,7 +1836,7 @@ class AudioDeviceManagerTests : public UnitTest bool on = false, playing = false; }; - class MockDeviceType : public AudioIODeviceType + class MockDeviceType final : public AudioIODeviceType { public: explicit MockDeviceType (String kind) @@ -1886,7 +1891,7 @@ class AudioDeviceManagerTests : public UnitTest ListenerList listeners; }; - class MockCallback : public AudioIODeviceCallback + class MockCallback final : public AudioIODeviceCallback { public: std::function callback; diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index b3fd6e81..52a6d10f 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -262,6 +262,9 @@ class JUCE_API AudioDeviceManager : public ChangeBroadcaster */ void setCurrentAudioDeviceType (const String& type, bool treatAsChosenDevice); + /** Returns the current audio device workgroup, if supported. */ + AudioWorkgroup getDeviceAudioWorkgroup() const; + /** Closes the currently-open device. You can call restartLastAudioDevice() later to reopen it in the same state that it was just in. diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index da5bfed5..e66d7b64 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h @@ -174,6 +174,21 @@ class JUCE_API AudioIODevice */ virtual StringArray getInputChannelNames() = 0; + //============================================================================== + /** For devices that support a default layout, returns the channels that are enabled in the + default layout. + + Returns nullopt if the device doesn't supply a default layout. + */ + virtual std::optional getDefaultOutputChannels() const { return {}; } + + /** For devices that support a default layout, returns the channels that are enabled in the + default layout. + + Returns nullopt if the device doesn't supply a default layout. + */ + virtual std::optional getDefaultInputChannels() const { return {}; } + //============================================================================== /** Returns the set of sample-rates this device supports. @see getCurrentSampleRate @@ -292,6 +307,8 @@ class JUCE_API AudioIODevice */ virtual int getInputLatencyInSamples() = 0; + /** Returns the workgroup for this device. */ + virtual AudioWorkgroup getWorkgroup() const { return {}; } //============================================================================== /** True if this device can show a pop-up control panel for editing its settings. diff --git a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SampleRateHelpers.cpp b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SampleRateHelpers.cpp index aa2fe826..4b1c1545 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SampleRateHelpers.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/audio_io/juce_SampleRateHelpers.cpp @@ -20,9 +20,7 @@ ============================================================================== */ -namespace juce -{ -namespace SampleRateHelpers +namespace juce::SampleRateHelpers { static inline const std::vector& getAllSampleRates() @@ -44,5 +42,4 @@ static inline const std::vector& getAllSampleRates() return sampleRates; } -} // namespace SampleRateHelpers -} // namespace juce +} // namespace juce::SampleRateHelpers diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp index ba60b96e..8a4ec9da 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.cpp @@ -50,6 +50,8 @@ //============================================================================== #if JUCE_MAC || JUCE_IOS + #include + #include #include #include #include "midi_io/ump/juce_UMPBytestreamInputHandler.h" @@ -77,6 +79,10 @@ #import #endif + #if JUCE_MODULE_AVAILABLE_juce_graphics + #include + #endif + #include "native/juce_Audio_ios.cpp" #include "native/juce_CoreMidi_mac.mm" diff --git a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h index 9e0e9a5d..d5b17a5e 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h +++ b/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h @@ -32,7 +32,7 @@ ID: juce_audio_devices vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE audio and MIDI I/O device classes description: Classes to play and record from audio and MIDI I/O devices website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp index e96a9d63..71954516 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp @@ -23,7 +23,7 @@ namespace juce { -class MidiDeviceListConnectionBroadcaster : private AsyncUpdater +class MidiDeviceListConnectionBroadcaster final : private AsyncUpdater { public: ~MidiDeviceListConnectionBroadcaster() override diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h b/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h index 1cdad80c..25122cc5 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -138,7 +136,6 @@ struct BytestreamToUMPHandler : public BytestreamInputHandler BytestreamToUMPDispatcher dispatcher; }; -} -} +} // juce::universal_midi_packets #endif diff --git a/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPU32InputHandler.h b/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPU32InputHandler.h index 15ee58d3..d0d37988 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPU32InputHandler.h +++ b/JuceLibraryCode/modules/juce_audio_devices/midi_io/ump/juce_UMPU32InputHandler.h @@ -22,9 +22,7 @@ #ifndef DOXYGEN -namespace juce -{ -namespace universal_midi_packets +namespace juce::universal_midi_packets { /** @@ -149,7 +147,7 @@ struct U32ToUMPHandler : public U32InputHandler GenericUMPConverter converter; }; -} -} +} // namespace juce::universal_midi_packets + #endif diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ALSA_linux.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ALSA_linux.cpp index 5120d89c..91073477 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ALSA_linux.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ALSA_linux.cpp @@ -169,7 +169,7 @@ class ALSADevice error << "The device \"" << deviceID << "\" is not available."; else error << "Could not open " << (forInput ? "input" : "output") << " device \"" << deviceID - << "\": " << snd_strerror(err) << " (" << err << ")"; + << "\": " << snd_strerror (err) << " (" << err << ")"; JUCE_ALSA_LOG ("snd_pcm_open failed; " << error); } @@ -481,7 +481,7 @@ class ALSADevice }; //============================================================================== -class ALSAThread : public Thread +class ALSAThread final : public Thread { public: ALSAThread (const String& inputDeviceID, const String& outputDeviceID) @@ -838,7 +838,7 @@ class ALSAThread : public Thread //============================================================================== -class ALSAAudioIODevice : public AudioIODevice +class ALSAAudioIODevice final : public AudioIODevice { public: ALSAAudioIODevice (const String& deviceName, @@ -967,7 +967,7 @@ class ALSAAudioIODevice : public AudioIODevice //============================================================================== -class ALSAAudioIODeviceType : public AudioIODeviceType +class ALSAAudioIODeviceType final : public AudioIODeviceType { public: ALSAAudioIODeviceType (bool onlySoundcards, const String& deviceTypeName) diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ASIO_windows.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ASIO_windows.cpp index 8b58323d..824becd5 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_ASIO_windows.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_ASIO_windows.cpp @@ -308,8 +308,8 @@ class ASIOAudioIODeviceType; static void sendASIODeviceChangeToListeners (ASIOAudioIODeviceType*); //============================================================================== -class ASIOAudioIODevice : public AudioIODevice, - private Timer +class ASIOAudioIODevice final : public AudioIODevice, + private Timer { public: ASIOAudioIODevice (ASIOAudioIODeviceType* ownerType, const String& devName, @@ -1438,7 +1438,7 @@ struct ASIOAudioIODevice::ASIOCallbackFunctions }; //============================================================================== -class ASIOAudioIODeviceType : public AudioIODeviceType +class ASIOAudioIODeviceType final : public AudioIODeviceType { public: ASIOAudioIODeviceType() : AudioIODeviceType ("ASIO") {} @@ -1453,7 +1453,7 @@ class ASIOAudioIODeviceType : public AudioIODeviceType HKEY hk = 0; int index = 0; - if (RegOpenKey (HKEY_LOCAL_MACHINE, _T("software\\asio"), &hk) == ERROR_SUCCESS) + if (RegOpenKey (HKEY_LOCAL_MACHINE, _T ("software\\asio"), &hk) == ERROR_SUCCESS) { TCHAR name[256] = {}; @@ -1554,7 +1554,7 @@ class ASIOAudioIODeviceType : public AudioIODeviceType HKEY hk = 0; bool ok = false; - if (RegOpenKey (HKEY_CLASSES_ROOT, _T("clsid"), &hk) == ERROR_SUCCESS) + if (RegOpenKey (HKEY_CLASSES_ROOT, _T ("clsid"), &hk) == ERROR_SUCCESS) { int index = 0; TCHAR name[512] = {}; @@ -1567,7 +1567,7 @@ class ASIOAudioIODeviceType : public AudioIODeviceType if (RegOpenKeyEx (hk, name, 0, KEY_READ, &subKey) == ERROR_SUCCESS) { - if (RegOpenKeyEx (subKey, _T("InprocServer32"), 0, KEY_READ, &pathKey) == ERROR_SUCCESS) + if (RegOpenKeyEx (subKey, _T ("InprocServer32"), 0, KEY_READ, &pathKey) == ERROR_SUCCESS) { TCHAR pathName[1024] = {}; DWORD dtype = REG_SZ; @@ -1610,7 +1610,7 @@ class ASIOAudioIODeviceType : public AudioIODeviceType DWORD dtype = REG_SZ; DWORD dsize = sizeof (buf); - if (RegQueryValueEx (subKey, _T("clsid"), 0, &dtype, (LPBYTE) buf, &dsize) == ERROR_SUCCESS) + if (RegQueryValueEx (subKey, _T ("clsid"), 0, &dtype, (LPBYTE) buf, &dsize) == ERROR_SUCCESS) { if (dsize > 0 && checkClassIsOk (buf)) { @@ -1622,7 +1622,7 @@ class ASIOAudioIODeviceType : public AudioIODeviceType dsize = sizeof (buf); String deviceName; - if (RegQueryValueEx (subKey, _T("description"), 0, &dtype, (LPBYTE) buf, &dsize) == ERROR_SUCCESS) + if (RegQueryValueEx (subKey, _T ("description"), 0, &dtype, (LPBYTE) buf, &dsize) == ERROR_SUCCESS) deviceName = buf; else deviceName = keyName; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_android.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_android.cpp index ada162b9..7671dde9 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_android.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_android.cpp @@ -65,8 +65,8 @@ enum const char* const javaAudioTypeName = "Android Audio"; //============================================================================== -class AndroidAudioIODevice : public AudioIODevice, - public Thread +class AndroidAudioIODevice final : public AudioIODevice, + public Thread { public: //============================================================================== @@ -191,9 +191,9 @@ class AndroidAudioIODevice : public AudioIODevice, if (numClientOutputChannels > 0) { numDeviceOutputChannels = 2; - outputDevice = GlobalRef (LocalRef(env->NewObject (AudioTrack, AudioTrack.constructor, - STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, - (jint) (minBufferSizeOut * numDeviceOutputChannels * static_cast (sizeof (int16))), MODE_STREAM))); + outputDevice = GlobalRef (LocalRef (env->NewObject (AudioTrack, AudioTrack.constructor, + STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, + (jint) (minBufferSizeOut * numDeviceOutputChannels * static_cast (sizeof (int16))), MODE_STREAM))); const bool supportsUnderrunCount = (getAndroidSDKVersion() >= 24); getUnderrunCount = supportsUnderrunCount ? env->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : nullptr; @@ -225,11 +225,11 @@ class AndroidAudioIODevice : public AudioIODevice, else { numDeviceInputChannels = jmin (numClientInputChannels, numDeviceInputChannelsAvailable); - inputDevice = GlobalRef (LocalRef(env->NewObject (AudioRecord, AudioRecord.constructor, - 0 /* (default audio source) */, sampleRate, - numDeviceInputChannelsAvailable > 1 ? CHANNEL_IN_STEREO : CHANNEL_IN_MONO, - ENCODING_PCM_16BIT, - (jint) (minBufferSizeIn * numDeviceInputChannels * static_cast (sizeof (int16)))))); + inputDevice = GlobalRef (LocalRef (env->NewObject (AudioRecord, AudioRecord.constructor, + 0 /* (default audio source) */, sampleRate, + numDeviceInputChannelsAvailable > 1 ? CHANNEL_IN_STEREO : CHANNEL_IN_MONO, + ENCODING_PCM_16BIT, + (jint) (minBufferSizeIn * numDeviceInputChannels * static_cast (sizeof (int16)))))); int inputDeviceState = env->CallIntMethod (inputDevice, AudioRecord.getState); if (inputDeviceState > 0) @@ -429,10 +429,10 @@ class AndroidAudioIODevice : public AudioIODevice, }; //============================================================================== -class AndroidAudioIODeviceType : public AudioIODeviceType +class AndroidAudioIODeviceType final : public AudioIODeviceType { public: - AndroidAudioIODeviceType() : AudioIODeviceType (javaAudioTypeName) {} + AndroidAudioIODeviceType() : AudioIODeviceType (javaAudioTypeName) {} //============================================================================== void scanForDevices() {} diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.cpp index 4f328b05..7aa04922 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.cpp @@ -20,8 +20,6 @@ ============================================================================== */ -#include - namespace juce { @@ -195,10 +193,6 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE @end //============================================================================== -#if JUCE_MODULE_AVAILABLE_juce_graphics - #include -#endif - namespace juce { #ifndef JUCE_IOS_AUDIO_LOGGING @@ -223,8 +217,8 @@ static void logNSError (NSError* e) #define JUCE_NSERROR_CHECK(X) { NSError* error = nil; X; logNSError (error); } //============================================================================== -class iOSAudioIODeviceType : public AudioIODeviceType, - public AsyncUpdater +class iOSAudioIODeviceType final : public AudioIODeviceType, + public AsyncUpdater { public: iOSAudioIODeviceType(); @@ -252,7 +246,7 @@ class iOSAudioIODeviceType : public AudioIODeviceType, }; //============================================================================== -struct iOSAudioIODevice::Pimpl : public AsyncUpdater +struct iOSAudioIODevice::Pimpl final : public AsyncUpdater { Pimpl (iOSAudioIODeviceType* ioDeviceType, iOSAudioIODevice& ioDevice) : deviceType (ioDeviceType), @@ -282,7 +276,7 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater static void setAudioSessionCategory (NSString* category) { - NSUInteger options = 0; + NSUInteger options = AVAudioSessionCategoryOptionAllowAirPlay; #if ! JUCE_DISABLE_AUDIO_MIXING_WITH_OTHER_APPS options |= AVAudioSessionCategoryOptionMixWithOthers; // Alternatively AVAudioSessionCategoryOptionDuckOthers @@ -290,8 +284,8 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater if (category == AVAudioSessionCategoryPlayAndRecord) { - options |= (AVAudioSessionCategoryOptionDefaultToSpeaker - | AVAudioSessionCategoryOptionAllowBluetooth); + options |= AVAudioSessionCategoryOptionDefaultToSpeaker + | AVAudioSessionCategoryOptionAllowBluetooth; if (@available (iOS 10.0, *)) options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP; @@ -563,7 +557,7 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater } //============================================================================== - class PlayHead : public AudioPlayHead + class PlayHead final : public AudioPlayHead { public: explicit PlayHead (Pimpl& implIn) : impl (implIn) {} @@ -640,18 +634,18 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater Boolean hostIsCycling = NO; Float64 hostCycleStartBeat = 0; Float64 hostCycleEndBeat = 0; - OSStatus err = callbackInfo.transportStateProc2 (callbackInfo.hostUserData, - &hostIsPlaying, - &hostIsRecording, - nullptr, - &hostCurrentSampleInTimeLine, - &hostIsCycling, - &hostCycleStartBeat, - &hostCycleEndBeat); - if (err == kAUGraphErr_CannotDoInCurrentContext) + auto transportErr = callbackInfo.transportStateProc2 (callbackInfo.hostUserData, + &hostIsPlaying, + &hostIsRecording, + nullptr, + &hostCurrentSampleInTimeLine, + &hostIsCycling, + &hostCycleStartBeat, + &hostCycleEndBeat); + if (transportErr == kAUGraphErr_CannotDoInCurrentContext) return {}; - jassert (err == noErr); + jassert (transportErr == noErr); PositionInfo result; @@ -660,14 +654,14 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater result.setIsRecording (hostIsRecording); result.setIsLooping (hostIsCycling); result.setLoopPoints (LoopPoints { hostCycleStartBeat, hostCycleEndBeat }); - result.setTimeInSeconds (*result.getTimeInSamples() / impl.sampleRate); + result.setTimeInSeconds ((double) *result.getTimeInSamples() / impl.sampleRate); Float64 hostBeat = 0; Float64 hostTempo = 0; - err = callbackInfo.beatAndTempoProc (callbackInfo.hostUserData, - &hostBeat, - &hostTempo); - jassert (err == noErr); + [[maybe_unused]] auto batErr = callbackInfo.beatAndTempoProc (callbackInfo.hostUserData, + &hostBeat, + &hostTempo); + jassert (batErr == noErr); result.setPpqPosition (hostBeat); result.setBpm (hostTempo); @@ -675,12 +669,12 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater Float32 hostTimeSigNumerator = 0; UInt32 hostTimeSigDenominator = 0; Float64 hostCurrentMeasureDownBeat = 0; - err = callbackInfo.musicalTimeLocationProc (callbackInfo.hostUserData, - nullptr, - &hostTimeSigNumerator, - &hostTimeSigDenominator, - &hostCurrentMeasureDownBeat); - jassert (err == noErr); + [[maybe_unused]] auto timeErr = callbackInfo.musicalTimeLocationProc (callbackInfo.hostUserData, + nullptr, + &hostTimeSigNumerator, + &hostTimeSigDenominator, + &hostCurrentMeasureDownBeat); + jassert (timeErr == noErr); result.setPpqPositionOfLastBarStart (hostCurrentMeasureDownBeat); result.setTimeSignature (TimeSignature { (int) hostTimeSigNumerator, (int) hostTimeSigDenominator }); @@ -707,7 +701,7 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater { if (interAppAudioConnected) { - if (UIImage* hostUIImage = AudioOutputUnitGetHostIcon (audioUnit, size)) + if (UIImage* hostUIImage = AudioOutputUnitGetHostIcon (audioUnit, (float) size)) return juce_createImageFromUIImage (hostUIImage); } } @@ -724,12 +718,12 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater CFURLRef hostUrl; UInt32 dataSize = sizeof (hostUrl); - OSStatus err = AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_PeerURL, - kAudioUnitScope_Global, - 0, - &hostUrl, - &dataSize); + OSStatus err = AudioUnitGetProperty (audioUnit, + kAudioUnitProperty_PeerURL, + kAudioUnitScope_Global, + 0, + &hostUrl, + &dataSize); if (err == noErr) { if (@available (iOS 10.0, *)) @@ -787,9 +781,9 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater switch (reason) { case AVAudioSessionRouteChangeReasonCategoryChange: - case AVAudioSessionRouteChangeReasonOverride: case AVAudioSessionRouteChangeReasonRouteConfigurationChange: break; + case AVAudioSessionRouteChangeReasonOverride: case AVAudioSessionRouteChangeReasonUnknown: case AVAudioSessionRouteChangeReasonNewDeviceAvailable: case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: @@ -991,7 +985,7 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater appDesc.componentFlags = 0; appDesc.componentFlagsMask = 0; OSStatus err = AudioOutputUnitPublish (&appDesc, - CFSTR(JucePlugin_IAAName), + CFSTR (JucePlugin_IAAName), JucePlugin_VersionCode, audioUnit); @@ -1065,6 +1059,19 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater } } + #if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + workgroup = [this] + { + UInt32 dataSize = sizeof (os_workgroup_t); + os_workgroup_t wgHandle = nullptr; + + AudioUnitGetProperty (audioUnit, kAudioOutputUnitProperty_OSWorkgroup, + kAudioUnitScope_Global, 0, &wgHandle, &dataSize); + + return makeRealAudioWorkgroup (wgHandle); + }(); + #endif + AudioUnitAddPropertyListener (audioUnit, kAudioUnitProperty_StreamFormat, dispatchAudioUnitPropertyChange, this); return true; @@ -1373,6 +1380,7 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater Atomic hardwareInfoNeedsUpdating { true }; AudioUnit audioUnit {}; + AudioWorkgroup workgroup; SharedResourcePointer sessionHolder; @@ -1429,6 +1437,7 @@ BigInteger iOSAudioIODevice::getActiveOutputChannels() const { return pim int iOSAudioIODevice::getInputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].inputLatency); } int iOSAudioIODevice::getOutputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].outputLatency); } int iOSAudioIODevice::getXRunCount() const noexcept { return pimpl->xrun; } +AudioWorkgroup iOSAudioIODevice::getWorkgroup() const { return pimpl->workgroup; } void iOSAudioIODevice::setMidiMessageCollector (MidiMessageCollector* collector) { pimpl->messageCollector = collector; } AudioPlayHead* iOSAudioIODevice::getAudioPlayHead() const { return &pimpl->playhead; } diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.h b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.h index 0c497491..78cd2e1a 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.h +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Audio_ios.h @@ -64,6 +64,8 @@ class iOSAudioIODevice : public AudioIODevice int getXRunCount() const noexcept override; + AudioWorkgroup getWorkgroup() const override; + //============================================================================== void setMidiMessageCollector (MidiMessageCollector*); AudioPlayHead* getAudioPlayHead() const; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Bela_linux.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Bela_linux.cpp index 57b47fc2..494d3a84 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Bela_linux.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Bela_linux.cpp @@ -180,7 +180,7 @@ Array MidiInput::Pimpl::midiInputs; //============================================================================== -class BelaAudioIODevice : public AudioIODevice +class BelaAudioIODevice final : public AudioIODevice { public: BelaAudioIODevice() : AudioIODevice (BelaAudioIODevice::belaTypeName, @@ -504,7 +504,7 @@ class BelaAudioIODevice : public AudioIODevice const char* const BelaAudioIODevice::belaTypeName = "Bela Analog"; //============================================================================== -struct BelaAudioIODeviceType : public AudioIODeviceType +struct BelaAudioIODeviceType final : public AudioIODeviceType { BelaAudioIODeviceType() : AudioIODeviceType ("Bela") {} diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreAudio_mac.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreAudio_mac.cpp index bc470fc3..fd810d18 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreAudio_mac.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreAudio_mac.cpp @@ -20,8 +20,6 @@ ============================================================================== */ -#include - namespace juce { @@ -41,7 +39,7 @@ constexpr auto juceAudioObjectPropertyElementMain = #endif //============================================================================== -class ManagedAudioBufferList : public AudioBufferList +class ManagedAudioBufferList final : public AudioBufferList { public: struct Deleter @@ -292,8 +290,8 @@ class CoreAudioIODeviceType; class CoreAudioIODevice; //============================================================================== -class CoreAudioInternal : private Timer, - private AsyncUpdater +class CoreAudioInternal final : private Timer, + private AsyncUpdater { private: // members with deduced return types need to be defined before they @@ -465,6 +463,24 @@ class CoreAudioInternal : private Timer, auto newBitDepth = jmax (getBitDepth (newInput), getBitDepth (newOutput)); + #if JUCE_AUDIOWORKGROUP_TYPES_AVAILABLE + audioWorkgroup = [this]() -> AudioWorkgroup + { + AudioObjectPropertyAddress pa; + pa.mSelector = kAudioDevicePropertyIOThreadOSWorkgroup; + pa.mScope = kAudioObjectPropertyScopeWildcard; + pa.mElement = juceAudioObjectPropertyElementMain; + + if (auto* workgroup = audioObjectGetProperty (deviceID, pa).value_or (nullptr)) + { + ScopeGuard scope { [&] { os_release (workgroup); } }; + return makeRealAudioWorkgroup (workgroup); + } + + return {}; + }(); + #endif + { const ScopedLock sl (callbackLock); @@ -676,7 +692,7 @@ class CoreAudioInternal : private Timer, scopedProcID = [&self = *this, &lock = callbackLock, nextProcID = ScopedAudioDeviceIOProcID { *this, deviceID, audioIOProc }, - deviceID = deviceID]() mutable -> ScopedAudioDeviceIOProcID + dID = deviceID]() mutable -> ScopedAudioDeviceIOProcID { // It *looks* like AudioDeviceStart may start the audio callback running, and then // immediately lock an internal mutex. @@ -690,7 +706,7 @@ class CoreAudioInternal : private Timer, { const ScopedUnlock su (lock); - if (self.OK (AudioDeviceStart (deviceID, procID))) + if (self.OK (AudioDeviceStart (dID, procID))) return std::move (nextProcID); } @@ -777,11 +793,15 @@ class CoreAudioInternal : private Timer, const auto* timeStamp = numOutputChans > 0 ? outputTimestamp : inputTimestamp; const auto nanos = timeStamp != nullptr ? timeConversions.hostTimeToNanos (timeStamp->mHostTime) : 0; + const AudioIODeviceCallbackContext context + { + timeStamp != nullptr ? &nanos : nullptr, + }; callback->audioDeviceIOCallbackWithContext (getTempBuffers (inStream), numInputChans, getTempBuffers (outStream), numOutputChans, bufferSize, - { timeStamp != nullptr ? &nanos : nullptr }); + context); for (int i = numOutputChans; --i >= 0;) { @@ -1025,6 +1045,8 @@ class CoreAudioInternal : private Timer, AudioDeviceID deviceID; std::unique_ptr inStream, outStream; + AudioWorkgroup audioWorkgroup; + private: class ScopedAudioDeviceIOProcID { @@ -1182,18 +1204,16 @@ class CoreAudioInternal : private Timer, //============================================================================== -class CoreAudioIODevice : public AudioIODevice, - private Timer +class CoreAudioIODevice final : public AudioIODevice, + private Timer { public: CoreAudioIODevice (CoreAudioIODeviceType* dt, const String& deviceName, - AudioDeviceID inputDeviceId, int inputIndex_, - AudioDeviceID outputDeviceId, int outputIndex_) + AudioDeviceID inputDeviceId, + AudioDeviceID outputDeviceId) : AudioIODevice (deviceName, "CoreAudio"), - deviceType (dt), - inputIndex (inputIndex_), - outputIndex (outputIndex_) + deviceType (dt) { internal = [this, &inputDeviceId, &outputDeviceId] { @@ -1241,7 +1261,7 @@ class CoreAudioIODevice : public AudioIODevice, int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); } int getXRunCount() const noexcept override { return internal->xruns; } - int getIndexOfDevice (bool asInput) const { return asInput ? inputIndex : outputIndex; } + int getIndexOfDevice (bool asInput) const { return deviceType->getDeviceNames (asInput).indexOf (getName()); } int getDefaultBufferSize() override { @@ -1319,6 +1339,11 @@ class CoreAudioIODevice : public AudioIODevice, return stopAndGetLastCallback(); } + AudioWorkgroup getWorkgroup() const override + { + return internal->audioWorkgroup; + } + bool isPlaying() override { return internal->isPlaying(); @@ -1365,7 +1390,6 @@ class CoreAudioIODevice : public AudioIODevice, bool shouldRestartDevice() const noexcept { return restartDevice; } WeakReference deviceType; - int inputIndex, outputIndex; bool hadDiscontinuity; private: @@ -1411,9 +1435,9 @@ class CoreAudioIODevice : public AudioIODevice, //============================================================================== -class AudioIODeviceCombiner : public AudioIODevice, - private AsyncRestarter, - private Timer +class AudioIODeviceCombiner final : public AudioIODevice, + private AsyncRestarter, + private Timer { public: AudioIODeviceCombiner (const String& deviceName, CoreAudioIODeviceType* deviceType, @@ -1427,7 +1451,7 @@ class AudioIODeviceCombiner : public AudioIODevice, outputWrapper (*this, std::move (outputDevice), false) { if (getAvailableSampleRates().isEmpty()) - lastError = TRANS("The input and output devices don't share a common sample rate!"); + lastError = TRANS ("The input and output devices don't share a common sample rate!"); } ~AudioIODeviceCombiner() override @@ -1514,6 +1538,11 @@ class AudioIODeviceCombiner : public AudioIODevice, return size; } + AudioWorkgroup getWorkgroup() const override + { + return inputWrapper.getWorkgroup(); + } + String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sampleRate, int bufferSize) override @@ -1671,7 +1700,7 @@ class AudioIODeviceCombiner : public AudioIODevice, if (! forwarder.encounteredError() && newCallback != nullptr) newCallback->audioDeviceAboutToStart (this); else if (lastError.isEmpty()) - lastError = TRANS("Failed to initialise all requested devices."); + lastError = TRANS ("Failed to initialise all requested devices."); } const ScopedLock sl (callbackLock); @@ -1941,7 +1970,7 @@ class AudioIODeviceCombiner : public AudioIODevice, void handleAudioDeviceError (const String& errorMessage) { shutdown (errorMessage.isNotEmpty() ? errorMessage : String ("unknown")); } //============================================================================== - struct DeviceWrapper : public AudioIODeviceCallback + struct DeviceWrapper final : public AudioIODeviceCallback { DeviceWrapper (AudioIODeviceCombiner& cd, std::unique_ptr d, bool shouldBeInput) : owner (cd), @@ -1997,6 +2026,7 @@ class AudioIODeviceCombiner : public AudioIODevice, void start (AudioIODeviceCallback* callbackToNotify) const { return device->start (callbackToNotify); } AudioIODeviceCallback* stopInternal() const { return device->stopInternal(); } void close() const { return device->close(); } + AudioWorkgroup getWorkgroup() const { return device->getWorkgroup(); } String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sampleRate, int bufferSizeSamples) const { @@ -2039,7 +2069,7 @@ class AudioIODeviceCombiner : public AudioIODevice, /* If the current AudioIODeviceCombiner::callback is nullptr, it sets itself as the callback and forwards error related callbacks to the provided callback */ - class ScopedErrorForwarder : public AudioIODeviceCallback + class ScopedErrorForwarder final : public AudioIODeviceCallback { public: ScopedErrorForwarder (AudioIODeviceCombiner& ownerIn, AudioIODeviceCallback* cb) @@ -2097,8 +2127,8 @@ class AudioIODeviceCombiner : public AudioIODevice, //============================================================================== -class CoreAudioIODeviceType : public AudioIODeviceType, - private AsyncUpdater +class CoreAudioIODeviceType final : public AudioIODeviceType, + private AsyncUpdater { public: CoreAudioIODeviceType() : AudioIODeviceType ("CoreAudio") @@ -2235,12 +2265,12 @@ class CoreAudioIODeviceType : public AudioIODeviceType, : outputDeviceName; if (inputDeviceID == outputDeviceID) - return std::make_unique (this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex).release(); + return std::make_unique (this, combinedName, inputDeviceID, outputDeviceID).release(); - auto in = inputDeviceID != 0 ? std::make_unique (this, inputDeviceName, inputDeviceID, inputIndex, 0, -1) + auto in = inputDeviceID != 0 ? std::make_unique (this, inputDeviceName, inputDeviceID, 0) : nullptr; - auto out = outputDeviceID != 0 ? std::make_unique (this, outputDeviceName, 0, -1, outputDeviceID, outputIndex) + auto out = outputDeviceID != 0 ? std::make_unique (this, outputDeviceName, 0, outputDeviceID) : nullptr; if (in == nullptr) return out.release(); diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreMidi_mac.mm b/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreMidi_mac.mm index aa65c856..e83686f1 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreMidi_mac.mm +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_CoreMidi_mac.mm @@ -80,7 +80,7 @@ static bool checkError (OSStatus err, [[maybe_unused]] int lineNum) #if JUCE_HAS_NEW_COREMIDI_API template <> - struct API_AVAILABLE (macos (11.0), ios (14.0)) Sender : public SenderBase + struct API_AVAILABLE (macos (11.0), ios (14.0)) Sender final : public SenderBase { void send (MIDIPortRef port, MIDIEndpointRef endpoint, const ump::BytestreamMidiView& m) override { @@ -167,7 +167,7 @@ void newSendImpl (MIDIPortRef port, MIDIEndpointRef endpoint, Params&&... params #if JUCE_HAS_OLD_COREMIDI_API template <> - struct Sender : public SenderBase + struct Sender final : public SenderBase { void send (MIDIPortRef port, MIDIEndpointRef endpoint, const ump::BytestreamMidiView& m) override { diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_DirectSound_windows.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_DirectSound_windows.cpp index bd113144..dcc6abed 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_DirectSound_windows.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_DirectSound_windows.cpp @@ -37,46 +37,46 @@ extern "C" #undef INTERFACE #define INTERFACE IDirectSound - DECLARE_INTERFACE_(IDirectSound, IUnknown) + DECLARE_INTERFACE_ (IDirectSound, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(CreateSoundBuffer) (THIS_ DSBUFFERDESC*, IDirectSoundBuffer**, LPUNKNOWN) PURE; - STDMETHOD(GetCaps) (THIS_ void*) PURE; - STDMETHOD(DuplicateSoundBuffer) (THIS_ IDirectSoundBuffer*, IDirectSoundBuffer**) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND, DWORD) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD) PURE; - STDMETHOD(SetSpeakerConfig) (THIS_ DWORD) PURE; - STDMETHOD(Initialize) (THIS_ const GUID*) PURE; + STDMETHOD (QueryInterface) (THIS_ REFIID, LPVOID*) PURE; + STDMETHOD_ (ULONG,AddRef) (THIS) PURE; + STDMETHOD_ (ULONG,Release) (THIS) PURE; + STDMETHOD (CreateSoundBuffer) (THIS_ DSBUFFERDESC*, IDirectSoundBuffer**, LPUNKNOWN) PURE; + STDMETHOD (GetCaps) (THIS_ void*) PURE; + STDMETHOD (DuplicateSoundBuffer) (THIS_ IDirectSoundBuffer*, IDirectSoundBuffer**) PURE; + STDMETHOD (SetCooperativeLevel) (THIS_ HWND, DWORD) PURE; + STDMETHOD (Compact) (THIS) PURE; + STDMETHOD (GetSpeakerConfig) (THIS_ LPDWORD) PURE; + STDMETHOD (SetSpeakerConfig) (THIS_ DWORD) PURE; + STDMETHOD (Initialize) (THIS_ const GUID*) PURE; }; #undef INTERFACE #define INTERFACE IDirectSoundBuffer - DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) + DECLARE_INTERFACE_ (IDirectSoundBuffer, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ void*) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD, LPDWORD) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD) PURE; - STDMETHOD(GetVolume) (THIS_ LPLONG) PURE; - STDMETHOD(GetPan) (THIS_ LPLONG) PURE; - STDMETHOD(GetFrequency) (THIS_ LPDWORD) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ IDirectSound*, DSBUFFERDESC*) PURE; - STDMETHOD(Lock) (THIS_ DWORD, DWORD, LPVOID*, LPDWORD, LPVOID*, LPDWORD, DWORD) PURE; - STDMETHOD(Play) (THIS_ DWORD, DWORD, DWORD) PURE; - STDMETHOD(SetCurrentPosition) (THIS_ DWORD) PURE; - STDMETHOD(SetFormat) (THIS_ const WAVEFORMATEX*) PURE; - STDMETHOD(SetVolume) (THIS_ LONG) PURE; - STDMETHOD(SetPan) (THIS_ LONG) PURE; - STDMETHOD(SetFrequency) (THIS_ DWORD) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE; - STDMETHOD(Restore) (THIS) PURE; + STDMETHOD (QueryInterface) (THIS_ REFIID, LPVOID*) PURE; + STDMETHOD_ (ULONG,AddRef) (THIS) PURE; + STDMETHOD_ (ULONG,Release) (THIS) PURE; + STDMETHOD (GetCaps) (THIS_ void*) PURE; + STDMETHOD (GetCurrentPosition) (THIS_ LPDWORD, LPDWORD) PURE; + STDMETHOD (GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD) PURE; + STDMETHOD (GetVolume) (THIS_ LPLONG) PURE; + STDMETHOD (GetPan) (THIS_ LPLONG) PURE; + STDMETHOD (GetFrequency) (THIS_ LPDWORD) PURE; + STDMETHOD (GetStatus) (THIS_ LPDWORD) PURE; + STDMETHOD (Initialize) (THIS_ IDirectSound*, DSBUFFERDESC*) PURE; + STDMETHOD (Lock) (THIS_ DWORD, DWORD, LPVOID*, LPDWORD, LPVOID*, LPDWORD, DWORD) PURE; + STDMETHOD (Play) (THIS_ DWORD, DWORD, DWORD) PURE; + STDMETHOD (SetCurrentPosition) (THIS_ DWORD) PURE; + STDMETHOD (SetFormat) (THIS_ const WAVEFORMATEX*) PURE; + STDMETHOD (SetVolume) (THIS_ LONG) PURE; + STDMETHOD (SetPan) (THIS_ LONG) PURE; + STDMETHOD (SetFrequency) (THIS_ DWORD) PURE; + STDMETHOD (Stop) (THIS) PURE; + STDMETHOD (Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD (Restore) (THIS) PURE; }; //============================================================================== @@ -93,32 +93,32 @@ extern "C" #undef INTERFACE #define INTERFACE IDirectSoundCapture - DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) + DECLARE_INTERFACE_ (IDirectSoundCapture, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(CreateCaptureBuffer) (THIS_ DSCBUFFERDESC*, IDirectSoundCaptureBuffer**, LPUNKNOWN) PURE; - STDMETHOD(GetCaps) (THIS_ void*) PURE; - STDMETHOD(Initialize) (THIS_ const GUID*) PURE; + STDMETHOD (QueryInterface) (THIS_ REFIID, LPVOID*) PURE; + STDMETHOD_ (ULONG,AddRef) (THIS) PURE; + STDMETHOD_ (ULONG,Release) (THIS) PURE; + STDMETHOD (CreateCaptureBuffer) (THIS_ DSCBUFFERDESC*, IDirectSoundCaptureBuffer**, LPUNKNOWN) PURE; + STDMETHOD (GetCaps) (THIS_ void*) PURE; + STDMETHOD (Initialize) (THIS_ const GUID*) PURE; }; #undef INTERFACE #define INTERFACE IDirectSoundCaptureBuffer - DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) + DECLARE_INTERFACE_ (IDirectSoundCaptureBuffer, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ void*) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD, LPDWORD) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD) PURE; - STDMETHOD(Initialize) (THIS_ IDirectSoundCapture*, DSCBUFFERDESC*) PURE; - STDMETHOD(Lock) (THIS_ DWORD, DWORD, LPVOID*, LPDWORD, LPVOID*, LPDWORD, DWORD) PURE; - STDMETHOD(Start) (THIS_ DWORD) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE; + STDMETHOD (QueryInterface) (THIS_ REFIID, LPVOID*) PURE; + STDMETHOD_ (ULONG,AddRef) (THIS) PURE; + STDMETHOD_ (ULONG,Release) (THIS) PURE; + STDMETHOD (GetCaps) (THIS_ void*) PURE; + STDMETHOD (GetCurrentPosition) (THIS_ LPDWORD, LPDWORD) PURE; + STDMETHOD (GetFormat) (THIS_ LPWAVEFORMATEX, DWORD, LPDWORD) PURE; + STDMETHOD (GetStatus) (THIS_ LPDWORD) PURE; + STDMETHOD (Initialize) (THIS_ IDirectSoundCapture*, DSCBUFFERDESC*) PURE; + STDMETHOD (Lock) (THIS_ DWORD, DWORD, LPVOID*, LPDWORD, LPVOID*, LPDWORD, DWORD) PURE; + STDMETHOD (Start) (THIS_ DWORD) PURE; + STDMETHOD (Stop) (THIS) PURE; + STDMETHOD (Unlock) (THIS_ LPVOID, DWORD, LPVOID, DWORD) PURE; }; #undef INTERFACE @@ -136,24 +136,24 @@ namespace DSoundLogging switch (hr) { - case MAKE_HRESULT(1, 0x878, 10): result = "Device already allocated"; break; - case MAKE_HRESULT(1, 0x878, 30): result = "Control unavailable"; break; - case E_INVALIDARG: result = "Invalid parameter"; break; - case MAKE_HRESULT(1, 0x878, 50): result = "Invalid call"; break; - case E_FAIL: result = "Generic error"; break; - case MAKE_HRESULT(1, 0x878, 70): result = "Priority level error"; break; - case E_OUTOFMEMORY: result = "Out of memory"; break; - case MAKE_HRESULT(1, 0x878, 100): result = "Bad format"; break; - case E_NOTIMPL: result = "Unsupported function"; break; - case MAKE_HRESULT(1, 0x878, 120): result = "No driver"; break; - case MAKE_HRESULT(1, 0x878, 130): result = "Already initialised"; break; - case CLASS_E_NOAGGREGATION: result = "No aggregation"; break; - case MAKE_HRESULT(1, 0x878, 150): result = "Buffer lost"; break; - case MAKE_HRESULT(1, 0x878, 160): result = "Another app has priority"; break; - case MAKE_HRESULT(1, 0x878, 170): result = "Uninitialised"; break; - case E_NOINTERFACE: result = "No interface"; break; - case S_OK: result = "No error"; break; - default: return "Unknown error: " + String ((int) hr); + case MAKE_HRESULT (1, 0x878, 10): result = "Device already allocated"; break; + case MAKE_HRESULT (1, 0x878, 30): result = "Control unavailable"; break; + case E_INVALIDARG: result = "Invalid parameter"; break; + case MAKE_HRESULT (1, 0x878, 50): result = "Invalid call"; break; + case E_FAIL: result = "Generic error"; break; + case MAKE_HRESULT (1, 0x878, 70): result = "Priority level error"; break; + case E_OUTOFMEMORY: result = "Out of memory"; break; + case MAKE_HRESULT (1, 0x878, 100): result = "Bad format"; break; + case E_NOTIMPL: result = "Unsupported function"; break; + case MAKE_HRESULT (1, 0x878, 120): result = "No driver"; break; + case MAKE_HRESULT (1, 0x878, 130): result = "Already initialised"; break; + case CLASS_E_NOAGGREGATION: result = "No aggregation"; break; + case MAKE_HRESULT (1, 0x878, 150): result = "Buffer lost"; break; + case MAKE_HRESULT (1, 0x878, 160): result = "Another app has priority"; break; + case MAKE_HRESULT (1, 0x878, 170): result = "Uninitialised"; break; + case E_NOINTERFACE: result = "No interface"; break; + case S_OK: result = "No error"; break; + default: return "Unknown error: " + String ((int) hr); } return result; @@ -739,8 +739,8 @@ struct DSoundInternalInChannel }; //============================================================================== -class DSoundAudioIODevice : public AudioIODevice, - public Thread +class DSoundAudioIODevice final : public AudioIODevice, + public Thread { public: DSoundAudioIODevice (const String& deviceName, @@ -753,14 +753,14 @@ class DSoundAudioIODevice : public AudioIODevice, { if (outputDeviceIndex_ >= 0) { - outChannels.add (TRANS("Left")); - outChannels.add (TRANS("Right")); + outChannels.add (TRANS ("Left")); + outChannels.add (TRANS ("Right")); } if (inputDeviceIndex_ >= 0) { - inChannels.add (TRANS("Left")); - inChannels.add (TRANS("Right")); + inChannels.add (TRANS ("Left")); + inChannels.add (TRANS ("Right")); } } @@ -923,10 +923,10 @@ class DSoundAudioIODevice : public AudioIODevice, sleep (5); for (int i = 0; i < outChans.size(); ++i) - outChans.getUnchecked(i)->synchronisePosition(); + outChans.getUnchecked (i)->synchronisePosition(); for (int i = 0; i < inChans.size(); ++i) - inChans.getUnchecked(i)->synchronisePosition(); + inChans.getUnchecked (i)->synchronisePosition(); } } @@ -949,13 +949,13 @@ class DSoundAudioIODevice : public AudioIODevice, for (int i = inChans.size(); --i >= 0;) { - inChans.getUnchecked(i)->doneFlag = false; + inChans.getUnchecked (i)->doneFlag = false; ++numToDo; } for (int i = outChans.size(); --i >= 0;) { - outChans.getUnchecked(i)->doneFlag = false; + outChans.getUnchecked (i)->doneFlag = false; ++numToDo; } @@ -968,7 +968,7 @@ class DSoundAudioIODevice : public AudioIODevice, { for (int i = inChans.size(); --i >= 0;) { - DSoundInternalInChannel* const in = inChans.getUnchecked(i); + DSoundInternalInChannel* const in = inChans.getUnchecked (i); if ((! in->doneFlag) && in->service()) { @@ -979,7 +979,7 @@ class DSoundAudioIODevice : public AudioIODevice, for (int i = outChans.size(); --i >= 0;) { - DSoundInternalOutChannel* const out = outChans.getUnchecked(i); + DSoundInternalOutChannel* const out = outChans.getUnchecked (i); if ((! out->doneFlag) && out->service()) { @@ -1192,10 +1192,10 @@ String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, if (error.isEmpty()) { for (int i = 0; i < outChans.size(); ++i) - outChans.getUnchecked(i)->synchronisePosition(); + outChans.getUnchecked (i)->synchronisePosition(); for (int i = 0; i < inChans.size(); ++i) - inChans.getUnchecked(i)->synchronisePosition(); + inChans.getUnchecked (i)->synchronisePosition(); startThread (Priority::highest); sleep (10); @@ -1214,7 +1214,7 @@ String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, } //============================================================================== -class DSoundAudioIODeviceType : public AudioIODeviceType +class DSoundAudioIODeviceType final : public AudioIODeviceType { public: DSoundAudioIODeviceType() diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_HighPerformanceAudioHelpers_android.h b/JuceLibraryCode/modules/juce_audio_devices/native/juce_HighPerformanceAudioHelpers_android.h index 0ba3b10c..39a26c8b 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_HighPerformanceAudioHelpers_android.h +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_HighPerformanceAudioHelpers_android.h @@ -20,9 +20,6 @@ ============================================================================== */ -namespace juce -{ - //============================================================================== /** Some shared helpers methods for using the high-performance audio paths on @@ -30,7 +27,7 @@ namespace juce @tags{Audio} */ -namespace AndroidHighPerformanceAudioHelpers +namespace juce::AndroidHighPerformanceAudioHelpers { //============================================================================== static double getNativeSampleRate() @@ -126,6 +123,5 @@ namespace AndroidHighPerformanceAudioHelpers auto defaultBuffersToEnqueue = buffersToQueueForBufferDuration (nativeBufferSize, defaultBufferLength, currentSampleRate); return defaultBuffersToEnqueue * nativeBufferSize; } -} -} // namespace juce +} // namespace juce::AndroidHighPerformanceAudioHelpers diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp index 643cf8bd..7b49ddf1 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp @@ -59,12 +59,12 @@ JUCE_DECL_JACK_FUNCTION (int, jack_activate, (jack_client_t* client), (client)) JUCE_DECL_JACK_FUNCTION (int, jack_deactivate, (jack_client_t* client), (client)) JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_buffer_size, (jack_client_t* client), (client)) JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_sample_rate, (jack_client_t* client), (client)) -JUCE_DECL_VOID_JACK_FUNCTION (jack_on_shutdown, (jack_client_t* client, void (*function)(void* arg), void* arg), (client, function, arg)) +JUCE_DECL_VOID_JACK_FUNCTION (jack_on_shutdown, (jack_client_t* client, void (*function) (void* arg), void* arg), (client, function, arg)) JUCE_DECL_VOID_JACK_FUNCTION (jack_on_info_shutdown, (jack_client_t* client, JackInfoShutdownCallback function, void* arg), (client, function, arg)) JUCE_DECL_JACK_FUNCTION (void* , jack_port_get_buffer, (jack_port_t* port, jack_nframes_t nframes), (port, nframes)) JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_port_get_total_latency, (jack_client_t* client, jack_port_t* port), (client, port)) JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_register, (jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size), (client, port_name, port_type, flags, buffer_size)) -JUCE_DECL_VOID_JACK_FUNCTION (jack_set_error_function, (void (*func)(const char*)), (func)) +JUCE_DECL_VOID_JACK_FUNCTION (jack_set_error_function, (void (*func) (const char*)), (func)) JUCE_DECL_JACK_FUNCTION (int, jack_set_process_callback, (jack_client_t* client, JackProcessCallback process_callback, void* arg), (client, process_callback, arg)) JUCE_DECL_JACK_FUNCTION (const char**, jack_get_ports, (jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags), (client, port_name_pattern, type_name_pattern, flags)) JUCE_DECL_JACK_FUNCTION (int, jack_connect, (jack_client_t* client, const char* source_port, const char* destination_port), (client, source_port, destination_port)) @@ -158,7 +158,7 @@ struct JackPortIterator }; //============================================================================== -class JackAudioIODevice : public AudioIODevice +class JackAudioIODevice final : public AudioIODevice { public: JackAudioIODevice (const String& inName, @@ -346,8 +346,8 @@ class JackAudioIODevice : public AudioIODevice if (client != nullptr) { - const auto result = juce::jack_deactivate (client); - jassertquiet (result == 0); + [[maybe_unused]] const auto result = juce::jack_deactivate (client); + jassert (result == 0); juce::jack_set_xrun_callback (client, xrunCallback, nullptr); juce::jack_set_process_callback (client, processCallback, nullptr); @@ -416,7 +416,7 @@ class JackAudioIODevice : public AudioIODevice private: //============================================================================== - class MainThreadDispatcher : private AsyncUpdater + class MainThreadDispatcher final : private AsyncUpdater { public: explicit MainThreadDispatcher (JackAudioIODevice& device) : ref (device) {} @@ -517,8 +517,7 @@ class JackAudioIODevice : public AudioIODevice if (oldCallback != nullptr) start (oldCallback); - if (notifyChannelsChanged != nullptr) - notifyChannelsChanged(); + NullCheckedInvocation::invoke (notifyChannelsChanged); } } @@ -544,9 +543,9 @@ class JackAudioIODevice : public AudioIODevice } } - static void infoShutdownCallback (jack_status_t code, [[maybe_unused]] const char* reason, void* arg) + static void infoShutdownCallback ([[maybe_unused]] jack_status_t code, [[maybe_unused]] const char* reason, void* arg) { - jassertquiet (code == 0); + jassert (code == 0); JUCE_JACK_LOG ("Shutting down with message:"); JUCE_JACK_LOG (reason); @@ -580,7 +579,7 @@ class JackAudioIODevice : public AudioIODevice //============================================================================== class JackAudioIODeviceType; -class JackAudioIODeviceType : public AudioIODeviceType +class JackAudioIODeviceType final : public AudioIODeviceType { public: JackAudioIODeviceType() diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_android.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_android.cpp index ad5e87b7..00b03274 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_android.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_android.cpp @@ -971,7 +971,7 @@ class AndroidMidiDeviceManager if (auto dm = deviceManager.get()) { if (auto javaMidiPort = getEnv()->CallObjectMethod (dm, MidiDeviceManager.openMidiOutputPortWithID, (jint) deviceID)) - return new MidiOutput::Pimpl (LocalRef(javaMidiPort)); + return new MidiOutput::Pimpl (LocalRef (javaMidiPort)); // Perhaps the port is already open jassertfalse; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_linux.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_linux.cpp index 3883bfa1..e0485028 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_linux.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_linux.cpp @@ -334,7 +334,7 @@ class AlsaClient // created on the main thread, but the MidiDeviceListConnectionBroadcaster's constructor // can't complete until the AlsaClient's destructor has run, which in turn requires the // SequencerThread to join. - class UpdateNotifier : private AsyncUpdater + class UpdateNotifier final : private AsyncUpdater { public: ~UpdateNotifier() override { cancelPendingUpdate(); } @@ -528,13 +528,13 @@ struct AlsaPortPtr explicit AlsaPortPtr (AlsaClient::Port* p) : ptr (p) {} - ~AlsaPortPtr() noexcept { AlsaClient::getInstance()->deletePort (ptr); } + virtual ~AlsaPortPtr() noexcept { AlsaClient::getInstance()->deletePort (ptr); } AlsaClient::Port* ptr = nullptr; }; //============================================================================== -class MidiInput::Pimpl : public AlsaPortPtr +class MidiInput::Pimpl final : public AlsaPortPtr { public: using AlsaPortPtr::AlsaPortPtr; @@ -633,7 +633,7 @@ void MidiInput::stop() } //============================================================================== -class MidiOutput::Pimpl : public AlsaPortPtr +class MidiOutput::Pimpl final : public AlsaPortPtr { public: using AlsaPortPtr::AlsaPortPtr; diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_windows.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_windows.cpp index 3119769c..aa3648fb 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_windows.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Midi_windows.cpp @@ -100,8 +100,8 @@ struct MidiServiceType }; //============================================================================== -struct Win32MidiService : public MidiServiceType, - private Timer +struct Win32MidiService final : public MidiServiceType, + private Timer { Win32MidiService() = default; @@ -131,7 +131,7 @@ struct Win32MidiService : public MidiServiceType, struct Win32InputWrapper; //============================================================================== - struct MidiInCollector : public ReferenceCountedObject + struct MidiInCollector final : public ReferenceCountedObject { MidiInCollector (Win32MidiService& s, MidiDeviceInfo d) : deviceInfo (d), midiService (s) @@ -370,6 +370,8 @@ struct Win32MidiService : public MidiServiceType, template struct Win32MidiDeviceQuery { + virtual ~Win32MidiDeviceQuery() = default; + static Array getAvailableDevices() { StringArray deviceNames, deviceIDs; @@ -419,8 +421,8 @@ struct Win32MidiService : public MidiServiceType, } }; - struct Win32InputWrapper : public MidiInput::Pimpl, - public Win32MidiDeviceQuery + struct Win32InputWrapper final : public MidiInput::Pimpl, + public Win32MidiDeviceQuery { Win32InputWrapper (Win32MidiService& parentService, MidiInput& midiInput, const String& deviceIdentifier, MidiInputCallback& c) : input (midiInput), callback (c) @@ -517,7 +519,7 @@ struct Win32MidiService : public MidiServiceType, }; //============================================================================== - struct MidiOutHandle : public ReferenceCountedObject + struct MidiOutHandle final : public ReferenceCountedObject { using Ptr = ReferenceCountedObjectPtr; @@ -543,8 +545,8 @@ struct Win32MidiService : public MidiServiceType, }; //============================================================================== - struct Win32OutputWrapper : public MidiOutput::Pimpl, - public Win32MidiDeviceQuery + struct Win32OutputWrapper final : public MidiOutput::Pimpl, + public Win32MidiDeviceQuery { Win32OutputWrapper (Win32MidiService& p, const String& deviceIdentifier) : parent (p) @@ -707,7 +709,7 @@ struct Win32MidiService : public MidiServiceType, const ScopedLock sl (activeCollectorLock); for (int i = activeCollectors.size(); --i >= 0;) - if (activeCollectors.getObjectPointer(i)->getReferenceCount() == 1) + if (activeCollectors.getObjectPointer (i)->getReferenceCount() == 1) activeCollectors.remove (i); } @@ -745,7 +747,7 @@ using namespace ABI::Windows::Devices::Enumeration; using namespace ABI::Windows::Storage::Streams; //============================================================================== -struct WinRTMidiService : public MidiServiceType +struct WinRTMidiService final : public MidiServiceType { public: //============================================================================== @@ -1008,7 +1010,7 @@ struct WinRTMidiService : public MidiServiceType private: //============================================================================== - struct DeviceEnumerationThread : public Thread + struct DeviceEnumerationThread final : public Thread { DeviceEnumerationThread (DeviceCallbackHandler& h, ComSmartPtr& w, @@ -1063,7 +1065,7 @@ struct WinRTMidiService : public MidiServiceType }; //============================================================================== - struct BLEDeviceWatcher final : private DeviceCallbackHandler + struct BLEDeviceWatcher final : private DeviceCallbackHandler { struct DeviceInfo { @@ -1253,7 +1255,7 @@ struct WinRTMidiService : public MidiServiceType //============================================================================== template - struct MidiIODeviceWatcher final : private DeviceCallbackHandler + struct MidiIODeviceWatcher final : private DeviceCallbackHandler { MidiIODeviceWatcher (ComSmartPtr& comFactory) : factory (comFactory) @@ -1503,7 +1505,7 @@ struct WinRTMidiService : public MidiServiceType //============================================================================== template - class WinRTIOWrapper : private BLEDeviceWatcher::Listener + class WinRTIOWrapper : private BLEDeviceWatcher::Listener { public: WinRTIOWrapper (BLEDeviceWatcher& bleWatcher, @@ -1586,8 +1588,8 @@ struct WinRTMidiService : public MidiServiceType }; //============================================================================== - struct WinRTInputWrapper final : public MidiInput::Pimpl, - private WinRTIOWrapper + struct WinRTInputWrapper final : public MidiInput::Pimpl, + private WinRTIOWrapper { WinRTInputWrapper (WinRTMidiService& service, MidiInput& input, const String& deviceIdentifier, MidiInputCallback& cb) @@ -1749,8 +1751,8 @@ struct WinRTMidiService : public MidiServiceType }; //============================================================================== - struct WinRTOutputWrapper final : public MidiOutput::Pimpl, - private WinRTIOWrapper + struct WinRTOutputWrapper final : public MidiOutput::Pimpl, + private WinRTIOWrapper { WinRTOutputWrapper (WinRTMidiService& service, const String& deviceIdentifier) : WinRTIOWrapper (*service.bleDeviceWatcher, *service.outputDeviceWatcher, deviceIdentifier) @@ -1834,7 +1836,7 @@ struct WinRTMidiService : public MidiServiceType extern RTL_OSVERSIONINFOW getWindowsVersionInfo(); #endif -struct MidiService : public DeletedAtShutdown +struct MidiService final : public DeletedAtShutdown { MidiService() { diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Oboe_android.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Oboe_android.cpp index 38152cb8..f2036079 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_Oboe_android.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_Oboe_android.cpp @@ -124,7 +124,7 @@ static String getOboeString (const Type& value) } //============================================================================== -class OboeAudioIODevice : public AudioIODevice +class OboeAudioIODevice final : public AudioIODevice { public: //============================================================================== @@ -370,7 +370,7 @@ class OboeAudioIODevice : public AudioIODevice // providing a callback is required on some devices to get a FAST track, so we pass an // empty one to the temp stream to get the best available buffer size - struct DummyCallback : public oboe::AudioStreamCallback + struct DummyCallback final : public oboe::AudioStreamCallback { oboe::DataCallbackResult onAudioReady (oboe::AudioStream*, void*, int32_t) override { return oboe::DataCallbackResult::Stop; } }; @@ -609,7 +609,7 @@ class OboeAudioIODevice : public AudioIODevice }; //============================================================================== - class OboeSessionBase : protected oboe::AudioStreamCallback + class OboeSessionBase : protected oboe::AudioStreamCallback { public: static OboeSessionBase* create (OboeAudioIODevice& owner, @@ -730,7 +730,7 @@ class OboeAudioIODevice : public AudioIODevice //============================================================================== template - class OboeSessionImpl : public OboeSessionBase + class OboeSessionImpl final : public OboeSessionBase { public: OboeSessionImpl (OboeAudioIODevice& ownerToUse, @@ -1038,7 +1038,7 @@ OboeAudioIODevice::OboeSessionBase* OboeAudioIODevice::OboeSessionBase::create ( } //============================================================================== -class OboeAudioIODeviceType : public AudioIODeviceType +class OboeAudioIODeviceType final : public AudioIODeviceType { public: OboeAudioIODeviceType() @@ -1302,7 +1302,7 @@ const char* const OboeAudioIODevice::oboeTypeName = "Android Oboe"; bool isOboeAvailable() { return OboeAudioIODeviceType::isOboeAvailable(); } //============================================================================== -class OboeRealtimeThread : private oboe::AudioStreamCallback +class OboeRealtimeThread final : private oboe::AudioStreamCallback { using OboeStream = OboeAudioIODevice::OboeStream; @@ -1344,7 +1344,7 @@ class OboeRealtimeThread : private oboe::AudioStreamCallback return testStream != nullptr && testStream->openedOk(); } - pthread_t startThread (void*(*entry)(void*), void* userPtr) + pthread_t startThread (void*(*entry) (void*), void* userPtr) { pthread_mutex_lock (&threadReadyMutex); diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_OpenSL_android.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_OpenSL_android.cpp index 1ed0173d..2a4920f0 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_OpenSL_android.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_OpenSL_android.cpp @@ -41,7 +41,7 @@ DECLARE_JNI_CLASS (AndroidAudioManager, "android/media/AudioManager") #endif //============================================================================== -struct PCMDataFormatEx : SLDataFormat_PCM +struct PCMDataFormatEx final : SLDataFormat_PCM { SLuint32 representation; }; @@ -106,7 +106,7 @@ class SlObjectRef private: //============================================================================== - struct ControlBlock : ReferenceCountedObject + struct ControlBlock final : ReferenceCountedObject { ControlBlock() = default; ControlBlock (SLObjectItf o) : ptr (o) {} @@ -118,7 +118,7 @@ class SlObjectRef }; template -class SlRef : public SlObjectRef +class SlRef final : public SlObjectRef { public: //============================================================================== @@ -312,7 +312,7 @@ OpenSLEngineHolder& getEngineHolder() class SLRealtimeThread; //============================================================================== -class OpenSLAudioIODevice : public AudioIODevice +class OpenSLAudioIODevice final : public AudioIODevice { public: //============================================================================== @@ -362,7 +362,7 @@ class OpenSLAudioIODevice : public AudioIODevice &audioRoutingJni); if (status == SL_RESULT_SUCCESS && audioRoutingJni != nullptr) - javaProxy = GlobalRef (LocalRef(getEnv()->NewLocalRef (audioRoutingJni))); + javaProxy = GlobalRef (LocalRef (getEnv()->NewLocalRef (audioRoutingJni))); } } @@ -391,7 +391,7 @@ class OpenSLAudioIODevice : public AudioIODevice } bool isBufferAvailable() const { return (numBlocksOut.get() < owner.numBuffers); } - T* getNextBuffer() { nextBlock.set((nextBlock.get() + 1) % owner.numBuffers); return getCurrentBuffer(); } + T* getNextBuffer() { nextBlock.set ((nextBlock.get() + 1) % owner.numBuffers); return getCurrentBuffer(); } T* getCurrentBuffer() { return nativeBuffer.get() + (static_cast (nextBlock.get()) * getBufferSizeInSamples()); } size_t getBufferSizeInSamples() const { return static_cast (owner.bufferSize * numChannels); } @@ -427,7 +427,7 @@ class OpenSLAudioIODevice : public AudioIODevice //============================================================================== template - struct OpenSLQueueRunnerPlayer : OpenSLQueueRunner, SLPlayItf_> + struct OpenSLQueueRunnerPlayer final : OpenSLQueueRunner, SLPlayItf_> { using Base = OpenSLQueueRunner, SLPlayItf_>; @@ -458,7 +458,7 @@ class OpenSLAudioIODevice : public AudioIODevice auto status = e->CreateAudioPlayer (holder.engine, &obj, &source, &sink, 2, queueInterfaces, interfaceRequired); - if (status != SL_RESULT_SUCCESS || obj == nullptr || (*obj)->Realize(obj, 0) != SL_RESULT_SUCCESS) + if (status != SL_RESULT_SUCCESS || obj == nullptr || (*obj)->Realize (obj, 0) != SL_RESULT_SUCCESS) { destroyObject (obj); return {}; @@ -472,7 +472,7 @@ class OpenSLAudioIODevice : public AudioIODevice }; template - struct OpenSLQueueRunnerRecorder : public OpenSLQueueRunner, SLRecordItf_> + struct OpenSLQueueRunnerRecorder final : public OpenSLQueueRunner, SLRecordItf_> { using Base = OpenSLQueueRunner, SLRecordItf_>; @@ -611,7 +611,7 @@ class OpenSLAudioIODevice : public AudioIODevice else { for (int i = 0; i < outputChannels; ++i) - zeromem (outputChannelData[i], sizeof(float) * static_cast (bufferSize)); + zeromem (outputChannelData[i], sizeof (float) * static_cast (bufferSize)); } } @@ -631,7 +631,7 @@ class OpenSLAudioIODevice : public AudioIODevice }; template - class OpenSLSessionT : public OpenSLSession + class OpenSLSessionT final : public OpenSLSession { public: OpenSLSessionT (int numInputChannels, int numOutputChannels, @@ -913,7 +913,7 @@ class OpenSLAudioIODevice : public AudioIODevice if (numInputChannels > 0 && numOutputChannels > 0 && RuntimePermissions::isGranted (RuntimePermissions::recordAudio)) { // New versions of the Android emulator do not seem to support audio input anymore on OS X - activeInputChans = BigInteger(0); + activeInputChans = BigInteger (0); numInputChannels = 0; session.reset (OpenSLSession::create (numInputChannels, numOutputChannels, @@ -1068,7 +1068,7 @@ OpenSLAudioIODevice::OpenSLSession* OpenSLAudioIODevice::OpenSLSession::create ( } //============================================================================== -class OpenSLAudioDeviceType : public AudioIODeviceType +class OpenSLAudioDeviceType final : public AudioIODeviceType { public: OpenSLAudioDeviceType() : AudioIODeviceType (OpenSLAudioIODevice::openSLTypeName) {} diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/juce_WASAPI_windows.cpp b/JuceLibraryCode/modules/juce_audio_devices/native/juce_WASAPI_windows.cpp index a224e196..ad65495e 100644 --- a/JuceLibraryCode/modules/juce_audio_devices/native/juce_WASAPI_windows.cpp +++ b/JuceLibraryCode/modules/juce_audio_devices/native/juce_WASAPI_windows.cpp @@ -527,6 +527,16 @@ class WASAPIDeviceBase isActive = true; } + std::optional getDefaultLayout() const + { + if (countNumberOfBits ((uint64) defaultFormatChannelMask) == defaultNumChannels) + return BigInteger ((int64) defaultFormatChannelMask); + + BigInteger integer; + integer.setRange (0, defaultNumChannels, true); + return integer; + } + //============================================================================== ComSmartPtr device; ComSmartPtr client; @@ -550,7 +560,7 @@ class WASAPIDeviceBase private: //============================================================================== - struct SessionEventCallback : public ComBaseClassHelper + struct SessionEventCallback final : public ComBaseClassHelper { SessionEventCallback (WASAPIDeviceBase& d) : owner (d) {} @@ -635,7 +645,7 @@ class WASAPIDeviceBase if (! check (client->GetMixFormat (&mixFormat))) return {}; - WAVEFORMATEXTENSIBLE format; + WAVEFORMATEXTENSIBLE format{}; copyWavFormat (format, mixFormat); CoTaskMemFree (mixFormat); @@ -756,7 +766,7 @@ class WASAPIDeviceBase : AUDCLNT_SHAREMODE_SHARED, (WAVEFORMATEX*) &format, isExclusiveMode (mode) ? nullptr - : &nearestFormat); + : &nearestFormat); logFailure (hr); auto supportsSRC = supportsSampleRateConversion (mode); @@ -888,7 +898,6 @@ class WASAPIDeviceBase bool tryInitialisingWithBufferSize (int bufferSizeSamples) { - if (auto format = findSupportedFormat (client, numChannels, sampleRate)) { auto isInitialised = isLowLatencyMode (deviceMode) ? initialiseLowLatencyClient (bufferSizeSamples, *format) @@ -914,7 +923,7 @@ class WASAPIDeviceBase }; //============================================================================== -class WASAPIInputDevice : public WASAPIDeviceBase +class WASAPIInputDevice final : public WASAPIDeviceBase { public: WASAPIInputDevice (const ComSmartPtr& d, WASAPIDeviceMode mode) @@ -1062,7 +1071,7 @@ class WASAPIInputDevice : public WASAPIDeviceBase }; //============================================================================== -class WASAPIOutputDevice : public WASAPIDeviceBase +class WASAPIOutputDevice final : public WASAPIDeviceBase { public: WASAPIOutputDevice (const ComSmartPtr& d, WASAPIDeviceMode mode) @@ -1164,11 +1173,14 @@ class WASAPIOutputDevice : public WASAPIDeviceBase if (isExclusiveMode (deviceMode) && WaitForSingleObject (clientEvent, 1000) == WAIT_TIMEOUT) break; + const auto numChannelsToCopy = jmin (actualNumChannels, numSrcBuffers); + jassert (numChannelsToCopy <= channelMaps.size()); + uint8* outputData = nullptr; if (check (renderClient->GetBuffer ((UINT32) samplesToDo, &outputData))) { - for (int i = 0; i < numSrcBuffers; ++i) - converter->convertSamples (outputData, channelMaps.getUnchecked(i), srcBuffers[i] + offset, 0, samplesToDo); + for (int i = 0; i < numChannelsToCopy; ++i) + converter->convertSamples (outputData, channelMaps.getUnchecked (i), srcBuffers[i] + offset, 0, samplesToDo); renderClient->ReleaseBuffer ((UINT32) samplesToDo, 0); } @@ -1186,7 +1198,7 @@ class WASAPIOutputDevice : public WASAPIDeviceBase }; //============================================================================== -class WASAPIAudioIODevice : public AudioIODevice, +class WASAPIAudioIODevice final : public AudioIODevice, public Thread, private AsyncUpdater { @@ -1336,6 +1348,16 @@ class WASAPIAudioIODevice : public AudioIODevice, String getLastError() override { return lastError; } int getXRunCount() const noexcept override { return inputDevice != nullptr ? inputDevice->xruns : -1; } + std::optional getDefaultOutputChannels() const override + { + return outputDevice != nullptr ? outputDevice->getDefaultLayout() : std::nullopt; + } + + std::optional getDefaultInputChannels() const override + { + return inputDevice != nullptr ? inputDevice->getDefaultLayout() : std::nullopt; + } + String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sampleRate, int bufferSizeSamples) override { @@ -1344,7 +1366,7 @@ class WASAPIAudioIODevice : public AudioIODevice, if (sampleRates.size() == 0 && inputDevice != nullptr && outputDevice != nullptr) { - lastError = TRANS("The input and output devices don't share a common sample rate!"); + lastError = TRANS ("The input and output devices don't share a common sample rate!"); return lastError; } @@ -1355,14 +1377,14 @@ class WASAPIAudioIODevice : public AudioIODevice, if (inputDevice != nullptr && ! inputDevice->open (currentSampleRate, inputChannels, bufferSizeSamples)) { - lastError = TRANS("Couldn't open the input device!"); + lastError = TRANS ("Couldn't open the input device!"); return lastError; } if (outputDevice != nullptr && ! outputDevice->open (currentSampleRate, outputChannels, bufferSizeSamples)) { close(); - lastError = TRANS("Couldn't open the output device!"); + lastError = TRANS ("Couldn't open the output device!"); return lastError; } @@ -1372,7 +1394,7 @@ class WASAPIAudioIODevice : public AudioIODevice, if (inputDevice != nullptr && outputDevice != nullptr && inputDevice->actualBufferSize != outputDevice->actualBufferSize) { close(); - lastError = TRANS("Couldn't open the output device (buffer size mismatch)"); + lastError = TRANS ("Couldn't open the output device (buffer size mismatch)"); return lastError; } @@ -1396,7 +1418,7 @@ class WASAPIAudioIODevice : public AudioIODevice, if (! inputDevice->start (currentBufferSizeSamples)) { close(); - lastError = TRANS("Couldn't start the input device!"); + lastError = TRANS ("Couldn't start the input device!"); return lastError; } } @@ -1408,7 +1430,7 @@ class WASAPIAudioIODevice : public AudioIODevice, if (! outputDevice->start()) { close(); - lastError = TRANS("Couldn't start the output device!"); + lastError = TRANS ("Couldn't start the output device!"); return lastError; } } @@ -1694,7 +1716,7 @@ class WASAPIAudioIODevice : public AudioIODevice, //============================================================================== -class WASAPIAudioIODeviceType : public AudioIODeviceType +class WASAPIAudioIODeviceType final : public AudioIODeviceType { public: explicit WASAPIAudioIODeviceType (WASAPIDeviceMode mode) @@ -1793,7 +1815,7 @@ class WASAPIAudioIODeviceType : public AudioIODeviceType ComSmartPtr enumerator; //============================================================================== - class ChangeNotificationClient : public ComBaseClassHelper + class ChangeNotificationClient final : public ComBaseClassHelper { public: explicit ChangeNotificationClient (WASAPIAudioIODeviceType* d) @@ -1801,7 +1823,7 @@ class WASAPIAudioIODeviceType : public AudioIODeviceType JUCE_COMRESULT OnDeviceAdded (LPCWSTR) { return notify(); } JUCE_COMRESULT OnDeviceRemoved (LPCWSTR) { return notify(); } - JUCE_COMRESULT OnDeviceStateChanged(LPCWSTR, DWORD) { return notify(); } + JUCE_COMRESULT OnDeviceStateChanged (LPCWSTR, DWORD) { return notify(); } JUCE_COMRESULT OnDefaultDeviceChanged (EDataFlow, ERole, LPCWSTR) { return notify(); } JUCE_COMRESULT OnPropertyValueChanged (LPCWSTR, const PROPERTYKEY) { return notify(); } @@ -2002,7 +2024,7 @@ struct MMDeviceMasterVolume JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MMDeviceMasterVolume) }; -} +} // namespace WasapiClasses //============================================================================== #define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1 diff --git a/JuceLibraryCode/modules/juce_audio_devices/native/oboe/.clang-tidy b/JuceLibraryCode/modules/juce_audio_devices/native/oboe/.clang-tidy new file mode 100644 index 00000000..857909fa --- /dev/null +++ b/JuceLibraryCode/modules/juce_audio_devices/native/oboe/.clang-tidy @@ -0,0 +1,3 @@ +# We want to ignore this directory, but we need to enable at least a single +# check to avoid an error +Checks: -*,darwin-dispatch-once-nonstatic diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 6974d048..1c6e052a 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -382,7 +382,7 @@ namespace AiffFileHelpers } //============================================================================== -class AiffAudioFormatReader : public AudioFormatReader +class AiffAudioFormatReader final : public AudioFormatReader { public: AiffAudioFormatReader (InputStream* in) @@ -640,7 +640,7 @@ class AiffAudioFormatReader : public AudioFormatReader }; //============================================================================== -class AiffAudioFormatWriter : public AudioFormatWriter +class AiffAudioFormatWriter final : public AudioFormatWriter { public: AiffAudioFormatWriter (OutputStream* out, double rate, @@ -818,7 +818,7 @@ class AiffAudioFormatWriter : public AudioFormatWriter }; //============================================================================== -class MemoryMappedAiffReader : public MemoryMappedAudioFormatReader +class MemoryMappedAiffReader final : public MemoryMappedAudioFormatReader { public: MemoryMappedAiffReader (const File& f, const AiffAudioFormatReader& reader) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h index 2396b3ba..0315ee46 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h @@ -88,7 +88,7 @@ class JUCE_API AiffAudioFormat : public AudioFormat using AudioFormat::createWriterFor; private: - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AiffAudioFormat) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AiffAudioFormat) }; } // namespace juce diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 034dcbcd..090f7ed7 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -267,7 +267,7 @@ struct CoreAudioFormatMetatdata for (int i = 0; i < numTimeSigEvents; ++i) { int numerator, denominator; - timeSigEvents.getEventPointer(i)->message.getTimeSignatureInfo (numerator, denominator); + timeSigEvents.getEventPointer (i)->message.getTimeSignatureInfo (numerator, denominator); String timeSigString; timeSigString << numerator << '/' << denominator; @@ -384,7 +384,7 @@ struct CoreAudioFormatMetatdata }; //============================================================================== -class CoreAudioReader : public AudioFormatReader +class CoreAudioReader final : public AudioFormatReader { public: using StreamKind = CoreAudioFormat::StreamKind; @@ -664,7 +664,7 @@ AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream*, #define DEFINE_CHANNEL_LAYOUT_DFL_ENTRY(x) CoreAudioChannelLayoutTag { x, #x, AudioChannelSet() } #define DEFINE_CHANNEL_LAYOUT_TAG_ENTRY(x, y) CoreAudioChannelLayoutTag { x, #x, y } -class CoreAudioLayoutsUnitTest : public UnitTest +class CoreAudioLayoutsUnitTest final : public UnitTest { public: CoreAudioLayoutsUnitTest() diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 3fed5337..c689bccc 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -183,7 +183,7 @@ template auto emptyRange (Item item) { return Range::emptyRange (item); } //============================================================================== -class FlacReader : public AudioFormatReader +class FlacReader final : public AudioFormatReader { public: FlacReader (InputStream* in) : AudioFormatReader (in, flacFormatName) @@ -386,7 +386,7 @@ class FlacReader : public AudioFormatReader //============================================================================== -class FlacWriter : public AudioFormatWriter +class FlacWriter final : public AudioFormatWriter { public: FlacWriter (OutputStream* out, double rate, uint32 numChans, uint32 bits, int qualityOptionIndex) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 00f31082..de7a76c3 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp @@ -28,7 +28,7 @@ namespace juce #if JUCE_USE_LAME_AUDIO_FORMAT -class LAMEEncoderAudioFormat::Writer : public AudioFormatWriter +class LAMEEncoderAudioFormat::Writer final : public AudioFormatWriter { public: Writer (OutputStream* destStream, const String& formatName, diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index d24df3df..9e782173 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -2954,7 +2954,7 @@ struct MP3Stream static const char* const mp3FormatName = "MP3 file"; //============================================================================== -class MP3Reader : public AudioFormatReader +class MP3Reader final : public AudioFormatReader { public: MP3Reader (InputStream* const in) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index fb133988..335777b1 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -109,7 +109,7 @@ const char* const OggVorbisAudioFormat::id3trackNumber = "id3trackNumber"; //============================================================================== -class OggReader : public AudioFormatReader +class OggReader final : public AudioFormatReader { public: OggReader (InputStream* inp) : AudioFormatReader (inp, oggFormatName) @@ -262,7 +262,7 @@ class OggReader : public AudioFormatReader }; //============================================================================== -class OggWriter : public AudioFormatWriter +class OggWriter final : public AudioFormatWriter { public: OggWriter (OutputStream* out, double rate, diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 0105a2c3..ff42cc13 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1204,7 +1204,7 @@ namespace WavFileHelpers } //============================================================================== -class WavAudioFormatReader : public AudioFormatReader +class WavAudioFormatReader final : public AudioFormatReader { public: WavAudioFormatReader (InputStream* in) : AudioFormatReader (in, wavFormatName) @@ -1579,7 +1579,7 @@ class WavAudioFormatReader : public AudioFormatReader }; //============================================================================== -class WavAudioFormatWriter : public AudioFormatWriter +class WavAudioFormatWriter final : public AudioFormatWriter { public: WavAudioFormatWriter (OutputStream* const out, const double rate, @@ -1843,7 +1843,7 @@ class WavAudioFormatWriter : public AudioFormatWriter }; //============================================================================== -class MemoryMappedWavReader : public MemoryMappedAudioFormatReader +class MemoryMappedWavReader final : public MemoryMappedAudioFormatReader { public: MemoryMappedWavReader (const File& wavFile, const WavAudioFormatReader& reader) @@ -2113,7 +2113,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai //============================================================================== #if JUCE_UNIT_TESTS -struct WaveAudioFormatTests : public UnitTest +struct WaveAudioFormatTests final : public UnitTest { WaveAudioFormatTests() : UnitTest ("Wave audio format tests", UnitTestCategories::audio) diff --git a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index cb7af04c..1f18d5e1 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -29,7 +29,7 @@ namespace juce namespace WindowsMediaCodec { -class JuceIStream : public ComBaseClassHelper +class JuceIStream final : public ComBaseClassHelper { public: JuceIStream (InputStream& in) noexcept @@ -127,7 +127,7 @@ static const char* wmFormatName = "Windows Media"; static const char* const extensions[] = { ".mp3", ".wmv", ".asf", ".wm", ".wma", nullptr }; //============================================================================== -class WMAudioReader : public AudioFormatReader +class WMAudioReader final : public AudioFormatReader { public: WMAudioReader (InputStream* const input_) diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_ARAAudioReaders.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_ARAAudioReaders.cpp index a285635e..25ea6bea 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_ARAAudioReaders.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_ARAAudioReaders.cpp @@ -74,19 +74,19 @@ void ARAAudioSourceReader::willUpdateAudioSourceProperties (ARAAudioSource* audi } } -void ARAAudioSourceReader::doUpdateAudioSourceContent (ARAAudioSource* audioSource, +void ARAAudioSourceReader::doUpdateAudioSourceContent ([[maybe_unused]] ARAAudioSource* audioSource, ARAContentUpdateScopes scopeFlags) { - jassertquiet (audioSourceBeingRead == audioSource); + jassert (audioSourceBeingRead == audioSource); // Don't invalidate if the audio signal is unchanged if (scopeFlags.affectSamples()) invalidate(); } -void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess (ARAAudioSource* audioSource, bool enable) +void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource, bool enable) { - jassertquiet (audioSourceBeingRead == audioSource); + jassert (audioSourceBeingRead == audioSource); // Invalidate our reader if sample access is disabled if (! enable) @@ -96,9 +96,9 @@ void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess (ARAAudioSource* a } } -void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess (ARAAudioSource* audioSource, bool enable) +void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource, bool enable) { - jassertquiet (audioSourceBeingRead == audioSource); + jassert (audioSourceBeingRead == audioSource); // Recreate our reader if sample access is enabled if (enable && isValid()) @@ -108,9 +108,9 @@ void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess (ARAAudioSource* au } } -void ARAAudioSourceReader::willDestroyAudioSource (ARAAudioSource* audioSource) +void ARAAudioSourceReader::willDestroyAudioSource ([[maybe_unused]] ARAAudioSource* audioSource) { - jassertquiet (audioSourceBeingRead == audioSource); + jassert (audioSourceBeingRead == audioSource); invalidate(); } @@ -290,19 +290,19 @@ void ARAPlaybackRegionReader::willUpdatePlaybackRegionProperties (ARAPlaybackReg } } -void ARAPlaybackRegionReader::didUpdatePlaybackRegionContent (ARAPlaybackRegion* playbackRegion, +void ARAPlaybackRegionReader::didUpdatePlaybackRegionContent ([[maybe_unused]] ARAPlaybackRegion* playbackRegion, ARAContentUpdateScopes scopeFlags) { - jassertquiet (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); + jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); // Invalidate if the audio signal is changed if (scopeFlags.affectSamples()) invalidate(); } -void ARAPlaybackRegionReader::willDestroyPlaybackRegion (ARAPlaybackRegion* playbackRegion) +void ARAPlaybackRegionReader::willDestroyPlaybackRegion ([[maybe_unused]] ARAPlaybackRegion* playbackRegion) { - jassertquiet (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); + jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); invalidate(); } diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index dfdba2e9..9ca241e6 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -35,7 +35,7 @@ AudioFormatWriter::AudioFormatWriter (OutputStream* const out, numChannels (numChannels_), bitsPerSample (bitsPerSample_), usesFloatingPointData (false), - channelLayout (AudioChannelSet::canonicalChannelSet(static_cast (numChannels_))), + channelLayout (AudioChannelSet::canonicalChannelSet (static_cast (numChannels_))), output (out), formatName (formatName_) { @@ -211,7 +211,7 @@ bool AudioFormatWriter::flush() } //============================================================================== -class AudioFormatWriter::ThreadedWriter::Buffer : private TimeSliceClient +class AudioFormatWriter::ThreadedWriter::Buffer final : private TimeSliceClient { public: Buffer (TimeSliceThread& tst, AudioFormatWriter* w, int channels, int numSamples) diff --git a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index 23018867..1e4f031c 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/JuceLibraryCode/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -185,7 +185,7 @@ static bool isSilent (const AudioBuffer& b) return true; } -struct TestAudioFormatReader : public AudioFormatReader +struct TestAudioFormatReader : public AudioFormatReader { explicit TestAudioFormatReader (const AudioBuffer* b) : AudioFormatReader (nullptr, {}), @@ -238,19 +238,19 @@ static AudioBuffer generateTestBuffer (Random& random, int bufferSize) return buffer; } -class BufferingAudioReaderTests : public UnitTest +class BufferingAudioReaderTests final : public UnitTest { public: BufferingAudioReaderTests() : UnitTest ("BufferingAudioReader", UnitTestCategories::audio) {} void runTest() override { - TimeSliceThread timeSlice ("TestBackgroundThread"); - timeSlice.startThread (Thread::Priority::normal); + TimeSliceThread thread ("TestBackgroundThread"); + thread.startThread (Thread::Priority::normal); - beginTest ("Timeout"); + beginTest ("Reading samples from a blocked reader should produce silence"); { - struct BlockingReader : public TestAudioFormatReader + struct BlockingReader final : public TestAudioFormatReader { explicit BlockingReader (const AudioBuffer* b) : TestAudioFormatReader (b) @@ -263,47 +263,50 @@ class BufferingAudioReaderTests : public UnitTest int64 startSampleInFile, int numSamples) override { - Thread::sleep (100); + unblock.wait(); return TestAudioFormatReader::readSamples (destChannels, numDestChannels, startOffsetInDestBuffer, startSampleInFile, numSamples); } + + WaitableEvent unblock; }; Random random { getRandom() }; + constexpr auto bufferSize = 1024; - const auto blockingBuffer = generateTestBuffer (random, 1024); - expect (! isSilent (blockingBuffer)); + const auto source = generateTestBuffer (random, bufferSize); + expect (! isSilent (source)); - BufferingAudioReader bufferingReader (new BlockingReader (&blockingBuffer), timeSlice, 64); - bufferingReader.setReadTimeout (10); + auto* blockingReader = new BlockingReader (&source); + BufferingAudioReader reader (blockingReader, thread, bufferSize); - const auto originalBuffer = generateTestBuffer (random, 1024); - expect (! isSilent (originalBuffer)); - expect (originalBuffer != blockingBuffer); + auto destination = generateTestBuffer (random, bufferSize); + expect (! isSilent (destination)); - auto readBuffer = originalBuffer; - expect (readBuffer == originalBuffer); + read (reader, destination); + expect (isSilent (destination)); - read (bufferingReader, readBuffer); - expect (readBuffer != originalBuffer); - expect (isSilent (readBuffer)); + blockingReader->unblock.signal(); } - beginTest ("Read samples"); + beginTest ("Reading samples from a reader should produce the same samples as its source"); { Random random { getRandom() }; for (auto i = 4; i < 18; ++i) { - const auto backgroundBufferSize = 1 << i; - const auto buffer = generateTestBuffer (random, backgroundBufferSize); + const auto bufferSize = 1 << i; + const auto source = generateTestBuffer (random, bufferSize); + expect (! isSilent (source)); - BufferingAudioReader bufferingReader (new TestAudioFormatReader (&buffer), timeSlice, backgroundBufferSize); - bufferingReader.setReadTimeout (-1); + BufferingAudioReader reader (new TestAudioFormatReader (&source), thread, bufferSize); + reader.setReadTimeout (-1); - AudioBuffer readBuffer { buffer.getNumChannels(), buffer.getNumSamples() }; - read (bufferingReader, readBuffer); + auto destination = generateTestBuffer (random, bufferSize); + expect (! isSilent (destination)); + expect (source != destination); - expect (buffer == readBuffer); + read (reader, destination); + expect (source == destination); } } } diff --git a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h index fd4e5431..91eab08a 100644 --- a/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h +++ b/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h @@ -35,7 +35,7 @@ ID: juce_audio_formats vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE audio file format codecs description: Classes for reading and writing various audio file formats. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 75fce26a..bf9c9cf7 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp @@ -68,7 +68,7 @@ std::unique_ptr AudioPluginFormat::createInstanceFromDescri return instance; } -struct AudioPluginFormat::AsyncCreateMessage : public Message +struct AudioPluginFormat::AsyncCreateMessage final : public Message { AsyncCreateMessage (const PluginDescription& d, double sr, int size, PluginCreationCallback call) : desc (d), sampleRate (sr), bufferSize (size), callbackToUse (std::move (call)) diff --git a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index 3e5c029b..a1418601 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -159,7 +159,7 @@ void AudioPluginFormatManager::createPluginInstanceAsync (const PluginDescriptio if (auto* format = findFormatForDescription (description, error)) return format->createPluginInstanceAsync (description, initialSampleRate, initialBufferSize, std::move (callback)); - struct DeliverError : public CallbackMessage + struct DeliverError final : public CallbackMessage { DeliverError (AudioPluginFormat::PluginCreationCallback c, const String& e) : call (std::move (c)), error (e) diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/public.sdk/source/common/pluginview.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/public.sdk/source/common/pluginview.cpp index 02dd9fd2..0b42b5ee 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/public.sdk/source/common/pluginview.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/public.sdk/source/common/pluginview.cpp @@ -51,6 +51,7 @@ CPluginView::CPluginView (const ViewRect* _rect) //------------------------------------------------------------------------ CPluginView::~CPluginView () { + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) setFrame (nullptr); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_ARAHosting.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_ARAHosting.cpp index 46204dea..2d959d3a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_ARAHosting.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_ARAHosting.cpp @@ -340,7 +340,7 @@ class ARAHostDocumentController::Impl using Vst3Fn = decltype (vst3Fn); using AuFn = decltype (auFn); - struct Visitor : ExtensionsVisitor, Vst3Fn, AuFn + struct Visitor final : public ExtensionsVisitor, Vst3Fn, AuFn { explicit Visitor (Vst3Fn vst3Fn, AuFn auFn) : Vst3Fn (std::move (vst3Fn)), AuFn (std::move (auFn)) {} void visitVST3Client (const VST3Client& x) override { Vst3Fn::operator() (x); } @@ -458,7 +458,7 @@ void createARAFactoryAsync (AudioPluginInstance& instance, std::function callbackIn) : callback (std::move (callbackIn)) @@ -472,7 +472,7 @@ void createARAFactoryAsync (AudioPluginInstance& instance, std::function callback; }; - Extensions extensions { std::move(cb) }; + Extensions extensions { std::move (cb) }; instance.getExtensions (extensions); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 6540a882..b7bba1e5 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -200,7 +200,7 @@ static bool getComponentDescFromFile ([[maybe_unused]] const String& fileOrIdent { if (auto bundleRef = CFUniquePtr (CFBundleCreate (kCFAllocatorDefault, url.get()))) { - CFTypeRef bundleName = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR("CFBundleName")); + CFTypeRef bundleName = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR ("CFBundleName")); if (bundleName != nullptr && CFGetTypeID (bundleName) == CFStringGetTypeID()) name = String::fromCFString ((CFStringRef) bundleName); @@ -208,12 +208,12 @@ static bool getComponentDescFromFile ([[maybe_unused]] const String& fileOrIdent if (name.isEmpty()) name = file.getFileNameWithoutExtension(); - CFTypeRef versionString = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR("CFBundleVersion")); + CFTypeRef versionString = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR ("CFBundleVersion")); if (versionString != nullptr && CFGetTypeID (versionString) == CFStringGetTypeID()) version = String::fromCFString ((CFStringRef) versionString); - CFTypeRef manuString = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR("CFBundleGetInfoString")); + CFTypeRef manuString = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR ("CFBundleGetInfoString")); if (manuString != nullptr && CFGetTypeID (manuString) == CFStringGetTypeID()) manufacturer = String::fromCFString ((CFStringRef) manuString); @@ -332,8 +332,8 @@ bool isValid() const noexcept using ViewComponentBaseClass = NSViewComponent; #endif - struct AutoResizingNSViewComponent : public ViewComponentBaseClass, - private AsyncUpdater + struct AutoResizingNSViewComponent final : public ViewComponentBaseClass, + private AsyncUpdater { void childBoundsChanged (Component*) override { triggerAsyncUpdate(); } void handleAsyncUpdate() override { resizeToFitView(); } @@ -675,7 +675,7 @@ String getText (float value, int maximumLength) const override { if (! auValueStrings.isEmpty()) { - auto index = roundToInt (jlimit (0.0f, 1.0f, value) * (auValueStrings.size() - 1)); + auto index = roundToInt (jlimit (0.0f, 1.0f, value) * (float) (auValueStrings.size() - 1)); return auValueStrings[index]; } @@ -714,7 +714,7 @@ float getValueForText (const String& text) const override auto index = auValueStrings.indexOf (text); if (index != -1) - return ((float) index) / (auValueStrings.size() - 1); + return ((float) index) / (float) (auValueStrings.size() - 1); } if (valuesHaveStrings) @@ -838,7 +838,7 @@ float scaleParamValue (float normalisedValue) const noexcept if (audioUnit != nullptr) { - struct AUDeleter : public CallbackMessage + struct AUDeleter final : public CallbackMessage { AUDeleter (AudioUnitPluginInstance& inInstance, WaitableEvent& inEvent) : auInstance (inInstance), completionSignal (inEvent) @@ -1001,12 +1001,11 @@ bool syncBusLayouts (const BusesLayout& layouts, bool isInitialized, bool& layou if (getElementCount (scope) != n && isBusCountWritable (isInput)) { - OSStatus err; auto newCount = static_cast (n); layoutHasChanged = true; - err = AudioUnitSetProperty (audioUnit, kAudioUnitProperty_ElementCount, scope, 0, &newCount, sizeof (newCount)); - jassertquiet (err == noErr); + [[maybe_unused]] auto err = AudioUnitSetProperty (audioUnit, kAudioUnitProperty_ElementCount, scope, 0, &newCount, sizeof (newCount)); + jassert (err == noErr); } for (int i = 0; i < n; ++i) @@ -1166,7 +1165,7 @@ void fillInPluginDescription (PluginDescription& desc) const override void getExtensions (ExtensionsVisitor& visitor) const override { - struct Extensions : public ExtensionsVisitor::AudioUnitClient + struct Extensions final : public ExtensionsVisitor::AudioUnitClient { explicit Extensions (const AudioUnitPluginInstance* instanceIn) : instance (instanceIn) {} @@ -1178,7 +1177,7 @@ explicit Extensions (const AudioUnitPluginInstance* instanceIn) : instance (inst visitor.visitAudioUnitClient (Extensions { this }); #ifdef JUCE_PLUGINHOST_ARA - struct ARAExtensions : public ExtensionsVisitor::ARAClient + struct ARAExtensions final : public ExtensionsVisitor::ARAClient { explicit ARAExtensions (const AudioUnitPluginInstance* instanceIn) : instance (instanceIn) {} @@ -1604,7 +1603,7 @@ const String getProgramName (int index) override { AUPreset current; current.presetNumber = -1; - current.presetName = CFSTR(""); + current.presetName = CFSTR (""); UInt32 prstsz = sizeof (AUPreset); @@ -1938,7 +1937,7 @@ float getValueForText (const String& text) const override float getDefaultValue() const override { return 0.0f; } String getName (int /*maximumStringLength*/) const override { return "Bypass"; } - String getText (float value, int) const override { return (value != 0.0f ? TRANS("On") : TRANS("Off")); } + String getText (float value, int) const override { return (value != 0.0f ? TRANS ("On") : TRANS ("Off")); } bool isAutomatable() const override { return true; } bool isDiscrete() const override { return true; } bool isBoolean() const override { return true; } @@ -1949,9 +1948,9 @@ float getValueForText (const String& text) const override String getParameterID() const override { return {}; } AudioUnitPluginInstance& parent; - const StringArray auOnStrings { TRANS("on"), TRANS("yes"), TRANS("true") }; - const StringArray auOffStrings { TRANS("off"), TRANS("no"), TRANS("false") }; - const StringArray values { TRANS("Off"), TRANS("On") }; + const StringArray auOnStrings { TRANS ("on"), TRANS ("yes"), TRANS ("true") }; + const StringArray auOffStrings { TRANS ("off"), TRANS ("no"), TRANS ("false") }; + const StringArray values { TRANS ("Off"), TRANS ("On") }; bool currentValue = false; }; @@ -2299,8 +2298,8 @@ OSStatus getMusicalTimeLocation (UInt32* outDeltaSampleOffsetToNextBeat, Float32 setIfNotNull (outCurrentMeasureDownBeat, getFromPlayHead (&AudioPlayHead::PositionInfo::getPpqPositionOfLastBarStart).orFallback (0.0)); const auto signature = getFromPlayHead (&AudioPlayHead::PositionInfo::getTimeSignature).orFallback (AudioPlayHead::TimeSignature{}); - setIfNotNull (outTimeSig_Numerator, (UInt32) signature.numerator); - setIfNotNull (outTimeSig_Denominator, (UInt32) signature.denominator); + setIfNotNull (outTimeSig_Numerator, (Float32) signature.numerator); + setIfNotNull (outTimeSig_Denominator, (UInt32) signature.denominator); return noErr; } @@ -2312,7 +2311,7 @@ OSStatus getTransportState (Boolean* outIsPlaying, Boolean* outTransportStateCha const auto nowPlaying = getFromPlayHead (&AudioPlayHead::PositionInfo::getIsPlaying); setIfNotNull (outIsPlaying, nowPlaying); setIfNotNull (outTransportStateChanged, std::exchange (wasPlaying, nowPlaying) != nowPlaying); - setIfNotNull (outCurrentSampleInTimeLine, getFromPlayHead (&AudioPlayHead::PositionInfo::getTimeInSamples).orFallback (0)); + setIfNotNull (outCurrentSampleInTimeLine, (double) getFromPlayHead (&AudioPlayHead::PositionInfo::getTimeInSamples).orFallback (0)); setIfNotNull (outIsCycling, getFromPlayHead (&AudioPlayHead::PositionInfo::getIsLooping)); const auto loopPoints = getFromPlayHead (&AudioPlayHead::PositionInfo::getLoopPoints).orFallback (AudioPlayHead::LoopPoints{}); @@ -2582,7 +2581,7 @@ void updateBypass (bool processBlockBypassedCalled) }; //============================================================================== -class AudioUnitPluginWindowCocoa : public AudioProcessorEditor +class AudioUnitPluginWindowCocoa final : public AudioProcessorEditor { public: AudioUnitPluginWindowCocoa (AudioUnitPluginInstance& p, bool createGenericViewIfNeeded) @@ -2748,7 +2747,7 @@ void requestViewControllerCallback (AUViewControllerBase* controller) if (! MessageManager::getInstance()->isThisTheMessageThread()) { - struct AsyncViewControllerCallback : public CallbackMessage + struct AsyncViewControllerCallback final : public CallbackMessage { AudioUnitPluginWindowCocoa* owner; JUCE_IOS_MAC_VIEW* controllerView; diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 275f2be8..7da21ed1 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -42,7 +42,7 @@ static int insideLADSPACallback = 0; #endif //============================================================================== -class LADSPAModuleHandle : public ReferenceCountedObject +class LADSPAModuleHandle final : public ReferenceCountedObject { public: LADSPAModuleHandle (const File& f) @@ -69,7 +69,7 @@ class LADSPAModuleHandle : public ReferenceCountedObject { for (auto i = getActiveModules().size(); --i >= 0;) { - auto* module = getActiveModules().getUnchecked(i); + auto* module = getActiveModules().getUnchecked (i); if (module->file == file) return module; @@ -157,8 +157,8 @@ class LADSPAPluginInstance final : public AudioPluginInstance jassert (insideLADSPACallback == 0); - if (handle != nullptr && plugin != nullptr && plugin->cleanup != nullptr) - plugin->cleanup (handle); + if (handle != nullptr && plugin != nullptr) + NullCheckedInvocation::invoke (plugin->cleanup, handle); initialised = false; module = nullptr; @@ -209,8 +209,8 @@ class LADSPAPluginInstance final : public AudioPluginInstance setLatencySamples (0); // Some plugins crash if this doesn't happen: - if (plugin->activate != nullptr) plugin->activate (handle); - if (plugin->deactivate != nullptr) plugin->deactivate (handle); + NullCheckedInvocation::invoke (plugin->activate, handle); + NullCheckedInvocation::invoke (plugin->deactivate, handle); } //============================================================================== @@ -275,15 +275,14 @@ class LADSPAPluginInstance final : public AudioPluginInstance firstParam->setValue (old); } - if (plugin->activate != nullptr) - plugin->activate (handle); + NullCheckedInvocation::invoke (plugin->activate, handle); } } void releaseResources() override { if (handle != nullptr && plugin->deactivate != nullptr) - plugin->deactivate (handle); + NullCheckedInvocation::invoke (plugin->deactivate, handle); tempBuffer.setSize (1, 1); } @@ -301,7 +300,7 @@ class LADSPAPluginInstance final : public AudioPluginInstance if (plugin->run != nullptr) { for (int i = 0; i < outputs.size(); ++i) - plugin->connect_port (handle, (size_t) outputs.getUnchecked(i), + plugin->connect_port (handle, (size_t) outputs.getUnchecked (i), i < buffer.getNumChannels() ? buffer.getWritePointer (i) : nullptr); plugin->run (handle, (size_t) numSamples); @@ -314,7 +313,7 @@ class LADSPAPluginInstance final : public AudioPluginInstance tempBuffer.clear(); for (int i = 0; i < outputs.size(); ++i) - plugin->connect_port (handle, (size_t) outputs.getUnchecked(i), tempBuffer.getWritePointer (i)); + plugin->connect_port (handle, (size_t) outputs.getUnchecked (i), tempBuffer.getWritePointer (i)); plugin->run_adding (handle, (size_t) numSamples); diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Common.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Common.h index 92a5a987..7180bbf3 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Common.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Common.h @@ -74,9 +74,7 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE #include #include -namespace juce -{ -namespace lv2_shared +namespace juce::lv2_shared { class AtomForge @@ -664,7 +662,6 @@ static inline String sanitiseStringAsTtlName (const String& input) return String (CharPointer_UTF32 { sanitised.data() }, sanitised.size()); } -} -} +} // namespace juce::lv2_shared #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat.cpp index b4f35881..d0710fdd 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat.cpp @@ -739,10 +739,11 @@ class Log LV2_Log_Log* getLogFeature() { return &logFeature; } private: - int vprintfCallback (LV2_URID type, const char* fmt, va_list ap) const + int vprintfCallback ([[maybe_unused]] LV2_URID type, const char* fmt, va_list ap) const { // If this is hit, the plugin has encountered some kind of error - jassertquiet (type != urids->mLV2_LOG__Error && type != urids->mLV2_LOG__Warning); + ignoreUnused (urids); + jassert (type != urids->mLV2_LOG__Error && type != urids->mLV2_LOG__Warning); return std::vfprintf (stderr, fmt, ap); } @@ -1086,7 +1087,7 @@ class HandleRegistry returns garbage, so make sure to check that the plugin `hasExtensionData` before constructing one of these! */ -class SharedThreadedWorker : public WorkerResponseListener +class SharedThreadedWorker final : public WorkerResponseListener { public: ~SharedThreadedWorker() noexcept override @@ -1382,7 +1383,7 @@ struct MessageBufferInterface }; template -class Messages : public MessageBufferInterface
+class Messages final : public MessageBufferInterface
{ using Read = typename LockTraits::Read; using Write = typename LockTraits::Write; @@ -1437,7 +1438,7 @@ class Messages : public MessageBufferInterface
}; //============================================================================== -class LambdaTimer : private Timer +class LambdaTimer final : private Timer { public: explicit LambdaTimer (std::function c) : callback (c) {} @@ -1465,7 +1466,7 @@ struct UiMessageHeader MessageHeader header; }; -class ProcessorToUi : public MessageBufferInterface +class ProcessorToUi final : public MessageBufferInterface { public: ProcessorToUi() { timer.startTimerHz (60); } @@ -1987,8 +1988,8 @@ class Ports std::vector atomPorts; }; -class InstanceWithSupports : private FeaturesDataListener, - private HandleHolder +class InstanceWithSupports final : private FeaturesDataListener, + private HandleHolder { public: InstanceWithSupports (World& world, @@ -2118,9 +2119,9 @@ class PortMap private: template - static float getValueFrom (const void* data, uint32_t size) + static float getValueFrom (const void* data, [[maybe_unused]] uint32_t size) { - jassertquiet (size == sizeof (Value)); + jassert (size == sizeof (Value)); return (float) readUnaligned (data); } @@ -2422,7 +2423,7 @@ class ParameterValuesAndFlags JUCE_LEAK_DETECTOR (ParameterValuesAndFlags) }; -class LV2Parameter : public AudioPluginInstance::HostedParameter +class LV2Parameter : public AudioPluginInstance::HostedParameter { public: LV2Parameter (const String& nameIn, @@ -2739,7 +2740,7 @@ struct TouchListener virtual void controlGrabbed (uint32_t port, bool grabbed) = 0; }; -class AsyncFn : public AsyncUpdater +class AsyncFn final : public AsyncUpdater { public: explicit AsyncFn (std::function callbackIn) @@ -2975,7 +2976,7 @@ static bool noneOf (Range&& range, Predicate&& pred) return std::none_of (begin (range), end (range), std::forward (pred)); } -class PeerChangedListener : private ComponentMovementWatcher +class PeerChangedListener final : private ComponentMovementWatcher { public: PeerChangedListener (Component& c, std::function peerChangedIn) @@ -2994,7 +2995,7 @@ class PeerChangedListener : private ComponentMovementWatcher std::function peerChanged; }; -struct ViewSizeListener : private ComponentMovementWatcher +struct ViewSizeListener final : private ComponentMovementWatcher { ViewSizeListener (Component& c, PhysicalResizeListener& l) : ComponentMovementWatcher (&c), listener (l) @@ -3024,8 +3025,8 @@ struct ViewSizeListener : private ComponentMovementWatcher PhysicalResizeListener& listener; }; -class ConfiguredEditorComponent : public Component, - private PhysicalResizeListener +class ConfiguredEditorComponent final : public Component, + private PhysicalResizeListener { public: ConfiguredEditorComponent (World& world, @@ -3181,7 +3182,7 @@ class ConfiguredEditorComponent : public Component, #if JUCE_LINUX || JUCE_BSD struct InnerHolder { - struct Inner : public XEmbedComponent + struct Inner final : public XEmbedComponent { Inner() : XEmbedComponent (true, true) { @@ -3193,8 +3194,8 @@ class ConfiguredEditorComponent : public Component, Inner inner; }; - struct ViewComponent : public InnerHolder, - public XEmbedComponent + struct ViewComponent final : public InnerHolder, + public XEmbedComponent { explicit ViewComponent (PhysicalResizeListener& l) : XEmbedComponent ((unsigned long) inner.getPeer()->getNativeHandle(), true, false), @@ -3220,7 +3221,7 @@ class ConfiguredEditorComponent : public Component, ViewSizeListener listener; }; #elif JUCE_MAC - struct ViewComponent : public NSViewComponentWithParent + struct ViewComponent final : public NSViewComponentWithParent { explicit ViewComponent (PhysicalResizeListener&) : NSViewComponentWithParent (WantsNudge::no) {} @@ -3230,7 +3231,7 @@ class ConfiguredEditorComponent : public Component, void prepareForDestruction() {} }; #elif JUCE_WINDOWS - struct ViewComponent : public HWNDComponent + struct ViewComponent final : public HWNDComponent { explicit ViewComponent (PhysicalResizeListener&) { @@ -3251,7 +3252,7 @@ class ConfiguredEditorComponent : public Component, void prepareForDestruction() {} private: - struct Inner : public Component + struct Inner final : public Component { Inner() { setOpaque (true); } void paint (Graphics& g) override { g.fillAll (Colours::black); } @@ -3260,7 +3261,7 @@ class ConfiguredEditorComponent : public Component, Inner inner; }; #else - struct ViewComponent : public Component + struct ViewComponent final : public Component { explicit ViewComponent (PhysicalResizeListener&) {} void* getWidget() { return nullptr; } @@ -3338,9 +3339,9 @@ struct InstanceProvider virtual InstanceWithSupports* getInstanceWithSupports() const = 0; }; -class Editor : public AudioProcessorEditor, - public UiEventListener, - private LogicalResizeListener +class Editor final : public AudioProcessorEditor, + public UiEventListener, + private LogicalResizeListener { public: Editor (World& worldIn, @@ -3784,7 +3785,7 @@ class IntermediateParameterTree JUCE_LEAK_DETECTOR (IntermediateParameterTree) }; -struct BypassParameter : public LV2Parameter +struct BypassParameter final : public LV2Parameter { BypassParameter (const ParameterInfo& parameterInfo, ParameterValuesAndFlags& cacheIn) : LV2Parameter ("Bypass", parameterInfo, cacheIn) {} @@ -4335,11 +4336,11 @@ class OptionalEditor void createView() {} void destroyView() {} - std::unique_ptr createEditor(World&, - AudioPluginInstance&, - InstanceProvider&, - TouchListener&, - EditorListener&) + std::unique_ptr createEditor (World&, + AudioPluginInstance&, + InstanceProvider&, + TouchListener&, + EditorListener&) { return nullptr; } @@ -4349,10 +4350,10 @@ class OptionalEditor }; //============================================================================== -class LV2AudioPluginInstance : public AudioPluginInstance, - private TouchListener, - private EditorListener, - private InstanceProvider +class LV2AudioPluginInstance final : public AudioPluginInstance, + private TouchListener, + private EditorListener, + private InstanceProvider { public: LV2AudioPluginInstance (std::shared_ptr worldIn, @@ -5174,7 +5175,7 @@ class LV2AudioPluginInstance : public AudioPluginInstance, JUCE_LEAK_DETECTOR (LV2AudioPluginInstance) }; -} // namespace lv2 +} // namespace lv2_host //============================================================================== class LV2PluginFormat::Pimpl diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat_test.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat_test.cpp index 3264b381..33f3106e 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat_test.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2PluginFormat_test.cpp @@ -28,7 +28,7 @@ namespace juce { -class LV2PluginFormatTests : public UnitTest +class LV2PluginFormatTests final : public UnitTest { public: LV2PluginFormatTests() diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Resources.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Resources.h index 0ff36da9..435aa2ae 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Resources.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LV2Resources.h @@ -33,9 +33,7 @@ #include -namespace juce -{ -namespace lv2 +namespace juce::lv2 { struct BundleResource @@ -52,8 +50,7 @@ struct Bundle static std::vector getAllBundles(); }; -} -} +} // namespace juce::lv2 std::vector juce::lv2::Bundle::getAllBundles() { diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp index a65a0d59..4cf81f02 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp @@ -29,7 +29,7 @@ namespace juce JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996) -class LegacyAudioParameter : public HostedAudioProcessorParameter +class LegacyAudioParameter final : public HostedAudioProcessorParameter { public: LegacyAudioParameter (AudioProcessor& audioProcessorToUse, int audioParameterIndex) diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3Common.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3Common.h index 9043a0d7..879bcab1 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -100,8 +100,8 @@ class InterfaceResultWithDeferredAddRef { const auto toReturn = result.extract (obj); - if (result.isOk() && addRefFn != nullptr && *obj != nullptr) - addRefFn (*obj); + if (result.isOk() && *obj != nullptr) + NullCheckedInvocation::invoke (addRefFn, *obj); return toReturn; } @@ -1166,31 +1166,35 @@ class HostBufferMapper }; //============================================================================== +// We have to trust that Steinberg won't double-delete +// NOLINTBEGIN(clang-analyzer-cplusplus.NewDelete) template class VSTComSmartPtr { public: - VSTComSmartPtr() noexcept : source (nullptr) {} - VSTComSmartPtr (ObjectType* object, bool autoAddRef = true) noexcept : source (object) { if (source != nullptr && autoAddRef) source->addRef(); } + VSTComSmartPtr() = default; VSTComSmartPtr (const VSTComSmartPtr& other) noexcept : source (other.source) { if (source != nullptr) source->addRef(); } ~VSTComSmartPtr() { if (source != nullptr) source->release(); } - operator ObjectType*() const noexcept { return source; } - ObjectType* get() const noexcept { return source; } - ObjectType& operator*() const noexcept { return *source; } - ObjectType* operator->() const noexcept { return source; } + explicit operator bool() const noexcept { return operator!= (nullptr); } + ObjectType* get() const noexcept { return source; } + ObjectType& operator*() const noexcept { return *source; } + ObjectType* operator->() const noexcept { return source; } - VSTComSmartPtr& operator= (const VSTComSmartPtr& other) { return operator= (other.source); } - - VSTComSmartPtr& operator= (ObjectType* const newObjectToTakePossessionOf) + VSTComSmartPtr& operator= (const VSTComSmartPtr& other) { - VSTComSmartPtr p (newObjectToTakePossessionOf); + auto p = other; std::swap (p.source, source); return *this; } - bool operator== (ObjectType* const other) noexcept { return source == other; } - bool operator!= (ObjectType* const other) noexcept { return source != other; } + VSTComSmartPtr& operator= (std::nullptr_t) + { + return operator= (VSTComSmartPtr{}); + } + + bool operator== (std::nullptr_t) const noexcept { return source == nullptr; } + bool operator!= (std::nullptr_t) const noexcept { return source != nullptr; } bool loadFrom (Steinberg::FUnknown* o) { @@ -1205,10 +1209,39 @@ class VSTComSmartPtr return factory->createInstance (uuid, ObjectType::iid, (void**) &source) == Steinberg::kResultOk; } + /** Increments refcount. */ + static auto addOwner (ObjectType* t) + { + return VSTComSmartPtr (t, true); + } + + /** Does not initially increment refcount; assumes t has a positive refcount. */ + static auto becomeOwner (ObjectType* t) + { + return VSTComSmartPtr (t, false); + } + private: - ObjectType* source; + explicit VSTComSmartPtr (ObjectType* object, bool autoAddRef) noexcept : source (object) { if (source != nullptr && autoAddRef) source->addRef(); } + ObjectType* source = nullptr; }; +/** Increments refcount. */ +template +auto addVSTComSmartPtrOwner (ObjectType* t) +{ + return VSTComSmartPtr::addOwner (t); +} + +/** Does not initially increment refcount; assumes t has a positive refcount. */ +template +auto becomeVSTComSmartPtrOwner (ObjectType* t) +{ + return VSTComSmartPtr::becomeOwner (t); +} + +// NOLINTEND(clang-analyzer-cplusplus.NewDelete) + //============================================================================== /* This class stores a plugin's preferred MIDI mappings. diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index e049cc9d..f253ca0b 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -119,7 +119,7 @@ static std::vector getAllParamIDs (Vst::IEditController& controlle /* Allows parameter updates to be queued up without blocking, and automatically dispatches these updates on the main thread. */ -class EditControllerParameterDispatcher : private Timer +class EditControllerParameterDispatcher final : private Timer { public: ~EditControllerParameterDispatcher() override { stopTimer(); } @@ -216,12 +216,13 @@ static std::vector createPluginDescriptions (const File& plug description.lastFileModTime = pluginFile.getLastModificationTime(); description.lastInfoUpdateTime = Time::getCurrentTime(); description.manufacturerName = CharPointer_UTF8 (info.factoryInfo.vendor.c_str()); - description.name = CharPointer_UTF8 (info.name.c_str()); - description.descriptiveName = CharPointer_UTF8 (info.name.c_str()); + description.name = CharPointer_UTF8 (c.name.c_str()); + description.descriptiveName = CharPointer_UTF8 (c.name.c_str()); description.pluginFormatName = "VST3"; description.numInputChannels = 0; description.numOutputChannels = 0; description.hasARAExtension = araMainFactoryClassNames.find (description.name) != araMainFactoryClassNames.end(); + description.version = CharPointer_UTF8 (c.version.c_str()); const auto uid = VST3::UID::fromString (c.cid); @@ -401,13 +402,13 @@ static void toProcessContext (Vst::ProcessContext& context, //============================================================================== class VST3PluginInstance; -struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 - public Vst::IComponentHandler2, // From VST V3.1.0 (a very well named class, of course!) - public Vst::IComponentHandler3, // From VST V3.5.0 (also very well named!) - public Vst::IContextMenuTarget, - public Vst::IHostApplication, - public Vst::IUnitHandler, - private ComponentRestarter::Listener +struct VST3HostContext final : public Vst::IComponentHandler, // From VST V3.0.0 + public Vst::IComponentHandler2, // From VST V3.1.0 (a very well named class, of course!) + public Vst::IComponentHandler3, // From VST V3.5.0 (also very well named!) + public Vst::IContextMenuTarget, + public Vst::IHostApplication, + public Vst::IUnitHandler, + private ComponentRestarter::Listener { VST3HostContext() { @@ -459,7 +460,7 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 } //============================================================================== - struct ContextMenu : public Vst::IContextMenu + struct ContextMenu final : public Vst::IContextMenu { ContextMenu (VST3PluginInstance& pluginInstance) : owner (pluginInstance) {} virtual ~ContextMenu() {} @@ -475,7 +476,7 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 ItemAndTarget newItem; newItem.item = item; - newItem.target = target; + newItem.target = addVSTComSmartPtrOwner (target); items.add (newItem); return kResultOk; @@ -485,9 +486,9 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 { for (int i = items.size(); --i >= 0;) { - auto& item = items.getReference(i); + auto& item = items.getReference (i); - if (item.item.tag == toRemove.tag && item.target == target) + if (item.item.tag == toRemove.tag && item.target.get() == target) items.remove (i); } @@ -498,14 +499,14 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 { for (int i = 0; i < items.size(); ++i) { - auto& item = items.getReference(i); + auto& item = items.getReference (i); if (item.item.tag == tag) { result = item.item; if (target != nullptr) - *target = item.target; + *target = item.target.get(); return kResultTrue; } @@ -545,7 +546,7 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 for (int i = 0; i < items.size(); ++i) { - auto& item = items.getReference(i); + auto& item = items.getReference (i); if ((int) item.item.tag == result) { @@ -562,10 +563,12 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 Vst::IContextMenu* PLUGIN_API createContextMenu (IPlugView*, const Vst::ParamID*) override { - if (plugin != nullptr) - return new ContextMenu (*plugin); + if (plugin == nullptr) + return nullptr; - return nullptr; + auto* result = new ContextMenu (*plugin); + result->addRef(); + return result; } tresult PLUGIN_API executeMenuItem (Steinberg::int32) override @@ -759,7 +762,7 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 }; //============================================================================== - class AttributeList : public Vst::IAttributeList + class AttributeList final : public Vst::IAttributeList { public: AttributeList() = default; @@ -847,7 +850,7 @@ struct VST3HostContext : public Vst::IComponentHandler, // From VST V3.0.0 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AttributeList) }; - struct Message : public Vst::IMessage + struct Message final : public Vst::IMessage { Message() = default; virtual ~Message() = default; @@ -975,8 +978,8 @@ struct DescriptionLister { if (component->initialize (host.getFUnknown()) == kResultOk) { - auto numInputs = getNumSingleDirectionChannelsFor (component, Direction::input); - auto numOutputs = getNumSingleDirectionChannelsFor (component, Direction::output); + auto numInputs = getNumSingleDirectionChannelsFor (component.get(), Direction::input); + auto numOutputs = getNumSingleDirectionChannelsFor (component.get(), Direction::output); createPluginDescription (desc, file, companyName, name, info, info2.get(), infoW.get(), numInputs, numOutputs); @@ -1023,7 +1026,7 @@ struct DLLHandle if (factory != nullptr) factory->release(); - using ExitModuleFn = bool (PLUGIN_API*) (); + using ExitModuleFn = bool (PLUGIN_API*)(); if (auto* exitFn = (ExitModuleFn) getFunction (exitFnName)) exitFn(); @@ -1076,7 +1079,7 @@ struct DLLHandle static constexpr const char* entryFnName = "InitDll"; static constexpr const char* exitFnName = "ExitDll"; - using EntryProc = bool (PLUGIN_API*) (); + using EntryProc = bool (PLUGIN_API*)(); #elif JUCE_LINUX || JUCE_BSD static constexpr const char* entryFnName = "ModuleEntry"; static constexpr const char* exitFnName = "ModuleExit"; @@ -1156,7 +1159,7 @@ struct DLLHandle JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DLLHandle) }; -struct DLLHandleCache : public DeletedAtShutdown +struct DLLHandleCache final : public DeletedAtShutdown { DLLHandleCache() = default; ~DLLHandleCache() override { clearSingletonInstance(); } @@ -1312,7 +1315,7 @@ class RunLoop final : public Steinberg::Linux::IRunLoop private: //============================================================================== - struct TimerCaller : private Timer + struct TimerCaller final : private Timer { TimerCaller (Linux::ITimerHandler* h, int interval) : handler (h) { startTimer (interval); } ~TimerCaller() override { stopTimer(); } @@ -1335,7 +1338,7 @@ class RunLoop final : public Steinberg::Linux::IRunLoop #endif //============================================================================== -struct VST3ModuleHandle : public ReferenceCountedObject +struct VST3ModuleHandle final : public ReferenceCountedObject { explicit VST3ModuleHandle (const File& pluginFile, const PluginDescription& pluginDesc) : file (pluginFile) @@ -1394,8 +1397,7 @@ struct VST3ModuleHandle : public ReferenceCountedObject //============================================================================== bool open (const PluginDescription& description) { - VSTComSmartPtr pluginFactory (DLLHandleCache::getInstance()->findOrCreateHandle (file.getFullPathName()) - .getPluginFactory()); + auto pluginFactory = addVSTComSmartPtrOwner (DLLHandleCache::getInstance()->findOrCreateHandle (file.getFullPathName()).getPluginFactory()); if (pluginFactory != nullptr) { @@ -1501,10 +1503,10 @@ struct VST3PluginWindow final : public AudioProcessorEditor, private ComponentBoundsConstrainer, private IPlugFrame { - VST3PluginWindow (AudioPluginInstance* owner, IPlugView* pluginView) + VST3PluginWindow (AudioPluginInstance* owner, VSTComSmartPtr pluginView) : AudioProcessorEditor (owner), ComponentMovementWatcher (this), - view (pluginView, false) + view (pluginView) #if JUCE_MAC , embeddedComponent (*owner) #endif @@ -1670,7 +1672,7 @@ struct VST3PluginWindow final : public AudioProcessorEditor, { const ScopedValueSetter recursiveResizeSetter (recursiveResize, true); - if (incomingView != nullptr && newSize != nullptr && incomingView == view) + if (incomingView != nullptr && newSize != nullptr && incomingView == view.get()) { const auto oldPhysicalSize = componentToVST3Rect (getLocalBounds()); const auto logicalSize = vst3ToComponentRect (*newSize); @@ -1783,7 +1785,7 @@ struct VST3PluginWindow final : public AudioProcessorEditor, #if JUCE_WINDOWS using HandleFormat = HWND; - struct ViewComponent : public HWNDComponent + struct ViewComponent final : public HWNDComponent { ViewComponent() { @@ -1797,7 +1799,7 @@ struct VST3PluginWindow final : public AudioProcessorEditor, void paint (Graphics& g) override { g.fillAll (Colours::black); } private: - struct Inner : public Component + struct Inner final : public Component { Inner() { setOpaque (true); } void paint (Graphics& g) override { g.fillAll (Colours::black); } @@ -1884,7 +1886,7 @@ struct VST3ComponentHolder { VST3ComponentHolder (const VST3ModuleHandle::Ptr& m) : module (m) { - host = new VST3HostContext(); + host = addVSTComSmartPtrOwner (new VST3HostContext()); } ~VST3ComponentHolder() @@ -1900,7 +1902,7 @@ struct VST3ComponentHolder return false; } - return VSTComSmartPtr().loadFrom (component); + return VSTComSmartPtr().loadFrom (component.get()); } bool fetchController (VSTComSmartPtr& editController) @@ -1908,7 +1910,7 @@ struct VST3ComponentHolder if (! isComponentInitialised && ! initialise()) return false; - editController.loadFrom (component); + editController.loadFrom (component.get()); // Get the IEditController: TUID controllerCID = { 0 }; @@ -1917,7 +1919,7 @@ struct VST3ComponentHolder && component->getControllerClassId (controllerCID) == kResultTrue && FUID (controllerCID).isValid()) { - editController.loadFrom (factory, controllerCID); + editController.loadFrom (factory.get(), controllerCID); } if (editController == nullptr) @@ -1931,7 +1933,7 @@ struct VST3ComponentHolder factory->getClassInfo (i, &classInfo); if (std::strcmp (classInfo.category, kVstComponentControllerClass) == 0) - editController.loadFrom (factory, classInfo.cid); + editController.loadFrom (factory.get(), classInfo.cid); } } @@ -1960,7 +1962,7 @@ struct VST3ComponentHolder std::unique_ptr info2; std::unique_ptr infoW; - if (pf2.loadFrom (factory)) + if (pf2.loadFrom (factory.get())) { info2.reset (new PClassInfo2()); pf2->getClassInfo2 (classIdx, info2.get()); @@ -1970,7 +1972,7 @@ struct VST3ComponentHolder info2.reset(); } - if (pf3.loadFrom (factory)) + if (pf3.loadFrom (factory.get())) { pf3->setHostContext (host->getFUnknown()); infoW.reset (new PClassInfoW()); @@ -2000,7 +2002,7 @@ struct VST3ComponentHolder totalNumInputChannels, totalNumOutputChannels); - description.hasARAExtension = hasARAExtension (factory, description.name); + description.hasARAExtension = hasARAExtension (factory.get(), description.name); return; } @@ -2019,7 +2021,7 @@ struct VST3ComponentHolder // initialisation are only called from the message thread. JUCE_ASSERT_MESSAGE_THREAD - factory = VSTComSmartPtr (module->getPluginFactory()); + factory = addVSTComSmartPtrOwner (module->getPluginFactory()); int classIdx; if ((classIdx = getClassIndex (module->getName())) < 0) @@ -2029,7 +2031,7 @@ struct VST3ComponentHolder if (factory->getClassInfo (classIdx, &info) != kResultOk) return false; - if (! component.loadFrom (factory, info.cid) || component == nullptr) + if (! component.loadFrom (factory.get(), info.cid) || component == nullptr) return false; cidOfComponent = FUID (info.cid); @@ -2084,7 +2086,7 @@ struct VST3ComponentHolder This is more memory-efficient than storing large vectors of parameter changes that we'll just throw away. */ -class ParamValueQueue : public Vst::IParamValueQueue +class ParamValueQueue final : public Vst::IParamValueQueue { public: ParamValueQueue (Vst::ParamID idIn, Steinberg::int32 parameterIndexIn) @@ -2152,13 +2154,13 @@ class ParamValueQueue : public Vst::IParamValueQueue - Lookup by paramID is also O(1) - addParameterData never allocates, as long you pass a paramID already passed to initialise */ -class ParameterChanges : public Vst::IParameterChanges +class ParameterChanges final : public Vst::IParameterChanges { static constexpr Steinberg::int32 notInVector = -1; struct Entry { - explicit Entry (std::unique_ptr queue) : ptr (queue.release()) {} + explicit Entry (std::unique_ptr queue) : ptr (addVSTComSmartPtrOwner (queue.release())) {} VSTComSmartPtr ptr; Steinberg::int32 index = notInVector; @@ -2408,8 +2410,8 @@ class VST3PluginInstance final : public AudioPluginInstance if (editControllerConnection != nullptr && componentConnection != nullptr) { - editControllerConnection->disconnect (componentConnection); - componentConnection->disconnect (editControllerConnection); + editControllerConnection->disconnect (componentConnection.get()); + componentConnection->disconnect (editControllerConnection.get()); } editController->setComponentHandler (nullptr); @@ -2452,7 +2454,7 @@ class VST3PluginInstance final : public AudioPluginInstance editController->initialize (holder->host->getFUnknown()); isControllerInitialised = true; - editController->setComponentHandler (holder->host); + editController->setComponentHandler (holder->host.get()); grabInformationObjects(); interconnectComponentAndController(); @@ -2480,12 +2482,12 @@ class VST3PluginInstance final : public AudioPluginInstance void getExtensions (ExtensionsVisitor& visitor) const override { - struct Extensions : public ExtensionsVisitor::VST3Client, - public ExtensionsVisitor::ARAClient + struct Extensions final : public ExtensionsVisitor::VST3Client, + public ExtensionsVisitor::ARAClient { explicit Extensions (const VST3PluginInstance* instanceIn) : instance (instanceIn) {} - Steinberg::Vst::IComponent* getIComponentPtr() const noexcept override { return instance->holder->component; } + Steinberg::Vst::IComponent* getIComponentPtr() const noexcept override { return instance->holder->component.get(); } MemoryBlock getPreset() const override { return instance->getStateForPresetFile(); } @@ -2511,7 +2513,7 @@ class VST3PluginInstance final : public AudioPluginInstance } } - void* getPlatformSpecificData() override { return holder->component; } + void* getPlatformSpecificData() override { return holder->component.get(); } void updateMidiMappings() { @@ -2537,7 +2539,7 @@ class VST3PluginInstance final : public AudioPluginInstance const auto numBuses = getBusCount (isInput); for (auto i = 0; i < numBuses; ++i) - result.push_back (getArrangementForBus (processor, isInput, i)); + result.push_back (getArrangementForBus (processor.get(), isInput, i)); return result; } @@ -2731,8 +2733,8 @@ class VST3PluginInstance final : public AudioPluginInstance data.symbolicSampleSize = sampleSize; data.numInputs = numInputAudioBuses; data.numOutputs = numOutputAudioBuses; - data.inputParameterChanges = inputParameterChanges; - data.outputParameterChanges = outputParameterChanges; + data.inputParameterChanges = inputParameterChanges.get(); + data.outputParameterChanges = outputParameterChanges.get(); data.numSamples = (Steinberg::int32) numSamples; updateTimingInformation (data, getSampleRate()); @@ -2870,12 +2872,12 @@ class VST3PluginInstance final : public AudioPluginInstance { if (trackInfoListener != nullptr) { - VSTComSmartPtr l (new TrackPropertiesAttributeList (properties)); - trackInfoListener->setChannelContextInfos (l); + auto l = addVSTComSmartPtrOwner (new TrackPropertiesAttributeList (properties)); + trackInfoListener->setChannelContextInfos (l.get()); } } - struct TrackPropertiesAttributeList : public Vst::IAttributeList + struct TrackPropertiesAttributeList final : public Vst::IAttributeList { TrackPropertiesAttributeList (const TrackProperties& properties) : props (properties) {} virtual ~TrackPropertiesAttributeList() {} @@ -2928,7 +2930,7 @@ class VST3PluginInstance final : public AudioPluginInstance //============================================================================== String getChannelName (int channelIndex, Direction direction) const { - auto numBuses = getNumSingleDirectionBusesFor (holder->component, MediaKind::audio, direction); + auto numBuses = getNumSingleDirectionBusesFor (holder->component.get(), MediaKind::audio, direction); int numCountedChannels = 0; @@ -2993,7 +2995,7 @@ class VST3PluginInstance final : public AudioPluginInstance //============================================================================== AudioProcessorEditor* createEditor() override { - if (auto* view = tryCreatingView()) + if (auto view = becomeVSTComSmartPtrOwner (tryCreatingView())) return new VST3PluginWindow (this, view); return nullptr; @@ -3005,7 +3007,7 @@ class VST3PluginInstance final : public AudioPluginInstance if (getActiveEditor() != nullptr) return true; - VSTComSmartPtr view (tryCreatingView(), false); + auto view = becomeVSTComSmartPtrOwner (tryCreatingView()); return view != nullptr; } @@ -3087,7 +3089,7 @@ class VST3PluginInstance final : public AudioPluginInstance auto componentStream (createMemoryStreamForState (*head, "IComponent")); if (componentStream != nullptr && holder->component != nullptr) - holder->component->setState (componentStream); + holder->component->setState (componentStream.get()); if (editController != nullptr) { @@ -3101,7 +3103,7 @@ class VST3PluginInstance final : public AudioPluginInstance auto controllerStream (createMemoryStreamForState (*head, "IEditController")); if (controllerStream != nullptr) - editController->setState (controllerStream); + editController->setState (controllerStream.get()); } } } @@ -3126,15 +3128,15 @@ class VST3PluginInstance final : public AudioPluginInstance MemoryBlock getStateForPresetFile() const { - VSTComSmartPtr memoryStream (new Steinberg::MemoryStream(), false); + auto memoryStream = becomeVSTComSmartPtrOwner (new Steinberg::MemoryStream()); if (memoryStream == nullptr || holder->component == nullptr) return {}; - const auto saved = Steinberg::Vst::PresetFile::savePreset (memoryStream, + const auto saved = Steinberg::Vst::PresetFile::savePreset (memoryStream.get(), holder->cidOfComponent, - holder->component, - editController); + holder->component.get(), + editController.get()); if (saved) return { memoryStream->getData(), static_cast (memoryStream->getSize()) }; @@ -3145,13 +3147,13 @@ class VST3PluginInstance final : public AudioPluginInstance bool setStateFromPresetFile (const MemoryBlock& rawData) const { auto rawDataCopy = rawData; - VSTComSmartPtr memoryStream (new Steinberg::MemoryStream (rawDataCopy.getData(), (int) rawDataCopy.getSize()), false); + auto memoryStream = becomeVSTComSmartPtrOwner (new Steinberg::MemoryStream (rawDataCopy.getData(), (int) rawDataCopy.getSize())); if (memoryStream == nullptr || holder->component == nullptr) return false; - return Steinberg::Vst::PresetFile::loadPreset (memoryStream, holder->cidOfComponent, - holder->component, editController, nullptr); + return Steinberg::Vst::PresetFile::loadPreset (memoryStream.get(), holder->cidOfComponent, + holder->component.get(), editController.get(), nullptr); } //============================================================================== @@ -3264,37 +3266,38 @@ class VST3PluginInstance final : public AudioPluginInstance if (mem.fromBase64Encoding (state->getAllSubText())) { - VSTComSmartPtr stream (new Steinberg::MemoryStream(), false); + auto stream = becomeVSTComSmartPtrOwner (new Steinberg::MemoryStream()); stream->setSize ((TSize) mem.getSize()); mem.copyTo (stream->getData(), 0, mem.getSize()); return stream; } } - return nullptr; + return {}; } CachedParamValues cachedParamValues; - VSTComSmartPtr inputParameterChanges { new ParameterChanges }; - VSTComSmartPtr outputParameterChanges { new ParameterChanges }; - VSTComSmartPtr midiInputs { new MidiEventList }, midiOutputs { new MidiEventList }; + VSTComSmartPtr inputParameterChanges = addVSTComSmartPtrOwner (new ParameterChanges); + VSTComSmartPtr outputParameterChanges = addVSTComSmartPtrOwner (new ParameterChanges); + VSTComSmartPtr midiInputs = addVSTComSmartPtrOwner (new MidiEventList); + VSTComSmartPtr midiOutputs = addVSTComSmartPtrOwner (new MidiEventList); Vst::ProcessContext timingInfo; //< Only use this in processBlock()! bool isControllerInitialised = false, isActive = false, lastProcessBlockCallWasBypass = false; - const bool hasMidiInput = getNumSingleDirectionBusesFor (holder->component, MediaKind::event, Direction::input) > 0, - hasMidiOutput = getNumSingleDirectionBusesFor (holder->component, MediaKind::event, Direction::output) > 0; + const bool hasMidiInput = getNumSingleDirectionBusesFor (holder->component.get(), MediaKind::event, Direction::input) > 0, + hasMidiOutput = getNumSingleDirectionBusesFor (holder->component.get(), MediaKind::event, Direction::output) > 0; VST3Parameter* bypassParam = nullptr; //============================================================================== /** Some plugins need to be "connected" to intercommunicate between their implemented classes */ void interconnectComponentAndController() { - componentConnection.loadFrom (holder->component); - editControllerConnection.loadFrom (editController); + componentConnection.loadFrom (holder->component.get()); + editControllerConnection.loadFrom (editController.get()); if (componentConnection != nullptr && editControllerConnection != nullptr) { - warnOnFailure (componentConnection->connect (editControllerConnection)); - warnOnFailure (editControllerConnection->connect (componentConnection)); + warnOnFailure (componentConnection->connect (editControllerConnection.get())); + warnOnFailure (editControllerConnection->connect (componentConnection.get())); } } @@ -3393,31 +3396,31 @@ class VST3PluginInstance final : public AudioPluginInstance void grabInformationObjects() { - processor.loadFrom (holder->component); - unitInfo.loadFrom (holder->component); - programListData.loadFrom (holder->component); - unitData.loadFrom (holder->component); - editController2.loadFrom (holder->component); - midiMapping.loadFrom (holder->component); - componentHandler.loadFrom (holder->component); - componentHandler2.loadFrom (holder->component); - trackInfoListener.loadFrom (holder->component); - - if (processor == nullptr) processor.loadFrom (editController); - if (unitInfo == nullptr) unitInfo.loadFrom (editController); - if (programListData == nullptr) programListData.loadFrom (editController); - if (unitData == nullptr) unitData.loadFrom (editController); - if (editController2 == nullptr) editController2.loadFrom (editController); - if (midiMapping == nullptr) midiMapping.loadFrom (editController); - if (componentHandler == nullptr) componentHandler.loadFrom (editController); - if (componentHandler2 == nullptr) componentHandler2.loadFrom (editController); - if (trackInfoListener == nullptr) trackInfoListener.loadFrom (editController); + processor.loadFrom (holder->component.get()); + unitInfo.loadFrom (holder->component.get()); + programListData.loadFrom (holder->component.get()); + unitData.loadFrom (holder->component.get()); + editController2.loadFrom (holder->component.get()); + midiMapping.loadFrom (holder->component.get()); + componentHandler.loadFrom (holder->component.get()); + componentHandler2.loadFrom (holder->component.get()); + trackInfoListener.loadFrom (holder->component.get()); + + if (processor == nullptr) processor.loadFrom (editController.get()); + if (unitInfo == nullptr) unitInfo.loadFrom (editController.get()); + if (programListData == nullptr) programListData.loadFrom (editController.get()); + if (unitData == nullptr) unitData.loadFrom (editController.get()); + if (editController2 == nullptr) editController2.loadFrom (editController.get()); + if (midiMapping == nullptr) midiMapping.loadFrom (editController.get()); + if (componentHandler == nullptr) componentHandler.loadFrom (editController.get()); + if (componentHandler2 == nullptr) componentHandler2.loadFrom (editController.get()); + if (trackInfoListener == nullptr) trackInfoListener.loadFrom (editController.get()); } void setStateForAllMidiBuses (bool newState) { - setStateForAllEventBuses (holder->component, newState, Direction::input); - setStateForAllEventBuses (holder->component, newState, Direction::output); + setStateForAllEventBuses (holder->component.get(), newState, Direction::input); + setStateForAllEventBuses (holder->component.get(), newState, Direction::output); } std::vector createChannelMappings (bool isInput) const @@ -3556,8 +3559,8 @@ class VST3PluginInstance final : public AudioPluginInstance }); } - destination.inputEvents = midiInputs; - destination.outputEvents = midiOutputs; + destination.inputEvents = midiInputs.get(); + destination.outputEvents = midiOutputs.get(); } void updateTimingInformation (Vst::ProcessData& destination, double processSampleRate) @@ -3618,7 +3621,7 @@ class VST3PluginInstance final : public AudioPluginInstance for (int idx = 0; idx < unitCount; ++idx) { - if (unitInfo->getUnitInfo(idx, uInfo) == kResultOk + if (unitInfo->getUnitInfo (idx, uInfo) == kResultOk && uInfo.id == programUnitID) { const int programListCount = unitInfo->getProgramListCount(); @@ -3833,7 +3836,7 @@ tresult VST3HostContext::ContextMenu::popup (Steinberg::UCoord x, Steinberg::UCo // Unfortunately, Steinberg's docs explicitly say this should be modal.. handleResult (topLevelMenu->showMenu (options)); #else - topLevelMenu->showMenuAsync (options, ModalCallbackFunction::create (menuFinished, VSTComSmartPtr (this))); + topLevelMenu->showMenuAsync (options, ModalCallbackFunction::create (menuFinished, addVSTComSmartPtrOwner (this))); #endif return kResultOk; @@ -3882,13 +3885,12 @@ void VST3PluginFormat::findAllTypesForFile (OwnedArray& resul for every housed plugin. */ - VSTComSmartPtr pluginFactory (DLLHandleCache::getInstance()->findOrCreateHandle (file) - .getPluginFactory()); + auto pluginFactory = addVSTComSmartPtrOwner (DLLHandleCache::getInstance()->findOrCreateHandle (file).getPluginFactory()); if (pluginFactory == nullptr) continue; - VSTComSmartPtr host (new VST3HostContext()); + auto host = addVSTComSmartPtrOwner (new VST3HostContext()); for (const auto& d : DescriptionLister::findDescriptionsSlow (*host, *pluginFactory, File (file))) results.add (new PluginDescription (d)); @@ -3904,11 +3906,10 @@ void VST3PluginFormat::createARAFactoryAsync (const PluginDescription& descripti } File file (description.fileOrIdentifier); - VSTComSmartPtr pluginFactory ( - DLLHandleCache::getInstance()->findOrCreateHandle (file.getFullPathName()).getPluginFactory()); + auto pluginFactory = addVSTComSmartPtrOwner (DLLHandleCache::getInstance()->findOrCreateHandle (file.getFullPathName()).getPluginFactory()); const auto* pluginName = description.name.toRawUTF8(); - callback ({ ARAFactoryWrapper { ::juce::getARAFactory (pluginFactory, pluginName) }, {} }); + callback ({ ARAFactoryWrapper { ::juce::getARAFactory (pluginFactory.get(), pluginName) }, {} }); } static std::unique_ptr createVST3Instance (VST3PluginFormat& format, diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat_test.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat_test.cpp index 27c10a2d..223bfe23 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat_test.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VST3PluginFormat_test.cpp @@ -29,7 +29,7 @@ namespace juce { -class VST3PluginFormatTests : public UnitTest +class VST3PluginFormatTests final : public UnitTest { public: VST3PluginFormatTests() diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTCommon.h b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTCommon.h index 851eef99..608c074a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTCommon.h +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTCommon.h @@ -185,7 +185,7 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e } } - VstSpeakerConfigurationHolder& operator= (const VstSpeakerConfigurationHolder& vstConfig) { return operator=(vstConfig.get()); } + VstSpeakerConfigurationHolder& operator= (const VstSpeakerConfigurationHolder& vstConfig) { return operator= (vstConfig.get()); } VstSpeakerConfigurationHolder& operator= (const Vst2::VstSpeakerArrangement& vstConfig) { Vst2::VstSpeakerArrangement& dst = *allocate (vstConfig.numChannels); diff --git a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 893d244f..d08e11f5 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -282,7 +282,7 @@ class VSTXMLInfo Group* parent = nullptr; }; - struct Param : public Base + struct Param final : public Base { int paramID; juce::String expr, name, label; @@ -292,7 +292,7 @@ class VSTXMLInfo float defaultValue; }; - struct Group : public Base + struct Group final : public Base { juce::String name; juce::OwnedArray paramTree; @@ -379,8 +379,8 @@ class VSTXMLInfo private: VSTXMLInfo (const juce::XmlElement& xml) { - switchValueType.entries.add (new Entry({ TRANS("Off"), Range ("[0, 0.5[") })); - switchValueType.entries.add (new Entry({ TRANS("On"), Range ("[0.5, 1]") })); + switchValueType.entries.add (new Entry ({ TRANS ("Off"), Range ("[0, 0.5[") })); + switchValueType.entries.add (new Entry ({ TRANS ("On"), Range ("[0.5, 1]") })); for (auto* item : xml.getChildIterator()) { @@ -443,7 +443,7 @@ class VSTXMLInfo if (entryXml->hasAttribute ("value")) { - entry->range.set(entryXml->getStringAttribute ("value")); + entry->range.set (entryXml->getStringAttribute ("value")); } else { @@ -582,7 +582,7 @@ class VSTXMLInfo }; //============================================================================== -struct ModuleHandle : public ReferenceCountedObject +struct ModuleHandle final : public ReferenceCountedObject { File file; MainCall moduleMain, customMain = {}; @@ -741,16 +741,16 @@ struct ModuleHandle : public ReferenceCountedObject { if (CFBundleLoadExecutable (bundleRef.get())) { - moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef.get(), CFSTR("main_macho")); + moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef.get(), CFSTR ("main_macho")); if (moduleMain == nullptr) - moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef.get(), CFSTR("VSTPluginMain")); + moduleMain = (MainCall) CFBundleGetFunctionPointerForName (bundleRef.get(), CFSTR ("VSTPluginMain")); JUCE_VST_WRAPPER_LOAD_CUSTOM_MAIN if (moduleMain != nullptr) { - if (CFTypeRef name = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR("CFBundleName"))) + if (CFTypeRef name = CFBundleGetValueForInfoDictionaryKey (bundleRef.get(), CFSTR ("CFBundleName"))) { if (CFGetTypeID (name) == CFStringGetTypeID()) { @@ -778,7 +778,7 @@ struct ModuleHandle : public ReferenceCountedObject .findChildFiles (File::findFiles, false, "*.vstxml"); if (! vstXmlFiles.isEmpty()) - vstXml = parseXML (vstXmlFiles.getReference(0)); + vstXml = parseXML (vstXmlFiles.getReference (0)); } } @@ -1257,7 +1257,7 @@ struct VSTPluginInstance final : public AudioPluginInstance, void getExtensions (ExtensionsVisitor& visitor) const override { - struct Extensions : public ExtensionsVisitor::VSTClient + struct Extensions final : public ExtensionsVisitor::VSTClient { explicit Extensions (const VSTPluginInstance* instanceIn) : instance (instanceIn) {} @@ -1996,9 +1996,9 @@ struct VSTPluginInstance final : public AudioPluginInstance, { VST2BypassParameter (VSTPluginInstance& effectToUse) : parent (effectToUse), - vstOnStrings (TRANS("on"), TRANS("yes"), TRANS("true")), - vstOffStrings (TRANS("off"), TRANS("no"), TRANS("false")), - values (TRANS("Off"), TRANS("On")) + vstOnStrings (TRANS ("on"), TRANS ("yes"), TRANS ("true")), + vstOffStrings (TRANS ("off"), TRANS ("no"), TRANS ("false")), + values (TRANS ("Off"), TRANS ("On")) { } @@ -2028,7 +2028,7 @@ struct VSTPluginInstance final : public AudioPluginInstance, float getValue() const override { return currentValue; } float getDefaultValue() const override { return 0.0f; } String getName (int /*maximumStringLength*/) const override { return "Bypass"; } - String getText (float value, int) const override { return (! approximatelyEqual (value, 0.0f) ? TRANS("On") : TRANS("Off")); } + String getText (float value, int) const override { return (! approximatelyEqual (value, 0.0f) ? TRANS ("On") : TRANS ("Off")); } bool isAutomatable() const override { return true; } bool isDiscrete() const override { return true; } bool isBoolean() const override { return true; } @@ -2121,7 +2121,7 @@ struct VSTPluginInstance final : public AudioPluginInstance, handleUpdateNowIfNeeded(); for (int i = ComponentPeer::getNumPeers(); --i >= 0;) - if (auto* p = ComponentPeer::getPeer(i)) + if (auto* p = ComponentPeer::getPeer (i)) p->performAnyPendingRepaintsNow(); } } @@ -2761,11 +2761,11 @@ struct VSTPluginWindow; static Array activeVSTWindows; //============================================================================== -struct VSTPluginWindow : public AudioProcessorEditor, - #if ! JUCE_MAC - private ComponentMovementWatcher, - #endif - private Timer +struct VSTPluginWindow final : public AudioProcessorEditor, + #if ! JUCE_MAC + private ComponentMovementWatcher, + #endif + private Timer { public: VSTPluginWindow (VSTPluginInstance& plug) @@ -3384,7 +3384,7 @@ struct VSTPluginWindow : public AudioProcessorEditor, NativeScaleFactorNotifier scaleNotifier { this, ScaleNotifierCallback { *this } }; #if JUCE_WINDOWS - struct ViewComponent : public HWNDComponent + struct ViewComponent final : public HWNDComponent { ViewComponent() { @@ -3398,7 +3398,7 @@ struct VSTPluginWindow : public AudioProcessorEditor, void paint (Graphics& g) override { g.fillAll (Colours::black); } private: - struct Inner : public Component + struct Inner final : public Component { Inner() { setOpaque (true); } void paint (Graphics& g) override { g.fillAll (Colours::black); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp index 27ed7c32..71a64c38 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.cpp @@ -108,8 +108,8 @@ void callOnMessageThread (Callback&& callback) request that the editor bounds are updated. We can call `setSize` on this component from inside those dedicated callbacks. */ -struct NSViewComponentWithParent : public NSViewComponent, - private AsyncUpdater +struct NSViewComponentWithParent : public NSViewComponent, + private AsyncUpdater { enum class WantsNudge { no, yes }; @@ -156,29 +156,28 @@ struct NSViewComponentWithParent : public NSViewComponent, } } - struct InnerNSView : public ObjCClass + struct InnerNSView final : public ObjCClass { InnerNSView() : ObjCClass ("JuceInnerNSView_") { addIvar ("owner"); - addMethod (@selector (isOpaque), isOpaque); - addMethod (@selector (didAddSubview:), didAddSubview); + addMethod (@selector (isOpaque), [] (id, SEL) { return YES; }); - registerClass(); - } + addMethod (@selector (didAddSubview:), [] (id self, SEL, NSView*) + { + if (auto* owner = getIvar (self, "owner")) + if (owner->wantsNudge == WantsNudge::yes) + owner->triggerAsyncUpdate(); + }); - static BOOL isOpaque (id, SEL) { return YES; } + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector") + addMethod (@selector (clipsToBounds), [] (id, SEL) { return YES; }); + JUCE_END_IGNORE_WARNINGS_GCC_LIKE - static void nudge (id self) - { - if (auto* owner = getIvar (self, "owner")) - if (owner->wantsNudge == WantsNudge::yes) - owner->triggerAsyncUpdate(); + registerClass(); } - - static void didAddSubview (id self, SEL, NSView*) { nudge (self); } }; static InnerNSView& getViewClass() diff --git a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h index 87d4c7be..c0067fca 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h +++ b/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h @@ -35,7 +35,7 @@ ID: juce_audio_processors vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE audio processor classes description: Classes for loading and playing VST, AU, LADSPA, or internally-generated audio processors. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp index e2927d04..6956eeb1 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioPluginInstance.cpp @@ -219,7 +219,7 @@ AudioPluginInstance::Parameter::Parameter() String AudioPluginInstance::Parameter::getText (float value, int maximumStringLength) const { if (isBoolean()) - return value < 0.5f ? TRANS("Off") : TRANS("On"); + return value < 0.5f ? TRANS ("Off") : TRANS ("On"); return String (value).substring (0, maximumStringLength); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 7ea8d23b..078c9387 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -434,7 +434,7 @@ void AudioProcessor::validateParameter (AudioProcessorParameter* param) /* If you're building this plugin as an AudioUnit, and you intend to use the plugin in Logic Pro or GarageBand, it's a good idea to set version hints on all of your parameters so that you can add parameters safely in future versions of the plugin. - See the documentation for AudioProcessorParameter(int) for more information. + See the documentation for AudioProcessorParameter (int) for more information. */ #if JucePlugin_Build_AU static std::once_flag flag; @@ -448,7 +448,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc #if JUCE_DEBUG && ! JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING if (auto* withID = dynamic_cast (param)) { - constexpr auto maximumSafeAAXParameterIdLength = 31; + [[maybe_unused]] constexpr auto maximumSafeAAXParameterIdLength = 31; const auto paramID = withID->getParameterID(); @@ -459,7 +459,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc // If you need to retain backwards-compatibility and are unable to change // the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING // to your preprocessor definitions to silence this assertion. - jassertquiet (paramID.length() <= maximumSafeAAXParameterIdLength); + jassert (paramID.length() <= maximumSafeAAXParameterIdLength); // If you hit this assertion, two or more parameters have duplicate paramIDs // after they have been truncated to support the AAX format. @@ -470,7 +470,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc // If you need to retain backwards-compatibility and are unable to change // the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING // to your preprocessor definitions to silence this assertion. - jassertquiet (trimmedParamIDs.insert (paramID.substring (0, maximumSafeAAXParameterIdLength)).second); + jassert (trimmedParamIDs.insert (paramID.substring (0, maximumSafeAAXParameterIdLength)).second); } #endif } @@ -720,8 +720,8 @@ AudioProcessor::BusesLayout AudioProcessor::getNextBestLayoutInList (const Buses auto outChannels = legacyLayouts.getReference (bestConfiguration).outChannels; auto currentState = getBusesLayout(); - auto currentInLayout = (getBusCount (true) > 0 ? currentState.inputBuses .getReference(0) : AudioChannelSet()); - auto currentOutLayout = (getBusCount (false) > 0 ? currentState.outputBuses.getReference(0) : AudioChannelSet()); + auto currentInLayout = (getBusCount (true) > 0 ? currentState.inputBuses .getReference (0) : AudioChannelSet()); + auto currentOutLayout = (getBusCount (false) > 0 ? currentState.outputBuses.getReference (0) : AudioChannelSet()); if (inBus != nullptr) { @@ -1104,7 +1104,7 @@ bool AudioProcessor::Bus::isLayoutSupported (const AudioChannelSet& set, BusesLa bool AudioProcessor::Bus::isNumberOfChannelsSupported (int channels) const { if (channels == 0) - return isLayoutSupported(AudioChannelSet::disabled()); + return isLayoutSupported (AudioChannelSet::disabled()); auto set = supportedLayoutWithChannels (channels); return (! set.isDisabled()) && isLayoutSupported (set); diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h index db98f02a..aa9995c2 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -1177,6 +1177,16 @@ class JUCE_API AudioProcessor : private AAXClientExtensions */ void setRateAndBufferSizeDetails (double sampleRate, int blockSize) noexcept; + /** This is called by the host when the thread workgroup context has changed. + + This will only be called on the audio thread, so you can join the audio workgroup + in your implementation of this function. + + You can use this workgroup id to synchronise any real-time threads you have. + Note: This is currently only called on Apple devices. + */ + virtual void audioWorkgroupContextChanged ([[maybe_unused]] const AudioWorkgroup& workgroup) {} + //============================================================================== /** Returns a reference to an object that implements AAX specific information regarding this AudioProcessor. diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index ea9b8968..6f80d24a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -542,16 +542,14 @@ struct GraphRenderSequence return; } - currentAudioInputBuffer = &buffer; currentAudioOutputBuffer.setSize (jmax (1, buffer.getNumChannels()), numSamples); currentAudioOutputBuffer.clear(); - currentMidiInputBuffer = &midiMessages; currentMidiOutputBuffer.clear(); { - const Context context { { *currentAudioInputBuffer, + const Context context { { buffer, currentAudioOutputBuffer, - *currentMidiInputBuffer, + midiMessages, currentMidiOutputBuffer }, audioPlayHead, numSamples }; @@ -565,14 +563,13 @@ struct GraphRenderSequence midiMessages.clear(); midiMessages.addEvents (currentMidiOutputBuffer, 0, buffer.getNumSamples(), 0); - currentAudioInputBuffer = nullptr; } JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4661) void addClearChannelOp (int index) { - struct ClearOp : public RenderOp + struct ClearOp final : public RenderOp { explicit ClearOp (int indexIn) : index (indexIn) {} @@ -595,7 +592,7 @@ struct GraphRenderSequence void addCopyChannelOp (int srcIndex, int dstIndex) { - struct CopyOp : public RenderOp + struct CopyOp final : public RenderOp { explicit CopyOp (int fromIn, int toIn) : from (fromIn), to (toIn) {} @@ -620,7 +617,7 @@ struct GraphRenderSequence void addAddChannelOp (int srcIndex, int dstIndex) { - struct AddOp : public RenderOp + struct AddOp final : public RenderOp { explicit AddOp (int fromIn, int toIn) : from (fromIn), to (toIn) {} @@ -647,7 +644,7 @@ struct GraphRenderSequence void addClearMidiBufferOp (int index) { - struct ClearOp : public RenderOp + struct ClearOp final : public RenderOp { explicit ClearOp (int indexIn) : index (indexIn) {} @@ -670,7 +667,7 @@ struct GraphRenderSequence void addCopyMidiBufferOp (int srcIndex, int dstIndex) { - struct CopyOp : public RenderOp + struct CopyOp final : public RenderOp { explicit CopyOp (int fromIn, int toIn) : from (fromIn), to (toIn) {} @@ -695,7 +692,7 @@ struct GraphRenderSequence void addAddMidiBufferOp (int srcIndex, int dstIndex) { - struct AddOp : public RenderOp + struct AddOp final : public RenderOp { explicit AddOp (int fromIn, int toIn) : from (fromIn), to (toIn) {} @@ -720,7 +717,7 @@ struct GraphRenderSequence void addDelayChannelOp (int chan, int delaySize) { - struct DelayChannelOp : public RenderOp + struct DelayChannelOp final : public RenderOp { DelayChannelOp (int chan, int delaySize) : buffer ((size_t) (delaySize + 1), (FloatType) 0), @@ -795,8 +792,6 @@ struct GraphRenderSequence currentAudioOutputBuffer.setSize (numBuffersNeeded + 1, blockSize); currentAudioOutputBuffer.clear(); - currentAudioInputBuffer = nullptr; - currentMidiInputBuffer = nullptr; currentMidiOutputBuffer.clear(); midiBuffers.clearQuick(); @@ -816,9 +811,7 @@ struct GraphRenderSequence int numBuffersNeeded = 0, numMidiBuffersNeeded = 0; AudioBuffer renderingBuffer, currentAudioOutputBuffer; - AudioBuffer* currentAudioInputBuffer = nullptr; - MidiBuffer* currentMidiInputBuffer = nullptr; MidiBuffer currentMidiOutputBuffer; Array midiBuffers; @@ -894,7 +887,7 @@ struct GraphRenderSequence const int midiBufferToUse; }; - struct ProcessOp : public NodeOp + struct ProcessOp final : public NodeOp { using NodeOp::NodeOp; @@ -943,7 +936,7 @@ struct GraphRenderSequence AudioBuffer tempBufferFloat, tempBufferDouble; }; - struct MidiInOp : public NodeOp + struct MidiInOp final : public NodeOp { using NodeOp::NodeOp; @@ -954,7 +947,7 @@ struct GraphRenderSequence } }; - struct MidiOutOp : public NodeOp + struct MidiOutOp final : public NodeOp { using NodeOp::NodeOp; @@ -965,7 +958,7 @@ struct GraphRenderSequence } }; - struct AudioInOp : public NodeOp + struct AudioInOp final : public NodeOp { using NodeOp::NodeOp; @@ -979,7 +972,7 @@ struct GraphRenderSequence } }; - struct AudioOutOp : public NodeOp + struct AudioOutOp final : public NodeOp { using NodeOp::NodeOp; @@ -1598,7 +1591,7 @@ class RenderSequenceSignature At the top of the audio callback, RenderSequenceExchange::updateAudioThreadState will attempt to install the most-recently-baked graph, if there's one waiting. */ -class RenderSequenceExchange : private Timer +class RenderSequenceExchange final : private Timer { public: RenderSequenceExchange() @@ -2110,7 +2103,7 @@ void AudioProcessorGraph::AudioGraphIOProcessor::setParentGraph (AudioProcessorG //============================================================================== #if JUCE_UNIT_TESTS -class AudioProcessorGraphTests : public UnitTest +class AudioProcessorGraphTests final : public UnitTest { public: AudioProcessorGraphTests() @@ -2246,7 +2239,7 @@ class AudioProcessorGraphTests : public UnitTest enum class MidiIn { no, yes }; enum class MidiOut { no, yes }; - class BasicProcessor : public AudioProcessor + class BasicProcessor final : public AudioProcessor { public: explicit BasicProcessor (const AudioProcessor::BusesProperties& layout, MidiIn mIn, MidiOut mOut) diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index b6b60546..62dda07d 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -151,7 +151,7 @@ class JUCE_API AudioProcessorGraph : public AudioProcessor, /** @internal - Returns true if setBypassed(true) was called on this node. + Returns true if setBypassed (true) was called on this node. This behaviour is different from isBypassed(), which may additionally return true if the node has a bypass parameter that is not set to 0. */ diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index 29d5d64d..bb5615de 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h @@ -276,7 +276,7 @@ class JUCE_API AudioProcessorParameter virtual StringArray getAllValueStrings() const; //============================================================================== - /** @see AudioProcessorParameter(int) */ + /** @see AudioProcessorParameter (int) */ int getVersionHint() const { return version; } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp index f66854c2..75e713d7 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp @@ -184,7 +184,7 @@ const AudioProcessorParameterGroup* AudioProcessorParameterGroup::getGroupForPar //============================================================================== #if JUCE_UNIT_TESTS -class ParameterGroupTests : public UnitTest +class ParameterGroupTests final : public UnitTest { public: ParameterGroupTests() @@ -292,7 +292,7 @@ class ParameterGroupTests : public UnitTest } private: - struct TestAudioProcessor : public AudioProcessor + struct TestAudioProcessor final : public AudioProcessor { const String getName() const override { return "ap"; } void prepareToPlay (double, int) override {} diff --git a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 7e32b8b7..425152fb 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -26,9 +26,9 @@ namespace juce { -class ParameterListener : private AudioProcessorParameter::Listener, - private AudioProcessorListener, - private Timer +class ParameterListener : private AudioProcessorParameter::Listener, + private AudioProcessorListener, + private Timer { public: ParameterListener (AudioProcessor& proc, AudioProcessorParameter& param) @@ -107,7 +107,7 @@ class ParameterComponent : public Component, }; //============================================================================== -class BooleanParameterComponent : public ParameterComponent +class BooleanParameterComponent final : public ParameterComponent { public: BooleanParameterComponent (AudioProcessor& proc, AudioProcessorParameter& param) @@ -154,7 +154,7 @@ class BooleanParameterComponent : public ParameterComponent }; //============================================================================== -class SwitchParameterComponent : public ParameterComponent +class SwitchParameterComponent final : public ParameterComponent { public: SwitchParameterComponent (AudioProcessor& proc, AudioProcessorParameter& param) @@ -256,7 +256,7 @@ class SwitchParameterComponent : public ParameterComponent }; //============================================================================== -class ChoiceParameterComponent : public ParameterComponent +class ChoiceParameterComponent final : public ParameterComponent { public: ChoiceParameterComponent (AudioProcessor& proc, AudioProcessorParameter& param) @@ -318,7 +318,7 @@ class ChoiceParameterComponent : public ParameterComponent }; //============================================================================== -class SliderParameterComponent : public ParameterComponent +class SliderParameterComponent final : public ParameterComponent { public: SliderParameterComponent (AudioProcessor& proc, AudioProcessorParameter& param) @@ -411,9 +411,9 @@ class SliderParameterComponent : public ParameterComponent }; //============================================================================== -class ParameterDisplayComponent : public Component, - private AudioProcessorListener, - private AsyncUpdater +class ParameterDisplayComponent final : public Component, + private AudioProcessorListener, + private AsyncUpdater { public: ParameterDisplayComponent (AudioProcessorEditor& editorIn, AudioProcessorParameter& param) @@ -515,7 +515,7 @@ class ParameterDisplayComponent : public Component, }; //============================================================================== -struct ParamControlItem : public TreeViewItem +struct ParamControlItem final : public TreeViewItem { ParamControlItem (AudioProcessorEditor& editorIn, AudioProcessorParameter& paramIn) : editor (editorIn), param (paramIn) {} @@ -533,7 +533,7 @@ struct ParamControlItem : public TreeViewItem AudioProcessorParameter& param; }; -struct ParameterGroupItem : public TreeViewItem +struct ParameterGroupItem final : public TreeViewItem { ParameterGroupItem (AudioProcessorEditor& editor, const AudioProcessorParameterGroup& group) : name (group.getName()) diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index 9775d299..7b0e62e4 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -420,7 +420,7 @@ struct PluginTreeUtils { for (int i = tree.subFolders.size(); --i >= 0;) { - auto& sub = *tree.subFolders.getUnchecked(i); + auto& sub = *tree.subFolders.getUnchecked (i); optimiseFolders (sub, concatenateName || (tree.subFolders.size() > 1)); if (sub.plugins.isEmpty()) diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 9af96f4a..da8b18c9 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -224,7 +224,7 @@ class JUCE_API KnownPluginList : public ChangeBroadcaster // to store the plug-in list at a point in time and use it when calling these methods. [[deprecated]] void addToMenu (PopupMenu& menu, SortMethod sortMethod, const String& currentlyTickedPluginID = {}) const; [[deprecated]] int getIndexChosenByMenu (int menuResultCode) const; - [[deprecated]] std::unique_ptr createTree (const SortMethod sortMethod) const; + [[deprecated]] std::unique_ptr createTree (SortMethod sortMethod) const; #endif private: diff --git a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index af4e0013..2aaaaeb7 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -381,7 +381,7 @@ void PluginListComponent::setLastSearchPath (PropertiesFile& properties, AudioPl } //============================================================================== -class PluginListComponent::Scanner : private Timer +class PluginListComponent::Scanner final : private Timer { public: Scanner (PluginListComponent& plc, AudioPluginFormat& format, const StringArray& filesOrIdentifiers, @@ -609,7 +609,7 @@ class PluginListComponent::Scanner : private Timer return false; } - struct ScanJob : public ThreadPoolJob + struct ScanJob final : public ThreadPoolJob { ScanJob (Scanner& s) : ThreadPoolJob ("pluginscan"), scanner (s) {} diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentControllerCommon.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentControllerCommon.cpp index 2b2364ce..028dbd12 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentControllerCommon.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentControllerCommon.cpp @@ -26,7 +26,7 @@ namespace juce { -class ARADocumentController : public ARA::PlugIn::DocumentController +class ARADocumentController : public ARA::PlugIn::DocumentController { public: using ARA::PlugIn::DocumentController::DocumentController; diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARAModelObjects.h b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARAModelObjects.h index 2f3096f2..3576ce62 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARAModelObjects.h +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARAModelObjects.h @@ -658,7 +658,7 @@ class JUCE_API ARARegionSequence : public ARA::PlugIn::RegionSequence, ARAObject* getChild (size_t index) override; - ARAObject* getParent () override { return getDocument(); } + ARAObject* getParent() override { return getDocument(); } void visit (ARAObjectVisitor& visitor) override { visitor.visitRegionSequence (*this); } diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARA_utils.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARA_utils.cpp index 9109d198..5e3db3ce 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARA_utils.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/ARA/juce_ARA_utils.cpp @@ -52,5 +52,5 @@ JUCE_API void JUCE_CALLTYPE handleARAAssertion (const char* file, const int line #include "juce_ARAPlugInInstanceRoles.cpp" #include "juce_AudioProcessor_ARAExtensions.cpp" -ARA_SETUP_DEBUG_MESSAGE_PREFIX(JucePlugin_Name); +ARA_SETUP_DEBUG_MESSAGE_PREFIX (JucePlugin_Name); #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AAXClientExtensions.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AAXClientExtensions.cpp index 61f37d63..2a47f1d2 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AAXClientExtensions.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AAXClientExtensions.cpp @@ -255,7 +255,7 @@ static int32 getPluginIDForMainBusConfigJuce705 (const AudioChannelSet& mainInpu return (idForAudioSuite ? 0x6a796161 /* 'jyaa' */ : 0x6a636161 /* 'jcaa' */) + uniqueFormatId; } -class AAXClientExtensionsTests : public UnitTest +class AAXClientExtensionsTests final : public UnitTest { public: AAXClientExtensionsTests() diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterBool.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterBool.cpp index 47911121..58efd3f0 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterBool.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterBool.cpp @@ -35,7 +35,7 @@ AudioParameterBool::AudioParameterBool (const ParameterID& idToUse, valueDefault (def), stringFromBoolFunction (attributes.getStringFromValueFunction() != nullptr ? attributes.getStringFromValueFunction() - : [] (bool v, int) { return v ? TRANS("On") : TRANS("Off"); }), + : [] (bool v, int) { return v ? TRANS ("On") : TRANS ("Off"); }), boolFromStringFunction (attributes.getValueFromStringFunction() != nullptr ? attributes.getValueFromStringFunction() : [] (const String& text) diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp index 3e087593..88fa68ad 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp @@ -84,7 +84,7 @@ AudioParameterChoice& AudioParameterChoice::operator= (int newValue) //============================================================================== #if JUCE_UNIT_TESTS -struct AudioParameterChoiceTests : public UnitTest +struct AudioParameterChoiceTests final : public UnitTest { AudioParameterChoiceTests() : UnitTest ("AudioParameterChoice", UnitTestCategories::audioProcessorParameters) diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterInt.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterInt.cpp index 356ca036..b1df4d1a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterInt.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioParameterInt.cpp @@ -80,7 +80,7 @@ AudioParameterInt& AudioParameterInt::operator= (int newValue) //============================================================================== #if JUCE_UNIT_TESTS -struct AudioParameterIntTests : public UnitTest +struct AudioParameterIntTests final : public UnitTest { AudioParameterIntTests() : UnitTest ("AudioParameterInt", UnitTestCategories::audioProcessorParameters) diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h index c5a622d2..9647dacc 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h @@ -44,7 +44,7 @@ class ParameterID @param versionHint Influences parameter ordering in Audio Unit plugins. Used to provide backwards compatibility of Audio Unit plugins in Logic and GarageBand. - @see AudioProcessorParameter(int) + @see AudioProcessorParameter (int) */ template > ParameterID (StringLike&& identifier, int versionHint = 0) @@ -53,7 +53,7 @@ class ParameterID /** @see AudioProcessorParameterWithID::paramID */ auto getParamID() const { return paramID; } - /** @see AudioProcessorParameter(int) */ + /** @see AudioProcessorParameter (int) */ auto getVersionHint() const { return version; } private: diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index fa9f91ab..05bd71ad 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -60,7 +60,7 @@ void AudioProcessorValueTreeState::Parameter::valueChanged (float newValue) } //============================================================================== -class AudioProcessorValueTreeState::ParameterAdapter : private AudioProcessorParameter::Listener +class AudioProcessorValueTreeState::ParameterAdapter final : private AudioProcessorParameter::Listener { private: using Listener = AudioProcessorValueTreeState::Listener; @@ -208,7 +208,7 @@ AudioProcessorValueTreeState::AudioProcessorValueTreeState (AudioProcessor& proc ParameterLayout parameterLayout) : AudioProcessorValueTreeState (processorToConnectTo, undoManagerToUse) { - struct PushBackVisitor : ParameterLayout::Visitor + struct PushBackVisitor final : ParameterLayout::Visitor { explicit PushBackVisitor (AudioProcessorValueTreeState& stateIn) : state (&stateIn) {} @@ -506,7 +506,7 @@ AudioProcessorValueTreeState::ButtonAttachment::ButtonAttachment (AudioProcessor //============================================================================== #if JUCE_UNIT_TESTS -struct ParameterAdapterTests : public UnitTest +struct ParameterAdapterTests final : public UnitTest { ParameterAdapterTests() : UnitTest ("Parameter Adapter", UnitTestCategories::audioProcessorParameters) @@ -600,7 +600,7 @@ inline bool operator!= (const NormalisableRange& a, } } // namespace -class AudioProcessorValueTreeStateTests : public UnitTest +class AudioProcessorValueTreeStateTests final : public UnitTest { private: using Parameter = AudioProcessorValueTreeState::Parameter; @@ -608,7 +608,7 @@ class AudioProcessorValueTreeStateTests : public UnitTest using ParameterLayout = AudioProcessorValueTreeState::ParameterLayout; using Attributes = AudioProcessorValueTreeStateParameterAttributes; - class TestAudioProcessor : public AudioProcessor + class TestAudioProcessor final : public AudioProcessor { public: TestAudioProcessor() = default; diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index 83d93962..7e728aca 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h @@ -514,7 +514,7 @@ class JUCE_API AudioProcessorValueTreeState : private Timer, if (func == nullptr) return nullptr; - return [func = std::move (func)] (float v, int) { return func (v); }; + return [f = std::move (func)] (float v, int) { return f (v); }; } void valueChanged (float) override; diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ExtensionsVisitor.h b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ExtensionsVisitor.h index dcf0ff8f..f320ac4a 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ExtensionsVisitor.h +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ExtensionsVisitor.h @@ -26,13 +26,10 @@ #ifndef DOXYGEN // Forward declarations to avoid leaking implementation details. -namespace Steinberg +namespace Steinberg::Vst { - namespace Vst - { - class IComponent; - } -} // namespace Steinberg + class IComponent; +} // namespace Steinberg::Vst #endif diff --git a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp index 3c092a16..f7a55e5c 100644 --- a/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp +++ b/JuceLibraryCode/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp @@ -105,8 +105,7 @@ void ParameterAttachment::parameterValueChanged (int, float newValue) void ParameterAttachment::handleAsyncUpdate() { - if (setValue != nullptr) - setValue (parameter.convertFrom0to1 (lastValue)); + NullCheckedInvocation::invoke (setValue, parameter.convertFrom0to1 (lastValue)); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp index 916ece51..f55d2d91 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -168,14 +168,14 @@ AbstractFifo::ScopedWrite AbstractFifo::write (int numToWrite) noexcept { ret //============================================================================== #if JUCE_UNIT_TESTS -class AbstractFifoTests : public UnitTest +class AbstractFifoTests final : public UnitTest { public: AbstractFifoTests() : UnitTest ("Abstract Fifo", UnitTestCategories::containers) {} - struct WriteThread : public Thread + struct WriteThread final : public Thread { WriteThread (AbstractFifo& f, int* b, Random rng) : Thread ("fifo writer"), fifo (f), buffer (b), random (rng) diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h index 9e4ddede..f5763083 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_AbstractFifo.h @@ -48,7 +48,7 @@ namespace juce copySomeData (myBuffer + scope.startIndex1, someData, scope.blockSize1); if (scope.blockSize2 > 0) - copySomeData (myBuffer + scope.startIndex2, someData, scope.blockSize2); + copySomeData (myBuffer + scope.startIndex2, someData + scope.blockSize1, scope.blockSize2); } void readFromFifo (int* someData, int numItems) diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.cpp index 9d2657c3..a2335c04 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.cpp @@ -99,12 +99,12 @@ static bool operator== (const ArrayBaseTestsHelpers::NonTriviallyCopyableType& n return tct == ntct; } -class ArrayBaseTests : public UnitTest +class ArrayBaseTests final : public UnitTest { using CopyableType = ArrayBaseTestsHelpers::TriviallyCopyableType; using NoncopyableType = ArrayBaseTestsHelpers::NonTriviallyCopyableType; - #if ! (defined(__GNUC__) && __GNUC__ < 5 && ! defined(__clang__)) + #if ! (defined (__GNUC__) && __GNUC__ < 5 && ! defined (__clang__)) static_assert (std::is_trivially_copyable_v, "Test TriviallyCopyableType is not trivially copyable"); static_assert (! std::is_trivially_copyable_v, @@ -545,7 +545,7 @@ class ArrayBaseTests : public UnitTest virtual ~Base() = default; }; - struct Derived : Base + struct Derived final : public Base { }; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.h b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.h index d24d5621..ecf4fa3f 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ArrayBase.h @@ -385,7 +385,7 @@ class ArrayBase : public TypeOfCriticalSectionToUse private: //============================================================================== - #if defined(__GNUC__) && __GNUC__ < 5 && ! defined(__clang__) + #if defined (__GNUC__) && __GNUC__ < 5 && ! defined (__clang__) static constexpr auto isTriviallyCopyable = std::is_scalar_v; #else static constexpr auto isTriviallyCopyable = std::is_trivially_copyable_v; @@ -567,14 +567,14 @@ class ArrayBase : public TypeOfCriticalSectionToUse } } - void checkSourceIsNotAMember (const ElementType& element) + void checkSourceIsNotAMember ([[maybe_unused]] const ElementType& element) { // when you pass a reference to an existing element into a method like add() which // may need to reallocate the array to make more space, the incoming reference may // be deleted indirectly during the reallocation operation! To work around this, // make a local copy of the item you're trying to add (and maybe use std::move to // move it into the add() method to avoid any extra overhead) - jassertquiet (std::addressof (element) < begin() || end() <= std::addressof (element)); + jassert (std::addressof (element) < begin() || end() <= std::addressof (element)); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp index 54488458..19aff6b2 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.cpp @@ -87,11 +87,11 @@ void DynamicObject::cloneAllProperties() *v = v->clone(); } -DynamicObject::Ptr DynamicObject::clone() +std::unique_ptr DynamicObject::clone() const { - Ptr d (new DynamicObject (*this)); - d->cloneAllProperties(); - return d; + auto result = std::make_unique (*this); + result->cloneAllProperties(); + return result; } void DynamicObject::writeAsJSON (OutputStream& out, const int indentLevel, const bool allOnOneLine, int maximumDecimalPlaces) diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h index e9c090dc..dba6a846 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_DynamicObject.h @@ -96,7 +96,10 @@ class JUCE_API DynamicObject : public ReferenceCountedObject void clear(); /** Returns the NamedValueSet that holds the object's properties. */ - NamedValueSet& getProperties() noexcept { return properties; } + NamedValueSet& getProperties() noexcept { return properties; } + + /** Returns the NamedValueSet that holds the object's properties. */ + const NamedValueSet& getProperties() const noexcept { return properties; } /** Calls var::clone() on all the properties that this object contains. */ void cloneAllProperties(); @@ -107,7 +110,7 @@ class JUCE_API DynamicObject : public ReferenceCountedObject with a (deep) copy of all of its properties. Subclasses can override this to implement their own custom copy routines. */ - virtual Ptr clone(); + virtual std::unique_ptr clone() const; //============================================================================== /** Writes this object to a text stream in JSON format. diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction.h b/JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction.h similarity index 94% rename from JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction.h rename to JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction.h index 1051e853..9536ca7c 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction.h @@ -1,241 +1,237 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2022 - Raw Material Software Limited - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 7 End-User License - Agreement and JUCE Privacy Policy. - - End User License Agreement: www.juce.com/juce-7-licence - Privacy Policy: www.juce.com/juce-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -namespace juce -{ -namespace dsp -{ - -#ifndef DOXYGEN - -namespace detail -{ - template - struct Vtable - { - using Storage = void*; - - using Move = void (*) (Storage, Storage); - using Call = Ret (*) (Storage, Args...); - using Clear = void (*) (Storage); - - constexpr Vtable (Move moveIn, Call callIn, Clear clearIn) noexcept - : move (moveIn), call (callIn), clear (clearIn) {} - - Move move = nullptr; - Call call = nullptr; - Clear clear = nullptr; - }; - - template - void move (void* from, void* to) - { - new (to) Fn (std::move (*reinterpret_cast (from))); - } - - template - std::enable_if_t, Ret> call (void* s, Args... args) - { - (*reinterpret_cast (s)) (args...); - } - - template - std::enable_if_t, Ret> call (void* s, Args... args) - { - return (*reinterpret_cast (s)) (std::forward (args)...); - } - - template - void clear (void* s) - { - // I know this looks insane, for some reason MSVC 14 sometimes thinks fn is unreferenced - [[maybe_unused]] auto& fn = *reinterpret_cast (s); - fn.~Fn(); - } - - template - constexpr Vtable makeVtable() - { - return { move , call , clear }; - } -} // namespace detail - -template -class FixedSizeFunction; - -#endif - -/** - A type similar to `std::function` that holds a callable object. - - Unlike `std::function`, the callable object will always be stored in - a buffer of size `len` that is internal to the FixedSizeFunction instance. - This in turn means that creating a FixedSizeFunction instance will never allocate, - making FixedSizeFunctions suitable for use in realtime contexts. - - @tags{DSP} -*/ -template -class FixedSizeFunction -{ -private: - using Storage = std::aligned_storage_t; - - template - using Decay = std::decay_t; - - template > - using IntIfValidConversion = std::enable_if_t, - int>; - -public: - /** Create an empty function. */ - FixedSizeFunction() noexcept = default; - - /** Create an empty function. */ - FixedSizeFunction (std::nullptr_t) noexcept - : FixedSizeFunction() {} - - FixedSizeFunction (const FixedSizeFunction&) = delete; - - /** Forwards the passed Callable into the internal storage buffer. */ - template , - IntIfValidConversion = 0> - FixedSizeFunction (Callable&& callable) - { - static_assert (sizeof (Fn) <= len, - "The requested function cannot fit in this FixedSizeFunction"); - static_assert (alignof (Fn) <= alignof (Storage), - "FixedSizeFunction cannot accommodate the requested alignment requirements"); - - static constexpr auto vtableForCallable = detail::makeVtable(); - vtable = &vtableForCallable; - - auto* ptr = new (&storage) Fn (std::forward (callable)); - jassertquiet ((void*) ptr == (void*) &storage); - } - - /** Move constructor. */ - FixedSizeFunction (FixedSizeFunction&& other) noexcept - : vtable (other.vtable) - { - move (std::move (other)); - } - - /** Converting constructor from smaller FixedSizeFunctions. */ - template = 0> - FixedSizeFunction (FixedSizeFunction&& other) noexcept - : vtable (other.vtable) - { - move (std::move (other)); - } - - /** Nulls this instance. */ - FixedSizeFunction& operator= (std::nullptr_t) noexcept - { - return *this = FixedSizeFunction(); - } - - FixedSizeFunction& operator= (const FixedSizeFunction&) = delete; - - /** Assigns a new callable to this instance. */ - template = 0> - FixedSizeFunction& operator= (Callable&& callable) - { - return *this = FixedSizeFunction (std::forward (callable)); - } - - /** Move assignment from smaller FixedSizeFunctions. */ - template = 0> - FixedSizeFunction& operator= (FixedSizeFunction&& other) noexcept - { - return *this = FixedSizeFunction (std::move (other)); - } - - /** Move assignment operator. */ - FixedSizeFunction& operator= (FixedSizeFunction&& other) noexcept - { - clear(); - vtable = other.vtable; - move (std::move (other)); - return *this; - } - - /** Destructor. */ - ~FixedSizeFunction() noexcept { clear(); } - - /** If this instance is currently storing a callable object, calls that object, - otherwise throws `std::bad_function_call`. - */ - Ret operator() (Args... args) const - { - if (vtable != nullptr) - return vtable->call (&storage, std::forward (args)...); - - throw std::bad_function_call(); - } - - /** Returns true if this instance currently holds a callable. */ - explicit operator bool() const noexcept { return vtable != nullptr; } - -private: - template - friend class FixedSizeFunction; - - void clear() noexcept - { - if (vtable != nullptr) - vtable->clear (&storage); - } - - template - void move (FixedSizeFunction&& other) noexcept - { - if (vtable != nullptr) - vtable->move (&other.storage, &storage); - } - - const detail::Vtable* vtable = nullptr; - mutable Storage storage; -}; - -template -bool operator!= (const FixedSizeFunction& fn, std::nullptr_t) { return bool (fn); } - -template -bool operator!= (std::nullptr_t, const FixedSizeFunction& fn) { return bool (fn); } - -template -bool operator== (const FixedSizeFunction& fn, std::nullptr_t) { return ! (fn != nullptr); } - -template -bool operator== (std::nullptr_t, const FixedSizeFunction& fn) { return ! (fn != nullptr); } - - -} -} +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#ifndef DOXYGEN + +namespace detail +{ + template + struct Vtable + { + using Storage = void*; + + using Move = void (*) (Storage, Storage); + using Call = Ret (*) (Storage, Args...); + using Clear = void (*) (Storage); + + constexpr Vtable (Move moveIn, Call callIn, Clear clearIn) noexcept + : move (moveIn), call (callIn), clear (clearIn) {} + + Move move = nullptr; + Call call = nullptr; + Clear clear = nullptr; + }; + + template + void move (void* from, void* to) + { + new (to) Fn (std::move (*reinterpret_cast (from))); + } + + template + std::enable_if_t, Ret> call (void* s, Args... args) + { + (*reinterpret_cast (s)) (std::forward (args)...); + } + + template + std::enable_if_t, Ret> call (void* s, Args... args) + { + return (*reinterpret_cast (s)) (std::forward (args)...); + } + + template + void clear (void* s) + { + // I know this looks insane, for some reason MSVC 14 sometimes thinks fn is unreferenced + [[maybe_unused]] auto& fn = *reinterpret_cast (s); + fn.~Fn(); + } + + template + constexpr Vtable makeVtable() + { + return { move , call , clear }; + } +} // namespace detail + +template +class FixedSizeFunction; + +#endif + +/** + A type similar to `std::function` that holds a callable object. + + Unlike `std::function`, the callable object will always be stored in + a buffer of size `len` that is internal to the FixedSizeFunction instance. + This in turn means that creating a FixedSizeFunction instance will never allocate, + making FixedSizeFunctions suitable for use in realtime contexts. + + @tags{DSP} +*/ +template +class FixedSizeFunction +{ +private: + using Storage = std::aligned_storage_t; + + template + using Decay = std::decay_t; + + template > + using IntIfValidConversion = std::enable_if_t, + int>; + +public: + /** Create an empty function. */ + FixedSizeFunction() noexcept = default; + + /** Create an empty function. */ + FixedSizeFunction (std::nullptr_t) noexcept + : FixedSizeFunction() {} + + FixedSizeFunction (const FixedSizeFunction&) = delete; + + /** Forwards the passed Callable into the internal storage buffer. */ + template , + IntIfValidConversion = 0> + FixedSizeFunction (Callable&& callable) + { + static_assert (sizeof (Fn) <= len, + "The requested function cannot fit in this FixedSizeFunction"); + static_assert (alignof (Fn) <= alignof (Storage), + "FixedSizeFunction cannot accommodate the requested alignment requirements"); + + static constexpr auto vtableForCallable = detail::makeVtable(); + vtable = &vtableForCallable; + + [[maybe_unused]] auto* ptr = new (&storage) Fn (std::forward (callable)); + jassert ((void*) ptr == (void*) &storage); + } + + /** Move constructor. */ + FixedSizeFunction (FixedSizeFunction&& other) noexcept + : vtable (other.vtable) + { + move (std::move (other)); + } + + /** Converting constructor from smaller FixedSizeFunctions. */ + template = 0> + FixedSizeFunction (FixedSizeFunction&& other) noexcept + : vtable (other.vtable) + { + move (std::move (other)); + } + + /** Nulls this instance. */ + FixedSizeFunction& operator= (std::nullptr_t) noexcept + { + return *this = FixedSizeFunction(); + } + + FixedSizeFunction& operator= (const FixedSizeFunction&) = delete; + + /** Assigns a new callable to this instance. */ + template = 0> + FixedSizeFunction& operator= (Callable&& callable) + { + return *this = FixedSizeFunction (std::forward (callable)); + } + + /** Move assignment from smaller FixedSizeFunctions. */ + template = 0> + FixedSizeFunction& operator= (FixedSizeFunction&& other) noexcept + { + return *this = FixedSizeFunction (std::move (other)); + } + + /** Move assignment operator. */ + FixedSizeFunction& operator= (FixedSizeFunction&& other) noexcept + { + clear(); + vtable = other.vtable; + move (std::move (other)); + return *this; + } + + /** Destructor. */ + ~FixedSizeFunction() noexcept { clear(); } + + /** If this instance is currently storing a callable object, calls that object, + otherwise throws `std::bad_function_call`. + */ + Ret operator() (Args... args) const + { + if (vtable != nullptr) + return vtable->call (&storage, std::forward (args)...); + + throw std::bad_function_call(); + } + + /** Returns true if this instance currently holds a callable. */ + explicit operator bool() const noexcept { return vtable != nullptr; } + +private: + template + friend class FixedSizeFunction; + + void clear() noexcept + { + if (vtable != nullptr) + vtable->clear (&storage); + } + + template + void move (FixedSizeFunction&& other) noexcept + { + if (vtable != nullptr) + vtable->move (&other.storage, &storage); + } + + const detail::Vtable* vtable = nullptr; + mutable Storage storage; +}; + +template +bool operator!= (const FixedSizeFunction& fn, std::nullptr_t) { return bool (fn); } + +template +bool operator!= (std::nullptr_t, const FixedSizeFunction& fn) { return bool (fn); } + +template +bool operator== (const FixedSizeFunction& fn, std::nullptr_t) { return ! (fn != nullptr); } + +template +bool operator== (std::nullptr_t, const FixedSizeFunction& fn) { return ! (fn != nullptr); } + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction_test.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction_test.cpp similarity index 93% rename from JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction_test.cpp rename to JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction_test.cpp index e8122191..a914f908 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_FixedSizeFunction_test.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_FixedSizeFunction_test.cpp @@ -1,355 +1,364 @@ -/* - ============================================================================== - - This file is part of the JUCE library. - Copyright (c) 2022 - Raw Material Software Limited - - JUCE is an open source library subject to commercial or open-source - licensing. - - By using JUCE, you agree to the terms of both the JUCE 7 End-User License - Agreement and JUCE Privacy Policy. - - End User License Agreement: www.juce.com/juce-7-licence - Privacy Policy: www.juce.com/juce-privacy-policy - - Or: You may also use this code under the terms of the GPL v3 (see - www.gnu.org/licenses). - - JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER - EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE - DISCLAIMED. - - ============================================================================== -*/ - -#if JUCE_ENABLE_ALLOCATION_HOOKS -#define JUCE_FAIL_ON_ALLOCATION_IN_SCOPE const UnitTestAllocationChecker checker (*this) -#else -#define JUCE_FAIL_ON_ALLOCATION_IN_SCOPE -#endif - -namespace juce -{ -namespace dsp -{ -namespace -{ - -class ConstructCounts -{ - auto tie() const noexcept { return std::tie (constructions, copies, moves, calls, destructions); } - -public: - int constructions = 0; - int copies = 0; - int moves = 0; - int calls = 0; - int destructions = 0; - - ConstructCounts withConstructions (int i) const noexcept { auto c = *this; c.constructions = i; return c; } - ConstructCounts withCopies (int i) const noexcept { auto c = *this; c.copies = i; return c; } - ConstructCounts withMoves (int i) const noexcept { auto c = *this; c.moves = i; return c; } - ConstructCounts withCalls (int i) const noexcept { auto c = *this; c.calls = i; return c; } - ConstructCounts withDestructions (int i) const noexcept { auto c = *this; c.destructions = i; return c; } - - bool operator== (const ConstructCounts& other) const noexcept { return tie() == other.tie(); } - bool operator!= (const ConstructCounts& other) const noexcept { return tie() != other.tie(); } -}; - -String& operator<< (String& str, const ConstructCounts& c) -{ - return str << "{ constructions: " << c.constructions - << ", copies: " << c.copies - << ", moves: " << c.moves - << ", calls: " << c.calls - << ", destructions: " << c.destructions - << " }"; -} - -class FixedSizeFunctionTest : public UnitTest -{ - static void toggleBool (bool& b) { b = ! b; } - - struct ConstructCounter - { - explicit ConstructCounter (ConstructCounts& countsIn) - : counts (countsIn) {} - - ConstructCounter (const ConstructCounter& c) - : counts (c.counts) - { - counts.copies += 1; - } - - ConstructCounter (ConstructCounter&& c) noexcept - : counts (c.counts) - { - counts.moves += 1; - } - - ~ConstructCounter() noexcept { counts.destructions += 1; } - - void operator()() const noexcept { counts.calls += 1; } - - ConstructCounts& counts; - }; - -public: - FixedSizeFunctionTest() - : UnitTest ("Fixed Size Function", UnitTestCategories::dsp) - {} - - void runTest() override - { - beginTest ("Can be constructed and called from a lambda"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - const auto result = 5; - bool wasCalled = false; - const auto lambda = [&] { wasCalled = true; return result; }; - - const FixedSizeFunction fn (lambda); - const auto out = fn(); - - expect (wasCalled); - expectEquals (result, out); - } - - beginTest ("void fn can be constructed from function with return value"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - bool wasCalled = false; - const auto lambda = [&] { wasCalled = true; return 5; }; - const FixedSizeFunction fn (lambda); - - fn(); - expect (wasCalled); - } - - beginTest ("Can be constructed and called from a function pointer"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - bool state = false; - - const FixedSizeFunction fn (toggleBool); - - fn (state); - expect (state); - - fn (state); - expect (! state); - - fn (state); - expect (state); - } - - beginTest ("Default constructed functions throw if called"); - { - const auto a = FixedSizeFunction<8, void()>(); - expectThrowsType (a(), std::bad_function_call) - - const auto b = FixedSizeFunction<8, void()> (nullptr); - expectThrowsType (b(), std::bad_function_call) - } - - beginTest ("Functions can be moved"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - ConstructCounts counts; - - auto a = FixedSizeFunction (ConstructCounter { counts }); - expectEquals (counts, ConstructCounts().withMoves (1).withDestructions (1)); // The temporary gets destroyed - - a(); - expectEquals (counts, ConstructCounts().withMoves (1).withDestructions (1).withCalls (1)); - - const auto b = std::move (a); - expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (1)); - - b(); - expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (2)); - - b(); - expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (3)); - } - - beginTest ("Functions are destructed properly"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - ConstructCounts counts; - const ConstructCounter toCopy { counts }; - - { - auto a = FixedSizeFunction (toCopy); - expectEquals (counts, ConstructCounts().withCopies (1)); - } - - expectEquals (counts, ConstructCounts().withCopies (1).withDestructions (1)); - } - - beginTest ("Avoid destructing functions that fail to construct"); - { - struct BadConstructor - { - explicit BadConstructor (ConstructCounts& c) - : counts (c) - { - counts.constructions += 1; - throw std::runtime_error { "this was meant to happen" }; - } - - BadConstructor (const BadConstructor&) = default; - BadConstructor& operator= (const BadConstructor&) = delete; - - ~BadConstructor() noexcept { counts.destructions += 1; } - - void operator()() const noexcept { counts.calls += 1; } - - ConstructCounts& counts; - }; - - ConstructCounts counts; - - expectThrowsType ((FixedSizeFunction (BadConstructor { counts })), - std::runtime_error) - - expectEquals (counts, ConstructCounts().withConstructions (1)); - } - - beginTest ("Equality checks work"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - FixedSizeFunction<8, void()> a; - expect (! bool (a)); - expect (a == nullptr); - expect (nullptr == a); - expect (! (a != nullptr)); - expect (! (nullptr != a)); - - FixedSizeFunction<8, void()> b ([] {}); - expect (bool (b)); - expect (b != nullptr); - expect (nullptr != b); - expect (! (b == nullptr)); - expect (! (nullptr == b)); - } - - beginTest ("Functions can be cleared"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - FixedSizeFunction<8, void()> fn ([] {}); - expect (bool (fn)); - - fn = nullptr; - expect (! bool (fn)); - } - - beginTest ("Functions can be assigned"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - using Fn = FixedSizeFunction<8, void()>; - - int numCallsA = 0; - int numCallsB = 0; - - Fn x; - Fn y; - expect (! bool (x)); - expect (! bool (y)); - - x = [&] { numCallsA += 1; }; - y = [&] { numCallsB += 1; }; - expect (bool (x)); - expect (bool (y)); - - x(); - expectEquals (numCallsA, 1); - expectEquals (numCallsB, 0); - - y(); - expectEquals (numCallsA, 1); - expectEquals (numCallsB, 1); - - x = std::move (y); - expectEquals (numCallsA, 1); - expectEquals (numCallsB, 1); - - x(); - expectEquals (numCallsA, 1); - expectEquals (numCallsB, 2); - } - - beginTest ("Functions may mutate internal state"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - using Fn = FixedSizeFunction<64, void()>; - - Fn x; - expect (! bool (x)); - - int numCalls = 0; - x = [&numCalls, counter = 0]() mutable { counter += 1; numCalls = counter; }; - expect (bool (x)); - - expectEquals (numCalls, 0); - - x(); - expectEquals (numCalls, 1); - - x(); - expectEquals (numCalls, 2); - } - - beginTest ("Functions can sink move-only parameters"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - using Fn = FixedSizeFunction<64, int (std::unique_ptr)>; - - auto value = 5; - auto ptr = std::make_unique (value); - - Fn fn = [] (std::unique_ptr p) { return *p; }; - - expect (value == fn (std::move (ptr))); - } - - beginTest ("Functions be converted from smaller functions"); - { - JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; - - using SmallFn = FixedSizeFunction<20, void()>; - using LargeFn = FixedSizeFunction<21, void()>; - - bool smallCalled = false; - bool largeCalled = false; - - SmallFn small = [&smallCalled, a = std::array{}] { smallCalled = true; ignoreUnused (a); }; - LargeFn large = [&largeCalled, a = std::array{}] { largeCalled = true; ignoreUnused (a); }; - - large = std::move (small); - - large(); - - expect (smallCalled); - expect (! largeCalled); - } - } -}; - -FixedSizeFunctionTest fixedSizedFunctionTest; - -} -} -} -#undef JUCE_FAIL_ON_ALLOCATION_IN_SCOPE +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +#if JUCE_ENABLE_ALLOCATION_HOOKS +#define JUCE_FAIL_ON_ALLOCATION_IN_SCOPE const UnitTestAllocationChecker checker (*this) +#else +#define JUCE_FAIL_ON_ALLOCATION_IN_SCOPE +#endif + +namespace juce +{ +namespace +{ + +class ConstructCounts +{ + auto tie() const noexcept { return std::tie (constructions, copies, moves, calls, destructions); } + +public: + int constructions = 0; + int copies = 0; + int moves = 0; + int calls = 0; + int destructions = 0; + + ConstructCounts withConstructions (int i) const noexcept { auto c = *this; c.constructions = i; return c; } + ConstructCounts withCopies (int i) const noexcept { auto c = *this; c.copies = i; return c; } + ConstructCounts withMoves (int i) const noexcept { auto c = *this; c.moves = i; return c; } + ConstructCounts withCalls (int i) const noexcept { auto c = *this; c.calls = i; return c; } + ConstructCounts withDestructions (int i) const noexcept { auto c = *this; c.destructions = i; return c; } + + bool operator== (const ConstructCounts& other) const noexcept { return tie() == other.tie(); } + bool operator!= (const ConstructCounts& other) const noexcept { return tie() != other.tie(); } +}; + +String& operator<< (String& str, const ConstructCounts& c) +{ + return str << "{ constructions: " << c.constructions + << ", copies: " << c.copies + << ", moves: " << c.moves + << ", calls: " << c.calls + << ", destructions: " << c.destructions + << " }"; +} + +class FixedSizeFunctionTest final : public UnitTest +{ + static void toggleBool (bool& b) { b = ! b; } + + struct ConstructCounter + { + explicit ConstructCounter (ConstructCounts& countsIn) + : counts (countsIn) {} + + ConstructCounter (const ConstructCounter& c) + : counts (c.counts) + { + counts.copies += 1; + } + + ConstructCounter (ConstructCounter&& c) noexcept + : counts (c.counts) + { + counts.moves += 1; + } + + ~ConstructCounter() noexcept { counts.destructions += 1; } + + void operator()() const noexcept { counts.calls += 1; } + + ConstructCounts& counts; + }; + +public: + FixedSizeFunctionTest() + : UnitTest ("Fixed Size Function", UnitTestCategories::containers) + {} + + void runTest() override + { + beginTest ("Can be constructed and called from a lambda"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + const auto result = 5; + bool wasCalled = false; + const auto lambda = [&] { wasCalled = true; return result; }; + + const FixedSizeFunction fn (lambda); + const auto out = fn(); + + expect (wasCalled); + expectEquals (result, out); + } + + beginTest ("void fn can be constructed from function with return value"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + bool wasCalled = false; + const auto lambda = [&] { wasCalled = true; return 5; }; + const FixedSizeFunction fn (lambda); + + fn(); + expect (wasCalled); + } + + beginTest ("Can be constructed and called from a function pointer"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + bool state = false; + + const FixedSizeFunction fn (toggleBool); + + fn (state); + expect (state); + + fn (state); + expect (! state); + + fn (state); + expect (state); + } + + beginTest ("Default constructed functions throw if called"); + { + const auto a = FixedSizeFunction<8, void()>(); + expectThrowsType (a(), std::bad_function_call) + + const auto b = FixedSizeFunction<8, void()> (nullptr); + expectThrowsType (b(), std::bad_function_call) + } + + beginTest ("Functions can be moved"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + ConstructCounts counts; + + auto a = FixedSizeFunction (ConstructCounter { counts }); + expectEquals (counts, ConstructCounts().withMoves (1).withDestructions (1)); // The temporary gets destroyed + + a(); + expectEquals (counts, ConstructCounts().withMoves (1).withDestructions (1).withCalls (1)); + + const auto b = std::move (a); + expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (1)); + + b(); + expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (2)); + + b(); + expectEquals (counts, ConstructCounts().withMoves (2).withDestructions (1).withCalls (3)); + } + + beginTest ("Functions are destructed properly"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + ConstructCounts counts; + const ConstructCounter toCopy { counts }; + + { + auto a = FixedSizeFunction (toCopy); + expectEquals (counts, ConstructCounts().withCopies (1)); + } + + expectEquals (counts, ConstructCounts().withCopies (1).withDestructions (1)); + } + + beginTest ("Avoid destructing functions that fail to construct"); + { + struct BadConstructor + { + explicit BadConstructor (ConstructCounts& c) + : counts (c) + { + counts.constructions += 1; + throw std::runtime_error { "this was meant to happen" }; + } + + BadConstructor (const BadConstructor&) = default; + BadConstructor& operator= (const BadConstructor&) = delete; + + ~BadConstructor() noexcept { counts.destructions += 1; } + + void operator()() const noexcept { counts.calls += 1; } + + ConstructCounts& counts; + }; + + ConstructCounts counts; + + expectThrowsType ((FixedSizeFunction (BadConstructor { counts })), + std::runtime_error) + + expectEquals (counts, ConstructCounts().withConstructions (1)); + } + + beginTest ("Equality checks work"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + FixedSizeFunction<8, void()> a; + expect (! bool (a)); + expect (a == nullptr); + expect (nullptr == a); + expect (! (a != nullptr)); + expect (! (nullptr != a)); + + FixedSizeFunction<8, void()> b ([] {}); + expect (bool (b)); + expect (b != nullptr); + expect (nullptr != b); + expect (! (b == nullptr)); + expect (! (nullptr == b)); + } + + beginTest ("Functions can be cleared"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + FixedSizeFunction<8, void()> fn ([] {}); + expect (bool (fn)); + + fn = nullptr; + expect (! bool (fn)); + } + + beginTest ("Functions can be assigned"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + using Fn = FixedSizeFunction<8, void()>; + + int numCallsA = 0; + int numCallsB = 0; + + Fn x; + Fn y; + expect (! bool (x)); + expect (! bool (y)); + + x = [&] { numCallsA += 1; }; + y = [&] { numCallsB += 1; }; + expect (bool (x)); + expect (bool (y)); + + x(); + expectEquals (numCallsA, 1); + expectEquals (numCallsB, 0); + + y(); + expectEquals (numCallsA, 1); + expectEquals (numCallsB, 1); + + x = std::move (y); + expectEquals (numCallsA, 1); + expectEquals (numCallsB, 1); + + x(); + expectEquals (numCallsA, 1); + expectEquals (numCallsB, 2); + } + + beginTest ("Functions may mutate internal state"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + using Fn = FixedSizeFunction<64, void()>; + + Fn x; + expect (! bool (x)); + + int numCalls = 0; + x = [&numCalls, counter = 0]() mutable { counter += 1; numCalls = counter; }; + expect (bool (x)); + + expectEquals (numCalls, 0); + + x(); + expectEquals (numCalls, 1); + + x(); + expectEquals (numCalls, 2); + } + + beginTest ("Functions can sink move-only parameters"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + using FnA = FixedSizeFunction<64, int (std::unique_ptr)>; + + auto value = 5; + auto ptr = std::make_unique (value); + + FnA fnA = [] (std::unique_ptr p) { return *p; }; + + expect (value == fnA (std::move (ptr))); + + using FnB = FixedSizeFunction<64, void (std::unique_ptr&&)>; + + FnB fnB = [&value] (std::unique_ptr&& p) + { + auto x = std::move (p); + value = *x; + }; + + const auto newValue = 10; + fnB (std::make_unique (newValue)); + expect (value == newValue); + } + + beginTest ("Functions be converted from smaller functions"); + { + JUCE_FAIL_ON_ALLOCATION_IN_SCOPE; + + using SmallFn = FixedSizeFunction<20, void()>; + using LargeFn = FixedSizeFunction<21, void()>; + + bool smallCalled = false; + bool largeCalled = false; + + SmallFn small = [&smallCalled, a = std::array{}] { smallCalled = true; ignoreUnused (a); }; + LargeFn large = [&largeCalled, a = std::array{}] { largeCalled = true; ignoreUnused (a); }; + + large = std::move (small); + + large(); + + expect (smallCalled); + expect (! largeCalled); + } + } +}; + +FixedSizeFunctionTest fixedSizedFunctionTest; + +} +} // namespace juce +#undef JUCE_FAIL_ON_ALLOCATION_IN_SCOPE diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h index 53414156..7cc55e4d 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap.h @@ -142,7 +142,7 @@ class HashMap for (auto i = hashSlots.size(); --i >= 0;) { - auto* h = hashSlots.getUnchecked(i); + auto* h = hashSlots.getUnchecked (i); while (h != nullptr) { @@ -217,7 +217,7 @@ class HashMap const ScopedLockType sl (getLock()); for (auto i = getNumSlots(); --i >= 0;) - for (auto* entry = hashSlots.getUnchecked(i); entry != nullptr; entry = entry->nextEntry) + for (auto* entry = hashSlots.getUnchecked (i); entry != nullptr; entry = entry->nextEntry) if (entry->value == valueToLookFor) return true; @@ -269,7 +269,7 @@ class HashMap for (auto i = getNumSlots(); --i >= 0;) { - auto* entry = hashSlots.getUnchecked(i); + auto* entry = hashSlots.getUnchecked (i); HashEntry* previous = nullptr; while (entry != nullptr) @@ -311,7 +311,7 @@ class HashMap { HashEntry* nextEntry = nullptr; - for (auto* entry = hashSlots.getUnchecked(i); entry != nullptr; entry = nextEntry) + for (auto* entry = hashSlots.getUnchecked (i); entry != nullptr; entry = nextEntry) { auto hashIndex = generateHashFor (entry->key, newNumberOfSlots); diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap_test.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap_test.cpp index a95ffa14..9c07ba8b 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_HashMap_test.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_HashMap_test.cpp @@ -23,7 +23,7 @@ namespace juce { -struct HashMapTest : public UnitTest +struct HashMapTest final : public UnitTest { HashMapTest() : UnitTest ("HashMap", UnitTestCategories::containers) diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.cpp index a7c9dd8d..3404ce88 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.cpp @@ -25,7 +25,7 @@ namespace juce #if JUCE_UNIT_TESTS -class ListenerListTests : public UnitTest +class ListenerListTests final : public UnitTest { public: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.h b/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.h index 5f657a07..2908f1c3 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ListenerList.h @@ -114,6 +114,18 @@ class ListenerList }); } + /** Adds a listener that will be automatically removed again when the Guard is destroyed. + + Be very careful to ensure that the ErasedScopeGuard is destroyed or released before the + ListenerList is destroyed, otherwise the ErasedScopeGuard may attempt to dereference a + dangling pointer when it is destroyed, which will result in a crash. + */ + ErasedScopeGuard addScoped (ListenerClass& listenerToAdd) + { + add (&listenerToAdd); + return ErasedScopeGuard { [this, &listenerToAdd] { remove (&listenerToAdd); } }; + } + /** Returns the number of registered listeners. */ int size() const noexcept { return listeners.size(); } @@ -248,18 +260,18 @@ class ListenerList //============================================================================== #ifndef DOXYGEN - void call (void (ListenerClass::*callbackFunction) ()) + void call (void (ListenerClass::*callbackFunction)()) { call ([=] (ListenerClass& l) { (l.*callbackFunction)(); }); } - void callExcluding (ListenerClass* listenerToExclude, void (ListenerClass::*callbackFunction) ()) + void callExcluding (ListenerClass* listenerToExclude, void (ListenerClass::*callbackFunction)()) { callExcluding (listenerToExclude, [=] (ListenerClass& l) { (l.*callbackFunction)(); }); } template - void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) ()) + void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction)()) { callChecked (bailOutChecker, [=] (ListenerClass& l) { (l.*callbackFunction)(); }); } @@ -267,7 +279,7 @@ class ListenerList template void callCheckedExcluding (ListenerClass* listenerToExclude, const BailOutCheckerType& bailOutChecker, - void (ListenerClass::*callbackFunction) ()) + void (ListenerClass::*callbackFunction)()) { callCheckedExcluding (listenerToExclude, bailOutChecker, [=] (ListenerClass& l) { (l.*callbackFunction)(); }); } diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp index 079a3c07..1058e2c9 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -96,9 +96,9 @@ bool NamedValueSet::operator== (const NamedValueSet& other) const noexcept for (int i = 0; i < num; ++i) { // optimise for the case where the keys are in the same order - if (values.getReference(i).name == other.values.getReference(i).name) + if (values.getReference (i).name == other.values.getReference (i).name) { - if (values.getReference(i).value != other.values.getReference(i).value) + if (values.getReference (i).value != other.values.getReference (i).value) return false; } else @@ -106,8 +106,8 @@ bool NamedValueSet::operator== (const NamedValueSet& other) const noexcept // if we encounter keys that are in a different order, search remaining items by brute force.. for (int j = i; j < num; ++j) { - if (auto* otherVal = other.getVarPointer (values.getReference(j).name)) - if (values.getReference(j).value == *otherVal) + if (auto* otherVal = other.getVarPointer (values.getReference (j).name)) + if (values.getReference (j).value == *otherVal) continue; return false; @@ -205,7 +205,7 @@ int NamedValueSet::indexOf (const Identifier& name) const noexcept auto numValues = values.size(); for (int i = 0; i < numValues; ++i) - if (values.getReference(i).name == name) + if (values.getReference (i).name == name) return i; return -1; @@ -217,7 +217,7 @@ bool NamedValueSet::remove (const Identifier& name) for (int i = 0; i < numValues; ++i) { - if (values.getReference(i).name == name) + if (values.getReference (i).name == name) { values.remove (i); return true; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Optional_test.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_Optional_test.cpp index b3e10de8..9853fb31 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Optional_test.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Optional_test.cpp @@ -31,7 +31,7 @@ struct ThrowOnMoveOrSwap }; static void swap (ThrowOnMoveOrSwap&, ThrowOnMoveOrSwap&) { throw std::bad_alloc{}; } -class OptionalUnitTest : public UnitTest +class OptionalUnitTest final : public UnitTest { public: OptionalUnitTest() : UnitTest ("Optional", UnitTestCategories::containers) {} @@ -297,7 +297,7 @@ class OptionalUnitTest : public UnitTest } struct Foo {}; - struct Bar : Foo {}; + struct Bar final : public Foo {}; beginTest ("Can be constructed from compatible type"); { diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.cpp index e452a561..1dc0caae 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_OwnedArray.cpp @@ -35,7 +35,7 @@ static struct OwnedArrayTest : public UnitTest JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Base) }; - struct Derived : Base + struct Derived final : public Base { Derived() = default; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.cpp index 313dbd9a..28ecb3ba 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_ReferenceCountedArray.cpp @@ -25,7 +25,7 @@ namespace juce #if JUCE_UNIT_TESTS -class ReferenceCountedArrayTests : public UnitTest +class ReferenceCountedArrayTests final : public UnitTest { public: ReferenceCountedArrayTests() @@ -134,7 +134,7 @@ class ReferenceCountedArrayTests : public UnitTest JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TestBaseObj) }; - struct TestDerivedObj : public TestBaseObj + struct TestDerivedObj final : public TestBaseObj { using Ptr = ReferenceCountedObjectPtr; @@ -143,7 +143,7 @@ class ReferenceCountedArrayTests : public UnitTest JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TestDerivedObj) }; - struct DestructorObj : public ReferenceCountedObject + struct DestructorObj final : public ReferenceCountedObject { DestructorObj (ReferenceCountedArrayTests& p, ReferenceCountedArray& arr) diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.cpp index cddd96d9..cb7e184a 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.cpp @@ -25,7 +25,7 @@ namespace juce #if JUCE_UNIT_TESTS -class SparseSetTests : public UnitTest +class SparseSetTests final : public UnitTest { public: SparseSetTests() diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h index 0dcff925..6343421d 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_SparseSet.h @@ -161,7 +161,7 @@ class SparseSet { for (int i = ranges.size(); --i >= 0;) { - auto& r = ranges.getReference(i); + auto& r = ranges.getReference (i); if (r.getEnd() <= rangeToRemove.getStart()) break; diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp index 12b1394f..ff4e5d1c 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.cpp @@ -314,7 +314,7 @@ struct var::VariantType static var objectClone (const var& original) { if (auto* d = original.getDynamicObject()) - return d->clone().get(); + return d->clone().release(); jassertfalse; // can only clone DynamicObjects! return {}; @@ -401,7 +401,7 @@ struct var::VariantType } } - struct RefCountedArray : public ReferenceCountedObject + struct RefCountedArray final : public ReferenceCountedObject { RefCountedArray (const Array& a) : array (a) { incReferenceCount(); } RefCountedArray (Array&& a) : array (std::move (a)) { incReferenceCount(); } diff --git a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h index d83df094..d9a43bf3 100644 --- a/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h +++ b/JuceLibraryCode/modules/juce_core/containers/juce_Variant.h @@ -340,26 +340,4 @@ JUCE_API bool operator== (const var&, const String&); JUCE_API bool operator!= (const var&, const String&); JUCE_API bool operator== (const var&, const char*); JUCE_API bool operator!= (const var&, const char*); - -//============================================================================== -/** This template-overloaded class can be used to convert between var and custom types. - - @tags{Core} -*/ -template -struct VariantConverter -{ - static Type fromVar (const var& v) { return static_cast (v); } - static var toVar (const Type& t) { return t; } -}; - -#ifndef DOXYGEN -template <> -struct VariantConverter -{ - static String fromVar (const var& v) { return v.toString(); } - static var toVar (const String& s) { return s; } -}; -#endif - } // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/files/juce_File.cpp b/JuceLibraryCode/modules/juce_core/files/juce_File.cpp index 43e226e3..486c61d3 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_File.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_File.cpp @@ -1037,7 +1037,7 @@ MemoryMappedFile::MemoryMappedFile (const File& file, const Range& fileRa //============================================================================== #if JUCE_UNIT_TESTS -class FileTests : public UnitTest +class FileTests final : public UnitTest { public: FileTests() @@ -1055,7 +1055,7 @@ class FileTests : public UnitTest expect (! File().existsAsFile()); expect (! File().isDirectory()); #if ! JUCE_WINDOWS - expect (File("/").isDirectory()); + expect (File ("/").isDirectory()); #endif expect (home.isDirectory()); expect (home.exists()); diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp index 8a40a47d..5a658191 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileInputStream.cpp @@ -81,7 +81,7 @@ bool FileInputStream::setPosition (int64 pos) //============================================================================== #if JUCE_UNIT_TESTS -struct FileInputStreamTests : public UnitTest +struct FileInputStreamTests final : public UnitTest { FileInputStreamTests() : UnitTest ("FileInputStream", UnitTestCategories::streams) diff --git a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp index 9b786ac0..9a0a5350 100644 --- a/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp +++ b/JuceLibraryCode/modules/juce_core/files/juce_FileSearchPath.cpp @@ -190,7 +190,7 @@ bool FileSearchPath::isFileInPath (const File& fileToCheck, //============================================================================== #if JUCE_UNIT_TESTS -class FileSearchPathTests : public UnitTest +class FileSearchPathTests final : public UnitTest { public: FileSearchPathTests() : UnitTest ("FileSearchPath", UnitTestCategories::files) {} diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_JSON.cpp b/JuceLibraryCode/modules/juce_core/javascript/juce_JSON.cpp index c7d96633..aa1394dc 100644 --- a/JuceLibraryCode/modules/juce_core/javascript/juce_JSON.cpp +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_JSON.cpp @@ -431,7 +431,7 @@ struct JSONFormatter if (! allOnOneLine) writeSpaces (out, indentLevel + indentSize); - write (out, array.getReference(i), indentLevel + indentSize, allOnOneLine, maximumDecimalPlaces); + write (out, array.getReference (i), indentLevel + indentSize, allOnOneLine, maximumDecimalPlaces); if (i < array.size() - 1) { @@ -545,7 +545,7 @@ Result JSON::parseQuotedString (String::CharPointerType& t, var& result) //============================================================================== #if JUCE_UNIT_TESTS -class JSONTests : public UnitTest +class JSONTests final : public UnitTest { public: JSONTests() diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation.h b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation.h new file mode 100644 index 00000000..3d441b4c --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation.h @@ -0,0 +1,532 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/** + Options that control conversion from arbitrary types to juce::var. + + @see ToVar + + @tags{Core} +*/ +class ToVarOptions +{ +public: + /** By default, conversion will serialise the type using the marshallingVersion defined for + that type. Setting an explicit version allows the type to be serialised as an earlier + version. + */ + [[nodiscard]] ToVarOptions withExplicitVersion (std::optional x) const { return withMember (*this, &ToVarOptions::explicitVersion, x); } + + /** By default, conversion will include version information for any type with a non-null + marshallingVersion. Setting versionIncluded to false will cause the version info to be + omitted, which is useful in situations where the version information is not needed + (e.g. when presenting transient information to the user, rather than writing data to + disk that must be deserialised in the future). + */ + [[nodiscard]] ToVarOptions withVersionIncluded (bool x) const { return withMember (*this, &ToVarOptions::versionIncluded, x); } + + /** @see withExplicitVersion() */ + [[nodiscard]] auto getExplicitVersion() const { return explicitVersion; } + + /** @see withVersionIncluded(). */ + [[nodiscard]] auto getVersionIncluded() const { return versionIncluded; } + +private: + std::optional> explicitVersion; + bool versionIncluded = true; +}; + +/** + Allows converting an object of arbitrary type to var. + + To use this, you must first ensure that the type passed to convert is set up for serialisation. + For details of what this entails, see the docs for SerialisationTraits. + + In short, the constant 'marshallingVersion', and either the single function 'serialise()', or + the function pair 'load()' and 'save()' must be defined for the type. These may be defined + as public members of the type T itself, or as public members of juce::SerialisationTraits, + which is a specialisation of the SerialisationTraits template struct for the type T. + + @see FromVar + + @tags{Core} +*/ +class ToVar +{ +public: + using Options = ToVarOptions; + + /** Attempts to convert the argument to a var using the serialisation utilities specified for + that type. + + This will return a non-null optional if conversion succeeds, or nullopt if conversion fails. + */ + template + static std::optional convert (const T& t, const Options& options = {}) + { + return Visitor::convert (t, options); + } + +private: + class Visitor + { + public: + template + static std::optional convert (const T& t, const Options& options) + { + constexpr auto fallbackVersion = detail::ForwardingSerialisationTraits::marshallingVersion; + const auto versionToUse = options.getExplicitVersion() + .value_or (fallbackVersion); + + if (versionToUse > fallbackVersion) + { + // The requested explicit version is higher than the declared version of the type. + return std::nullopt; + } + + Visitor visitor { versionToUse, options.getVersionIncluded() }; + detail::doSave (visitor, t); + return visitor.value; + } + + std::optional getVersion() const { return version; } + + template + void operator() (Ts&&... ts) + { + (visit (std::forward (ts)), ...); + } + + private: + Visitor (const std::optional& explicitVersion, bool includeVersion) + : version (explicitVersion), + value ([&]() -> var + { + if (! (version.has_value() && includeVersion)) + return var(); + + auto obj = std::make_unique(); + obj->setProperty ("__version__", *version); + return obj.release(); + }()), + versionIncluded (includeVersion) {} + + template + void visit (const T& t) + { + if constexpr (std::is_integral_v) + { + push ((int64) t); + } + else if constexpr (std::is_floating_point_v) + { + push ((double) t); + } + else if (auto converted = convert (t)) + { + push (*converted); + } + else + { + value.reset(); + } + } + + template + void visit (const Named& named) + { + if (! value.has_value()) + return; + + if (value == var()) + value = new DynamicObject; + + auto* obj = value->getDynamicObject(); + + if (obj == nullptr) + { + // Serialisation failure! This may be caused by archiving a primitive or + // SerialisationSize, and then attempting to archive a named pair to the same + // archive instance. + // When using named pairs, *all* items serialised with a particular archiver must be + // named pairs. + jassertfalse; + + value.reset(); + return; + } + + if (! trySetProperty (*obj, named)) + value.reset(); + } + + template + void visit (const SerialisationSize&) + { + push (Array{}); + } + + void visit (const bool& t) + { + push (t); + } + + void visit (const String& t) + { + push (t); + } + + void visit (const var& t) + { + push (t); + } + + template + std::optional convert (const T& t) + { + return convert (t, Options{}.withVersionIncluded (versionIncluded)); + } + + void push (var v) + { + if (! value.has_value()) + return; + + if (*value == var()) + *value = v; + else if (auto* array = value->getArray()) + array->add (v); + else + value.reset(); + } + + template + bool trySetProperty (DynamicObject& obj, const Named& n) + { + if (const auto converted = convert (n.value)) + { + obj.setProperty (Identifier (std::string (n.name)), *converted); + return true; + } + + return false; + } + + std::optional version; + std::optional value; + bool versionIncluded = true; + }; +}; + +//============================================================================== +/** + Allows converting a var to an object of arbitrary type. + + To use this, you must first ensure that the type passed to convert is set up for serialisation. + For details of what this entails, see the docs for SerialisationTraits. + + In short, the constant 'marshallingVersion', and either the single function 'serialise()', or + the function pair 'load()' and 'save()' must be defined for the type. These may be defined + as public members of the type T itself, or as public members of juce::SerialisationTraits, + which is a specialisation of the SerialisationTraits template struct for the type T. + + @see ToVar + + @tags{Core} +*/ +class FromVar +{ +public: + /** Attempts to convert a var to an instance of type T. + + This will return a non-null optional if conversion succeeds, or nullopt if conversion fails. + */ + template + static std::optional convert (const var& v) + { + return Visitor::convert (v); + } + +private: + class Visitor + { + public: + template + static std::optional convert (const var& v) + { + const auto version = [&]() -> std::optional + { + if (auto* obj = v.getDynamicObject()) + if (obj->hasProperty ("__version__")) + return (int) obj->getProperty ("__version__"); + + return std::nullopt; + }(); + + Visitor visitor { version, v }; + T t{}; + detail::doLoad (visitor, t); + return ! visitor.failed ? std::optional (std::move (t)) + : std::nullopt; + } + + std::optional getVersion() const { return version; } + + template + void operator() (Ts&&... ts) + { + (visit (std::forward (ts)), ...); + } + + private: + Visitor (std::optional vn, const var& i) + : version (vn), input (i) {} + + template + void visit (T& t) + { + if constexpr (std::is_integral_v) + { + readPrimitive (std::in_place_type, t); + } + else if constexpr (std::is_floating_point_v) + { + readPrimitive (std::in_place_type, t); + } + else + { + auto node = getNodeToRead(); + + if (! node.has_value()) + return; + + auto converted = convert (*node); + + if (converted.has_value()) + t = *converted; + else + failed = true; + } + } + + template + void visit (const Named& named) + { + auto node = getNodeToRead(); + + if (! node.has_value()) + return; + + auto* obj = node->getDynamicObject(); + + failed = obj == nullptr || ! tryGetProperty (*obj, named); + } + + template + void visit (const SerialisationSize& t) + { + if (failed) + return; + + if (auto* array = input.getArray()) + { + t.size = static_cast (array->size()); + currentArrayIndex = 0; + } + else + { + failed = true; + } + } + + void visit (bool& t) + { + readPrimitive (std::in_place_type, t); + } + + void visit (String& t) + { + readPrimitive (std::in_place_type, t); + } + + void visit (var& t) + { + t = input; + } + + static std::optional pullTyped (std::in_place_type_t, const var& source) + { + return source.isDouble() ? std::optional ((double) source) : std::nullopt; + } + + static std::optional pullTyped (std::in_place_type_t, const var& source) + { + return source.isInt() || source.isInt64() ? std::optional ((int64) source) : std::nullopt; + } + + static std::optional pullTyped (std::in_place_type_t, const var& source) + { + return std::optional ((bool) source); + } + + static std::optional pullTyped (std::in_place_type_t, const var& source) + { + return source.isString() ? std::optional (source.toString()) : std::nullopt; + } + + std::optional getNodeToRead() + { + if (failed) + return std::nullopt; + + if (currentArrayIndex == std::numeric_limits::max()) + return input; + + const auto* array = input.getArray(); + + if (array == nullptr) + return input; + + if ((int) currentArrayIndex < array->size()) + return array->getReference ((int) currentArrayIndex++); + + failed = true; + return std::nullopt; + } + + template + void readPrimitive (std::in_place_type_t tag, T& t) + { + auto node = getNodeToRead(); + + if (! node.has_value()) + return; + + auto typed = pullTyped (tag, *node); + + if (typed.has_value()) + t = static_cast (*typed); + else + failed = true; + } + + template + static bool tryGetProperty (const DynamicObject& obj, const Named& n) + { + const Identifier identifier (String (n.name.data(), n.name.size())); + + if (! obj.hasProperty (identifier)) + return false; + + const auto converted = convert (obj.getProperty (identifier)); + + if (! converted.has_value()) + return false; + + n.value = *converted; + return true; + } + + std::optional version; + var input; + size_t currentArrayIndex = std::numeric_limits::max(); + bool failed = false; + }; +}; + +//============================================================================== +/** + This template-overloaded class can be used to convert between var and custom types. + + If not specialised, the variant converter will attempt to use serialisation functions + if they are detected for the given type. + For details of what this entails, see the docs for SerialisationTraits. + + In short, the constant 'marshallingVersion', and either the single function 'serialise()', or + the function pair 'load()' and 'save()' must be defined for the type. These may be defined + as public members of the type T itself, or as public members of juce::SerialisationTraits, + which is a specialisation of the SerialisationTraits template struct for the type T. + + @see ToVar, FromVar + + @tags{Core} +*/ +template +struct VariantConverter +{ + static Type fromVar (const var& v) + { + return static_cast (v); + } + + static var toVar (const Type& t) + { + return t; + } +}; + +#ifndef DOXYGEN + +template <> +struct VariantConverter +{ + static String fromVar (const var& v) { return v.toString(); } + static var toVar (const String& s) { return s; } +}; + +#endif + +/** + A helper type that can be used to implement specialisations of VariantConverter that use + FromVar::convert and ToVar::convert internally. + + If you've already implemented SerialisationTraits for a specific type, and don't want to write + a custom VariantConverter that duplicates that implementation, you can instead write: + @code + template <> + struct juce::VariantConverter : public juce::StrictVariantConverter {}; + @endcode +*/ +template +struct StrictVariantConverter +{ + static_assert (detail::serialisationKind != detail::SerialisationKind::none); + + static Type fromVar (const var& v) + { + auto converted = FromVar::convert (v); + jassert (converted.has_value()); + return std::move (converted).value_or (Type{}); + } + + static var toVar (const Type& t) + { + auto converted = ToVar::convert<> (t); + jassert (converted.has_value()); + return std::move (converted).value_or (var{}); + } +}; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation_test.cpp b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation_test.cpp new file mode 100644 index 00000000..61b99ab0 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONSerialisation_test.cpp @@ -0,0 +1,614 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +struct TypeWithExternalUnifiedSerialisation +{ + int a; + std::string b; + std::vector c; + std::map d; + + auto operator== (const TypeWithExternalUnifiedSerialisation& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.a, x.b, x.c, x.d); }; + return tie (*this) == tie (other); + } + + auto operator!= (const TypeWithExternalUnifiedSerialisation& other) const { return ! operator== (other); } +}; + +template <> +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = 2; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("a", t.a), + named ("b", t.b), + named ("c", t.c), + named ("d", t.d)); + } +}; + +// Now that the serialiser trait is visible, it should be detected +static_assert (detail::serialisationKind == detail::SerialisationKind::external); + +struct TypeWithInternalUnifiedSerialisation +{ + double a; + float b; + String c; + StringArray d; + + auto operator== (const TypeWithInternalUnifiedSerialisation& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.a, x.b, x.c, x.d); }; + return tie (*this) == tie (other); + } + + auto operator!= (const TypeWithInternalUnifiedSerialisation& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = 5; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("a", t.a), + named ("b", t.b), + named ("c", t.c), + named ("d", t.d)); + } +}; + +static_assert (detail::serialisationKind == detail::SerialisationKind::internal); + +struct TypeWithExternalSplitSerialisation +{ + std::optional a; + Array b; + + auto operator== (const TypeWithExternalSplitSerialisation& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.a, x.b); }; + return tie (*this) == tie (other); + } + + auto operator!= (const TypeWithExternalSplitSerialisation& other) const { return ! operator== (other); } +}; + +template <> +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = 10; + + template + static void load (Archive& archive, TypeWithExternalSplitSerialisation& t) + { + std::optional a; + Array hexStrings; + archive (named ("a", a), named ("b", hexStrings)); + + Array b; + + for (auto& i : hexStrings) + b.add (i.getHexValue32()); + + t = { a, b }; + } + + template + static void save (Archive& archive, const TypeWithExternalSplitSerialisation& t) + { + Array hexStrings; + + for (auto& i : t.b) + hexStrings.add ("0x" + String::toHexString (i)); + + archive (named ("a", t.a), named ("b", hexStrings)); + } +}; + +// Now that the serialiser trait is visible, it should be detected +static_assert (detail::serialisationKind == detail::SerialisationKind::external); + +// Check that serialisation kinds are correctly detected for primitives +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind< int8_t> == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind< uint8_t> == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind< int16_t> == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind< int32_t> == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind< int64_t> == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); +static_assert (detail::serialisationKind == detail::SerialisationKind::primitive); + +// Check that serialisation is disabled for types with no serialsation defined +static_assert (detail::serialisationKind == detail::SerialisationKind::none); +static_assert (detail::serialisationKind == detail::SerialisationKind::none); + +struct TypeWithInternalSplitSerialisation +{ + std::string a; + Array b; + + auto operator== (const TypeWithInternalSplitSerialisation& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.a, x.b); }; + return tie (*this) == tie (other); + } + + auto operator!= (const TypeWithInternalSplitSerialisation& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = 1; + + template + static void load (Archive& archive, TypeWithInternalSplitSerialisation& t) + { + std::string a; + Array hexStrings; + archive (named ("a", a), named ("b", hexStrings)); + + Array b; + + for (auto& i : hexStrings) + b.add (i.getHexValue32()); + + t = { a, b }; + } + + template + static void save (Archive& archive, const TypeWithInternalSplitSerialisation& t) + { + Array hexStrings; + + for (auto& i : t.b) + hexStrings.add ("0x" + String::toHexString (i)); + + archive (named ("a", t.a), named ("b", hexStrings)); + } +}; + +static_assert (detail::serialisationKind == detail::SerialisationKind::internal); + +struct TypeWithBrokenObjectSerialisation +{ + int a; + int b; + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + // Archiving a named value will start reading/writing an object + archive (named ("a", t.a)); + // Archiving a non-named value will assume that the current node is convertible + archive (t.b); + } +}; + +struct TypeWithBrokenPrimitiveSerialisation +{ + int a; + int b; + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + // Archiving a non-named value will assume that the current node is convertible + archive (t.a); + // Archiving a named value will fail if the current node holds a non-object type + archive (named ("b", t.b)); + } +}; + +struct TypeWithBrokenArraySerialisation +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T&) + { + size_t size = 5; + archive (size); + + // serialisationSize should always be serialised first! + archive (serialisationSize (size)); + } +}; + +struct TypeWithBrokenNestedSerialisation +{ + int a; + TypeWithBrokenObjectSerialisation b; + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("a", t.a), named ("b", t.b)); + } +}; + +struct TypeWithBrokenDynamicSerialisation +{ + std::vector a; + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (t.a); + } +}; + +struct TypeWithVersionedSerialisation +{ + int a{}, b{}, c{}, d{}; + + bool operator== (const TypeWithVersionedSerialisation& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.a, x.b, x.c, x.d); }; + return tie (*this) == tie (other); + } + + bool operator!= (const TypeWithVersionedSerialisation& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = 3; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("a", t.a)); + + if (archive.getVersion() >= 1) + archive (named ("b", t.b)); + + if (archive.getVersion() >= 2) + archive (named ("c", t.c)); + + if (archive.getVersion() >= 3) + archive (named ("d", t.d)); + } +}; + +struct TypeWithRawVarLast +{ + int status = 0; + String message; + var extended; + + bool operator== (const TypeWithRawVarLast& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.status, x.message, x.extended); }; + return tie (*this) == tie (other); + } + + bool operator!= (const TypeWithRawVarLast& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("status", t.status), + named ("message", t.message), + named ("extended", t.extended)); + } +}; + +struct TypeWithRawVarFirst +{ + int status = 0; + String message; + var extended; + + bool operator== (const TypeWithRawVarFirst& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.status, x.message, x.extended); }; + return tie (*this) == tie (other); + } + + bool operator!= (const TypeWithRawVarFirst& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("extended", t.extended), + named ("status", t.status), + named ("message", t.message)); + } +}; + +struct TypeWithInnerVar +{ + int eventId = 0; + var payload; + + bool operator== (const TypeWithInnerVar& other) const + { + const auto tie = [] (const auto& x) { return std::tie (x.eventId, x.payload); }; + return tie (*this) == tie (other); + } + + bool operator!= (const TypeWithInnerVar& other) const { return ! operator== (other); } + + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("eventId", t.eventId), + named ("payload", t.payload)); + } +}; + +class JSONSerialisationTest final : public UnitTest +{ +public: + JSONSerialisationTest() : UnitTest ("JSONSerialisation", UnitTestCategories::json) {} + + void runTest() override + { + beginTest ("ToVar"); + { + expectDeepEqual (ToVar::convert (false), false); + expectDeepEqual (ToVar::convert (true), true); + expectDeepEqual (ToVar::convert (1), 1); + expectDeepEqual (ToVar::convert (5.0f), 5.0); + expectDeepEqual (ToVar::convert (6LL), 6); + expectDeepEqual (ToVar::convert ("hello world"), "hello world"); + expectDeepEqual (ToVar::convert (String ("hello world")), "hello world"); + expectDeepEqual (ToVar::convert (std::vector { 1, 2, 3 }), Array { 1, 2, 3 }); + expectDeepEqual (ToVar::convert (TypeWithExternalUnifiedSerialisation { 7, + "hello world", + { 5, 6, 7 }, + { { "foo", 4 }, { "bar", 5 } } }), + JSONUtils::makeObject ({ { "__version__", 2 }, + { "a", 7 }, + { "b", "hello world" }, + { "c", Array { 5, 6, 7 } }, + { "d", + Array { JSONUtils::makeObject ({ { "first", "bar" }, + { "second", 5 } }), + JSONUtils::makeObject ({ { "first", "foo" }, + { "second", 4 } }) } } })); + expectDeepEqual (ToVar::convert (TypeWithInternalUnifiedSerialisation { 7.89, + 4.321f, + "custom string", + { "foo", "bar", "baz" } }), + JSONUtils::makeObject ({ { "__version__", 5 }, + { "a", 7.89 }, + { "b", 4.321f }, + { "c", "custom string" }, + { "d", Array { "foo", "bar", "baz" } } })); + expectDeepEqual (ToVar::convert (TypeWithExternalSplitSerialisation { "string", { 1, 2, 3 } }), + JSONUtils::makeObject ({ { "__version__", 10 }, + { "a", JSONUtils::makeObject ({ { "engaged", true }, { "value", "string" } }) }, + { "b", Array { "0x1", "0x2", "0x3" } } })); + expectDeepEqual (ToVar::convert (TypeWithInternalSplitSerialisation { "string", { 16, 32, 48 } }), + JSONUtils::makeObject ({ { "__version__", 1 }, + { "a", "string" }, + { "b", Array { "0x10", "0x20", "0x30" } } })); + + expect (ToVar::convert (TypeWithBrokenObjectSerialisation { 1, 2 }) == std::nullopt); + expect (ToVar::convert (TypeWithBrokenPrimitiveSerialisation { 1, 2 }) == std::nullopt); + expect (ToVar::convert (TypeWithBrokenArraySerialisation {}) == std::nullopt); + expect (ToVar::convert (TypeWithBrokenNestedSerialisation {}) == std::nullopt); + expect (ToVar::convert (TypeWithBrokenDynamicSerialisation { std::vector (10) }) == std::nullopt); + + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }), + JSONUtils::makeObject ({ { "__version__", 3 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 }, + { "d", 4 } })); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withVersionIncluded (false)), + JSONUtils::makeObject ({ { "a", 1 }, + { "b", 2 }, + { "c", 3 }, + { "d", 4 } })); + // Requested explicit version is higher than the type's declared version + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (4)), + std::nullopt); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (3)), + JSONUtils::makeObject ({ { "__version__", 3 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 }, + { "d", 4 } })); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (2)), + JSONUtils::makeObject ({ { "__version__", 2 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 } })); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (1)), + JSONUtils::makeObject ({ { "__version__", 1 }, + { "a", 1 }, + { "b", 2 } })); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (0)), + JSONUtils::makeObject ({ { "__version__", 0 }, + { "a", 1 } })); + expectDeepEqual (ToVar::convert (TypeWithVersionedSerialisation { 1, 2, 3, 4 }, ToVar::Options {}.withExplicitVersion (std::nullopt)), + JSONUtils::makeObject ({ { "a", 1 } })); + + expectDeepEqual (ToVar::convert (TypeWithRawVarLast { 200, "success", true }), + JSONUtils::makeObject ({ { "status", 200 }, { "message", "success" }, { "extended", true } })); + expectDeepEqual (ToVar::convert (TypeWithRawVarLast { 200, + "success", + JSONUtils::makeObject ({ { "status", 123.456 }, + { "message", "failure" }, + { "extended", true } }) }), + JSONUtils::makeObject ({ { "status", 200 }, + { "message", "success" }, + { "extended", JSONUtils::makeObject ({ { "status", 123.456 }, + { "message", "failure" }, + { "extended", true } }) } })); + + expectDeepEqual (ToVar::convert (TypeWithRawVarFirst { 200, "success", true }), + JSONUtils::makeObject ({ { "status", 200 }, { "message", "success" }, { "extended", true } })); + expectDeepEqual (ToVar::convert (TypeWithRawVarFirst { 200, + "success", + JSONUtils::makeObject ({ { "status", 123.456 }, + { "message", "failure" }, + { "extended", true } }) }), + JSONUtils::makeObject ({ { "status", 200 }, + { "message", "success" }, + { "extended", JSONUtils::makeObject ({ { "status", 123.456 }, + { "message", "failure" }, + { "extended", true } }) } })); + + const auto payload = JSONUtils::makeObject ({ { "foo", 1 }, { "bar", 2 } }); + expectDeepEqual (ToVar::convert (TypeWithInnerVar { 404, payload }), + JSONUtils::makeObject ({ { "eventId", 404 }, { "payload", payload } })); + } + + beginTest ("FromVar"); + { + expect (FromVar::convert (JSON::fromString ("false")) == false); + expect (FromVar::convert (JSON::fromString ("true")) == true); + expect (FromVar::convert (JSON::fromString ("0")) == false); + expect (FromVar::convert (JSON::fromString ("1")) == true); + expect (FromVar::convert (JSON::fromString ("1")) == 1); + expect (FromVar::convert (JSON::fromString ("5.0f")) == 5.0f); + expect (FromVar::convert (JSON::fromString ("6")) == 6); + expect (FromVar::convert (JSON::fromString ("\"hello world\"")) == "hello world"); + expect (FromVar::convert> (JSON::fromString ("[1,2,3]")) == std::vector { 1, 2, 3 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 2 }, + { "a", 7 }, + { "b", "hello world" }, + { "c", Array { 5, 6, 7 } }, + { "d", + Array { JSONUtils::makeObject ({ { "first", "bar" }, + { "second", 5 } }), + JSONUtils::makeObject ({ { "first", "foo" }, + { "second", 4 } }) } } })) + == TypeWithExternalUnifiedSerialisation { 7, + "hello world", + { 5, 6, 7 }, + { { "foo", 4 }, { "bar", 5 } } }); + + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 5 }, + { "a", 7.89 }, + { "b", 4.321f }, + { "c", "custom string" }, + { "d", Array { "foo", "bar", "baz" } } })) + == TypeWithInternalUnifiedSerialisation { 7.89, + 4.321f, + "custom string", + { "foo", "bar", "baz" } }); + + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 10 }, + { "a", JSONUtils::makeObject ({ { "engaged", true }, { "value", "string" } }) }, + { "b", Array { "0x1", "0x2", "0x3" } } })) + == TypeWithExternalSplitSerialisation { "string", { 1, 2, 3 } }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 1 }, + { "a", "string" }, + { "b", Array { "0x10", "0x20", "0x30" } } })) + == TypeWithInternalSplitSerialisation { "string", { 16, 32, 48 } }); + + expect (FromVar::convert (JSON::fromString ("null")) == std::nullopt); + expect (FromVar::convert (JSON::fromString ("null")) == std::nullopt); + expect (FromVar::convert (JSON::fromString ("null")) == std::nullopt); + expect (FromVar::convert (JSON::fromString ("null")) == std::nullopt); + expect (FromVar::convert (JSON::fromString ("null")) == std::nullopt); + + expect (FromVar::convert (JSONUtils::makeObject ({ { "a", 7.89 }, + { "b", 4.321f } })) + == std::nullopt); + + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 3 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 }, + { "d", 4 } })) + == TypeWithVersionedSerialisation { 1, 2, 3, 4 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 4 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 }, + { "d", 4 } })) + == TypeWithVersionedSerialisation { 1, 2, 3, 4 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 2 }, + { "a", 1 }, + { "b", 2 }, + { "c", 3 } })) + == TypeWithVersionedSerialisation { 1, 2, 3, 0 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 1 }, + { "a", 1 }, + { "b", 2 } })) + == TypeWithVersionedSerialisation { 1, 2, 0, 0 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "__version__", 0 }, + { "a", 1 } })) + == TypeWithVersionedSerialisation { 1, 0, 0, 0 }); + expect (FromVar::convert (JSONUtils::makeObject ({ { "a", 1 } })) + == TypeWithVersionedSerialisation { 1, 0, 0, 0 }); + + const auto raw = JSONUtils::makeObject ({ { "status", 200 }, { "message", "success" }, { "extended", "another string" } }); + expect (FromVar::convert (raw) == TypeWithRawVarLast { 200, "success", "another string" }); + expect (FromVar::convert (raw) == TypeWithRawVarFirst { 200, "success", "another string" }); + + const var payloads[] { JSONUtils::makeObject ({ { "foo", 1 }, { "bar", 2 } }), + var (Array { 1, 2 }), + var() }; + + for (const auto& payload : payloads) + { + const auto objectWithPayload = JSONUtils::makeObject ({ { "eventId", 404 }, { "payload", payload } }); + expect (FromVar::convert (objectWithPayload) == TypeWithInnerVar { 404, payload }); + } + } + } + +private: + void expectDeepEqual (const std::optional& a, const std::optional& b) + { + expect (deepEqual (a, b), a.has_value() && b.has_value() ? JSON::toString (*a) + " != " + JSON::toString (*b) : String()); + } + + static bool deepEqual (const std::optional& a, const std::optional& b) + { + if (a.has_value() && b.has_value()) + return JSONUtils::deepEqual (*a, *b); + + return a == b; + } +}; + +static JSONSerialisationTest jsonSerialisationTest; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.cpp b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.cpp new file mode 100644 index 00000000..cfc984c3 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.cpp @@ -0,0 +1,215 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +var JSONUtils::makeObject (const std::map& source) +{ + auto result = std::make_unique(); + + for (const auto& [name, value] : source) + result->setProperty (name, value); + + return var (result.release()); +} + +var JSONUtils::makeObjectWithKeyFirst (const std::map& source, + Identifier key) +{ + auto result = std::make_unique(); + + if (const auto iter = source.find (key); iter != source.end()) + result->setProperty (key, iter->second); + + for (const auto& [name, value] : source) + if (name != key) + result->setProperty (name, value); + + return var (result.release()); +} + +std::optional JSONUtils::setPointer (const var& v, + String pointer, + const var& newValue) +{ + if (pointer.isEmpty()) + return newValue; + + if (! pointer.startsWith ("/")) + { + // This is not a well-formed JSON pointer + jassertfalse; + return {}; + } + + const auto findResult = pointer.indexOfChar (1, '/'); + const auto pos = findResult < 0 ? pointer.length() : findResult; + const String head (pointer.begin() + 1, pointer.begin() + pos); + const String tail (pointer.begin() + pos, pointer.end()); + + const auto unescaped = head.replace ("~1", "/").replace ("~0", "~"); + + if (auto* object = v.getDynamicObject()) + { + if (const auto newProperty = setPointer (object->getProperty (unescaped), tail, newValue)) + { + auto cloned = object->clone(); + cloned->setProperty (unescaped, *newProperty); + return var (cloned.release()); + } + } + else if (auto* array = v.getArray()) + { + const auto index = [&]() -> size_t + { + if (unescaped == "-") + return (size_t) array->size(); + + if (unescaped == "0") + return 0; + + if (! unescaped.startsWith ("0")) + return (size_t) unescaped.getLargeIntValue(); + + return std::numeric_limits::max(); + }(); + + if (const auto newIndex = setPointer ((*array)[(int) index], tail, newValue)) + { + auto copied = *array; + + if ((int) index == copied.size()) + copied.add ({}); + + if (isPositiveAndBelow (index, copied.size())) + { + copied.getReference ((int) index) = *newIndex; + return var (copied); + } + } + } + + return {}; +} + +bool JSONUtils::deepEqual (const var& a, const var& b) +{ + const auto compareObjects = [] (const DynamicObject& x, const DynamicObject& y) + { + if (x.getProperties().size() != y.getProperties().size()) + return false; + + for (const auto& [key, value] : x.getProperties()) + { + if (! y.hasProperty (key)) + return false; + + if (! deepEqual (value, y.getProperty (key))) + return false; + } + + return true; + }; + + if (auto* i = a.getDynamicObject()) + if (auto* j = b.getDynamicObject()) + return compareObjects (*i, *j); + + if (auto* i = a.getArray()) + if (auto* j = b.getArray()) + return std::equal (i->begin(), i->end(), j->begin(), j->end(), [] (const var& x, const var& y) { return deepEqual (x, y); }); + + return a == b; +} + +//============================================================================== +//============================================================================== +#if JUCE_UNIT_TESTS + +class JSONUtilsTests final : public UnitTest +{ +public: + JSONUtilsTests() : UnitTest ("JSONUtils", UnitTestCategories::json) {} + + void runTest() override + { + beginTest ("JSON pointers"); + { + const auto obj = JSON::parse (R"({ "name": "PIANO 4" + , "lfoSpeed": 30 + , "lfoWaveform": "triangle" + , "pitchEnvelope": { "rates": [94,67,95,60], "levels": [50,50,50,50] } + })"); + expectDeepEqual (JSONUtils::setPointer (obj, "", "hello world"), var ("hello world")); + expectDeepEqual (JSONUtils::setPointer (obj, "/lfoWaveform/foobar", "str"), std::nullopt); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"({"foo":0,"bar":1})"), "/foo", 2), JSON::parse (R"({"foo":2,"bar":1})")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"({"foo":0,"bar":1})"), "/baz", 2), JSON::parse (R"({"foo":0,"bar":1,"baz":2})")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"({"foo":{},"bar":{}})"), "/foo/bar", 2), JSON::parse (R"({"foo":{"bar":2},"bar":{}})")); + expectDeepEqual (JSONUtils::setPointer (obj, "/pitchEnvelope/rates/01", "str"), std::nullopt); + expectDeepEqual (JSONUtils::setPointer (obj, "/pitchEnvelope/rates/10", "str"), std::nullopt); + expectDeepEqual (JSONUtils::setPointer (obj, "/lfoSpeed", 10), JSON::parse (R"({ "name": "PIANO 4" + , "lfoSpeed": 10 + , "lfoWaveform": "triangle" + , "pitchEnvelope": { "rates": [94,67,95,60], "levels": [50,50,50,50] } + })")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"([0,1,2])"), "/0", "bang"), JSON::parse (R"(["bang",1,2])")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"([0,1,2])"), "/0", "bang"), JSON::parse (R"(["bang",1,2])")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"({"/":"fizz"})"), "/~1", "buzz"), JSON::parse (R"({"/":"buzz"})")); + expectDeepEqual (JSONUtils::setPointer (JSON::parse (R"({"~":"fizz"})"), "/~0", "buzz"), JSON::parse (R"({"~":"buzz"})")); + expectDeepEqual (JSONUtils::setPointer (obj, "/pitchEnvelope/rates/0", 80), JSON::parse (R"({ "name": "PIANO 4" + , "lfoSpeed": 30 + , "lfoWaveform": "triangle" + , "pitchEnvelope": { "rates": [80,67,95,60], "levels": [50,50,50,50] } + })")); + expectDeepEqual (JSONUtils::setPointer (obj, "/pitchEnvelope/levels/0", 80), JSON::parse (R"({ "name": "PIANO 4" + , "lfoSpeed": 30 + , "lfoWaveform": "triangle" + , "pitchEnvelope": { "rates": [94,67,95,60], "levels": [80,50,50,50] } + })")); + expectDeepEqual (JSONUtils::setPointer (obj, "/pitchEnvelope/levels/-", 100), JSON::parse (R"({ "name": "PIANO 4" + , "lfoSpeed": 30 + , "lfoWaveform": "triangle" + , "pitchEnvelope": { "rates": [94,67,95,60], "levels": [50,50,50,50,100] } + })")); + } + } + + void expectDeepEqual (const std::optional& a, const std::optional& b) + { + expect (deepEqual (a, b), a.has_value() && b.has_value() ? JSON::toString (*a) + " != " + JSON::toString (*b) : String()); + } + + static bool deepEqual (const std::optional& a, const std::optional& b) + { + if (a.has_value() && b.has_value()) + return JSONUtils::deepEqual (*a, *b); + + return a == b; + } +}; + +static JSONUtilsTests jsonUtilsTests; + +#endif + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.h b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.h new file mode 100644 index 00000000..f35d19fd --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_JSONUtils.h @@ -0,0 +1,67 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/** + A mini namespace to hold utility functions for working with juce::vars. + + @tags{Core} +*/ +struct JSONUtils +{ + /** No constructor. */ + JSONUtils() = delete; + + /** Given a JSON array/object 'v', a string representing a JSON pointer, + and a new property value 'newValue', returns a copy of 'v' where the + property or array index referenced by the pointer has been set to 'newValue'. + + If the pointer cannot be followed, due to referencing missing array indices + or fields, then this returns nullopt. + + For more details, check the JSON Pointer RFC 6901: + https://datatracker.ietf.org/doc/html/rfc6901 + */ + static std::optional setPointer (const var& v, String pointer, const var& newValue); + + /** Converts the provided key/value pairs into a JSON object. */ + static var makeObject (const std::map& source); + + /** Converts the provided key/value pairs into a JSON object with the provided + key at the first position in the object. + + This is useful because the MIDI-CI spec requires that certain fields (e.g. + status) should be placed at the beginning of a MIDI-CI header. + */ + static var makeObjectWithKeyFirst (const std::map& source, Identifier key); + + /** Returns true if and only if the contents of a match the contents of b. + + Unlike var::operator==, this will recursively check that contained DynamicObject and Array + instances compare equal. + */ + static bool deepEqual (const var& a, const var& b); +}; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/javascript/juce_Javascript.cpp b/JuceLibraryCode/modules/juce_core/javascript/juce_Javascript.cpp index 3a1f9ba8..a8b1f68e 100644 --- a/JuceLibraryCode/modules/juce_core/javascript/juce_Javascript.cpp +++ b/JuceLibraryCode/modules/juce_core/javascript/juce_Javascript.cpp @@ -57,7 +57,7 @@ namespace TokenTypes JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4702) //============================================================================== -struct JavascriptEngine::RootObject : public DynamicObject +struct JavascriptEngine::RootObject final : public DynamicObject { RootObject() { @@ -245,7 +245,7 @@ struct JavascriptEngine::RootObject : public DynamicObject struct Statement { Statement (const CodeLocation& l) noexcept : location (l) {} - virtual ~Statement() {} + virtual ~Statement() = default; enum ResultCode { ok = 0, returnWasHit, breakWasHit, continueWasHit }; virtual ResultCode perform (const Scope&, var*) const { return ok; } @@ -266,7 +266,7 @@ struct JavascriptEngine::RootObject : public DynamicObject using ExpPtr = std::unique_ptr; - struct BlockStatement : public Statement + struct BlockStatement final : public Statement { BlockStatement (const CodeLocation& l) noexcept : Statement (l) {} @@ -282,20 +282,20 @@ struct JavascriptEngine::RootObject : public DynamicObject OwnedArray statements; }; - struct IfStatement : public Statement + struct IfStatement final : public Statement { IfStatement (const CodeLocation& l) noexcept : Statement (l) {} ResultCode perform (const Scope& s, var* returnedValue) const override { - return (condition->getResult(s) ? trueBranch : falseBranch)->perform (s, returnedValue); + return (condition->getResult (s) ? trueBranch : falseBranch)->perform (s, returnedValue); } ExpPtr condition; std::unique_ptr trueBranch, falseBranch; }; - struct VarStatement : public Statement + struct VarStatement final : public Statement { VarStatement (const CodeLocation& l) noexcept : Statement (l) {} @@ -309,7 +309,7 @@ struct JavascriptEngine::RootObject : public DynamicObject ExpPtr initialiser; }; - struct LoopStatement : public Statement + struct LoopStatement final : public Statement { LoopStatement (const CodeLocation& l, bool isDo) noexcept : Statement (l), isDoLoop (isDo) {} @@ -339,7 +339,7 @@ struct JavascriptEngine::RootObject : public DynamicObject bool isDoLoop; }; - struct ReturnStatement : public Statement + struct ReturnStatement final : public Statement { ReturnStatement (const CodeLocation& l, Expression* v) noexcept : Statement (l), returnValue (v) {} @@ -352,26 +352,26 @@ struct JavascriptEngine::RootObject : public DynamicObject ExpPtr returnValue; }; - struct BreakStatement : public Statement + struct BreakStatement final : public Statement { BreakStatement (const CodeLocation& l) noexcept : Statement (l) {} ResultCode perform (const Scope&, var*) const override { return breakWasHit; } }; - struct ContinueStatement : public Statement + struct ContinueStatement final : public Statement { ContinueStatement (const CodeLocation& l) noexcept : Statement (l) {} ResultCode perform (const Scope&, var*) const override { return continueWasHit; } }; - struct LiteralValue : public Expression + struct LiteralValue final : public Expression { LiteralValue (const CodeLocation& l, const var& v) noexcept : Expression (l), value (v) {} var getResult (const Scope&) const override { return value; } var value; }; - struct UnqualifiedName : public Expression + struct UnqualifiedName final : public Expression { UnqualifiedName (const CodeLocation& l, const Identifier& n) noexcept : Expression (l), name (n) {} @@ -388,7 +388,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Identifier name; }; - struct DotOperator : public Expression + struct DotOperator final : public Expression { DotOperator (const CodeLocation& l, ExpPtr& p, const Identifier& c) noexcept : Expression (l), parent (p.release()), child (c) {} @@ -422,7 +422,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Identifier child; }; - struct ArraySubscript : public Expression + struct ArraySubscript final : public Expression { ArraySubscript (const CodeLocation& l) noexcept : Expression (l) {} @@ -476,7 +476,7 @@ struct JavascriptEngine::RootObject : public DynamicObject ExpPtr object, index; }; - struct BinaryOperatorBase : public Expression + struct BinaryOperatorBase : public Expression { BinaryOperatorBase (const CodeLocation& l, ExpPtr& a, ExpPtr& b, TokenType op) noexcept : Expression (l), lhs (a.release()), rhs (b.release()), operation (op) {} @@ -485,7 +485,7 @@ struct JavascriptEngine::RootObject : public DynamicObject TokenType operation; }; - struct BinaryOperator : public BinaryOperatorBase + struct BinaryOperator : public BinaryOperatorBase { BinaryOperator (const CodeLocation& l, ExpPtr& a, ExpPtr& b, TokenType op) noexcept : BinaryOperatorBase (l, a, b, op) {} @@ -516,7 +516,7 @@ struct JavascriptEngine::RootObject : public DynamicObject { location.throwError (getTokenName (operation) + " is not allowed on the " + typeName + " type"); return {}; } }; - struct EqualsOp : public BinaryOperator + struct EqualsOp final : public BinaryOperator { EqualsOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::equals) {} var getWithUndefinedArg() const override { return true; } @@ -526,7 +526,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithArrayOrObject (const var& a, const var& b) const override { return a == b; } }; - struct NotEqualsOp : public BinaryOperator + struct NotEqualsOp final : public BinaryOperator { NotEqualsOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::notEquals) {} var getWithUndefinedArg() const override { return false; } @@ -536,7 +536,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithArrayOrObject (const var& a, const var& b) const override { return a != b; } }; - struct LessThanOp : public BinaryOperator + struct LessThanOp final : public BinaryOperator { LessThanOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::lessThan) {} var getWithDoubles (double a, double b) const override { return a < b; } @@ -544,7 +544,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithStrings (const String& a, const String& b) const override { return a < b; } }; - struct LessThanOrEqualOp : public BinaryOperator + struct LessThanOrEqualOp final : public BinaryOperator { LessThanOrEqualOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::lessThanOrEqual) {} var getWithDoubles (double a, double b) const override { return a <= b; } @@ -552,7 +552,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithStrings (const String& a, const String& b) const override { return a <= b; } }; - struct GreaterThanOp : public BinaryOperator + struct GreaterThanOp final : public BinaryOperator { GreaterThanOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::greaterThan) {} var getWithDoubles (double a, double b) const override { return a > b; } @@ -560,7 +560,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithStrings (const String& a, const String& b) const override { return a > b; } }; - struct GreaterThanOrEqualOp : public BinaryOperator + struct GreaterThanOrEqualOp final : public BinaryOperator { GreaterThanOrEqualOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::greaterThanOrEqual) {} var getWithDoubles (double a, double b) const override { return a >= b; } @@ -568,7 +568,7 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithStrings (const String& a, const String& b) const override { return a >= b; } }; - struct AdditionOp : public BinaryOperator + struct AdditionOp final : public BinaryOperator { AdditionOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::plus) {} var getWithDoubles (double a, double b) const override { return a + b; } @@ -576,95 +576,95 @@ struct JavascriptEngine::RootObject : public DynamicObject var getWithStrings (const String& a, const String& b) const override { return a + b; } }; - struct SubtractionOp : public BinaryOperator + struct SubtractionOp final : public BinaryOperator { SubtractionOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::minus) {} var getWithDoubles (double a, double b) const override { return a - b; } var getWithInts (int64 a, int64 b) const override { return a - b; } }; - struct MultiplyOp : public BinaryOperator + struct MultiplyOp final : public BinaryOperator { MultiplyOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::times) {} var getWithDoubles (double a, double b) const override { return a * b; } var getWithInts (int64 a, int64 b) const override { return a * b; } }; - struct DivideOp : public BinaryOperator + struct DivideOp final : public BinaryOperator { DivideOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::divide) {} var getWithDoubles (double a, double b) const override { return exactlyEqual (b, 0.0) ? std::numeric_limits::infinity() : a / b; } var getWithInts (int64 a, int64 b) const override { return b != 0 ? var ((double) a / (double) b) : var (std::numeric_limits::infinity()); } }; - struct ModuloOp : public BinaryOperator + struct ModuloOp final : public BinaryOperator { ModuloOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::modulo) {} var getWithDoubles (double a, double b) const override { return exactlyEqual (b, 0.0) ? std::numeric_limits::infinity() : fmod (a, b); } var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a % b) : var (std::numeric_limits::infinity()); } }; - struct BitwiseOrOp : public BinaryOperator + struct BitwiseOrOp final : public BinaryOperator { BitwiseOrOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::bitwiseOr) {} var getWithInts (int64 a, int64 b) const override { return a | b; } }; - struct BitwiseAndOp : public BinaryOperator + struct BitwiseAndOp final : public BinaryOperator { BitwiseAndOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::bitwiseAnd) {} var getWithInts (int64 a, int64 b) const override { return a & b; } }; - struct BitwiseXorOp : public BinaryOperator + struct BitwiseXorOp final : public BinaryOperator { BitwiseXorOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::bitwiseXor) {} var getWithInts (int64 a, int64 b) const override { return a ^ b; } }; - struct LeftShiftOp : public BinaryOperator + struct LeftShiftOp final : public BinaryOperator { LeftShiftOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::leftShift) {} var getWithInts (int64 a, int64 b) const override { return ((int) a) << (int) b; } }; - struct RightShiftOp : public BinaryOperator + struct RightShiftOp final : public BinaryOperator { RightShiftOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::rightShift) {} var getWithInts (int64 a, int64 b) const override { return ((int) a) >> (int) b; } }; - struct RightShiftUnsignedOp : public BinaryOperator + struct RightShiftUnsignedOp final : public BinaryOperator { RightShiftUnsignedOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::rightShiftUnsigned) {} var getWithInts (int64 a, int64 b) const override { return (int) (((uint32) a) >> (int) b); } }; - struct LogicalAndOp : public BinaryOperatorBase + struct LogicalAndOp final : public BinaryOperatorBase { LogicalAndOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperatorBase (l, a, b, TokenTypes::logicalAnd) {} var getResult (const Scope& s) const override { return lhs->getResult (s) && rhs->getResult (s); } }; - struct LogicalOrOp : public BinaryOperatorBase + struct LogicalOrOp final : public BinaryOperatorBase { LogicalOrOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperatorBase (l, a, b, TokenTypes::logicalOr) {} var getResult (const Scope& s) const override { return lhs->getResult (s) || rhs->getResult (s); } }; - struct TypeEqualsOp : public BinaryOperatorBase + struct TypeEqualsOp final : public BinaryOperatorBase { TypeEqualsOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperatorBase (l, a, b, TokenTypes::typeEquals) {} var getResult (const Scope& s) const override { return areTypeEqual (lhs->getResult (s), rhs->getResult (s)); } }; - struct TypeNotEqualsOp : public BinaryOperatorBase + struct TypeNotEqualsOp final : public BinaryOperatorBase { TypeNotEqualsOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperatorBase (l, a, b, TokenTypes::typeNotEquals) {} var getResult (const Scope& s) const override { return ! areTypeEqual (lhs->getResult (s), rhs->getResult (s)); } }; - struct ConditionalOp : public Expression + struct ConditionalOp final : public Expression { ConditionalOp (const CodeLocation& l) noexcept : Expression (l) {} @@ -674,7 +674,7 @@ struct JavascriptEngine::RootObject : public DynamicObject ExpPtr condition, trueBranch, falseBranch; }; - struct Assignment : public Expression + struct Assignment final : public Expression { Assignment (const CodeLocation& l, ExpPtr& dest, ExpPtr& source) noexcept : Expression (l), target (dest.release()), newValue (source.release()) {} @@ -688,7 +688,7 @@ struct JavascriptEngine::RootObject : public DynamicObject ExpPtr target, newValue; }; - struct SelfAssignment : public Expression + struct SelfAssignment : public Expression { SelfAssignment (const CodeLocation& l, Expression* dest, Expression* source) noexcept : Expression (l), target (dest), newValue (source) {} @@ -705,7 +705,7 @@ struct JavascriptEngine::RootObject : public DynamicObject TokenType op; }; - struct PostAssignment : public SelfAssignment + struct PostAssignment final : public SelfAssignment { PostAssignment (const CodeLocation& l, Expression* dest, Expression* source) noexcept : SelfAssignment (l, dest, source) {} @@ -717,7 +717,7 @@ struct JavascriptEngine::RootObject : public DynamicObject } }; - struct FunctionCall : public Expression + struct FunctionCall : public Expression { FunctionCall (const CodeLocation& l) noexcept : Expression (l) {} @@ -761,7 +761,7 @@ struct JavascriptEngine::RootObject : public DynamicObject OwnedArray arguments; }; - struct NewOperator : public FunctionCall + struct NewOperator final : public FunctionCall { NewOperator (const CodeLocation& l) noexcept : FunctionCall (l) {} @@ -784,7 +784,7 @@ struct JavascriptEngine::RootObject : public DynamicObject } }; - struct ObjectDeclaration : public Expression + struct ObjectDeclaration final : public Expression { ObjectDeclaration (const CodeLocation& l) noexcept : Expression (l) {} @@ -793,7 +793,7 @@ struct JavascriptEngine::RootObject : public DynamicObject DynamicObject::Ptr newObject (new DynamicObject()); for (int i = 0; i < names.size(); ++i) - newObject->setProperty (names.getUnchecked(i), initialisers.getUnchecked(i)->getResult (s)); + newObject->setProperty (names.getUnchecked (i), initialisers.getUnchecked (i)->getResult (s)); return newObject.get(); } @@ -802,7 +802,7 @@ struct JavascriptEngine::RootObject : public DynamicObject OwnedArray initialisers; }; - struct ArrayDeclaration : public Expression + struct ArrayDeclaration final : public Expression { ArrayDeclaration (const CodeLocation& l) noexcept : Expression (l) {} @@ -811,7 +811,7 @@ struct JavascriptEngine::RootObject : public DynamicObject Array a; for (int i = 0; i < values.size(); ++i) - a.add (values.getUnchecked(i)->getResult (s)); + a.add (values.getUnchecked (i)->getResult (s)); // std::move() needed here for older compilers JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wredundant-move") @@ -823,7 +823,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct FunctionObject : public DynamicObject + struct FunctionObject final : public DynamicObject { FunctionObject() noexcept {} @@ -833,7 +833,7 @@ struct JavascriptEngine::RootObject : public DynamicObject tb.parseFunctionParamsAndBody (*this); } - DynamicObject::Ptr clone() override { return *new FunctionObject (*this); } + std::unique_ptr clone() const override { return std::make_unique (*this); } void writeAsJSON (OutputStream& out, int /*indentLevel*/, bool /*allOnOneLine*/, int /*maximumDecimalPlaces*/) override { @@ -848,7 +848,7 @@ struct JavascriptEngine::RootObject : public DynamicObject functionRoot->setProperty (thisIdent, args.thisObject); for (int i = 0; i < parameters.size(); ++i) - functionRoot->setProperty (parameters.getReference(i), + functionRoot->setProperty (parameters.getReference (i), i < args.numArguments ? args.arguments[i] : var::undefined()); var result; @@ -1056,7 +1056,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct ExpressionTreeBuilder : private TokenIterator + struct ExpressionTreeBuilder final : private TokenIterator { ExpressionTreeBuilder (const String code) : TokenIterator (code) {} @@ -1531,7 +1531,7 @@ struct JavascriptEngine::RootObject : public DynamicObject static String getString (Args a, int index) noexcept { return get (a, index).toString(); } //============================================================================== - struct ObjectClass : public DynamicObject + struct ObjectClass final : public DynamicObject { ObjectClass() { @@ -1545,7 +1545,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct ArrayClass : public DynamicObject + struct ArrayClass final : public DynamicObject { ArrayClass() { @@ -1641,7 +1641,7 @@ struct JavascriptEngine::RootObject : public DynamicObject auto target = get (a, 0); for (int i = (a.numArguments > 1 ? getInt (a, 1) : 0); i < array->size(); ++i) - if (array->getReference(i) == target) + if (array->getReference (i) == target) return i; } @@ -1650,7 +1650,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct StringClass : public DynamicObject + struct StringClass final : public DynamicObject { StringClass() { @@ -1692,7 +1692,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct MathClass : public DynamicObject + struct MathClass final : public DynamicObject { MathClass() { @@ -1763,7 +1763,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct JSONClass : public DynamicObject + struct JSONClass final : public DynamicObject { JSONClass() { setMethod ("stringify", stringify); } static Identifier getClassName() { static const Identifier i ("JSON"); return i; } @@ -1771,7 +1771,7 @@ struct JavascriptEngine::RootObject : public DynamicObject }; //============================================================================== - struct IntegerClass : public DynamicObject + struct IntegerClass final : public DynamicObject { IntegerClass() { setMethod ("parseInt", parseInt); } static Identifier getClassName() { static const Identifier i ("Integer"); return i; } @@ -1780,7 +1780,7 @@ struct JavascriptEngine::RootObject : public DynamicObject { auto s = getString (a, 0).trim(); - return s[0] == '0' ? (s[1] == 'x' ? s.substring(2).getHexValue64() : getOctalValue (s)) + return s[0] == '0' ? (s[1] == 'x' ? s.substring (2).getHexValue64() : getOctalValue (s)) : s.getLargeIntValue(); } }; diff --git a/JuceLibraryCode/modules/juce_core/juce_core.cpp b/JuceLibraryCode/modules/juce_core/juce_core.cpp index 788c74b0..7bbe6ba6 100644 --- a/JuceLibraryCode/modules/juce_core/juce_core.cpp +++ b/JuceLibraryCode/modules/juce_core/juce_core.cpp @@ -146,6 +146,7 @@ #include "misc/juce_Result.cpp" #include "misc/juce_Uuid.cpp" #include "misc/juce_ConsoleApplication.cpp" +#include "misc/juce_ScopeGuard.cpp" #include "network/juce_MACAddress.cpp" #include "network/juce_NamedPipe.cpp" #include "network/juce_Socket.cpp" @@ -177,6 +178,7 @@ #include "unit_tests/juce_UnitTest.cpp" #include "containers/juce_Variant.cpp" #include "javascript/juce_JSON.cpp" +#include "javascript/juce_JSONUtils.cpp" #include "javascript/juce_Javascript.cpp" #include "containers/juce_DynamicObject.cpp" #include "xml/juce_XmlDocument.cpp" @@ -279,6 +281,11 @@ #include "containers/juce_Optional_test.cpp" #include "maths/juce_MathsFunctions_test.cpp" #include "misc/juce_EnumHelpers_test.cpp" + #include "containers/juce_FixedSizeFunction_test.cpp" + #include "javascript/juce_JSONSerialisation_test.cpp" + #if JUCE_MAC || JUCE_IOS + #include "native/juce_ObjCHelpers_mac_test.mm" + #endif #endif //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/juce_core.h b/JuceLibraryCode/modules/juce_core/juce_core.h index f23eaed6..e3e3589d 100644 --- a/JuceLibraryCode/modules/juce_core/juce_core.h +++ b/JuceLibraryCode/modules/juce_core/juce_core.h @@ -32,7 +32,7 @@ ID: juce_core vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE core classes description: The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality. website: http://www.juce.com/juce @@ -259,6 +259,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC #include "containers/juce_ArrayBase.h" #include "containers/juce_Array.h" #include "containers/juce_LinkedListPointer.h" +#include "misc/juce_ScopeGuard.h" #include "containers/juce_ListenerList.h" #include "containers/juce_OwnedArray.h" #include "containers/juce_ReferenceCountedArray.h" @@ -285,6 +286,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC #include "containers/juce_NamedValueSet.h" #include "containers/juce_DynamicObject.h" #include "containers/juce_HashMap.h" +#include "containers/juce_FixedSizeFunction.h" #include "time/juce_RelativeTime.h" #include "time/juce_Time.h" #include "streams/juce_InputStream.h" @@ -307,6 +309,9 @@ JUCE_END_IGNORE_WARNINGS_MSVC #include "streams/juce_FileInputSource.h" #include "logging/juce_FileLogger.h" #include "javascript/juce_JSON.h" +#include "javascript/juce_JSONUtils.h" +#include "serialisation/juce_Serialisation.h" +#include "javascript/juce_JSONSerialisation.h" #include "javascript/juce_Javascript.h" #include "maths/juce_BigInteger.h" #include "maths/juce_Expression.h" @@ -349,6 +354,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC #include "streams/juce_AndroidDocumentInputSource.h" #if JUCE_CORE_INCLUDE_OBJC_HELPERS && (JUCE_MAC || JUCE_IOS) + #include "native/juce_CFHelpers_mac.h" #include "native/juce_ObjCHelpers_mac.h" #endif diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp index fd780c88..ba1e11f1 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.cpp @@ -162,6 +162,8 @@ BigInteger& BigInteger::operator= (const BigInteger& other) return *this; } +BigInteger::~BigInteger() = default; + uint32* BigInteger::getValues() const noexcept { jassert (heapAllocation != nullptr || allocatedSize <= numPreallocatedInts); @@ -1003,7 +1005,7 @@ void BigInteger::montgomeryMultiplication (const BigInteger& other, const BigInt void BigInteger::extendedEuclidean (const BigInteger& a, const BigInteger& b, BigInteger& x, BigInteger& y) { - BigInteger p(a), q(b), gcd(1); + BigInteger p (a), q (b), gcd (1); Array tempValues; while (! q.isZero()) @@ -1294,7 +1296,7 @@ uint32 readLittleEndianBitsInBuffer (const void* buffer, uint32 startBit, uint32 //============================================================================== #if JUCE_UNIT_TESTS -class BigIntegerTests : public UnitTest +class BigIntegerTests final : public UnitTest { public: BigIntegerTests() @@ -1319,12 +1321,12 @@ class BigIntegerTests : public UnitTest Random r = getRandom(); expect (BigInteger().isZero()); - expect (BigInteger(1).isOne()); + expect (BigInteger (1).isOne()); for (int j = 10000; --j >= 0;) { - BigInteger b1 (getBigRandom(r)), - b2 (getBigRandom(r)); + BigInteger b1 (getBigRandom (r)), + b2 (getBigRandom (r)); BigInteger b3 = b1 + b2; expect (b3 > b1 && b3 > b2); diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h index 8d35e5f1..49b66479 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_BigInteger.h @@ -69,7 +69,7 @@ class JUCE_API BigInteger BigInteger& operator= (BigInteger&&) noexcept; /** Destructor. */ - ~BigInteger() = default; + ~BigInteger(); //============================================================================== /** Copies another BigInteger onto this one. */ diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp index 49542942..97a10bcd 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Expression.cpp @@ -23,7 +23,7 @@ namespace juce { -class Expression::Term : public SingleThreadedReferenceCountedObject +class Expression::Term : public SingleThreadedReferenceCountedObject { public: Term() {} @@ -69,7 +69,7 @@ class Expression::Term : public SingleThreadedReferenceCountedObject virtual void visitAllSymbols (SymbolVisitor& visitor, const Scope& scope, int recursionDepth) { for (int i = getNumInputs(); --i >= 0;) - getInput(i)->visitAllSymbols (visitor, scope, recursionDepth); + getInput (i)->visitAllSymbols (visitor, scope, recursionDepth); } private: @@ -92,7 +92,7 @@ struct Expression::Helpers //============================================================================== /** An exception that can be thrown by Expression::evaluate(). */ - class EvaluationError : public std::exception + class EvaluationError final : public std::exception { public: EvaluationError (const String& desc) : description (desc) @@ -104,7 +104,7 @@ struct Expression::Helpers }; //============================================================================== - class Constant : public Term + class Constant final : public Term { public: Constant (double val, bool resolutionTarget) @@ -193,7 +193,7 @@ struct Expression::Helpers }; //============================================================================== - class SymbolTerm : public Term + class SymbolTerm final : public Term { public: explicit SymbolTerm (const String& sym) : symbol (sym) {} @@ -226,7 +226,7 @@ struct Expression::Helpers }; //============================================================================== - class Function : public Term + class Function final : public Term { public: explicit Function (const String& name) : functionName (name) {} @@ -238,7 +238,7 @@ struct Expression::Helpers Type getType() const noexcept { return functionType; } Term* clone() const { return new Function (functionName, parameters); } int getNumInputs() const { return parameters.size(); } - Term* getInput (int i) const { return parameters.getReference(i).term.get(); } + Term* getInput (int i) const { return parameters.getReference (i).term.get(); } String getName() const { return functionName; } TermPtr resolve (const Scope& scope, int recursionDepth) @@ -252,7 +252,7 @@ struct Expression::Helpers HeapBlock params (numParams); for (int i = 0; i < numParams; ++i) - params[i] = parameters.getReference(i).term->resolve (scope, recursionDepth + 1)->toDouble(); + params[i] = parameters.getReference (i).term->resolve (scope, recursionDepth + 1)->toDouble(); result = scope.evaluateFunction (functionName, params, numParams); } @@ -267,7 +267,7 @@ struct Expression::Helpers int getInputIndexFor (const Term* possibleInput) const { for (int i = 0; i < parameters.size(); ++i) - if (parameters.getReference(i).term == possibleInput) + if (parameters.getReference (i).term == possibleInput) return i; return -1; @@ -282,7 +282,7 @@ struct Expression::Helpers for (int i = 0; i < parameters.size(); ++i) { - s << parameters.getReference(i).term->toString(); + s << parameters.getReference (i).term->toString(); if (i < parameters.size() - 1) s << ", "; @@ -297,7 +297,7 @@ struct Expression::Helpers }; //============================================================================== - class DotOperator : public BinaryTerm + class DotOperator final : public BinaryTerm { public: DotOperator (SymbolTerm* l, TermPtr r) : BinaryTerm (TermPtr (l), r) {} @@ -347,7 +347,7 @@ struct Expression::Helpers private: //============================================================================== - class EvaluationVisitor : public Scope::Visitor + class EvaluationVisitor final : public Scope::Visitor { public: EvaluationVisitor (const TermPtr& t, const int recursion) @@ -363,7 +363,7 @@ struct Expression::Helpers JUCE_DECLARE_NON_COPYABLE (EvaluationVisitor) }; - class SymbolVisitingVisitor : public Scope::Visitor + class SymbolVisitingVisitor final : public Scope::Visitor { public: SymbolVisitingVisitor (const TermPtr& t, SymbolVisitor& v, const int recursion) @@ -379,7 +379,7 @@ struct Expression::Helpers JUCE_DECLARE_NON_COPYABLE (SymbolVisitingVisitor) }; - class SymbolRenamingVisitor : public Scope::Visitor + class SymbolRenamingVisitor final : public Scope::Visitor { public: SymbolRenamingVisitor (const TermPtr& t, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_) @@ -402,7 +402,7 @@ struct Expression::Helpers }; //============================================================================== - class Negate : public Term + class Negate final : public Term { public: explicit Negate (const TermPtr& t) : input (t) @@ -447,7 +447,7 @@ struct Expression::Helpers }; //============================================================================== - class Add : public BinaryTerm + class Add final : public BinaryTerm { public: Add (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} @@ -471,7 +471,7 @@ struct Expression::Helpers }; //============================================================================== - class Subtract : public BinaryTerm + class Subtract final : public BinaryTerm { public: Subtract (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} @@ -500,7 +500,7 @@ struct Expression::Helpers }; //============================================================================== - class Multiply : public BinaryTerm + class Multiply final : public BinaryTerm { public: Multiply (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} @@ -523,7 +523,7 @@ struct Expression::Helpers }; //============================================================================== - class Divide : public BinaryTerm + class Divide final : public BinaryTerm { public: Divide (TermPtr l, TermPtr r) : BinaryTerm (l, r) {} @@ -621,7 +621,7 @@ struct Expression::Helpers } //============================================================================== - class SymbolCheckVisitor : public Term::SymbolVisitor + class SymbolCheckVisitor final : public Term::SymbolVisitor { public: SymbolCheckVisitor (const Symbol& s) : symbol (s) {} @@ -636,7 +636,7 @@ struct Expression::Helpers }; //============================================================================== - class SymbolListVisitor : public Term::SymbolVisitor + class SymbolListVisitor final : public Term::SymbolVisitor { public: SymbolListVisitor (Array& list_) : list (list_) {} diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h index 30365240..be3c90c6 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h +++ b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions.h @@ -149,7 +149,7 @@ struct MathConstants /** A predefined value for Euler's number */ static constexpr FloatType euler = static_cast (2.71828182845904523536L); - /** A predefined value for sqrt(2) */ + /** A predefined value for sqrt (2) */ static constexpr FloatType sqrt2 = static_cast (1.4142135623730950488L); }; @@ -276,8 +276,8 @@ static Tolerance relativeTolerance (Type tolerance) differences that are subnormal are always considered equal. It is highly recommend this value is reviewed depending on the calculation being carried out. In general specifying an absolute value is useful when considering values close to zero. For example you might - expect sin(pi) to return 0, but what it actually returns is close to the error of the value pi. - Therefore, in this example it might be better to set the absolute tolerance to sin(pi). + expect sin (pi) to return 0, but what it actually returns is close to the error of the value pi. + Therefore, in this example it might be better to set the absolute tolerance to sin (pi). The default relative tolerance is equal to the machine epsilon which is the difference between 1.0 and the next floating-point value that can be represented by Type. In most cases this value diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions_test.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions_test.cpp index 4545044c..02848f50 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions_test.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_MathsFunctions_test.cpp @@ -215,7 +215,7 @@ class ApproximatelyEqualTests final : public UnitTest expect (! approximatelyEqual (nan, nan)); - const auto expectNotEqualTo = [&](auto value) + const auto expectNotEqualTo = [&] (auto value) { expect (! approximatelyEqual (value, nan)); expect (! approximatelyEqual (nan, value)); @@ -242,7 +242,7 @@ class ApproximatelyEqualTests final : public UnitTest expect (! approximatelyEqual (inf, -inf)); expect (! approximatelyEqual (-inf, inf)); - const auto expectNotEqualTo = [&](auto value) + const auto expectNotEqualTo = [&] (auto value) { expect (! approximatelyEqual (value, inf)); expect (! approximatelyEqual (value, -inf)); @@ -274,11 +274,11 @@ class ApproximatelyEqualTests final : public UnitTest (T) 0.0078125 /* 2^-7 */ }; - const auto testTolerance = [&](auto tolerance) + const auto testTolerance = [&] (auto tolerance) { const auto t = Tolerance{}.withAbsolute ((T) tolerance); - const auto testValue= [&](auto value) + const auto testValue= [&] (auto value) { const auto boundary = value + tolerance; diff --git a/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp b/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp index b98dc5e6..e8e4eb52 100644 --- a/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp +++ b/JuceLibraryCode/modules/juce_core/maths/juce_Random.cpp @@ -164,7 +164,7 @@ void Random::fillBitsRandomly (BigInteger& arrayToChange, int startBit, int numB //============================================================================== #if JUCE_UNIT_TESTS -class RandomTests : public UnitTest +class RandomTests final : public UnitTest { public: RandomTests() diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h b/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h index ef05ca28..baa12962 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_ByteOrder.h @@ -20,10 +20,6 @@ ============================================================================== */ -#if ! defined (DOXYGEN) && (JUCE_MAC || JUCE_IOS) - #include -#endif - namespace juce { diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h b/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h index 1d114cc4..8310395d 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_HeapBlock.h @@ -109,9 +109,8 @@ class HeapBlock */ template , int> = 0> explicit HeapBlock (SizeType numElements) - : data (static_cast (std::malloc (static_cast (numElements) * sizeof (ElementType)))) + : data (mallocWrapper (static_cast (numElements) * sizeof (ElementType))) { - throwOnAllocationFailure(); } /** Creates a HeapBlock containing a number of elements. @@ -121,11 +120,9 @@ class HeapBlock */ template , int> = 0> HeapBlock (SizeType numElements, bool initialiseToZero) - : data (static_cast (initialiseToZero - ? std::calloc (static_cast (numElements), sizeof (ElementType)) - : std::malloc (static_cast (numElements) * sizeof (ElementType)))) + : data (initialiseToZero ? callocWrapper (static_cast (numElements), sizeof (ElementType)) + : mallocWrapper (static_cast (numElements) * sizeof (ElementType))) { - throwOnAllocationFailure(); } /** Destructor. @@ -252,8 +249,7 @@ class HeapBlock void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::malloc (static_cast (newNumElements) * elementSize)); - throwOnAllocationFailure(); + data = mallocWrapper (static_cast (newNumElements) * elementSize); } /** Allocates a specified amount of memory and clears it. @@ -263,8 +259,7 @@ class HeapBlock void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType)) { std::free (data); - data = static_cast (std::calloc (static_cast (newNumElements), elementSize)); - throwOnAllocationFailure(); + data = callocWrapper (static_cast (newNumElements), elementSize); } /** Allocates a specified amount of memory and optionally clears it. @@ -275,10 +270,8 @@ class HeapBlock void allocate (SizeType newNumElements, bool initialiseToZero) { std::free (data); - data = static_cast (initialiseToZero - ? std::calloc (static_cast (newNumElements), sizeof (ElementType)) - : std::malloc (static_cast (newNumElements) * sizeof (ElementType))); - throwOnAllocationFailure(); + data = initialiseToZero ? callocWrapper (static_cast (newNumElements), sizeof (ElementType)) + : mallocWrapper (static_cast (newNumElements) * sizeof (ElementType)); } /** Re-allocates a specified amount of memory. @@ -289,9 +282,7 @@ class HeapBlock template void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) { - data = static_cast (data == nullptr ? std::malloc (static_cast (newNumElements) * elementSize) - : std::realloc (data, static_cast (newNumElements) * elementSize)); - throwOnAllocationFailure(); + data = reallocWrapper (data, static_cast (newNumElements) * elementSize); } /** Frees any currently-allocated data. @@ -327,20 +318,46 @@ class HeapBlock private: //============================================================================== - ElementType* data = nullptr; - - void throwOnAllocationFailure() const + // Calls to malloc, calloc and realloc with zero size have implementation-defined + // behaviour where either nullptr or a non-null pointer is returned. + template + static ElementType* wrapper (size_t size, Functor&& f) { + if (size == 0) + return nullptr; + + auto* memory = static_cast (f()); + #if JUCE_EXCEPTIONS_DISABLED - jassert (data != nullptr); // without exceptions, you'll need to find a better way to handle this failure case. + jassert (memory != nullptr); // without exceptions, you'll need to find a better way to handle this failure case. #else - HeapBlockHelper::ThrowOnFail::checkPointer (data); + HeapBlockHelper::ThrowOnFail::checkPointer (memory); #endif + + return memory; + } + + static ElementType* mallocWrapper (size_t size) + { + return wrapper (size, [size] { return std::malloc (size); }); + } + + static ElementType* callocWrapper (size_t num, size_t size) + { + return wrapper (num * size, [num, size] { return std::calloc (num, size); }); + } + + static ElementType* reallocWrapper (void* ptr, size_t newSize) + { + return wrapper (newSize, [ptr, newSize] { return std::realloc (ptr, newSize); }); } template friend class HeapBlock; + //============================================================================== + ElementType* data = nullptr; + #if ! (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)) JUCE_DECLARE_NON_COPYABLE (HeapBlock) JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point! diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h b/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h index 808b069a..bc95cffb 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_LeakedObjectDetector.h @@ -113,7 +113,7 @@ class LeakedObjectDetector #if (DOXYGEN || JUCE_CHECK_MEMORY_LEAKS) /** This macro lets you embed a leak-detecting object inside a class. - To use it, simply declare a JUCE_LEAK_DETECTOR(YourClassName) inside a private section + To use it, simply declare a JUCE_LEAK_DETECTOR (YourClassName) inside a private section of the class declaration. E.g. @code diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h index 0a2d1fd9..e431bfce 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_MemoryBlock.h @@ -41,7 +41,7 @@ class JUCE_API MemoryBlock @param initialSize the size of block to create @param initialiseToZero whether to clear the memory or just leave it uninitialised */ - MemoryBlock (const size_t initialSize, + MemoryBlock (size_t initialSize, bool initialiseToZero = false); /** Creates a copy of another memory block. */ @@ -138,7 +138,7 @@ class JUCE_API MemoryBlock uninitialised @see ensureSize */ - void setSize (const size_t newSize, + void setSize (size_t newSize, bool initialiseNewSpaceToZero = false); /** Increases the block's size only if it's smaller than a given size. @@ -150,7 +150,7 @@ class JUCE_API MemoryBlock uninitialised @see setSize */ - void ensureSize (const size_t minimumSize, + void ensureSize (size_t minimumSize, bool initialiseNewSpaceToZero = false); /** Frees all the blocks data, setting its size to 0. */ diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_SharedResourcePointer.h b/JuceLibraryCode/modules/juce_core/memory/juce_SharedResourcePointer.h index 2f9a526b..98570b9b 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_SharedResourcePointer.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_SharedResourcePointer.h @@ -135,7 +135,7 @@ class SharedResourcePointer static SharedObjectHolder& getSharedObjectHolder() noexcept { - static void* holder [(sizeof (SharedObjectHolder) + sizeof(void*) - 1) / sizeof(void*)] = { nullptr }; + static void* holder [(sizeof (SharedObjectHolder) + sizeof (void*) - 1) / sizeof (void*)] = { nullptr }; return *reinterpret_cast (holder); } diff --git a/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h b/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h index 697b3312..e40fed61 100644 --- a/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h +++ b/JuceLibraryCode/modules/juce_core/memory/juce_Singleton.h @@ -128,10 +128,10 @@ struct SingletonHolder : private MutexType // (inherited so we can use the empt /** Macro to generate the appropriate methods and boilerplate for a singleton class. - To use this, add the line JUCE_DECLARE_SINGLETON(MyClass, doNotRecreateAfterDeletion) + To use this, add the line JUCE_DECLARE_SINGLETON (MyClass, doNotRecreateAfterDeletion) to the class's definition. - Then put a macro JUCE_IMPLEMENT_SINGLETON(MyClass) along with the class's + Then put a macro JUCE_IMPLEMENT_SINGLETON (MyClass) along with the class's implementation code. It's also a very good idea to also add the call clearSingletonInstance() in your class's diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_ConsoleApplication.cpp b/JuceLibraryCode/modules/juce_core/misc/juce_ConsoleApplication.cpp index 7b6e172a..89cc06de 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_ConsoleApplication.cpp +++ b/JuceLibraryCode/modules/juce_core/misc/juce_ConsoleApplication.cpp @@ -201,7 +201,7 @@ String ArgumentList::getValueForOption (StringRef option) const for (int i = 0; i < arguments.size(); ++i) { - auto& arg = arguments.getReference(i); + auto& arg = arguments.getReference (i); if (arg == option) { @@ -227,7 +227,7 @@ String ArgumentList::removeValueForOption (StringRef option) for (int i = 0; i < arguments.size(); ++i) { - auto& arg = arguments.getReference(i); + auto& arg = arguments.getReference (i); if (arg == option) { diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_EnumHelpers_test.cpp b/JuceLibraryCode/modules/juce_core/misc/juce_EnumHelpers_test.cpp index 50e4555e..d8484f2a 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_EnumHelpers_test.cpp +++ b/JuceLibraryCode/modules/juce_core/misc/juce_EnumHelpers_test.cpp @@ -35,7 +35,7 @@ enum class TestEnum JUCE_DECLARE_SCOPED_ENUM_BITWISE_OPERATORS (TestEnum) } -class EnumHelperTest : public UnitTest +class EnumHelperTest final : public UnitTest { public: EnumHelperTest() : UnitTest ("EnumHelpers", UnitTestCategories::containers) {} @@ -75,8 +75,6 @@ class EnumHelperTest : public UnitTest beginTest ("operators work as expected"); { - e = {}; - e = TestEnum::one; expect ((e & TestEnum::one) != TestEnum{}); e |= TestEnum::other; diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_Functional.h b/JuceLibraryCode/modules/juce_core/misc/juce_Functional.h index 040132f7..db5bd0d1 100644 --- a/JuceLibraryCode/modules/juce_core/misc/juce_Functional.h +++ b/JuceLibraryCode/modules/juce_core/misc/juce_Functional.h @@ -86,35 +86,6 @@ template struct ScopeGuard : Fn { ~ScopeGuard() { Fn::operator()(); } }; -template ScopeGuard (Fn) -> ScopeGuard; - #ifndef DOXYGEN namespace detail { diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.cpp b/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.cpp new file mode 100644 index 00000000..7cb7f2a9 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.cpp @@ -0,0 +1,55 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +ErasedScopeGuard::ErasedScopeGuard (std::function d) + : detach (std::move (d)) {} + +ErasedScopeGuard::ErasedScopeGuard (ErasedScopeGuard&& other) noexcept + : detach (std::exchange (other.detach, nullptr)) {} + +ErasedScopeGuard& ErasedScopeGuard::operator= (ErasedScopeGuard&& other) noexcept +{ + ErasedScopeGuard token { std::move (other) }; + std::swap (token.detach, detach); + return *this; +} + +ErasedScopeGuard::~ErasedScopeGuard() noexcept +{ + reset(); +} + +void ErasedScopeGuard::reset() +{ + if (auto d = std::exchange (detach, nullptr)) + d(); +} + +void ErasedScopeGuard::release() +{ + detach = nullptr; +} + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.h b/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.h new file mode 100644 index 00000000..c8994a66 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/misc/juce_ScopeGuard.h @@ -0,0 +1,113 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/** An easy way to ensure that a function is called at the end of the current + scope. + + Usage: + @code + { + if (flag == true) + return; + + // While this code executes, flag is true e.g. to prevent reentrancy + flag = true; + // When we exit this scope, flag must be false + const ScopeGuard scope { [&] { flag = false; } }; + + if (checkInitialCondition()) + return; // Scope's lambda will fire here... + + if (checkCriticalCondition()) + throw std::runtime_error{}; // ...or here... + + doWorkHavingEstablishedPreconditions(); + } // ...or here! + @endcode + + @tags{Core} +*/ +template struct ScopeGuard : Fn { ~ScopeGuard() { Fn::operator()(); } }; +template ScopeGuard (Fn) -> ScopeGuard; + +/** + A ScopeGuard that uses a std::function internally to allow type erasure. + This can be handy; it allows lots of ErasedScopeGuards, all with different + callbacks, to be stored in a homogeneous container. + + An instance of this type will automatically call its callback when it is destroyed. + + ErasedScopeGuard has a few similarities with std::unique_ptr: + - Calling reset() on a unique_ptr destroys the object if it hasn't been destroyed yet + and puts the unique_ptr back into a default/null state; calling reset() on an + ErasedScopeGuard calls the callback if it hasn't been called yet and puts the Guard + back into a default/null state. + - Calling release() on a unique_ptr returns the unique_ptr back to a default state + without destroying the managed object; calling release() on an ErasedScopeGuard + returns the Guard back to a default state without calling the callback. + - Moving a unique_ptr transfers the responsibility of destroying the managed object + to another unique_ptr instance; moving an ErasedScopeGuard transfers the + responsibility of calling the callback to another Guard instance. +*/ +class [[nodiscard]] ErasedScopeGuard +{ +public: + /** Constructs an ErasedScopeGuard with no callback. */ + ErasedScopeGuard() = default; + + /** Constructs an ErasedScopeGuard that will call the provided callback + when the Guard is destroyed. + */ + explicit ErasedScopeGuard (std::function d); + + /** Constructs an instance that assumes responsibility for calling other's callback. */ + ErasedScopeGuard (ErasedScopeGuard&& other) noexcept; + + /** Calls the stored callback, if any, then assumes responsibility for calling + other's callback. After this call, other will be reset to its default state. + */ + ErasedScopeGuard& operator= (ErasedScopeGuard&& other) noexcept; + + /** Destructor, calls the callback assigned to this ScopeGuard. + */ + ~ErasedScopeGuard() noexcept; + + /** Calls the stored callback, if any, then resets this instance to its + default state. + */ + void reset(); + + /** Resets this instance to its default state without calling the stored + callback. + */ + void release(); + + JUCE_DECLARE_NON_COPYABLE (ErasedScopeGuard) + +private: + std::function detach; +}; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/native/juce_AndroidDocument_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_AndroidDocument_android.cpp index 0438d200..fbd4f511 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_AndroidDocument_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_AndroidDocument_android.cpp @@ -161,7 +161,7 @@ struct AndroidDocumentDetail documentId.get()) }; return DocumentsContractIteratorEngine { Columns { GlobalRef { uri }, - GlobalRefImpl { javaString("document_id") } }, + GlobalRefImpl { javaString ("document_id") } }, childrenUri.get() }; } diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Files_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Files_android.cpp index 18edb2b1..9e3f6dc5 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Files_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Files_android.cpp @@ -487,7 +487,7 @@ struct AndroidContentUriResolver }; //============================================================================== -struct AndroidContentUriOutputStream : public OutputStream +struct AndroidContentUriOutputStream final : public OutputStream { explicit AndroidContentUriOutputStream (LocalRef&& streamIn) : stream (std::move (streamIn)) {} @@ -572,7 +572,7 @@ struct AndroidStreamHelpers }; //============================================================================== -struct AndroidContentUriInputStream : public InputStream +struct AndroidContentUriInputStream final : public InputStream { explicit AndroidContentUriInputStream (const GlobalRef& uriIn) : uri (uriIn), @@ -824,7 +824,7 @@ void File::revealToUser() const } //============================================================================== -class SingleMediaScanner : public MediaScannerConnectionClient +class SingleMediaScanner final : public MediaScannerConnectionClient { public: SingleMediaScanner (const String& filename) diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Files_windows.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Files_windows.cpp index 54b84e9f..03b50525 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Files_windows.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Files_windows.cpp @@ -777,7 +777,7 @@ String File::getVersion() const VS_FIXEDFILEINFO* vffi; UINT len = 0; - if (VerQueryValue (buffer, (LPTSTR) _T("\\"), (LPVOID*) &vffi, &len)) + if (VerQueryValue (buffer, (LPTSTR) _T ("\\"), (LPVOID*) &vffi, &len)) { result << (int) HIWORD (vffi->dwFileVersionMS) << '.' << (int) LOWORD (vffi->dwFileVersionMS) << '.' diff --git a/JuceLibraryCode/modules/juce_core/native/juce_JNIHelpers_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_JNIHelpers_android.cpp index 7540a333..94b3c2c4 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_JNIHelpers_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_JNIHelpers_android.cpp @@ -139,14 +139,14 @@ Array& JNIClassBase::getClasses() static File getCodeCacheDirectory() { int pid = getpid(); - File cmdline("/proc/" + String(pid) + "/cmdline"); + File cmdline ("/proc/" + String (pid) + "/cmdline"); auto bundleId = cmdline.loadFileAsString().trimStart().trimEnd(); if (bundleId.isEmpty()) return {}; - return File("/data/data/" + bundleId + "/code_cache"); + return File ("/data/data/" + bundleId + "/code_cache"); } void JNIClassBase::initialise (JNIEnv* env, jobject context) @@ -279,14 +279,14 @@ void JNIClassBase::initialiseAllClasses (JNIEnv* env, jobject context) { const Array& classes = getClasses(); for (int i = classes.size(); --i >= 0;) - classes.getUnchecked(i)->initialise (env, context); + classes.getUnchecked (i)->initialise (env, context); } void JNIClassBase::releaseAllClasses (JNIEnv* env) { const Array& classes = getClasses(); for (int i = classes.size(); --i >= 0;) - classes.getUnchecked(i)->release (env); + classes.getUnchecked (i)->release (env); } jmethodID JNIClassBase::resolveMethod (JNIEnv* env, const char* methodName, const char* params) diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Network_curl.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Network_curl.cpp index a8d07948..d2456753 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Network_curl.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Network_curl.cpp @@ -379,7 +379,7 @@ class WebInputStream::Pimpl { #else curl_off_t curlLength; - if (symbols->curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &curlLength) == CURLE_OK) + if (symbols->curl_easy_getinfo (curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &curlLength) == CURLE_OK) { #endif contentLength = static_cast (curlLength); diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Network_linux.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Network_linux.cpp index ce5a359a..fa4393ca 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Network_linux.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Network_linux.cpp @@ -511,9 +511,9 @@ class WebInputStream::Pimpl else writeHost (header, httpRequestCmd, originalURL, proxyName, proxyPort); - writeValueIfNotPresent (header, userHeaders, "User-Agent:", "JUCE/" JUCE_STRINGIFY(JUCE_MAJOR_VERSION) - "." JUCE_STRINGIFY(JUCE_MINOR_VERSION) - "." JUCE_STRINGIFY(JUCE_BUILDNUMBER)); + writeValueIfNotPresent (header, userHeaders, "User-Agent:", "JUCE/" JUCE_STRINGIFY (JUCE_MAJOR_VERSION) + "." JUCE_STRINGIFY (JUCE_MINOR_VERSION) + "." JUCE_STRINGIFY (JUCE_BUILDNUMBER)); writeValueIfNotPresent (header, userHeaders, "Connection:", "close"); const auto postDataSize = postData.getSize(); diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Network_mac.mm b/JuceLibraryCode/modules/juce_core/native/juce_Network_mac.mm index 1a089403..027c0002 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Network_mac.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_Network_mac.mm @@ -107,7 +107,7 @@ } //============================================================================== -class URLConnectionStateBase : public Thread +class URLConnectionStateBase : public Thread { public: explicit URLConnectionStateBase (NSURLRequest* req, int maxRedirects) @@ -155,7 +155,7 @@ explicit URLConnectionStateBase (NSURLRequest* req, int maxRedirects) // so we'll turn off deprecation warnings. This code will be removed at some point // in the future. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated") -class URLConnectionStatePreYosemite : public URLConnectionStateBase +class URLConnectionStatePreYosemite final : public URLConnectionStateBase { public: URLConnectionStatePreYosemite (NSURLRequest* req, const int maxRedirects) @@ -331,7 +331,7 @@ void run() override private: //============================================================================== - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCENetworkDelegate_") { @@ -391,7 +391,7 @@ static void connectionDidFinishLoading (id self, SEL, NSURLConnection*) #endif //============================================================================== -class API_AVAILABLE (macos (10.9)) URLConnectionState : public URLConnectionStateBase +class API_AVAILABLE (macos (10.9)) URLConnectionState final : public URLConnectionStateBase { public: URLConnectionState (NSURLRequest* req, const int maxRedirects) @@ -599,7 +599,7 @@ void run() override private: //============================================================================== - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCE_URLDelegate_") { @@ -669,7 +669,7 @@ static void didCompleteWithError (id self, SEL, NSURLConnection*, NSURLSessionTa //============================================================================== #if JUCE_IOS -struct BackgroundDownloadTask : public URL::DownloadTask +struct BackgroundDownloadTask final : public URL::DownloadTask { BackgroundDownloadTask (const URL& urlToUse, const File& targetLocationToUse, @@ -869,7 +869,7 @@ static void invokeNotify (const String& identifier) } //============================================================================== - struct DelegateClass : public ObjCClass> + struct DelegateClass final : public ObjCClass> { DelegateClass() : ObjCClass> ("JUCE_URLDelegate_") { diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Network_windows.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Network_windows.cpp index 0427c650..ca8ab26d 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Network_windows.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Network_windows.cpp @@ -274,7 +274,7 @@ class WebInputStream::Pimpl void createConnection (const String& address, WebInputStream::Listener* listener) { - static HINTERNET sessionHandle = InternetOpen (_T("juce"), INTERNET_OPEN_TYPE_PRECONFIG, nullptr, nullptr, 0); + static HINTERNET sessionHandle = InternetOpen (_T ("juce"), INTERNET_OPEN_TYPE_PRECONFIG, nullptr, nullptr, 0); closeConnection(); @@ -388,7 +388,7 @@ class WebInputStream::Pimpl void openHTTPConnection (URL_COMPONENTS& uc, const String& address, WebInputStream::Listener* listener) { - const TCHAR* mimeTypes[] = { _T("*/*"), nullptr }; + const TCHAR* mimeTypes[] = { _T ("*/*"), nullptr }; DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_AUTO_REDIRECT; diff --git a/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac.h b/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac.h index 22bee6cf..d9360178 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac.h @@ -20,8 +20,6 @@ ============================================================================== */ -#include "juce_CFHelpers_mac.h" - /* This file contains a few helper functions that are used internally but which need to be kept away from the public headers because they use obj-C symbols. */ @@ -46,17 +44,22 @@ inline String nsStringToJuce (NSString* s) inline NSString* juceStringToNS (const String& s) { - return [NSString stringWithUTF8String: s.toUTF8()]; + // This cast helps linters determine nullability + return (NSString* _Nonnull) [NSString stringWithUTF8String: s.toUTF8()]; } inline NSString* nsStringLiteral (const char* const s) noexcept { - return [NSString stringWithUTF8String: s]; + jassert (s != nullptr); + + // This cast helps linters determine nullability + return (NSString* _Nonnull) [NSString stringWithUTF8String: s]; } inline NSString* nsEmptyString() noexcept { - return [NSString string]; + // This cast helps linters determine nullability + return (NSString* _Nonnull) [NSString string]; } inline NSURL* createNSURLFromFile (const String& f) @@ -71,127 +74,62 @@ inline NSURL* createNSURLFromFile (const File& f) inline NSArray* createNSArrayFromStringArray (const StringArray& strings) { - auto array = [[NSMutableArray alloc] init]; + auto array = [[NSMutableArray alloc] initWithCapacity: (NSUInteger) strings.size()]; - for (auto string: strings) - [array addObject:juceStringToNS (string)]; + for (const auto& string: strings) + [array addObject: juceStringToNS (string)]; return [array autorelease]; } -inline NSArray* varArrayToNSArray (const var& varToParse); - -inline NSDictionary* varObjectToNSDictionary (const var& varToParse) +inline NSData* varToJsonData (const var& varToParse) { - auto dictionary = [NSMutableDictionary dictionary]; - - if (varToParse.isObject()) - { - auto* dynamicObject = varToParse.getDynamicObject(); - - auto& properties = dynamicObject->getProperties(); - - for (int i = 0; i < properties.size(); ++i) - { - auto* keyString = juceStringToNS (properties.getName (i).toString()); - - const var& valueVar = properties.getValueAt (i); - - if (valueVar.isObject()) - { - auto* valueDictionary = varObjectToNSDictionary (valueVar); - - [dictionary setObject: valueDictionary forKey: keyString]; - } - else if (valueVar.isArray()) - { - auto* valueArray = varArrayToNSArray (valueVar); - - [dictionary setObject: valueArray forKey: keyString]; - } - else - { - auto* valueString = juceStringToNS (valueVar.toString()); - - [dictionary setObject: valueString forKey: keyString]; - } - } - } - - return dictionary; + return [juceStringToNS (JSON::toString (varToParse)) dataUsingEncoding: NSUTF8StringEncoding]; } -inline NSArray* varArrayToNSArray (const var& varToParse) +inline var jsonDataToVar (NSData* jsonData) { - jassert (varToParse.isArray()); - - if (! varToParse.isArray()) - return nil; - - const auto* varArray = varToParse.getArray(); - - auto array = [NSMutableArray arrayWithCapacity: (NSUInteger) varArray->size()]; - - for (const auto& aVar : *varArray) - { - if (aVar.isObject()) - { - auto* valueDictionary = varObjectToNSDictionary (aVar); - - [array addObject: valueDictionary]; - } - else if (aVar.isArray()) - { - auto* valueArray = varArrayToNSArray (aVar); - - [array addObject: valueArray]; - } - else - { - auto* valueString = juceStringToNS (aVar.toString()); - - [array addObject: valueString]; - } - } + auto* jsonString = [[NSString alloc] initWithData: jsonData + encoding: NSUTF8StringEncoding]; - return array; + jassert (jsonString != nullptr); + return JSON::parse (nsStringToJuce ([jsonString autorelease])); } -var nsObjectToVar (NSObject* array); - -inline var nsDictionaryToVar (NSDictionary* dictionary) +inline NSDictionary* varObjectToNSDictionary (const var& varToParse) { - DynamicObject::Ptr dynamicObject (new DynamicObject()); + jassert (varToParse.isObject()); - for (NSString* key in dictionary) - dynamicObject->setProperty (nsStringToJuce (key), nsObjectToVar ([dictionary objectForKey: key])); + if (! varToParse.isObject()) + return nullptr; - return var (dynamicObject.get()); + NSError* error { nullptr }; + NSDictionary* dictionary = [NSJSONSerialization JSONObjectWithData: varToJsonData (varToParse) + options: NSJSONReadingMutableContainers + error: &error]; + + jassert (error == nullptr); + jassert (dictionary != nullptr); + + return dictionary; } -inline var nsArrayToVar (NSArray* array) +inline NSData* jsonObjectToData (const NSObject* jsonObject) { - Array resultArray; + NSError* error { nullptr }; + auto* jsonData = [NSJSONSerialization dataWithJSONObject: jsonObject + options: 0 + error: &error]; - for (id value in array) - resultArray.add (nsObjectToVar (value)); + jassert (error == nullptr); + jassert (jsonData != nullptr); - return var (resultArray); + return jsonData; } -inline var nsObjectToVar (NSObject* obj) +inline var nsDictionaryToVar (NSDictionary* dictionary) { - if ([obj isKindOfClass: [NSString class]]) return nsStringToJuce ((NSString*) obj); - else if ([obj isKindOfClass: [NSNumber class]]) return nsStringToJuce ([(NSNumber*) obj stringValue]); - else if ([obj isKindOfClass: [NSDictionary class]]) return nsDictionaryToVar ((NSDictionary*) obj); - else if ([obj isKindOfClass: [NSArray class]]) return nsArrayToVar ((NSArray*) obj); - else - { - // Unsupported yet, add here! - jassertfalse; - } - - return {}; + return jsonDataToVar (jsonObjectToData (dictionary)); } #if JUCE_MAC @@ -359,9 +297,11 @@ struct ObjCClass ObjCClass (const char* nameRoot) : cls (objc_allocateClassPair ([SuperclassType class], getRandomisedName (nameRoot).toUTF8(), 0)) { + // The class could not be created. Is the name already in use? + jassert (cls != nil); } - ~ObjCClass() + virtual ~ObjCClass() { auto kvoSubclassName = String ("NSKVONotifying_") + class_getName (cls); @@ -371,7 +311,8 @@ struct ObjCClass void registerClass() { - objc_registerClassPair (cls); + if (cls != nil) + objc_registerClassPair (cls); } SuperclassType* createInstance() const @@ -393,8 +334,8 @@ struct ObjCClass void addMethod (SEL selector, Result (*callbackFn) (id, SEL, Args...)) { const auto s = detail::makeCompileTimeStr (@encode (Result), @encode (id), @encode (SEL), @encode (Args)...); - const auto b = class_addMethod (cls, selector, (IMP) callbackFn, s.data()); - jassertquiet (b); + [[maybe_unused]] const auto b = class_addMethod (cls, selector, (IMP) callbackFn, s.data()); + jassert (b); } void addProtocol (Protocol* protocol) diff --git a/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac_test.mm b/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac_test.mm new file mode 100644 index 00000000..babfea94 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/native/juce_ObjCHelpers_mac_test.mm @@ -0,0 +1,72 @@ +namespace juce +{ + +class ObjCHelpersTest final : public UnitTest +{ +public: + ObjCHelpersTest() : UnitTest { "ObjCHelpers", UnitTestCategories::native } {} + + void runTest() final + { + beginTest ("Range"); + { + constexpr auto start = 10; + constexpr auto length = 20; + + const auto juceRange = Range::withStartAndLength (start, length); + const auto nsRange = NSMakeRange (start, length); + + expect (nsRangeToJuce (nsRange) == juceRange); + expect (NSEqualRanges (nsRange, juceRangeToNS (juceRange))); + } + + beginTest ("String"); + { + String juceString { "Hello world!" }; + NSString *nsString { @"Hello world!" }; + + expect (nsStringToJuce (nsString) == juceString); + expect ([nsString isEqualToString: juceStringToNS (juceString)]); + expect ([nsString isEqualToString: nsStringLiteral ("Hello world!")]); + } + + beginTest ("StringArray"); + { + const StringArray stringArray { "Hello world!", "this", "is", "a", "test" }; + NSArray *nsArray { @[@"Hello world!", @"this", @"is", @"a", @"test"] }; + + expect ([nsArray isEqualToArray: createNSArrayFromStringArray (stringArray)]); + } + + beginTest ("Dictionary"); + { + DynamicObject::Ptr data { new DynamicObject() }; + data->setProperty ("integer", 1); + data->setProperty ("double", 2.3); + data->setProperty ("boolean", true); + data->setProperty ("string", "Hello world!"); + + Array array { 45, 67.8, true, "Hello array!" }; + data->setProperty ("array", array); + + auto *nsDictionary = varObjectToNSDictionary (data.get()); + auto clone = nsDictionaryToVar (nsDictionary); + + expect (clone.getProperty ("integer", {}).isInt()); + expect (clone.getProperty ("double", {}).isDouble()); + expect (clone.getProperty ("boolean", {}).isBool()); + expect (clone.getProperty ("string", {}).isString()); + expect (clone.getProperty ("array", {}).isArray()); + + expect (clone.getProperty ("integer", {}) == var { 1 }); + expect (clone.getProperty ("double", {}) == var { 2.3 }); + expect (clone.getProperty ("boolean", {}) == var { true }); + expect (clone.getProperty ("string", {}) == var { "Hello world!" }); + expect (clone.getProperty ("array", {}) == array); + } + } +}; + +static ObjCHelpersTest objCHelpersTest; + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/native/juce_RuntimePermissions_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_RuntimePermissions_android.cpp index 52584e19..b6d9d734 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_RuntimePermissions_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_RuntimePermissions_android.cpp @@ -104,7 +104,7 @@ struct PermissionsRequest }; //============================================================================== -struct PermissionsOverlay : FragmentOverlay +struct PermissionsOverlay final : public FragmentOverlay { PermissionsOverlay (CriticalSection& cs) : overlayGuard (cs) {} ~PermissionsOverlay() override = default; @@ -182,13 +182,13 @@ struct PermissionsOverlay : FragmentOverlay auto requestPermissionsMethodID - = env->GetMethodID(AndroidFragment, "requestPermissions", "([Ljava/lang/String;I)V"); + = env->GetMethodID (AndroidFragment, "requestPermissions", "([Ljava/lang/String;I)V"); // this code should only be reached for SDKs >= 23, so this method should be // be available - jassert(requestPermissionsMethodID != nullptr); + jassert (requestPermissionsMethodID != nullptr); - env->CallVoidMethod (getNativeHandle(), requestPermissionsMethodID, jPermissionsArray.get (), 0); + env->CallVoidMethod (getNativeHandle(), requestPermissionsMethodID, jPermissionsArray.get(), 0); } else { diff --git a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_android.cpp index 4a56391c..667ca166 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_android.cpp @@ -128,7 +128,7 @@ int SystemStats::getCpuSpeedInMegahertz() for (int i = 0; i < getNumCpus(); ++i) { - int freqKHz = File ("/sys/devices/system/cpu/cpu" + String(i) + "/cpufreq/cpuinfo_max_freq") + int freqKHz = File ("/sys/devices/system/cpu/cpu" + String (i) + "/cpufreq/cpuinfo_max_freq") .loadFileAsString() .getIntValue(); diff --git a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_mac.mm b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_mac.mm index eaa14782..2c922c07 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_mac.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_mac.mm @@ -311,7 +311,7 @@ static String getLocaleValue (CFStringRef key) } highResTimerFrequency = (timebase.denom * (uint64) 1000000000) / timebase.numer; - highResTimerToMillisecRatio = hiResCounterNumerator / (double) hiResCounterDenominator; + highResTimerToMillisecRatio = (double) hiResCounterNumerator / (double) hiResCounterDenominator; } uint32 millisecondsSinceStartup() const noexcept @@ -321,7 +321,7 @@ uint32 millisecondsSinceStartup() const noexcept double getMillisecondCounterHiRes() const noexcept { - return mach_absolute_time() * highResTimerToMillisecRatio; + return (double) mach_absolute_time() * highResTimerToMillisecRatio; } int64 highResTimerFrequency; diff --git a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_windows.cpp b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_windows.cpp index 0972e83d..151dc5cc 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_windows.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_SystemStats_windows.cpp @@ -244,7 +244,7 @@ static DebugFlagsInitialiser debugFlagsInitialiser; #if JUCE_MINGW static uint64 getWindowsVersion() { - auto filename = _T("kernel32.dll"); + auto filename = _T ("kernel32.dll"); DWORD handle = 0; if (auto size = GetFileVersionInfoSize (filename, &handle)) @@ -256,7 +256,7 @@ static DebugFlagsInitialiser debugFlagsInitialiser; VS_FIXEDFILEINFO* info = nullptr; UINT verSize = 0; - if (VerQueryValue (data, (LPCTSTR) _T("\\"), (void**) &info, &verSize)) + if (VerQueryValue (data, (LPCTSTR) _T ("\\"), (void**) &info, &verSize)) if (size > 0 && info != nullptr && info->dwSignature == 0xfeef04bd) return ((uint64) info->dwFileVersionMS << 32) | (uint64) info->dwFileVersionLS; } diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Threads_android.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Threads_android.cpp index 19a0507d..21b7a910 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Threads_android.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Threads_android.cpp @@ -72,7 +72,7 @@ extern "C" jint JNIEXPORT JNI_OnLoad (JavaVM* vm, void*) auto* env = getEnv(); // register the initialisation function - auto juceJavaClass = env->FindClass("com/rmsl/juce/Java"); + auto juceJavaClass = env->FindClass ("com/rmsl/juce/Java"); if (juceJavaClass != nullptr) { @@ -94,7 +94,7 @@ extern "C" jint JNIEXPORT JNI_OnLoad (JavaVM* vm, void*) } //============================================================================== -class JuceActivityWatcher : public ActivityLifecycleCallbacks +class JuceActivityWatcher final : public ActivityLifecycleCallbacks { public: JuceActivityWatcher() diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Threads_mac.mm b/JuceLibraryCode/modules/juce_core/native/juce_Threads_mac.mm index ed81ea2d..64b10957 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Threads_mac.mm +++ b/JuceLibraryCode/modules/juce_core/native/juce_Threads_mac.mm @@ -237,7 +237,7 @@ static bool tryToUpgradeCurrentThreadToRealtime (const Thread::RealtimeOptions& #if JUCE_MAC [NSApp hide: nil]; #elif JUCE_IOS - [[UIApplication sharedApplication] performSelector: @selector(suspend)]; + [[UIApplication sharedApplication] performSelector: @selector (suspend)]; #endif } } diff --git a/JuceLibraryCode/modules/juce_core/native/juce_Threads_windows.cpp b/JuceLibraryCode/modules/juce_core/native/juce_Threads_windows.cpp index a4a39bd1..594f145c 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_Threads_windows.cpp +++ b/JuceLibraryCode/modules/juce_core/native/juce_Threads_windows.cpp @@ -178,7 +178,7 @@ struct SleepEvent SleepEvent() noexcept : handle (CreateEvent (nullptr, FALSE, FALSE, #if JUCE_DEBUG - _T("JUCE Sleep Event"))) + _T ("JUCE Sleep Event"))) #else nullptr)) #endif diff --git a/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp index f9394112..e2880507 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_IPAddress.cpp @@ -377,7 +377,7 @@ Array IPAddress::getAllAddresses (bool includeIPv6) //============================================================================== #if JUCE_UNIT_TESTS -struct IPAddressTests : public UnitTest +struct IPAddressTests final : public UnitTest { IPAddressTests() : UnitTest ("IPAddress", UnitTestCategories::networking) diff --git a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp index c47aa5c9..a42e066b 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_NamedPipe.cpp @@ -69,7 +69,7 @@ String NamedPipe::getName() const //============================================================================== #if JUCE_UNIT_TESTS -class NamedPipeTests : public UnitTest +class NamedPipeTests final : public UnitTest { public: //============================================================================== @@ -200,7 +200,7 @@ class NamedPipeTests : public UnitTest private: //============================================================================== - struct NamedPipeThread : public Thread + struct NamedPipeThread : public Thread { NamedPipeThread (const String& tName, const String& pName, bool shouldCreatePipe, WaitableEvent& completed) @@ -220,7 +220,7 @@ class NamedPipeTests : public UnitTest }; //============================================================================== - struct SenderThread : public NamedPipeThread + struct SenderThread final : public NamedPipeThread { SenderThread (const String& pName, bool shouldCreatePipe, WaitableEvent& completed, int sData) @@ -243,7 +243,7 @@ class NamedPipeTests : public UnitTest }; //============================================================================== - struct ReceiverThread : public NamedPipeThread + struct ReceiverThread final : public NamedPipeThread { ReceiverThread (const String& pName, bool shouldCreatePipe, WaitableEvent& completed) diff --git a/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp b/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp index c020720b..c788ba6b 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp @@ -794,7 +794,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC //============================================================================== #if JUCE_UNIT_TESTS -struct SocketTests : public UnitTest +struct SocketTests final : public UnitTest { SocketTests() : UnitTest ("Sockets", UnitTestCategories::networking) diff --git a/JuceLibraryCode/modules/juce_core/network/juce_Socket.h b/JuceLibraryCode/modules/juce_core/network/juce_Socket.h index 6d877fad..68916171 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_Socket.h +++ b/JuceLibraryCode/modules/juce_core/network/juce_Socket.h @@ -69,7 +69,7 @@ class JUCE_API StreamingSocket final @returns true on success; false may indicate that another socket is already bound on the same port - @see bindToPort(int localPortNumber), IPAddress::getAllAddresses + @see bindToPort (int localPortNumber), IPAddress::getAllAddresses */ bool bindToPort (int localPortNumber, const String& localAddress); @@ -238,7 +238,7 @@ class JUCE_API DatagramSocket final @returns true on success; false may indicate that another socket is already bound on the same port - @see bindToPort(int localPortNumber), IPAddress::getAllAddresses + @see bindToPort (int localPortNumber), IPAddress::getAllAddresses */ bool bindToPort (int localPortNumber, const String& localAddress); diff --git a/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp b/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp index dd10be08..878e7928 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_URL.cpp @@ -23,8 +23,8 @@ namespace juce { -struct FallbackDownloadTask : public URL::DownloadTask, - public Thread +struct FallbackDownloadTask final : public URL::DownloadTask, + public Thread { FallbackDownloadTask (std::unique_ptr outputStreamToUse, size_t bufferSizeToUse, @@ -598,7 +598,7 @@ template struct iOSFileStreamWrapperFlush { static void flu template <> struct iOSFileStreamWrapperFlush { static void flush (OutputStream* o) { o->flush(); } }; template -class iOSFileStreamWrapper : public Stream +class iOSFileStreamWrapper final : public Stream { public: iOSFileStreamWrapper (URL& urlToUse) @@ -769,7 +769,7 @@ std::unique_ptr URL::createInputStream (const InputStreamOptions& o return stream; }(); - struct ProgressCallbackCaller : public WebInputStream::Listener + struct ProgressCallbackCaller final : public WebInputStream::Listener { ProgressCallbackCaller (std::function progressCallbackToUse) : callback (std::move (progressCallbackToUse)) @@ -947,7 +947,7 @@ String URL::removeEscapeChars (const String& s) for (int i = 0; i < utf8.size(); ++i) { - if (utf8.getUnchecked(i) == '%') + if (utf8.getUnchecked (i) == '%') { auto hexDigit1 = CharacterFunctions::getHexDigitValue ((juce_wchar) (uint8) utf8 [i + 1]); auto hexDigit2 = CharacterFunctions::getHexDigitValue ((juce_wchar) (uint8) utf8 [i + 2]); @@ -975,7 +975,7 @@ String URL::addEscapeChars (const String& s, bool isParameter, bool roundBracket for (int i = 0; i < utf8.size(); ++i) { - auto c = utf8.getUnchecked(i); + auto c = utf8.getUnchecked (i); if (! (CharacterFunctions::isLetterOrDigit (c) || legalChars.containsChar ((juce_wchar) c))) @@ -1022,7 +1022,7 @@ std::unique_ptr URL::createInputStream (bool usePostCommand, .withConnectionTimeoutMs (timeOutMs) .withResponseHeaders (responseHeaders) .withStatusCode (statusCode) - .withNumRedirectsToFollow(numRedirectsToFollow) + .withNumRedirectsToFollow (numRedirectsToFollow) .withHttpRequestCmd (httpRequestCmd)); } diff --git a/JuceLibraryCode/modules/juce_core/network/juce_WebInputStream.cpp b/JuceLibraryCode/modules/juce_core/network/juce_WebInputStream.cpp index 71b58311..4a00d62c 100644 --- a/JuceLibraryCode/modules/juce_core/network/juce_WebInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/network/juce_WebInputStream.cpp @@ -33,7 +33,7 @@ WebInputStream::~WebInputStream() } WebInputStream& WebInputStream::withExtraHeaders (const String& extra) { pimpl->withExtraHeaders (extra); return *this; } -WebInputStream& WebInputStream::withCustomRequestCommand (const String& cmd) { pimpl->withCustomRequestCommand(cmd); return *this; } +WebInputStream& WebInputStream::withCustomRequestCommand (const String& cmd) { pimpl->withCustomRequestCommand (cmd); return *this; } WebInputStream& WebInputStream::withConnectionTimeout (int t) { pimpl->withConnectionTimeout (t); return *this; } WebInputStream& WebInputStream::withNumRedirectsToFollow (int num) { pimpl->withNumRedirectsToFollow (num); return *this; } StringPairArray WebInputStream::getRequestHeaders() const { return pimpl->getRequestHeaders(); } diff --git a/JuceLibraryCode/modules/juce_core/serialisation/juce_Serialisation.h b/JuceLibraryCode/modules/juce_core/serialisation/juce_Serialisation.h new file mode 100644 index 00000000..09b5c5f5 --- /dev/null +++ b/JuceLibraryCode/modules/juce_core/serialisation/juce_Serialisation.h @@ -0,0 +1,576 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/** + Allows serialisation functions to be attached to a specific type without having to modify the + declaration of that type. + + A specialisation of SerialisationTraits must include: + - A static constexpr data member named 'marshallingVersion' with a value that is convertible + to std::optional. + - Either: + - Normally, a single function with the following signature: + @code + template + static void serialise (Archive& archive, Item& item); + @endcode + - For types that must do slightly different work when loading and saving, you may supply two + functions with the following signatures, where "T" is a placeholder for the type on which + SerialisationTraits is specialised: + @code + template + static void load (Archive& archive, T& item); + + template + static void save (Archive& archive, const T& item); + @endcode + + If the marshallingVersion converts to a null optional, then all versioning information will be + ignored when marshalling the type. Otherwise, if the value converts to a non-null optional, this + versioning information will be included when serialising the type. + + Inside serialise() and load() you may call archive.getVersion() to find the detected version + of the object being deserialised. archive.getVersion() will return an std::optional, + where 'nullopt' indicates that no versioning information was detected. + + Marshalling functions can also be specified directly inside the type to be marshalled. This + approach may be preferable as it is more concise. Internal marshalling functions are written + in exactly the same way as external ones; i.e. the type must include a marshallingVersion, + and either a single serialise function, or a load/save pair of functions, as specified above. + + @tags{Core} +*/ +template struct SerialisationTraits +{ + /* Intentionally left blank. */ +}; + +#define JUCE_COMPARISON_OPS X(==) X(!=) X(<) X(<=) X(>) X(>=) + +/** + Combines an object with a name. + + Instances of Named have reference-like semantics. That is, Named stores a reference + to a wrapped value, rather than storing the value internally. + + @tparam T the type of reference that is wrapped. Passing "const T" will cause the Named + instance to hold a "const T&"; passing "T" will cause the Named instance to + hold a "T&". + + @see named() + + @tags{Core} +*/ +template +struct Named +{ + #define X(op) auto operator op (const Named& other) const { return value op other.value; } + JUCE_COMPARISON_OPS + #undef X + + std::string_view name; ///< A name that corresponds to the value + T& value; ///< A reference to a value to wrap +}; + +/** Produces a Named instance that holds a mutable reference. */ +template constexpr auto named (std::string_view c, T& t) { return Named { c, t }; } + +/** Produces a Named instance that holds an immutable reference. */ +template constexpr auto named (std::string_view c, const T& t) { return Named { c, t }; } + +/** + Holds a reference to some kind of size value, used to indicate that an object being marshalled + is of variable size (e.g. Array, vector, map, set, etc.). + + If you need to write your own serialisation routines for a dynamically-sized type, ensure + that you archive an instance of SerialisationSize before any of the contents of the container. + + @tparam T the (probably numeric) type of the size value + + @see serialisztionSize() + + @tags{Core} +*/ +template +struct SerialisationSize +{ + #define X(op) auto operator op (const SerialisationSize& other) const { return size op other.size; } + JUCE_COMPARISON_OPS + #undef X + + T& size; +}; + +/** Produces a SerialisationSize instance that holds a mutable reference to a size value. */ +template constexpr auto serialisationSize (T& t) -> std::enable_if_t, SerialisationSize> { return { t }; } + +/** Produces a SerialisationSize instance that holds an immutable reference to a size value. */ +template constexpr auto serialisationSize (const T& t) -> std::enable_if_t, SerialisationSize> { return { t }; } + +#undef JUCE_COMPARISON_OPS + +//============================================================================== +/* + The following are specialisations of SerialisationTraits for commonly-used types. +*/ + +#ifndef DOXYGEN + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + t.resize (size); + + for (auto& element : t) + archive (element); + } + + template + static void save (Archive& archive, const T& t) + { + archive (serialisationSize (t.size())); + + for (auto& element : t) + archive (element); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + t.resize (size); + + for (auto& element : t) + archive (element); + } + + template + static void save (Archive& archive, const T& t) + { + archive (serialisationSize (t.size())); + + for (auto& element : t) + archive (element); + } +}; + +template <> +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (t.strings); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) + { + archive (named ("first", t.first), named ("second", t.second)); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, std::optional& t) + { + bool engaged = false; + + archive (named ("engaged", engaged)); + + if (! engaged) + return; + + t.emplace(); + archive (named ("value", *t)); + } + + template + static void save (Archive& archive, const std::optional& t) + { + archive (named ("engaged", t.has_value())); + + if (t.has_value()) + archive (named ("value", *t)); + } +}; + +template <> +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, std::string& t) + { + String temporary; + archive (temporary); + t = temporary.toStdString(); + } + + template + static void save (Archive& archive, const std::string& t) + { + archive (String (t)); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + + for (auto i = (decltype (size)) 0; i < size; ++i) + { + std::pair element; + archive (element); + t.insert (element); + } + } + + template + static void save (Archive& archive, const T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + + for (const auto& element : t) + archive (element); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + + for (auto i = (decltype (size)) 0; i < size; ++i) + { + typename T::value_type element; + archive (element); + t.insert (element); + } + } + + template + static void save (Archive& archive, const T& t) + { + auto size = t.size(); + archive (serialisationSize (size)); + + for (const auto& element : t) + archive (element); + } +}; + +template +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void serialise (Archive& archive, T& t) { archive (String (t, N)); } +}; + +template +struct SerialisationTraits +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = N; + archive (serialisationSize (size)); + + for (auto& element : t) + archive (element); + } + + template + static void save (Archive& archive, const T& t) + { + const auto size = N; + archive (serialisationSize (size)); + + for (auto& element : t) + archive (element); + } +}; + +template +struct SerialisationTraits> +{ + static constexpr auto marshallingVersion = std::nullopt; + + template + static void load (Archive& archive, T& t) + { + auto size = N; + archive (serialisationSize (size)); + + for (auto& element : t) + archive (element); + } + + template + static void save (Archive& archive, const T& t) + { + const auto size = N; + archive (serialisationSize (size)); + + for (auto& element : t) + archive (element); + } +}; + +/* + This namespace holds utilities for detecting and using serialisation functions. + + The contents of this namespace are private, and liable to change, so you shouldn't use any of + the contents directly. +*/ +namespace detail +{ + struct DummyArchive + { + template + bool operator() (Ts&&...); + + std::optional getVersion() const { return {}; } + }; + + template + constexpr auto hasInternalVersion = false; + + template + constexpr auto hasInternalVersion> = true; + + template + constexpr auto hasInternalSerialise = false; + + template + constexpr auto hasInternalSerialise(), std::declval()))>> = true; + + template + constexpr auto hasInternalLoad = false; + + template + constexpr auto hasInternalLoad(), std::declval()))>> = true; + + template + constexpr auto hasInternalSave = false; + + template + constexpr auto hasInternalSave(), std::declval()))>> = true; + + template + struct SerialisedTypeTrait { using type = T; }; + + template + struct SerialisedTypeTrait> { using type = T; }; + + template + using SerialisedType = typename SerialisedTypeTrait::type; + + template + constexpr auto hasSerialisation = hasInternalVersion> + || hasInternalSerialise> + || hasInternalLoad> + || hasInternalSave>; + + /* Different kinds of serialisation function. */ + enum class SerialisationKind + { + none, // The type doesn't have any serialisation + primitive, // The type has serialisation handling defined directly on the archiver. enums will be converted to equivalent integral values + internal, // The type has internally-defined serialisation utilities + external, // The type has an external specialisation of SerialisationTraits + }; + + /* The SerialisationKind to use for the type T. + + Primitive serialisation is used for arithmetic types, enums, Strings, and vars. + Internal serialisation is used for types that declare an internal marshallingVersion, + serialise(), load(), or save(). + External serialisation is used in all other cases. + */ + template + constexpr auto serialisationKind = [] + { + if constexpr (std::is_arithmetic_v || std::is_enum_v || std::is_same_v || std::is_same_v) + return SerialisationKind::primitive; + else if constexpr (hasSerialisation) + return SerialisationKind::internal; + else if constexpr (hasSerialisation>) + return SerialisationKind::external; + else + return SerialisationKind::none; + }(); + + /* This trait defines the serialisation utilities that are used for primitive types. */ + template > + struct ForwardingSerialisationTraits + { + static constexpr auto marshallingVersion = std::nullopt; + + template + static auto load (Archive& archive, Primitive& t) + { + if constexpr (std::is_enum_v) + return archive (*reinterpret_cast*> (&t)); + else + return archive (t); + } + + template + static auto save (Archive& archive, const Primitive& t) + { + if constexpr (std::is_enum_v) + return archive (*reinterpret_cast*> (&t)); + else + return archive (t); + } + }; + + /* This specialisation will be used for types with internal serialisation. + + All members of ForwardingSerialisationTraits forward to the corresponding member of T. + */ + template + struct ForwardingSerialisationTraits + { + static constexpr std::optional marshallingVersion { T::marshallingVersion }; + + template + static auto serialise (Archive& archive, Item& t) -> decltype (Item::serialise (archive, t)) { return Item::serialise (archive, t); } + + template + static auto load (Archive& archive, Item& t) -> decltype (Item::load (archive, t)) { return Item::load (archive, t); } + + template + static auto save (Archive& archive, const Item& t) -> decltype (Item::save (archive, t)) { return Item::save (archive, t); } + }; + + /* This specialisation will be used for types with external serialisation. + + @see SerialisationTraits + */ + template + struct ForwardingSerialisationTraits : SerialisationTraits {}; + + template + constexpr auto hasSerialise = false; + + template + constexpr auto hasSerialise::serialise (std::declval(), std::declval()))>> = true; + + template + constexpr auto hasLoad = false; + + template + constexpr auto hasLoad::load (std::declval(), std::declval()))>> = true; + + template + constexpr auto hasSave = false; + + template + constexpr auto hasSave::save (std::declval(), std::declval()))>> = true; + + template + constexpr auto delayStaticAssert = false; + + /* Calls the correct function (serialise or save) to save the argument t to the archive. + */ + template + auto doSave (Archive& archive, const T& t) + { + if constexpr (serialisationKind == SerialisationKind::none) + static_assert (delayStaticAssert, "No serialisation function found or marshallingVersion unset"); + else if constexpr (hasSerialise && ! hasSave) + return ForwardingSerialisationTraits::serialise (archive, t); + else if constexpr (! hasSerialise && hasSave) + return ForwardingSerialisationTraits::save (archive, t); + else + static_assert (delayStaticAssert, "Multiple serialisation functions found"); + } + + /* Calls the correct function (serialise or load) to load the argument t from the archive. + */ + template + auto doLoad (Archive& archive, T& t) + { + if constexpr (serialisationKind == SerialisationKind::none) + static_assert (delayStaticAssert, "No serialisation function found or marshallingVersion unset"); + else if constexpr (hasSerialise && ! hasLoad) + return ForwardingSerialisationTraits::serialise (archive, t); + else if constexpr (! hasSerialise && hasLoad) + return ForwardingSerialisationTraits::load (archive, t); + else + static_assert (delayStaticAssert, "Multiple serialisation functions found"); + } +} // namespace detail + +#endif + +} // namespace juce diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp index fdde48a6..ab94eac9 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_BufferedInputStream.cpp @@ -185,7 +185,7 @@ String BufferedInputStream::readString() //============================================================================== #if JUCE_UNIT_TESTS -struct BufferedInputStreamTests : public UnitTest +struct BufferedInputStreamTests final : public UnitTest { template static void applyImpl (Fn&& fn, std::index_sequence, Values&& values) diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp index 80064673..ee62517e 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -104,7 +104,7 @@ void MemoryInputStream::skipNextBytes (int64 numBytesToSkip) //============================================================================== #if JUCE_UNIT_TESTS -class MemoryStreamTests : public UnitTest +class MemoryStreamTests final : public UnitTest { public: MemoryStreamTests() diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp index bb2572a1..c4c63353 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_SubregionStream.cpp @@ -83,7 +83,7 @@ bool SubregionStream::isExhausted() //============================================================================== #if JUCE_UNIT_TESTS -struct SubregionInputStreamTests : public UnitTest +struct SubregionInputStreamTests final : public UnitTest { SubregionInputStreamTests() : UnitTest ("SubregionInputStream", UnitTestCategories::streams) diff --git a/JuceLibraryCode/modules/juce_core/streams/juce_URLInputSource.cpp b/JuceLibraryCode/modules/juce_core/streams/juce_URLInputSource.cpp index d50c4c54..468b46a1 100644 --- a/JuceLibraryCode/modules/juce_core/streams/juce_URLInputSource.cpp +++ b/JuceLibraryCode/modules/juce_core/streams/juce_URLInputSource.cpp @@ -46,7 +46,7 @@ InputStream* URLInputSource::createInputStreamFor (const String& relatedItemPath { auto sub = u.getSubPath(); auto parent = sub.containsChar (L'/') ? sub.upToLastOccurrenceOf ("/", false, false) - : String (); + : String(); return u.withNewSubPath (parent) .getChildURL (relatedItemPath) diff --git a/JuceLibraryCode/modules/juce_core/system/juce_CompilerSupport.h b/JuceLibraryCode/modules/juce_core/system/juce_CompilerSupport.h index c1e173c5..b0d88cb4 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_CompilerSupport.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_CompilerSupport.h @@ -63,6 +63,39 @@ #endif #endif + #if ! defined (JUCE_SILENCE_XCODE_15_LINKER_WARNING) \ + && defined (__apple_build_version__) \ + && __clang_major__ == 15 \ + && __clang_minor__ == 0 + // This is a warning because builds may be usable when LTO is disabled + #pragma GCC warning "If you are using Link Time Optimisation (LTO), the " \ + "new linker introduced in Xcode 15 may produce a broken binary.\n" \ + "As a workaround, add either '-Wl,-weak_reference_mismatches,weak' or " \ + "'-Wl,-ld_classic' to your linker flags.\n" \ + "Once you've selected a workaround, you can add " \ + "JUCE_SILENCE_XCODE_15_LINKER_WARNING to your preprocessor definitions " \ + "to silence this warning." + + #if ((defined (MAC_OS_X_VERSION_MIN_REQUIRED) \ + && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_13_0) \ + || (defined (__IPHONE_OS_VERSION_MIN_REQUIRED) \ + && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_15_0)) + // This is an error because the linker _will_ produce a binary that is + // broken on older platforms + static_assert (std::string_view (__clang_version__) + != std::string_view ("15.0.0 (clang-1500.0.40.1)"), + "The new linker introduced in Xcode 15.0 will produce " + "broken binaries when targeting older platforms.\n" + "To work around this issue, bump your deployment target to " + "macOS 13 or iOS 15, re-enable the old linker by adding " + "'-Wl,-ld_classic' to your link flags, or update to Xcode " + "15.1.\n" + "Once you've selected a workaround, you can add " + "JUCE_SILENCE_XCODE_15_LINKER_WARNING to your preprocessor " + "definitions to silence this warning."); + #endif + #endif + #define JUCE_CXX14_IS_AVAILABLE (__cplusplus >= 201402L) #define JUCE_CXX17_IS_AVAILABLE (__cplusplus >= 201703L) diff --git a/JuceLibraryCode/modules/juce_core/system/juce_CompilerWarnings.h b/JuceLibraryCode/modules/juce_core/system/juce_CompilerWarnings.h index e13af095..9c4657b9 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_CompilerWarnings.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_CompilerWarnings.h @@ -232,8 +232,8 @@ */ #if JUCE_CLANG && __clang_major__ >= JUCE_SANITIZER_ATTRIBUTE_MINIMUM_CLANG_VERSION #define JUCE_BEGIN_NO_SANITIZE(warnings) \ - _Pragma(JUCE_TO_STRING(clang attribute push(__attribute__((no_sanitize(warnings))), apply_to=function))) - #define JUCE_END_NO_SANITIZE _Pragma(JUCE_TO_STRING(clang attribute pop)) + _Pragma (JUCE_TO_STRING (clang attribute push (__attribute__ ((no_sanitize (warnings))), apply_to=function))) + #define JUCE_END_NO_SANITIZE _Pragma (JUCE_TO_STRING (clang attribute pop)) #else #define JUCE_BEGIN_NO_SANITIZE(warnings) #define JUCE_END_NO_SANITIZE diff --git a/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h b/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h index 0b7e64a3..4aad3b39 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_PlatformDefs.h @@ -87,7 +87,7 @@ namespace juce #if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN) #if __has_feature (attribute_analyzer_noreturn) - inline void __attribute__((analyzer_noreturn)) juce_assert_noreturn() {} + inline void __attribute__ ((analyzer_noreturn)) juce_assert_noreturn() {} #define JUCE_ANALYZER_NORETURN juce::juce_assert_noreturn(); #endif #endif @@ -163,9 +163,7 @@ namespace juce /** Platform-independent assertion macro which suppresses ignored-variable warnings in all build modes. You should probably use a plain jassert() - by default, and only replace it with jassertquiet() once you've - convinced yourself that any unused-variable warnings emitted by the - compiler are harmless. + and [[maybe_unused]] by default. */ #define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;) @@ -174,7 +172,7 @@ namespace juce // If debugging is disabled, these dummy debug and assertion macros are used.. #define DBG(textToWrite) - #define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION) + #define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION;) #if JUCE_LOG_ASSERTIONS #define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;) @@ -285,7 +283,7 @@ namespace juce #if JUCE_MSVC #define forcedinline __forceinline #else - #define forcedinline inline __attribute__((always_inline)) + #define forcedinline inline __attribute__ ((always_inline)) #endif #endif @@ -308,7 +306,7 @@ namespace juce //============================================================================== #if JUCE_GCC || JUCE_CLANG - #define JUCE_PACKED __attribute__((packed)) + #define JUCE_PACKED __attribute__ ((packed)) #elif ! defined (DOXYGEN) #define JUCE_PACKED #endif @@ -317,7 +315,7 @@ namespace juce #if JUCE_GCC || DOXYGEN /** This can be appended to a function declaration to tell gcc to disable associative math optimisations which break some floating point algorithms. */ - #define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS __attribute__((__optimize__("no-associative-math"))) + #define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS __attribute__ ((__optimize__ ("no-associative-math"))) #else #define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS #endif diff --git a/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h b/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h index a7b2d350..182c3c71 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h +++ b/JuceLibraryCode/modules/juce_core/system/juce_StandardHeader.h @@ -29,7 +29,7 @@ */ #define JUCE_MAJOR_VERSION 7 #define JUCE_MINOR_VERSION 0 -#define JUCE_BUILDNUMBER 7 +#define JUCE_BUILDNUMBER 8 /** Current JUCE version number. @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4514 4245 4100) #if JUCE_MAC || JUCE_IOS #include + #include #include #include #endif @@ -146,7 +148,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC #pragma warning (disable: 1125) // (virtual override warning) #endif #elif defined (JUCE_DLL) || defined (JUCE_DLL_BUILD) - #define JUCE_API __attribute__ ((visibility("default"))) + #define JUCE_API __attribute__ ((visibility ("default"))) #endif //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp index 5f9b7526..3d81430b 100644 --- a/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp +++ b/JuceLibraryCode/modules/juce_core/system/juce_SystemStats.cpp @@ -37,9 +37,9 @@ String SystemStats::getJUCEVersion() static_assert (sizeof (int64) == 8, "Basic sanity test failed: please report!"); static_assert (sizeof (uint64) == 8, "Basic sanity test failed: please report!"); - return "JUCE v" JUCE_STRINGIFY(JUCE_MAJOR_VERSION) - "." JUCE_STRINGIFY(JUCE_MINOR_VERSION) - "." JUCE_STRINGIFY(JUCE_BUILDNUMBER); + return "JUCE v" JUCE_STRINGIFY (JUCE_MAJOR_VERSION) + "." JUCE_STRINGIFY (JUCE_MINOR_VERSION) + "." JUCE_STRINGIFY (JUCE_BUILDNUMBER); } #if JUCE_ANDROID && ! defined (JUCE_DISABLE_JUCE_VERSION_PRINTING) @@ -292,7 +292,7 @@ bool SystemStats::isRunningInAppExtensionSandbox() noexcept #if JUCE_UNIT_TESTS -class UniqueHardwareIDTest : public UnitTest +class UniqueHardwareIDTest final : public UnitTest { public: //============================================================================== diff --git a/JuceLibraryCode/modules/juce_core/text/juce_Base64.cpp b/JuceLibraryCode/modules/juce_core/text/juce_Base64.cpp index 4cfe6980..d7f9ac05 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_Base64.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_Base64.cpp @@ -108,8 +108,8 @@ bool Base64::convertFromBase64 (OutputStream& binaryOutput, StringRef base64Text String Base64::toBase64 (const void* sourceData, size_t sourceDataSize) { MemoryOutputStream m ((sourceDataSize * 4) / 3 + 3); - bool ok = convertToBase64 (m, sourceData, sourceDataSize); - jassertquiet (ok); // should always succeed for this simple case + [[maybe_unused]] bool ok = convertToBase64 (m, sourceData, sourceDataSize); + jassert (ok); // should always succeed for this simple case return m.toString(); } @@ -123,7 +123,7 @@ String Base64::toBase64 (const String& text) //============================================================================== #if JUCE_UNIT_TESTS -class Base64Tests : public UnitTest +class Base64Tests final : public UnitTest { public: Base64Tests() diff --git a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp index 407e70a6..024fe61e 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -379,7 +379,7 @@ void withAllPrefixesAndSuffixes (const std::vector& prefixes, } template -class CharacterFunctionsTests : public UnitTest +class CharacterFunctionsTests final : public UnitTest { public: using CharType = typename CharPointerType::CharType; diff --git a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h index 61198e65..0049008c 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_LocalisedStrings.h @@ -55,10 +55,10 @@ namespace juce (you can use this to add comments). Note that this is a singleton class, so don't create or destroy the object directly. - There's also a TRANS(text) macro defined to make it easy to use the this. + There's also a TRANS (text) macro defined to make it easy to use the this. @code - printSomething (TRANS("hello")); + printSomething (TRANS ("hello")); @endcode This macro is used in the JUCE classes themselves, so your application has a chance to diff --git a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp index 4675f1ec..c5542608 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp @@ -439,7 +439,7 @@ namespace NumberToStringConverters return printDigits (t, v); } - struct StackArrayStream : public std::basic_streambuf> + struct StackArrayStream final : public std::basic_streambuf> { explicit StackArrayStream (char* d) { @@ -789,7 +789,7 @@ namespace StringHelpers template inline String& operationAddAssign (String& str, const T number) { - char buffer [(sizeof(T) * 8) / 2]; + char buffer [(sizeof (T) * 8) / 2]; auto* end = buffer + numElementsInArray (buffer); auto* start = NumberToStringConverters::numberToString (end, number); @@ -2319,7 +2319,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC #define STRINGIFY2(X) #X #define STRINGIFY(X) STRINGIFY2(X) -class StringTests : public UnitTest +class StringTests final : public UnitTest { public: StringTests() @@ -2420,12 +2420,12 @@ class StringTests : public UnitTest expect (s.compare (String ("012345678")) == 0); expect (s.compare (String ("012345679")) < 0); expect (s.compare (String ("012345676")) > 0); - expect (String("a").compareNatural ("A") == 0); - expect (String("A").compareNatural ("B") < 0); - expect (String("a").compareNatural ("B") < 0); - expect (String("10").compareNatural ("2") > 0); - expect (String("Abc 10").compareNatural ("aBC 2") > 0); - expect (String("Abc 1").compareNatural ("aBC 2") < 0); + expect (String ("a").compareNatural ("A") == 0); + expect (String ("A").compareNatural ("B") < 0); + expect (String ("a").compareNatural ("B") < 0); + expect (String ("10").compareNatural ("2") > 0); + expect (String ("Abc 10").compareNatural ("aBC 2") > 0); + expect (String ("Abc 1").compareNatural ("aBC 2") < 0); expect (s.substring (2, 3) == String::charToString (s[2])); expect (s.substring (0, 1) == String::charToString (s[0])); expect (s.getLastCharacter() == s [s.length() - 1]); @@ -2707,7 +2707,7 @@ class StringTests : public UnitTest expectEquals (s5.upToLastOccurrenceOf (String(), true, false), s5); expectEquals (s5.upToLastOccurrenceOf ("zword", true, false), s5); expectEquals (s5.upToLastOccurrenceOf ("word", true, false), s5.dropLastCharacters (1)); - expectEquals (s5.dropLastCharacters(1).upToLastOccurrenceOf ("word", true, false), s5.dropLastCharacters (1)); + expectEquals (s5.dropLastCharacters (1).upToLastOccurrenceOf ("word", true, false), s5.dropLastCharacters (1)); expectEquals (s5.upToLastOccurrenceOf ("Word", true, true), s5.dropLastCharacters (1)); expectEquals (s5.upToLastOccurrenceOf ("word", false, false), s5.dropLastCharacters (5)); expectEquals (s5.upToLastOccurrenceOf ("Word", false, true), s5.dropLastCharacters (5)); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_String.h b/JuceLibraryCode/modules/juce_core/text/juce_String.h index f7f72906..2eaf1813 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_String.h +++ b/JuceLibraryCode/modules/juce_core/text/juce_String.h @@ -24,7 +24,7 @@ // Annoyingly we can only forward-declare a typedef by forward-declaring the // aliased type #if __has_attribute(objc_bridge) - #define JUCE_CF_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) + #define JUCE_CF_BRIDGED_TYPE(T) __attribute__ ((objc_bridge (T))) #else #define JUCE_CF_BRIDGED_TYPE(T) #endif diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp index e2a445f1..2650a6e6 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringArray.cpp @@ -201,7 +201,7 @@ int StringArray::indexOf (StringRef stringToLookFor, bool ignoreCase, int i) con if (ignoreCase) { for (; i < numElements; ++i) - if (strings.getReference(i).equalsIgnoreCase (stringToLookFor)) + if (strings.getReference (i).equalsIgnoreCase (stringToLookFor)) return i; } else @@ -230,7 +230,7 @@ void StringArray::removeString (StringRef stringToRemove, bool ignoreCase) if (ignoreCase) { for (int i = size(); --i >= 0;) - if (strings.getReference(i).equalsIgnoreCase (stringToRemove)) + if (strings.getReference (i).equalsIgnoreCase (stringToRemove)) strings.remove (i); } else @@ -252,13 +252,13 @@ void StringArray::removeEmptyStrings (bool removeWhitespaceStrings) if (removeWhitespaceStrings) { for (int i = size(); --i >= 0;) - if (! strings.getReference(i).containsNonWhitespaceChars()) + if (! strings.getReference (i).containsNonWhitespaceChars()) strings.remove (i); } else { for (int i = size(); --i >= 0;) - if (strings.getReference(i).isEmpty()) + if (strings.getReference (i).isEmpty()) strings.remove (i); } } @@ -304,7 +304,7 @@ String StringArray::joinIntoString (StringRef separator, int start, int numberTo auto bytesNeeded = (size_t) (last - start - 1) * separatorBytes; for (int i = start; i < last; ++i) - bytesNeeded += strings.getReference(i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); + bytesNeeded += strings.getReference (i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); String result; result.preallocateBytes (bytesNeeded); @@ -412,7 +412,7 @@ void StringArray::removeDuplicates (bool ignoreCase) { for (int i = 0; i < size() - 1; ++i) { - auto s = strings.getReference(i); + auto s = strings.getReference (i); for (int nextIndex = i + 1;;) { @@ -439,7 +439,7 @@ void StringArray::appendNumbersToDuplicates (bool ignoreCase, for (int i = 0; i < size() - 1; ++i) { - auto& s = strings.getReference(i); + auto& s = strings.getReference (i); auto nextIndex = indexOf (s, ignoreCase, i + 1); if (nextIndex >= 0) diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp index ecc0c82b..efe8fa4b 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPairArray.cpp @@ -214,7 +214,7 @@ static String operator""_S (const char* chars, size_t) return String { chars }; } -class StringPairArrayTests : public UnitTest +class StringPairArrayTests final : public UnitTest { public: StringPairArrayTests() diff --git a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp index 2caf18e0..2a56c75a 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_StringPool.cpp @@ -149,7 +149,7 @@ void StringPool::garbageCollect() const ScopedLock sl (lock); for (int i = strings.size(); --i >= 0;) - if (strings.getReference(i).getReferenceCount() == 1) + if (strings.getReference (i).getReferenceCount() == 1) strings.remove (i); lastGarbageCollectionTime = Time::getApproximateMillisecondCounter(); diff --git a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp index 03f30fbb..c6f47d73 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_TextDiff.cpp @@ -224,7 +224,7 @@ String TextDiff::Change::appliedTo (const String& text) const noexcept //============================================================================== #if JUCE_UNIT_TESTS -class DiffTests : public UnitTest +class DiffTests final : public UnitTest { public: DiffTests() diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp index 1e559b1c..3a1d9cf0 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ChildProcess.cpp @@ -85,7 +85,7 @@ String ChildProcess::readAllProcessOutput() //============================================================================== #if JUCE_UNIT_TESTS -class ChildProcessTests : public UnitTest +class ChildProcessTests final : public UnitTest { public: ChildProcessTests() diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp index cec29223..34617564 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_HighResolutionTimer.cpp @@ -138,7 +138,7 @@ bool HighResolutionTimer::isTimerRunning() const noexcept //============================================================================== #if JUCE_UNIT_TESTS -class HighResolutionTimerTests : public UnitTest +class HighResolutionTimerTests final : public UnitTest { public: HighResolutionTimerTests() @@ -153,7 +153,7 @@ class HighResolutionTimerTests : public UnitTest WaitableEvent timerFiredOnce; WaitableEvent timerFiredTwice; - Timer timer {[&, callbackCount = 0] () mutable + Timer timer {[&, callbackCount = 0]() mutable { switch (++callbackCount) { @@ -181,7 +181,7 @@ class HighResolutionTimerTests : public UnitTest { WaitableEvent stoppedTimer; - auto timerCallback = [&](Timer& timer) + auto timerCallback = [&] (Timer& timer) { expect (timer.isTimerRunning()); timer.stopTimer(); @@ -200,7 +200,7 @@ class HighResolutionTimerTests : public UnitTest WaitableEvent timerRestarted; WaitableEvent timerFiredAfterRestart; - Timer timer {[&, callbackCount = 0] () mutable + Timer timer {[&, callbackCount = 0]() mutable { switch (++callbackCount) { @@ -240,7 +240,7 @@ class HighResolutionTimerTests : public UnitTest WaitableEvent stoppingTimer; std::atomic timerCallbackFinished { false }; - Timer timer {[&, callbackCount = 0] () mutable + Timer timer {[&, callbackCount = 0]() mutable { switch (++callbackCount) { @@ -295,7 +295,7 @@ class HighResolutionTimerTests : public UnitTest WaitableEvent timerFiredAfterRestart; std::atomic lastCallbackCount {0}; - Timer timer {[&, callbackCount = 0] () mutable + Timer timer {[&, callbackCount = 0]() mutable { switch (++callbackCount) { @@ -336,7 +336,7 @@ class HighResolutionTimerTests : public UnitTest WaitableEvent timerStopped; WaitableEvent timerFiredAfterRestart; - Timer timer {[&, callbackCount = 0] () mutable + Timer timer {[&, callbackCount = 0]() mutable { switch (++callbackCount) { @@ -411,7 +411,7 @@ class HighResolutionTimerTests : public UnitTest } } - class Timer : public HighResolutionTimer + class Timer final : public HighResolutionTimer { public: explicit Timer (std::function fn) diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp index 71366088..af0b4f9f 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.cpp @@ -48,7 +48,7 @@ Thread::~Thread() //============================================================================== // Use a ref-counted object to hold this shared data, so that it can outlive its static // shared pointer when threads are still running during static shutdown. -struct CurrentThreadHolder : public ReferenceCountedObject +struct CurrentThreadHolder final : public ReferenceCountedObject { CurrentThreadHolder() noexcept {} @@ -296,7 +296,7 @@ void Thread::notify() const } //============================================================================== -struct LambdaThread : public Thread +struct LambdaThread final : public Thread { LambdaThread (std::function&& f) : Thread ("anonymous"), fn (std::move (f)) {} @@ -354,7 +354,7 @@ bool JUCE_CALLTYPE Process::isRunningUnderDebugger() noexcept //============================================================================== #if JUCE_UNIT_TESTS -class AtomicTests : public UnitTest +class AtomicTests final : public UnitTest { public: AtomicTests() @@ -366,9 +366,9 @@ class AtomicTests : public UnitTest beginTest ("Misc"); char a1[7]; - expect (numElementsInArray(a1) == 7); + expect (numElementsInArray (a1) == 7); int a2[3]; - expect (numElementsInArray(a2) == 3); + expect (numElementsInArray (a2) == 3); expect (ByteOrder::swap ((uint16) 0x1122) == 0x2211); expect (ByteOrder::swap ((uint32) 0x11223344) == 0x44332211); @@ -478,8 +478,8 @@ class AtomicTests : public UnitTest static AtomicTests atomicUnitTests; //============================================================================== -class ThreadLocalValueUnitTest : public UnitTest, - private Thread +class ThreadLocalValueUnitTest final : public UnitTest, + private Thread { public: ThreadLocalValueUnitTest() diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h index 94abaea6..91ebd32a 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h +++ b/JuceLibraryCode/modules/juce_core/threads/juce_Thread.h @@ -111,6 +111,25 @@ class JUCE_API Thread return withMember (*this, &RealtimeOptions::maximumProcessingTimeMs, newMaximumProcessingTimeMs); } + /** Specify the maximum amount of processing time required each time the thread wakes up. + + This is identical to 'withMaximumProcessingTimeMs' except it calculates the processing time + from a sample rate and block size. This is useful if you want to run this thread in parallel + to an audio device thread. + + Only used by macOS/iOS. + + @see withMaximumProcessingTimeMs, AudioWorkgroup, ScopedWorkgroupToken + */ + [[nodiscard]] RealtimeOptions withApproximateAudioProcessingTime (int samplesPerFrame, double sampleRate) const + { + jassert (samplesPerFrame > 0); + jassert (sampleRate > 0.0); + + const auto approxFrameTimeMs = (samplesPerFrame / sampleRate) * 1000.0; + return withMaximumProcessingTimeMs (approxFrameTimeMs); + } + /** Specify the approximate amount of time between each thread wake up. Alternatively call withPeriodHz(). diff --git a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp index 3d6a7891..b6351f71 100644 --- a/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/JuceLibraryCode/modules/juce_core/threads/juce_ThreadPool.cpp @@ -23,7 +23,7 @@ namespace juce { -struct ThreadPool::ThreadPoolThread : public Thread +struct ThreadPool::ThreadPoolThread final : public Thread { ThreadPoolThread (ThreadPool& p, const Options& options) : Thread { options.threadName, options.threadStackSizeBytes }, @@ -154,7 +154,7 @@ void ThreadPool::addJob (ThreadPoolJob* job, bool deleteJobWhenFinished) void ThreadPool::addJob (std::function jobToRun) { - struct LambdaJobWrapper : public ThreadPoolJob + struct LambdaJobWrapper final : public ThreadPoolJob { LambdaJobWrapper (std::function j) : ThreadPoolJob ("lambda"), job (j) {} JobStatus runJob() override { return job(); } @@ -167,7 +167,7 @@ void ThreadPool::addJob (std::function jobToRun) void ThreadPool::addJob (std::function jobToRun) { - struct LambdaJobWrapper : public ThreadPoolJob + struct LambdaJobWrapper final : public ThreadPoolJob { LambdaJobWrapper (std::function j) : ThreadPoolJob ("lambda"), job (std::move (j)) {} JobStatus runJob() override { job(); return ThreadPoolJob::jobHasFinished; } @@ -277,7 +277,7 @@ bool ThreadPool::removeAllJobs (bool interruptRunningJobs, int timeOutMs, for (int i = jobs.size(); --i >= 0;) { - auto* job = jobs.getUnchecked(i); + auto* job = jobs.getUnchecked (i); if (selectedJobsToRemove == nullptr || selectedJobsToRemove->isJobSuitable (job)) { diff --git a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp index bd8c233d..ed74b88a 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp +++ b/JuceLibraryCode/modules/juce_core/time/juce_RelativeTime.cpp @@ -75,13 +75,13 @@ static String translateTimeField (int n, const char* singular, const char* plura return TRANS (n == 1 ? singular : plural).replace (n == 1 ? "1" : "2", String (n)); } -static String describeYears (int n) { return translateTimeField (n, NEEDS_TRANS("1 year"), NEEDS_TRANS("2 years")); } -static String describeMonths (int n) { return translateTimeField (n, NEEDS_TRANS("1 month"), NEEDS_TRANS("2 months")); } -static String describeWeeks (int n) { return translateTimeField (n, NEEDS_TRANS("1 week"), NEEDS_TRANS("2 weeks")); } -static String describeDays (int n) { return translateTimeField (n, NEEDS_TRANS("1 day"), NEEDS_TRANS("2 days")); } -static String describeHours (int n) { return translateTimeField (n, NEEDS_TRANS("1 hr"), NEEDS_TRANS("2 hrs")); } -static String describeMinutes (int n) { return translateTimeField (n, NEEDS_TRANS("1 min"), NEEDS_TRANS("2 mins")); } -static String describeSeconds (int n) { return translateTimeField (n, NEEDS_TRANS("1 sec"), NEEDS_TRANS("2 secs")); } +static String describeYears (int n) { return translateTimeField (n, NEEDS_TRANS ("1 year"), NEEDS_TRANS ("2 years")); } +static String describeMonths (int n) { return translateTimeField (n, NEEDS_TRANS ("1 month"), NEEDS_TRANS ("2 months")); } +static String describeWeeks (int n) { return translateTimeField (n, NEEDS_TRANS ("1 week"), NEEDS_TRANS ("2 weeks")); } +static String describeDays (int n) { return translateTimeField (n, NEEDS_TRANS ("1 day"), NEEDS_TRANS ("2 days")); } +static String describeHours (int n) { return translateTimeField (n, NEEDS_TRANS ("1 hr"), NEEDS_TRANS ("2 hrs")); } +static String describeMinutes (int n) { return translateTimeField (n, NEEDS_TRANS ("1 min"), NEEDS_TRANS ("2 mins")); } +static String describeSeconds (int n) { return translateTimeField (n, NEEDS_TRANS ("1 sec"), NEEDS_TRANS ("2 secs")); } String RelativeTime::getApproximateDescription() const { diff --git a/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp b/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp index 72dd854b..66ce3e54 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp +++ b/JuceLibraryCode/modules/juce_core/time/juce_Time.cpp @@ -568,7 +568,8 @@ Time& Time::operator-= (RelativeTime delta) noexcept { millisSinceEpoc Time operator+ (Time time, RelativeTime delta) noexcept { Time t (time); return t += delta; } Time operator- (Time time, RelativeTime delta) noexcept { Time t (time); return t -= delta; } Time operator+ (RelativeTime delta, Time time) noexcept { Time t (time); return t += delta; } -const RelativeTime operator- (Time time1, Time time2) noexcept { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); } + +RelativeTime operator- (Time time1, Time time2) noexcept { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); } bool operator== (Time time1, Time time2) noexcept { return time1.toMilliseconds() == time2.toMilliseconds(); } bool operator!= (Time time1, Time time2) noexcept { return time1.toMilliseconds() != time2.toMilliseconds(); } @@ -610,7 +611,7 @@ Time Time::getCompilationDate() //============================================================================== #if JUCE_UNIT_TESTS -class TimeTests : public UnitTest +class TimeTests final : public UnitTest { public: TimeTests() diff --git a/JuceLibraryCode/modules/juce_core/time/juce_Time.h b/JuceLibraryCode/modules/juce_core/time/juce_Time.h index 1c8bf3eb..295a54a3 100644 --- a/JuceLibraryCode/modules/juce_core/time/juce_Time.h +++ b/JuceLibraryCode/modules/juce_core/time/juce_Time.h @@ -383,7 +383,7 @@ JUCE_API Time operator+ (RelativeTime delta, Time time) noexcept; /** Subtracts a RelativeTime from a Time. */ JUCE_API Time operator- (Time time, RelativeTime delta) noexcept; /** Returns the relative time difference between two times. */ -JUCE_API const RelativeTime operator- (Time time1, Time time2) noexcept; +JUCE_API RelativeTime operator- (Time time1, Time time2) noexcept; /** Compares two Time objects. */ JUCE_API bool operator== (Time time1, Time time2) noexcept; diff --git a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTestCategories.h b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTestCategories.h index c4fa4b5d..b68bbd23 100644 --- a/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTestCategories.h +++ b/JuceLibraryCode/modules/juce_core/unit_tests/juce_UnitTestCategories.h @@ -20,11 +20,9 @@ ============================================================================== */ -namespace juce +namespace juce::UnitTestCategories { -namespace UnitTestCategories -{ static const String analytics { "Analytics" }; static const String audio { "Audio" }; static const String audioProcessorParameters { "AudioProcessorParameters" }; @@ -40,6 +38,7 @@ namespace UnitTestCategories static const String json { "JSON" }; static const String maths { "Maths" }; static const String midi { "MIDI" }; + static const String native { "Native" }; static const String networking { "Networking" }; static const String osc { "OSC" }; static const String smoothedValues { "SmoothedValues" }; @@ -49,6 +48,5 @@ namespace UnitTestCategories static const String time { "Time" }; static const String values { "Values" }; static const String xml { "XML" }; -} -} // namespace juce +} // namespace juce::UnitTestCategories diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp index f3d8ab0f..d3ba6958 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.cpp @@ -993,7 +993,7 @@ void XmlElement::deleteAllTextElements() noexcept //============================================================================== #if JUCE_UNIT_TESTS -class XmlElementTests : public UnitTest +class XmlElementTests final : public UnitTest { public: XmlElementTests() diff --git a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h index c5ddd312..fc85f676 100644 --- a/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h +++ b/JuceLibraryCode/modules/juce_core/xml/juce_XmlElement.h @@ -206,7 +206,7 @@ class JUCE_API XmlElement /** Returns the name of one of the elements attributes. E.g. for an element such as \, then - getAttributeName(1) would return "antlers". + getAttributeName (1) would return "antlers". @see getAttributeValue, getStringAttribute */ @@ -215,7 +215,7 @@ class JUCE_API XmlElement /** Returns the value of one of the elements attributes. E.g. for an element such as \, then - getAttributeName(1) would return "2". + getAttributeName (1) would return "2". @see getAttributeName, getStringAttribute */ @@ -689,7 +689,7 @@ class JUCE_API XmlElement return *this; } - Iterator operator++(int) + Iterator operator++ (int) { auto copy = *this; ++(*this); @@ -790,7 +790,7 @@ class JUCE_API XmlElement void reorderChildElements (XmlElement**, int) noexcept; XmlAttributeNode* getAttribute (StringRef) const noexcept; - // Sigh.. L"" or _T("") string literals are problematic in general, and really inappropriate + // 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*) = delete; diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index af89f3d3..1388ac70 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -159,7 +159,7 @@ bool GZIPCompressorOutputStream::setPosition (int64 /*newPosition*/) //============================================================================== #if JUCE_UNIT_TESTS -struct GZIPTests : public UnitTest +struct GZIPTests final : public UnitTest { GZIPTests() : UnitTest ("GZIP", UnitTestCategories::compression) diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 9252d57f..e6734bbd 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -294,7 +294,7 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) //============================================================================== #if JUCE_UNIT_TESTS -struct GZIPDecompressorInputStreamTests : public UnitTest +struct GZIPDecompressorInputStreamTests final : public UnitTest { GZIPDecompressorInputStreamTests() : UnitTest ("GZIPDecompressorInputStreamTests", UnitTestCategories::streams) diff --git a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp index 4bdd518f..8ec13c92 100644 --- a/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp +++ b/JuceLibraryCode/modules/juce_core/zip/juce_ZipFile.cpp @@ -136,7 +136,7 @@ static bool hasSymbolicPart (const File& root, const File& f) } //============================================================================== -struct ZipFile::ZipInputStream : public InputStream +struct ZipFile::ZipInputStream final : public InputStream { ZipInputStream (ZipFile& zf, const ZipFile::ZipEntryHolder& zei) : file (zf), @@ -670,7 +670,7 @@ bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progre //============================================================================== #if JUCE_UNIT_TESTS -struct ZIPTests : public UnitTest +struct ZIPTests final : public UnitTest { ZIPTests() : UnitTest ("ZIP", UnitTestCategories::compression) diff --git a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp index a47e4598..71055245 100644 --- a/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/encryption/juce_BlowFish.cpp @@ -251,7 +251,7 @@ void BlowFish::encrypt (uint32& data1, uint32& data2) const noexcept for (int i = 0; i < 16; ++i) { l ^= p[i]; - r ^= F(l); + r ^= F (l); std::swap (l, r); } @@ -267,7 +267,7 @@ void BlowFish::decrypt (uint32& data1, uint32& data2) const noexcept for (int i = 17; i > 1; --i) { l ^= p[i]; - r ^= F(l); + r ^= F (l); std::swap (l, r); } @@ -317,7 +317,7 @@ bool BlowFish::apply (void* data, size_t size, void (BlowFish::*op) (uint32&, ui { union AlignedAccessHelper { - int8 byte[sizeof(uint32) * 2]; + int8 byte[sizeof (uint32) * 2]; uint32 data[2]; }; @@ -356,7 +356,7 @@ int BlowFish::unpad (const void* data, size_t size) noexcept return -1; // remove padding according to https://tools.ietf.org/html/rfc2898#section-6.1.1 - auto paddingSize = reinterpret_cast(data)[size - 1u]; + auto paddingSize = reinterpret_cast (data)[size - 1u]; if (paddingSize == 0 || paddingSize > 8 || paddingSize > size) return -1; @@ -369,7 +369,7 @@ int BlowFish::unpad (const void* data, size_t size) noexcept //============================================================================== #if JUCE_UNIT_TESTS -class BlowFishTests : public UnitTest +class BlowFishTests final : public UnitTest { public: BlowFishTests() @@ -382,7 +382,7 @@ class BlowFishTests : public UnitTest auto* dst = reinterpret_cast (block.getData()); for (size_t i = 0; i < n; ++i) - dst[i] = static_cast (random.nextInt(255)); + dst[i] = static_cast (random.nextInt (255)); } void expectEqualData (const void* dataA, const void* dataB, size_t size, const String& failureMessage) @@ -437,7 +437,7 @@ class BlowFishTests : public UnitTest for (int i = 0; i < 100; ++i) { - const int keySize = (random.nextInt(17) + 1) * static_cast (sizeof (uint32)); + const int keySize = (random.nextInt (17) + 1) * static_cast (sizeof (uint32)); MemoryBlock key (static_cast (keySize)); fillMemoryBlockWithRandomData (key, random); @@ -459,7 +459,7 @@ class BlowFishTests : public UnitTest { // Test unaligned data encryption/decryption. This will be flagged up by a check for // undefined behaviour! - auto nudge = static_cast (random.nextInt (sizeof(void*) - 1)); + auto nudge = static_cast (random.nextInt (sizeof (void*) - 1)); auto unalignedData = (void*) (reinterpret_cast (data.getData()) + nudge); size_t newSize = data.getSize() - nudge; diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp index 117eb07b..d8e325d5 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_MD5.cpp @@ -268,7 +268,7 @@ bool MD5::operator!= (const MD5& other) const noexcept { return ! operator== ( //============================================================================== #if JUCE_UNIT_TESTS -class MD5Tests : public UnitTest +class MD5Tests final : public UnitTest { public: MD5Tests() @@ -297,7 +297,7 @@ class MD5Tests : public UnitTest test ("The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6"); test ("The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0"); - expectEquals (MD5 (CharPointer_UTF8(nullptr)).toHexString(), String ("d41d8cd98f00b204e9800998ecf8427e")); + expectEquals (MD5 (CharPointer_UTF8 (nullptr)).toHexString(), String ("d41d8cd98f00b204e9800998ecf8427e")); } }; diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp index 44e9a4c8..284dce92 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_SHA256.cpp @@ -215,7 +215,7 @@ bool SHA256::operator!= (const SHA256& other) const noexcept { return ! operato //============================================================================== #if JUCE_UNIT_TESTS -class SHA256Tests : public UnitTest +class SHA256Tests final : public UnitTest { public: SHA256Tests() diff --git a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_Whirlpool.cpp b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_Whirlpool.cpp index 001f108a..e5c9aec9 100644 --- a/JuceLibraryCode/modules/juce_cryptography/hashing/juce_Whirlpool.cpp +++ b/JuceLibraryCode/modules/juce_cryptography/hashing/juce_Whirlpool.cpp @@ -616,7 +616,7 @@ bool Whirlpool::operator!= (const Whirlpool& other) const noexcept { return ! o //============================================================================== #if JUCE_UNIT_TESTS -class WhirlpoolTests : public UnitTest +class WhirlpoolTests final : public UnitTest { public: WhirlpoolTests() diff --git a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h index 807d0c2d..a0fff358 100644 --- a/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h +++ b/JuceLibraryCode/modules/juce_cryptography/juce_cryptography.h @@ -35,7 +35,7 @@ ID: juce_cryptography vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE cryptography classes description: Classes for various basic cryptography functions, including RSA, Blowfish, MD5, SHA, etc. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h index a39fb1ea..b397df69 100644 --- a/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h +++ b/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h @@ -35,7 +35,7 @@ ID: juce_data_structures vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE data model helper classes description: Classes for undo/redo management, and smart data structures. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index ccd89d81..06266a61 100644 --- a/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -43,7 +43,7 @@ struct UndoManager::ActionSet bool undo() const { for (int i = actions.size(); --i >= 0;) - if (! actions.getUnchecked(i)->undo()) + if (! actions.getUnchecked (i)->undo()) return false; return true; diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_CachedValue.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_CachedValue.cpp index c056a861..c69a0a4d 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_CachedValue.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_CachedValue.cpp @@ -28,7 +28,7 @@ namespace juce #if JUCE_UNIT_TESTS -class CachedValueTests : public UnitTest +class CachedValueTests final : public UnitTest { public: CachedValueTests() diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp index 4b5c5fe6..18f11245 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_Value.cpp @@ -64,7 +64,7 @@ void Value::ValueSource::sendChangeMessage (const bool synchronous) } //============================================================================== -class SimpleValueSource : public Value::ValueSource +class SimpleValueSource final : public Value::ValueSource { public: SimpleValueSource() diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp index a3903d9f..3b324c2d 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -26,7 +26,7 @@ namespace juce { -class ValueTree::SharedObject : public ReferenceCountedObject +class ValueTree::SharedObject final : public ReferenceCountedObject { public: using Ptr = ReferenceCountedObjectPtr; @@ -408,7 +408,7 @@ class ValueTree::SharedObject : public ReferenceCountedObject } //============================================================================== - struct SetPropertyAction : public UndoableAction + struct SetPropertyAction final : public UndoableAction { SetPropertyAction (Ptr targetObject, const Identifier& propertyName, const var& newVal, const var& oldVal, bool isAdding, bool isDeleting, @@ -472,7 +472,7 @@ class ValueTree::SharedObject : public ReferenceCountedObject }; //============================================================================== - struct AddOrRemoveChildAction : public UndoableAction + struct AddOrRemoveChildAction final : public UndoableAction { AddOrRemoveChildAction (Ptr parentObject, int index, SharedObject* newChild) : target (std::move (parentObject)), @@ -524,7 +524,7 @@ class ValueTree::SharedObject : public ReferenceCountedObject }; //============================================================================== - struct MoveChildAction : public UndoableAction + struct MoveChildAction final : public UndoableAction { MoveChildAction (Ptr parentObject, int fromIndex, int toIndex) noexcept : parent (std::move (parentObject)), startIndex (fromIndex), endIndex (toIndex) @@ -809,8 +809,8 @@ int ValueTree::getReferenceCount() const noexcept } //============================================================================== -struct ValueTreePropertyValueSource : public Value::ValueSource, - private ValueTree::Listener +struct ValueTreePropertyValueSource final : public Value::ValueSource, + private ValueTree::Listener { ValueTreePropertyValueSource (const ValueTree& vt, const Identifier& prop, UndoManager* um, bool sync) : tree (vt), property (prop), undoManager (um), updateSynchronously (sync) @@ -1118,7 +1118,7 @@ JUCE_END_IGNORE_WARNINGS_MSVC //============================================================================== #if JUCE_UNIT_TESTS -class ValueTreeTests : public UnitTest +class ValueTreeTests final : public UnitTest { public: ValueTreeTests() diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h index c5a14a56..214d2dcf 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h @@ -293,8 +293,7 @@ class JUCE_API ValueTreePropertyWithDefault : private Value::Listener void valueChanged (Value&) override { - if (onDefaultChange != nullptr) - onDefaultChange(); + NullCheckedInvocation::invoke (onDefaultChange); } void referToWithDefault (ValueTree v, diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault_test.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault_test.cpp index 0009f6a9..cbad98a7 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault_test.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault_test.cpp @@ -26,7 +26,7 @@ namespace juce { -class ValueTreePropertyWithDefaultTests : public UnitTest +class ValueTreePropertyWithDefaultTests final : public UnitTest { public: ValueTreePropertyWithDefaultTests() diff --git a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp index 22606f72..d31ac2eb 100644 --- a/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp +++ b/JuceLibraryCode/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp @@ -68,7 +68,7 @@ namespace ValueTreeSynchroniserHelpers stream.writeCompressedInt (path.size()); for (int i = path.size(); --i >= 0;) - stream.writeCompressedInt (path.getUnchecked(i)); + stream.writeCompressedInt (path.getUnchecked (i)); } static ValueTree readSubTreeLocation (MemoryInputStream& input, ValueTree v) diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock.h b/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock.h index 2ccf95db..c1b23d43 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock.h +++ b/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { #ifndef DOXYGEN @@ -891,5 +889,4 @@ class AudioBlock friend class AudioBlock; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock_test.cpp b/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock_test.cpp index bfd2f8aa..6b2fbaf9 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/containers/juce_AudioBlock_test.cpp @@ -23,16 +23,16 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { +#if JUCE_USE_SIMD template String& operator<< (String& str, SIMDRegister) { return str; } +#endif template -class AudioBlockUnitTests : public UnitTest +class AudioBlockUnitTests final : public UnitTest { public: //============================================================================== @@ -494,5 +494,4 @@ static AudioBlockUnitTests> audioBlockSIMDFloatUnitTests; static AudioBlockUnitTests> audioBlockSIMDDoubleUnitTests; #endif -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister.h b/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister.h index 04449a79..705214de 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister.h +++ b/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { #ifndef DOXYGEN @@ -392,9 +390,4 @@ struct SIMDRegister } }; -} // namespace dsp -} // namespace juce - -#ifndef DOXYGEN - #include "juce_SIMDRegister_Impl.h" -#endif +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp b/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp index 7b2bcbc5..c7e64e06 100644 --- a/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { namespace SIMDRegister_test_internal @@ -103,7 +101,7 @@ namespace SIMDRegister_test_internal // These tests need to be strictly run on all platforms supported by JUCE as the // SIMD code is highly platform dependent. -class SIMDRegisterUnitTests : public UnitTest +class SIMDRegisterUnitTests final : public UnitTest { public: template struct Tag {}; @@ -262,9 +260,9 @@ class SIMDRegisterUnitTests : public UnitTest { #ifdef _MSC_VER - __declspec(align(sizeof (SIMDRegister))) type elements[SIMDRegister::SIMDNumElements]; + __declspec (align (sizeof (SIMDRegister))) type elements[SIMDRegister::SIMDNumElements]; #else - type elements[SIMDRegister::SIMDNumElements] __attribute__((aligned(sizeof (SIMDRegister)))); + type elements[SIMDRegister::SIMDNumElements] __attribute__ ((aligned (sizeof (SIMDRegister)))); #endif SIMDRegister_test_internal::fillVec (elements, random); SIMDRegister a (SIMDRegister::fromRawArray (elements)); @@ -412,9 +410,9 @@ class SIMDRegisterUnitTests : public UnitTest Operation::template inplace (b.intVersion, bitmask); #ifdef _MSC_VER - __declspec(align(sizeof (SIMDRegister))) type elements[SIMDRegister::SIMDNumElements]; + __declspec (align (sizeof (SIMDRegister))) type elements[SIMDRegister::SIMDNumElements]; #else - type elements[SIMDRegister::SIMDNumElements] __attribute__((aligned(sizeof (SIMDRegister)))); + type elements[SIMDRegister::SIMDNumElements] __attribute__ ((aligned (sizeof (SIMDRegister)))); #endif b.floatVersion.copyToRawArray (elements); @@ -876,5 +874,4 @@ class SIMDRegisterUnitTests : public UnitTest static SIMDRegisterUnitTests SIMDRegisterUnitTests; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.cpp b/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.cpp index 5bd99b79..79c262e9 100644 --- a/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.cpp +++ b/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -469,7 +467,7 @@ ReferenceCountedArray> auto v0 = std::asinh (epss) / (N * halfPi); if (r == 1) - pa.add(-1.0 / (k / omegap * std::sinh (v0 * halfPi))); + pa.add (-1.0 / (k / omegap * std::sinh (v0 * halfPi))); for (int i = 1; i <= L; ++i) { @@ -697,5 +695,4 @@ typename FilterDesign::IIRPolyphaseAllpassStructure template struct FilterDesign; template struct FilterDesign; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.h b/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.h index cd2719aa..35d127de 100644 --- a/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.h +++ b/JuceLibraryCode/modules/juce_dsp/filter_design/juce_FilterDesign.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -295,5 +293,4 @@ struct FilterDesign FilterDesign() = delete; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.cpp b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.cpp index ef44a2ce..bdc163a2 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -72,7 +70,7 @@ class Queue std::vector storage; }; -class BackgroundMessageQueue : private Thread +class BackgroundMessageQueue : private Thread { public: explicit BackgroundMessageQueue (int entries) @@ -845,7 +843,7 @@ static void setImpulseResponse (ConvolutionEngineFactory& factory, // this object when adding commands to the background message queue. // That way, we can avoid dangling references in the background thread in the case // that a Convolution instance is deleted before the background message queue. -class ConvolutionEngineQueue : public std::enable_shared_from_this +class ConvolutionEngineQueue final : public std::enable_shared_from_this { public: ConvolutionEngineQueue (BackgroundMessageQueue& queue, @@ -1293,5 +1291,4 @@ int Convolution::getCurrentIRSize() const { return pimpl->getCurrentIRSize(); } int Convolution::getLatency() const { return pimpl->getLatency(); } -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.h b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.h index 19c44f57..d12db50b 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.h +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -306,5 +304,4 @@ class JUCE_API Convolution JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Convolution) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution_test.cpp b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution_test.cpp index e705f9d1..88ed1d74 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Convolution_test.cpp @@ -29,14 +29,12 @@ #define JUCE_FAIL_ON_ALLOCATION_IN_SCOPE #endif -namespace juce -{ -namespace dsp +namespace juce::dsp { namespace { -class ConvolutionTest : public UnitTest +class ConvolutionTest final : public UnitTest { template static void nTimes (int n, Callback&& callback) @@ -575,7 +573,6 @@ class ConvolutionTest : public UnitTest ConvolutionTest convolutionUnitTest; } -} -} +} // namespace juce::dsp #undef JUCE_FAIL_ON_ALLOCATION_IN_SCOPE diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.cpp b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.cpp index bc383271..481b9053 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.cpp +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { struct FFT::Instance @@ -79,7 +77,7 @@ struct FFT::EngineImpl : public FFT::Engine //============================================================================== //============================================================================== -struct FFTFallback : public FFT::Instance +struct FFTFallback final : public FFT::Instance { // this should have the least priority of all engines static constexpr int priority = -1; @@ -105,7 +103,7 @@ struct FFTFallback : public FFT::Instance return; } - const SpinLock::ScopedLockType sl(processLock); + const SpinLock::ScopedLockType sl (processLock); jassert (configForward != nullptr); @@ -232,7 +230,7 @@ struct FFTFallback : public FFT::Instance for (int i = fftSize / 2; i < fftSize; ++i) { auto index = fftSize / 2 - (i - fftSize / 2); - twiddleTable[i] = conj(twiddleTable[index]); + twiddleTable[i] = conj (twiddleTable[index]); } } @@ -434,7 +432,7 @@ FFT::EngineImpl fftFallback; //============================================================================== //============================================================================== #if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK -struct AppleFFT : public FFT::Instance +struct AppleFFT final : public FFT::Instance { static constexpr int priority = 5; @@ -733,7 +731,7 @@ FFT::EngineImpl fftwEngine; //============================================================================== //============================================================================== #if JUCE_DSP_USE_INTEL_MKL -struct IntelFFT : public FFT::Instance +struct IntelFFT final : public FFT::Instance { static constexpr int priority = 8; @@ -819,7 +817,7 @@ FFT::EngineImpl fftwEngine; // setting at 'Project' > 'Properties' > 'Configuration Properties' > 'Intel // Performance Libraries' > 'Use Intel(R) IPP' #if _IPP_SEQUENTIAL_STATIC || _IPP_SEQUENTIAL_DYNAMIC || _IPP_PARALLEL_STATIC || _IPP_PARALLEL_DYNAMIC -class IntelPerformancePrimitivesFFT : public FFT::Instance +class IntelPerformancePrimitivesFFT final : public FFT::Instance { public: static constexpr auto priority = 9; @@ -997,5 +995,4 @@ void FFT::performFrequencyOnlyForwardTransform (float* inputOutputData, bool ign zeromem (inputOutputData + limit, static_cast (size * 2 - limit) * sizeof (float)); } -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.h b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.h index b0e03406..fd897ca6 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.h +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -128,5 +126,4 @@ class JUCE_API FFT JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FFT) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT_test.cpp b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT_test.cpp index 4e3e999e..3cf20e11 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_FFT_test.cpp @@ -23,12 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { -struct FFTUnitTest : public UnitTest +struct FFTUnitTest final : public UnitTest { FFTUnitTest() : UnitTest ("FFT", UnitTestCategories::dsp) @@ -63,7 +61,7 @@ struct FFTUnitTest : public UnitTest / static_cast (n)); for (size_t i = 0; i < n; ++i) - out[i] = freqConvolution (in, static_cast(i) * base_freq, n); + out[i] = freqConvolution (in, static_cast (i) * base_freq, n); } static void performReferenceFourier (const float* in, Complex* out, @@ -78,7 +76,7 @@ struct FFTUnitTest : public UnitTest / static_cast (n)); for (size_t i = 0; i < n; ++i) - out[i] = freqConvolution (buffer.getData(), static_cast(i) * base_freq, n); + out[i] = freqConvolution (buffer.getData(), static_cast (i) * base_freq, n); } @@ -167,7 +165,7 @@ struct FFTUnitTest : public UnitTest struct ComplexTest { - static void run(FFTUnitTest& u) + static void run (FFTUnitTest& u) { Random random (378272); @@ -214,5 +212,4 @@ struct FFTUnitTest : public UnitTest static FFTUnitTest fftUnitTest; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.cpp b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.cpp index e8f56119..78afebec 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.cpp +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -192,5 +190,4 @@ const char* WindowingFunction::getWindowingMethodName (WindowingMetho template class WindowingFunction; template class WindowingFunction; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.h b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.h index 573e89bb..9e4a41b0 100644 --- a/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.h +++ b/JuceLibraryCode/modules/juce_dsp/frequency/juce_Windowing.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -107,5 +105,4 @@ class JUCE_API WindowingFunction JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowingFunction) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/juce_dsp.cpp b/JuceLibraryCode/modules/juce_dsp/juce_dsp.cpp index f53eccdb..e34bfe56 100644 --- a/JuceLibraryCode/modules/juce_dsp/juce_dsp.cpp +++ b/JuceLibraryCode/modules/juce_dsp/juce_dsp.cpp @@ -101,7 +101,6 @@ #endif #include "containers/juce_AudioBlock_test.cpp" - #include "containers/juce_FixedSizeFunction_test.cpp" #include "frequency/juce_Convolution_test.cpp" #include "frequency/juce_FFT_test.cpp" #include "processors/juce_FIRFilter_test.cpp" diff --git a/JuceLibraryCode/modules/juce_dsp/juce_dsp.h b/JuceLibraryCode/modules/juce_dsp/juce_dsp.h index cc6e746e..533ec579 100644 --- a/JuceLibraryCode/modules/juce_dsp/juce_dsp.h +++ b/JuceLibraryCode/modules/juce_dsp/juce_dsp.h @@ -35,7 +35,7 @@ ID: juce_dsp vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE DSP classes description: Classes for audio buffer manipulation, digital audio processing, filtering, oversampling, fast math functions etc. website: http://www.juce.com/juce @@ -58,9 +58,9 @@ #include #include -#if defined(_M_X64) || defined(__amd64__) || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) +#if defined (_M_X64) || defined (__amd64__) || defined (__SSE2__) || (defined (_M_IX86_FP) && _M_IX86_FP == 2) - #if defined(_M_X64) || defined(__amd64__) + #if defined (_M_X64) || defined (__amd64__) #ifndef __SSE2__ #define __SSE2__ #endif @@ -96,7 +96,7 @@ #ifndef JUCE_VECTOR_CALLTYPE // __vectorcall does not work on 64-bit due to internal compiler error in // release mode VS2017. Re-enable when Microsoft fixes this - #if _MSC_VER && JUCE_USE_SIMD && ! (defined(_M_X64) || defined(__amd64__)) + #if _MSC_VER && JUCE_USE_SIMD && ! (defined (_M_X64) || defined (__amd64__)) #define JUCE_VECTOR_CALLTYPE __vectorcall #else #define JUCE_VECTOR_CALLTYPE @@ -188,34 +188,36 @@ #undef Factor #undef check -namespace juce +namespace juce::dsp { - namespace dsp - { - template - using Complex = std::complex; - - //============================================================================== - namespace util - { - /** Use this function to prevent denormals on intel CPUs. - This function will work with both primitives and simple containers. - */ - #if JUCE_DSP_ENABLE_SNAP_TO_ZERO - inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } - #ifndef DOXYGEN - inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } - inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } - #endif - #else - inline void snapToZero ([[maybe_unused]] float& x) noexcept {} - #ifndef DOXYGEN - inline void snapToZero ([[maybe_unused]] double& x) noexcept {} - inline void snapToZero ([[maybe_unused]] long double& x) noexcept {} - #endif - #endif - } - } + +template +using Complex = std::complex; + +template +using FixedSizeFunction = juce::FixedSizeFunction; + +//============================================================================== +namespace util +{ + /** Use this function to prevent denormals on intel CPUs. + This function will work with both primitives and simple containers. + */ + #if JUCE_DSP_ENABLE_SNAP_TO_ZERO + inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #ifndef DOXYGEN + inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #endif + #else + inline void snapToZero ([[maybe_unused]] float& x) noexcept {} + #ifndef DOXYGEN + inline void snapToZero ([[maybe_unused]] double& x) noexcept {} + inline void snapToZero ([[maybe_unused]] long double& x) noexcept {} + #endif + #endif +} + } //============================================================================== @@ -223,7 +225,7 @@ namespace juce #include "native/juce_SIMDNativeOps_fallback.h" // include the correct native file for this build target CPU - #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) + #if defined (__i386__) || defined (__amd64__) || defined (_M_X64) || defined (_X86_) || defined (_M_IX86) #ifdef __AVX2__ #include "native/juce_SIMDNativeOps_avx.h" #else @@ -236,6 +238,7 @@ namespace juce #endif #include "containers/juce_SIMDRegister.h" + #include "containers/juce_SIMDRegister_Impl.h" #endif #include "maths/juce_SpecialFunctions.h" @@ -246,12 +249,12 @@ namespace juce #include "maths/juce_LookupTable.h" #include "maths/juce_LogRampedValue.h" #include "containers/juce_AudioBlock.h" -#include "containers/juce_FixedSizeFunction.h" #include "processors/juce_ProcessContext.h" #include "processors/juce_ProcessorWrapper.h" #include "processors/juce_ProcessorChain.h" #include "processors/juce_ProcessorDuplicator.h" #include "processors/juce_IIRFilter.h" +#include "processors/juce_IIRFilter_Impl.h" #include "processors/juce_FIRFilter.h" #include "processors/juce_StateVariableFilter.h" #include "processors/juce_FirstOrderTPTFilter.h" diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_FastMathApproximations.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_FastMathApproximations.h index 03882441..b9b570d5 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_FastMathApproximations.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_FastMathApproximations.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -260,5 +258,4 @@ struct FastMathApproximations } }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue.h index 821e07e2..a714c3a8 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -185,5 +183,4 @@ class LogRampedValue : public SmoothedValueBase > FloatType temp = 0, source = 0, r = 0, d = 1; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue_test.cpp b/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue_test.cpp index 4c729c36..94bf27ba 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_LogRampedValue_test.cpp @@ -23,14 +23,12 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { static CommonSmoothedValueTests > commonLogRampedValueTests; -class LogRampedValueTests : public UnitTest +class LogRampedValueTests final : public UnitTest { public: LogRampedValueTests() @@ -92,5 +90,4 @@ class LogRampedValueTests : public UnitTest static LogRampedValueTests LogRampedValueTests; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.cpp b/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.cpp index 5e8f729c..8e96cbb4 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.cpp +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -152,5 +150,4 @@ template class LookupTable; template class LookupTableTransform; template class LookupTableTransform; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.h index 77987cb6..d4b455b1 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_LookupTable.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -326,5 +324,4 @@ class LookupTableTransform JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookupTableTransform) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.cpp b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.cpp index 6d5c8acd..8d22df76 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.cpp +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -34,7 +32,7 @@ Matrix Matrix::identity (size_t size) Matrix result (size, size); for (size_t i = 0; i < size; ++i) - result(i, i) = 1; + result (i, i) = 1; return result; } @@ -60,8 +58,8 @@ Matrix Matrix::toeplitz (const Matrix& vector, size_t template Matrix Matrix::hankel (const Matrix& vector, size_t size, size_t offset) { - jassert(vector.isOneColumnVector()); - jassert(vector.rows >= (2 * (size - 1) + 1)); + jassert (vector.isOneColumnVector()); + jassert (vector.rows >= (2 * (size - 1) + 1)); Matrix result (size, size); @@ -313,5 +311,4 @@ String Matrix::toString() const template class Matrix; template class Matrix; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.h index c3345cf4..39d36567 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -250,5 +248,4 @@ class Matrix JUCE_LEAK_DETECTOR (Matrix) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix_test.cpp b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix_test.cpp index 18aaeb0d..a6686acf 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_Matrix_test.cpp @@ -23,12 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { -struct LinearAlgebraUnitTest : public UnitTest +struct LinearAlgebraUnitTest final : public UnitTest { LinearAlgebraUnitTest() : UnitTest ("Linear Algebra UnitTests", UnitTestCategories::dsp) @@ -47,7 +45,7 @@ struct LinearAlgebraUnitTest : public UnitTest Matrix mat2 (2, 4, data2); Matrix mat3 (2, 4, data3); - u.expect((mat1 + mat2) == mat3); + u.expect ((mat1 + mat2) == mat3); } }; @@ -64,7 +62,7 @@ struct LinearAlgebraUnitTest : public UnitTest Matrix mat2 (2, 4, data2); Matrix mat3 (2, 4, data3); - u.expect((mat1 - mat2) == mat3); + u.expect ((mat1 - mat2) == mat3); } }; @@ -114,7 +112,7 @@ struct LinearAlgebraUnitTest : public UnitTest Matrix mat2 (4, 2, data2); Matrix mat3 (2, 2, data3); - u.expect((mat1 * mat2) == mat3); + u.expect ((mat1 * mat2) == mat3); } }; @@ -169,5 +167,4 @@ struct LinearAlgebraUnitTest : public UnitTest static LinearAlgebraUnitTest linearAlgebraUnitTest; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_Phase.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_Phase.h index 7cf296cc..45a2a97e 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_Phase.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_Phase.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -63,5 +61,4 @@ struct Phase Type phase = 0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_Polynomial.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_Polynomial.h index 77487bb5..47e9bf58 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_Polynomial.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_Polynomial.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -94,7 +92,7 @@ class Polynomial FloatingType y (0); for (int i = coeffs.size(); --i >= 0;) - y = (x * y) + coeffs.getUnchecked(i); + y = (x * y) + coeffs.getUnchecked (i); return y; } @@ -164,5 +162,4 @@ class Polynomial JUCE_LEAK_DETECTOR (Polynomial) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.cpp b/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.cpp index 36a97920..dc1f2e06 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.cpp +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { double SpecialFunctions::besselI0 (double x) noexcept @@ -139,5 +137,4 @@ Complex SpecialFunctions::asne (Complex w, double k) noexcept return 2.0 / MathConstants::pi * std::asin (last); } -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.h b/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.h index d9a57639..8fbd459f 100644 --- a/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.h +++ b/JuceLibraryCode/modules/juce_dsp/maths/juce_SpecialFunctions.h @@ -23,11 +23,8 @@ ============================================================================== */ -namespace juce +namespace juce::dsp { -namespace dsp -{ - /** Contains miscellaneous filter design and windowing functions. @@ -63,5 +60,4 @@ struct SpecialFunctions static Complex asne (Complex w, double k) noexcept; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.cpp b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.cpp index c8d2d14a..6ae058bf 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.cpp +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.cpp @@ -23,36 +23,33 @@ ============================================================================== */ -namespace juce +namespace juce::dsp { - namespace dsp - { - DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; - DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast (0x80000000), 0, static_cast (0x80000000), 0, static_cast (0x80000000), 0, static_cast (0x80000000), 0 }; + DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; - DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; - DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; + DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; - DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; - DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; - DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; - DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; - DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; - DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; + DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; - DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; - DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; - } + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; } diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.h b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.h index 95fd708e..cc2fd5bc 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.h +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_avx.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { #ifndef DOXYGEN @@ -34,17 +32,17 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wignored-attributes") #ifdef _MSC_VER #define DECLARE_AVX_SIMD_CONST(type, name) \ - static __declspec(align(32)) const type name[32 / sizeof (type)] + static __declspec (align (32)) const type name[32 / sizeof (type)] #define DEFINE_AVX_SIMD_CONST(type, class_type, name) \ - __declspec(align(32)) const type SIMDNativeOps:: name[32 / sizeof (type)] + __declspec (align (32)) const type SIMDNativeOps:: name[32 / sizeof (type)] #else #define DECLARE_AVX_SIMD_CONST(type, name) \ - static const type name[32 / sizeof (type)] __attribute__((aligned(32))) + static const type name[32 / sizeof (type)] __attribute__ ((aligned (32))) #define DEFINE_AVX_SIMD_CONST(type, class_type, name) \ - const type SIMDNativeOps:: name[32 / sizeof (type)] __attribute__((aligned(32))) + const type SIMDNativeOps:: name[32 / sizeof (type)] __attribute__ ((aligned (32))) #endif @@ -657,5 +655,4 @@ struct SIMDNativeOps JUCE_END_IGNORE_WARNINGS_GCC_LIKE -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_fallback.h b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_fallback.h index 6b02f867..14069770 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_fallback.h +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_fallback.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** A template specialisation to find corresponding mask type for primitives. */ @@ -263,5 +261,4 @@ struct SIMDFallbackOps } }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.cpp b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.cpp index d99c71ca..b1a5e9e7 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.cpp +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.cpp @@ -23,26 +23,23 @@ ============================================================================== */ -namespace juce +namespace juce::dsp { - namespace dsp - { - DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; - DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; - DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; - - #if JUCE_64BIT - DEFINE_NEON_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1 }; - DEFINE_NEON_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; - #endif - - DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; - DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; - DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; - DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; - DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; - } + DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast (0x80000000), 0, static_cast (0x80000000), 0 }; + DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + + #if JUCE_64BIT + DEFINE_NEON_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1 }; + DEFINE_NEON_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; + #endif + + DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; } diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.h b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.h index 53c504d6..489f75d1 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.h +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_neon.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { #ifndef DOXYGEN @@ -34,17 +32,17 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wignored-attributes") #ifdef _MSC_VER #define DECLARE_NEON_SIMD_CONST(type, name) \ - static __declspec(align(16)) const type name [16 / sizeof (type)] + static __declspec (align (16)) const type name [16 / sizeof (type)] #define DEFINE_NEON_SIMD_CONST(type, class_type, name) \ - __declspec(align(16)) const type SIMDNativeOps:: name [16 / sizeof (type)] + __declspec (align (16)) const type SIMDNativeOps:: name [16 / sizeof (type)] #else #define DECLARE_NEON_SIMD_CONST(type, name) \ - static const type name [16 / sizeof (type)] __attribute__((aligned(16))) + static const type name [16 / sizeof (type)] __attribute__ ((aligned (16))) #define DEFINE_NEON_SIMD_CONST(type, class_type, name) \ - const type SIMDNativeOps:: name [16 / sizeof (type)] __attribute__((aligned(16))) + const type SIMDNativeOps:: name [16 / sizeof (type)] __attribute__ ((aligned (16))) #endif @@ -538,5 +536,4 @@ struct SIMDNativeOps JUCE_END_IGNORE_WARNINGS_GCC_LIKE -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.cpp b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.cpp index 2b3174df..f219f1e4 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.cpp +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.cpp @@ -23,36 +23,33 @@ ============================================================================== */ -namespace juce +namespace juce::dsp { - namespace dsp - { - DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; - DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; - DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast (0x80000000), 0, static_cast (0x80000000), 0 }; + DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; - DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; - DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast(0x8000000000000000), 0 }; - DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0 }; + DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; - DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; - DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; - DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; - DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; - DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; - DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; - DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; - DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; + DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; - DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; - DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; - } + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; } diff --git a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.h b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.h index f09cbe2e..96d8ec3e 100644 --- a/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.h +++ b/JuceLibraryCode/modules/juce_dsp/native/juce_SIMDNativeOps_sse.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { #ifndef DOXYGEN @@ -34,17 +32,17 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wignored-attributes") #ifdef _MSC_VER #define DECLARE_SSE_SIMD_CONST(type, name) \ - static __declspec(align(16)) const type name [16 / sizeof (type)] + static __declspec (align (16)) const type name [16 / sizeof (type)] #define DEFINE_SSE_SIMD_CONST(type, class_type, name) \ - __declspec(align(16)) const type SIMDNativeOps:: name [16 / sizeof (type)] + __declspec (align (16)) const type SIMDNativeOps:: name [16 / sizeof (type)] #else #define DECLARE_SSE_SIMD_CONST(type, name) \ - static const type name [16 / sizeof (type)] __attribute__((aligned(16))) + static const type name [16 / sizeof (type)] __attribute__ ((aligned (16))) #define DEFINE_SSE_SIMD_CONST(type, class_type, name) \ - const type SIMDNativeOps:: name [16 / sizeof (type)] __attribute__((aligned(16))) + const type SIMDNativeOps:: name [16 / sizeof (type)] __attribute__ ((aligned (16))) #endif @@ -105,9 +103,9 @@ struct SIMDNativeOps static forcedinline float JUCE_VECTOR_CALLTYPE sum (__m128 a) noexcept { - #if defined(__SSE4__) + #if defined (__SSE4__) const auto retval = _mm_dp_ps (a, _mm_loadu_ps (kOne), 0xff); - #elif defined(__SSE3__) + #elif defined (__SSE3__) const auto shuffled = _mm_movehdup_ps (a); const auto sums = _mm_add_ps (a, shuffled); const auto retval = _mm_add_ss (sums, _mm_movehl_ps (shuffled, sums)); @@ -175,9 +173,9 @@ struct SIMDNativeOps static forcedinline double JUCE_VECTOR_CALLTYPE sum (__m128d a) noexcept { - #if defined(__SSE4__) + #if defined (__SSE4__) __m128d retval = _mm_dp_pd (a, vconst (kOne), 0xff); - #elif defined(__SSE3__) + #elif defined (__SSE3__) __m128d retval = _mm_hadd_pd (a, a); #else __m128d retval = _mm_add_pd (_mm_shuffle_pd (a, a, 0x01), a); @@ -211,7 +209,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_xor (__m128i a, __m128i b) noexcept { return _mm_xor_si128 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_andnot (__m128i a, __m128i b) noexcept { return _mm_andnot_si128 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_not (__m128i a) noexcept { return _mm_andnot_si128 (a, vconst (kAllBitsSet)); } - #if defined(__SSE4__) + #if defined (__SSE4__) static forcedinline __m128i JUCE_VECTOR_CALLTYPE min (__m128i a, __m128i b) noexcept { return _mm_min_epi8 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE max (__m128i a, __m128i b) noexcept { return _mm_max_epi8 (a, b); } #else @@ -411,7 +409,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_xor (__m128i a, __m128i b) noexcept { return _mm_xor_si128 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_andnot (__m128i a, __m128i b) noexcept { return _mm_andnot_si128 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE bit_not (__m128i a) noexcept { return _mm_andnot_si128 (a, vconst (kAllBitsSet)); } - #if defined(__SSE4__) + #if defined (__SSE4__) static forcedinline __m128i JUCE_VECTOR_CALLTYPE min (__m128i a, __m128i b) noexcept { return _mm_min_epu16 (a, b); } static forcedinline __m128i JUCE_VECTOR_CALLTYPE max (__m128i a, __m128i b) noexcept { return _mm_max_epu16 (a, b); } #else @@ -492,19 +490,19 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE mul (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_mullo_epi32 (a, b); #else __m128i even = _mm_mul_epu32 (a,b); __m128i odd = _mm_mul_epu32 (_mm_srli_si128 (a,4), _mm_srli_si128 (b,4)); - return _mm_unpacklo_epi32 (_mm_shuffle_epi32(even, _MM_SHUFFLE (0,0,2,0)), - _mm_shuffle_epi32(odd, _MM_SHUFFLE (0,0,2,0))); + return _mm_unpacklo_epi32 (_mm_shuffle_epi32 (even, _MM_SHUFFLE (0,0,2,0)), + _mm_shuffle_epi32 (odd, _MM_SHUFFLE (0,0,2,0))); #endif } static forcedinline __m128i JUCE_VECTOR_CALLTYPE min (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_min_epi32 (a, b); #else __m128i lt = greaterThan (b, a); @@ -514,7 +512,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE max (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_max_epi32 (a, b); #else __m128i gt = greaterThan (a, b); @@ -574,19 +572,19 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE mul (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_mullo_epi32 (a, b); #else __m128i even = _mm_mul_epu32 (a,b); __m128i odd = _mm_mul_epu32 (_mm_srli_si128 (a,4), _mm_srli_si128 (b,4)); - return _mm_unpacklo_epi32 (_mm_shuffle_epi32(even, _MM_SHUFFLE (0,0,2,0)), - _mm_shuffle_epi32(odd, _MM_SHUFFLE (0,0,2,0))); + return _mm_unpacklo_epi32 (_mm_shuffle_epi32 (even, _MM_SHUFFLE (0,0,2,0)), + _mm_shuffle_epi32 (odd, _MM_SHUFFLE (0,0,2,0))); #endif } static forcedinline __m128i JUCE_VECTOR_CALLTYPE min (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_min_epi32 (a, b); #else __m128i lt = greaterThan (b, a); @@ -596,7 +594,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE max (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_max_epi32 (a, b); #else __m128i gt = greaterThan (a, b); @@ -644,7 +642,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE equal (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_cmpeq_epi64 (a, b); #else __m128i bitmask = _mm_cmpeq_epi32 (a, b); @@ -655,7 +653,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_2__) + #if defined (__SSE4_2__) return _mm_cmpgt_epi64 (a, b); #else return SIMDFallbackOps::greaterThan (a, b); @@ -704,7 +702,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE equal (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined (__SSE4_1__) return _mm_cmpeq_epi64 (a, b); #else __m128i bitmask = _mm_cmpeq_epi32 (a, b); @@ -715,7 +713,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_2__) + #if defined (__SSE4_2__) return _mm_cmpgt_epi64 (ssign (a), ssign (b)); #else return SIMDFallbackOps::greaterThan (a, b); @@ -727,5 +725,4 @@ struct SIMDNativeOps JUCE_END_IGNORE_WARNINGS_GCC_LIKE -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.cpp index c999a764..a6e43fb3 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -126,5 +124,4 @@ SampleType BallisticsFilter::calculateLimitedCte (SampleType timeMs) template class BallisticsFilter; template class BallisticsFilter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.h index e1a79575..7cc09e65 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_BallisticsFilter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class BallisticsFilterLevelCalculationType @@ -146,5 +144,4 @@ class BallisticsFilter LevelCalculationType levelType = LevelCalculationType::peak; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.cpp index a3f020ae..e801f172 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -114,7 +112,7 @@ template SampleType DelayLine::popSample (int channel, SampleType delayInSamples, bool updateReadPointer) { if (delayInSamples >= 0) - setDelay(delayInSamples); + setDelay (delayInSamples); auto result = interpolateSample (channel); @@ -134,5 +132,4 @@ template class DelayLine; template class DelayLine; template class DelayLine; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.h index 29c53d28..8e365bd9 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_DelayLine.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -313,5 +311,4 @@ class DelayLine SampleType alpha = 0.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.cpp index 03a68a76..01f29ec9 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -210,7 +208,7 @@ template class DryWetMixer; //============================================================================== #if JUCE_UNIT_TESTS -struct DryWetMixerTests : public UnitTest +struct DryWetMixerTests final : public UnitTest { DryWetMixerTests() : UnitTest ("DryWetMixer", UnitTestCategories::dsp) {} @@ -367,5 +365,4 @@ static const DryWetMixerTests dryWetMixerTests; #endif -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.h index 6023f7c1..612dd698 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_DryWetMixer.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class DryWetMixingRule @@ -116,5 +114,4 @@ class DryWetMixer int maximumWetLatencyInSamples = 0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.cpp index 4ebff528..d53079e1 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { template @@ -157,5 +155,4 @@ void FIR::Coefficients::Coefficients::normalise() noexcept template struct FIR::Coefficients; template struct FIR::Coefficients; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.h index 203c1283..1bdf46d5 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter.h @@ -23,15 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp -{ - /** Classes for FIR filter processing. */ -namespace FIR +namespace juce::dsp::FIR { template struct Coefficients; @@ -76,11 +71,11 @@ namespace FIR //============================================================================== /** Prepare this filter for processing. */ - inline void prepare (const ProcessSpec& spec) noexcept + inline void prepare ([[maybe_unused]] const ProcessSpec& spec) noexcept { // This class can only process mono signals. Use the ProcessorDuplicator class // to apply this filter on a multi-channel audio stream. - jassertquiet (spec.numChannels == 1); + jassert (spec.numChannels == 1); reset(); } @@ -279,7 +274,5 @@ namespace FIR */ Array coefficients; }; -} -} // namespace dsp -} // namespace juce +} // namespace juce::dsp::FIR diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter_test.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter_test.cpp index 466ed942..892040a5 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_FIRFilter_test.cpp @@ -23,12 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { -class FIRFilterTest : public UnitTest +class FIRFilterTest final : public UnitTest { template struct Helpers @@ -218,5 +216,4 @@ class FIRFilterTest : public UnitTest static FIRFilterTest firFilterUnitTest; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.cpp index 2b145dd5..62f4806c 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -118,5 +116,4 @@ void FirstOrderTPTFilter::update() template class FirstOrderTPTFilter; template class FirstOrderTPTFilter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.h index 7e24fd8b..686e26a5 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_FirstOrderTPTFilter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class FirstOrderTPTFilterType @@ -147,5 +145,4 @@ class FirstOrderTPTFilter SampleType cutoffFrequency = 1000.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.cpp index 37bed1e8..64b9e41a 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.cpp @@ -23,11 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp -{ -namespace IIR +namespace juce::dsp::IIR { constexpr auto minimumDecibels = -300.0; @@ -498,7 +494,7 @@ void Coefficients::getMagnitudeForFrequencyArray (const double* fre factor *= jw; } - magnitudes[i] = std::abs(numerator / denominator); + magnitudes[i] = std::abs (numerator / denominator); } } @@ -574,6 +570,4 @@ void Coefficients::getPhaseForFrequencyArray (double* frequencies, template struct Coefficients; template struct Coefficients; -} // namespace IIR -} // namespace dsp -} // namespace juce +} // namespace juce::dsp::IIR diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.h index 48d54c48..422759f7 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter.h @@ -23,15 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp -{ - /** Classes for IIR filter processing. */ -namespace IIR +namespace juce::dsp::IIR { /** A set of coefficients for use in an Filter object. @@ -396,8 +391,4 @@ namespace IIR JUCE_LEAK_DETECTOR (Filter) }; -} // namespace IIR -} // namespace dsp -} // namespace juce - -#include "juce_IIRFilter_Impl.h" +} // namespace juce::dsp::IIR diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter_Impl.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter_Impl.h index b30caf7c..70d6802e 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter_Impl.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_IIRFilter_Impl.h @@ -23,11 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp -{ -namespace IIR +namespace juce::dsp::IIR { #ifndef DOXYGEN @@ -241,6 +237,4 @@ void Filter::check() #endif -} // namespace IIR -} // namespace dsp -} // namespace juce +} // namespace juce::dsp::IIR diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.cpp index 8d41ca44..be4ed0cf 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -145,5 +143,4 @@ void LinkwitzRileyFilter::update() template class LinkwitzRileyFilter; template class LinkwitzRileyFilter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.h index 4661762b..ad731df7 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_LinkwitzRileyFilter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class LinkwitzRileyFilterType @@ -139,5 +137,4 @@ class LinkwitzRileyFilter Type filterType = Type::lowpass; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.cpp index 8600b18e..59ad7539 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** Abstract class for the provided oversampling stages used internally in @@ -70,7 +68,7 @@ struct Oversampling::OversamplingStage signal, which could be equivalent to a "one time" oversampling processing. */ template -struct OversamplingDummy : public Oversampling::OversamplingStage +struct OversamplingDummy final : public Oversampling::OversamplingStage { using ParentType = typename Oversampling::OversamplingStage; @@ -110,7 +108,7 @@ struct OversamplingDummy : public Oversampling::OversamplingStage leading to specific processing optimizations. */ template -struct Oversampling2TimesEquirippleFIR : public Oversampling::OversamplingStage +struct Oversampling2TimesEquirippleFIR final : public Oversampling::OversamplingStage { using ParentType = typename Oversampling::OversamplingStage; @@ -262,7 +260,7 @@ struct Oversampling2TimesEquirippleFIR : public Oversampling::Overs phase, and provided with a method to get the exact resulting latency. */ template -struct Oversampling2TimesPolyphaseIIR : public Oversampling::OversamplingStage +struct Oversampling2TimesPolyphaseIIR final : public Oversampling::OversamplingStage { using ParentType = typename Oversampling::OversamplingStage; @@ -729,11 +727,11 @@ void Oversampling::processSamplesDown (AudioBlock& outpu auto currentNumSamples = outputBlock.getNumSamples(); for (int n = 0; n < stages.size() - 1; ++n) - currentNumSamples *= stages.getUnchecked(n)->factor; + currentNumSamples *= stages.getUnchecked (n)->factor; for (int n = stages.size() - 1; n > 0; --n) { - auto& stage = *stages.getUnchecked(n); + auto& stage = *stages.getUnchecked (n); auto audioBlock = stages.getUnchecked (n - 1)->getProcessedSamples (currentNumSamples); stage.processSamplesDown (audioBlock); @@ -766,5 +764,4 @@ void Oversampling::updateDelayLine() template class Oversampling; template class Oversampling; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.h index 9d5990ae..e57f87ce 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_Oversampling.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -210,5 +208,4 @@ class JUCE_API Oversampling JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling) }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.cpp index 879cb519..c94d0de5 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -139,5 +137,4 @@ void Panner::update() template class Panner; template class Panner; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.h index 46bd7e2c..18211adc 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_Panner.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class PannerRule @@ -82,9 +80,9 @@ class Panner const auto numInputChannels = inputBlock.getNumChannels(); const auto numOutputChannels = outputBlock.getNumChannels(); - const auto numSamples = outputBlock.getNumSamples(); + [[maybe_unused]] const auto numSamples = outputBlock.getNumSamples(); - jassertquiet (inputBlock.getNumSamples() == numSamples); + jassert (inputBlock.getNumSamples() == numSamples); if (numOutputChannels != 2 || numInputChannels == 0 || numInputChannels > 2) return; @@ -117,5 +115,4 @@ class Panner double sampleRate = 44100.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessContext.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessContext.h index 6da17bb7..9c2dc380 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessContext.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessContext.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -185,5 +183,4 @@ struct ProcessContextNonReplacing AudioBlockType& outputBlock; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain.h index 9f821018..b3370bfa 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -120,7 +118,7 @@ class ProcessorChain } std::tuple processors; - std::array bypassed { {} }; + std::array bypassed { {} }; }; /** Non-member equivalent of ProcessorChain::get which avoids awkward @@ -159,8 +157,7 @@ inline bool isBypassed (const ProcessorChain& chain) noexcept return chain.template isBypassed(); } -} // namespace dsp -} // namespace juce +} // namespace juce::dsp #ifndef DOXYGEN namespace std diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain_test.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain_test.cpp index 80ff01fe..50c4445c 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain_test.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorChain_test.cpp @@ -23,12 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { -class ProcessorChainTest : public UnitTest +class ProcessorChainTest final : public UnitTest { template struct MockProcessor @@ -163,5 +161,4 @@ class ProcessorChainTest : public UnitTest static ProcessorChainTest processorChainUnitTest; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorDuplicator.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorDuplicator.h index dbc92419..a1e0ed69 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorDuplicator.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorDuplicator.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -95,5 +93,4 @@ struct ProcessorDuplicator juce::OwnedArray processors; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorWrapper.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorWrapper.h index 3ebe2a0c..4c3d9d26 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorWrapper.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_ProcessorWrapper.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -77,5 +75,4 @@ struct ProcessorWrapper : public ProcessorBase ProcessorType processor; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableFilter.h index 6554b2bc..a6c2ed71 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -23,15 +23,10 @@ ============================================================================== */ -namespace juce -{ -namespace dsp -{ - /** Classes for state variable filter processing. */ -namespace StateVariableFilter +namespace juce::dsp::StateVariableFilter { template struct Parameters; @@ -224,7 +219,7 @@ namespace StateVariableFilter Note: The bandwidth of the resonance increases with the value of the parameter. To have a standard 12 dB/octave filter, the value must be set - at 1 / sqrt(2). + at 1 / sqrt (2). */ void setCutOffFrequency (double sampleRate, NumericType frequency, NumericType resonance = static_cast (1.0 / MathConstants::sqrt2)) noexcept @@ -254,7 +249,5 @@ namespace StateVariableFilter NumericType R2 = static_cast (MathConstants::sqrt2); NumericType h = static_cast (1.0 / (1.0 + R2 * g + g * g)); }; -} -} // namespace dsp -} // namespace juce +} // namespace juce::dsp::StateVariableFilter diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.cpp b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.cpp index aa85ff48..f1e458aa 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -133,5 +131,4 @@ void StateVariableTPTFilter::update() template class StateVariableTPTFilter; template class StateVariableTPTFilter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.h b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.h index 9137f079..227fc32b 100644 --- a/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/processors/juce_StateVariableTPTFilter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class StateVariableTPTFilterType @@ -80,7 +78,7 @@ class StateVariableTPTFilter Note: The bandwidth of the resonance increases with the value of the parameter. To have a standard 12 dB / octave filter, the value must be set - at 1 / sqrt(2). + at 1 / sqrt (2). */ void setResonance (SampleType newResonance); @@ -162,5 +160,4 @@ class StateVariableTPTFilter resonance = static_cast (1.0 / std::sqrt (2.0)); }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Bias.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Bias.h index cbd68b86..d2a6415c 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Bias.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Bias.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -155,5 +153,4 @@ class Bias } }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.cpp index 7976fc8d..d929677a 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -137,5 +135,4 @@ void Chorus::update() template class Chorus; template class Chorus; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.h index 01395061..a3c60a18 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Chorus.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -103,7 +101,7 @@ class Chorus return; } - auto delayValuesBlock = AudioBlock(bufferDelayTimes).getSubBlock (0, numSamples); + auto delayValuesBlock = AudioBlock (bufferDelayTimes).getSubBlock (0, numSamples); auto contextDelay = ProcessContextReplacing (delayValuesBlock); delayValuesBlock.clear(); @@ -165,5 +163,4 @@ class Chorus maximumDelayModulation = 20.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.cpp index e2a73f78..cad1b5f8 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -117,5 +115,4 @@ void Compressor::update() template class Compressor; template class Compressor; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.h index f05b9a23..9395371f 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Compressor.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -106,5 +104,4 @@ class Compressor SampleType thresholddB = 0.0, ratio = 1.0, attackTime = 1.0, releaseTime = 100.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Gain.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Gain.h index 1e98dc69..3faa834f 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Gain.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Gain.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -144,5 +142,4 @@ class Gain double sampleRate = 0, rampDurationSeconds = 0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.cpp index 6a2ad9dc..54212637 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -172,5 +170,4 @@ void LadderFilter::setSampleRate (SampleType newValue) noexcept template class LadderFilter; template class LadderFilter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.h index e2f7b58f..47b79051 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_LadderFilter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { enum class LadderFilterMode @@ -149,5 +147,4 @@ class LadderFilter bool enabled = true; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.cpp index 7a48ef63..0fb364f5 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -94,5 +92,4 @@ void Limiter::update() template class Limiter; template class Limiter; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.h index e61c1797..eacfaa89 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Limiter.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -101,5 +99,4 @@ class Limiter SampleType thresholddB = -10.0, releaseTime = 100.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.cpp index 840ee3b5..b41da0f4 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -125,5 +123,4 @@ void NoiseGate::update() template class NoiseGate; template class NoiseGate; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.h index 58de30a6..5432f53b 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_NoiseGate.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -106,5 +104,4 @@ class NoiseGate SampleType thresholddB = -100, ratio = 10.0, attackTime = 1.0, releaseTime = 100.0; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Oscillator.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Oscillator.h index 92582707..082d5df8 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Oscillator.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Oscillator.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -247,5 +245,4 @@ class Oscillator Phase phase; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.cpp b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.cpp index 50b17d5f..2b573d29 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.cpp +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.cpp @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { //============================================================================== @@ -150,5 +148,4 @@ void Phaser::update() template class Phaser; template class Phaser; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.h index 2a130274..d569150a 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Phaser.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -114,7 +112,7 @@ class Phaser if (numSamplesDown > 0) { - auto freqBlock = AudioBlock(bufferFrequency).getSubBlock (0, (size_t) numSamplesDown); + auto freqBlock = AudioBlock (bufferFrequency).getSubBlock (0, (size_t) numSamplesDown); auto contextFreq = ProcessContextReplacing (freqBlock); freqBlock.clear(); @@ -202,5 +200,4 @@ class Phaser static constexpr int numStages = 6; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Reverb.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Reverb.h index 677df27a..6d21a96f 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_Reverb.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_Reverb.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -111,5 +109,4 @@ class Reverb bool enabled = true; }; -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_dsp/widgets/juce_WaveShaper.h b/JuceLibraryCode/modules/juce_dsp/widgets/juce_WaveShaper.h index 995c20e7..ac531001 100644 --- a/JuceLibraryCode/modules/juce_dsp/widgets/juce_WaveShaper.h +++ b/JuceLibraryCode/modules/juce_dsp/widgets/juce_WaveShaper.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace dsp +namespace juce::dsp { /** @@ -79,5 +77,4 @@ template static WaveShaper, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; } #endif -} // namespace dsp -} // namespace juce +} // namespace juce::dsp diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index d21c9890..40cc12fe 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -23,7 +23,7 @@ namespace juce { -class ActionBroadcaster::ActionMessage : public MessageManager::MessageBase +class ActionBroadcaster::ActionMessage final : public MessageManager::MessageBase { public: ActionMessage (const ActionBroadcaster* ab, @@ -86,7 +86,7 @@ void ActionBroadcaster::sendActionMessage (const String& message) const const ScopedLock sl (actionListenerLock); for (int i = actionListeners.size(); --i >= 0;) - (new ActionMessage (this, message, actionListeners.getUnchecked(i)))->post(); + (new ActionMessage (this, message, actionListeners.getUnchecked (i)))->post(); } } // namespace juce diff --git a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index aff0a276..e11ccb56 100644 --- a/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/JuceLibraryCode/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp @@ -23,7 +23,7 @@ namespace juce { -class AsyncUpdater::AsyncUpdaterMessage : public CallbackMessage +class AsyncUpdater::AsyncUpdaterMessage final : public CallbackMessage { public: AsyncUpdaterMessage (AsyncUpdater& au) : owner (au) {} diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp b/JuceLibraryCode/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp index dce744f3..95a6b066 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp @@ -43,8 +43,8 @@ static String getCommandLinePrefix (const String& commandLineUniqueID) //============================================================================== // This thread sends and receives ping messages every second, so that it // can find out if the other process has stopped running. -struct ChildProcessPingThread : public Thread, - private AsyncUpdater +struct ChildProcessPingThread : public Thread, + private AsyncUpdater { ChildProcessPingThread (int timeout) : Thread ("IPC ping"), timeoutMs (timeout) { @@ -86,8 +86,8 @@ struct ChildProcessPingThread : public Thread, }; //============================================================================== -struct ChildProcessCoordinator::Connection : public InterprocessConnection, - private ChildProcessPingThread +struct ChildProcessCoordinator::Connection final : public InterprocessConnection, + private ChildProcessPingThread { Connection (ChildProcessCoordinator& m, const String& pipeName, int timeout) : InterprocessConnection (false, magicCoordWorkerConnectionHeader), @@ -196,8 +196,8 @@ void ChildProcessCoordinator::killWorkerProcess() } //============================================================================== -struct ChildProcessWorker::Connection : public InterprocessConnection, - private ChildProcessPingThread +struct ChildProcessWorker::Connection final : public InterprocessConnection, + private ChildProcessPingThread { Connection (ChildProcessWorker& p, const String& pipeName, int timeout) : InterprocessConnection (false, magicCoordWorkerConnectionHeader), diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 2b8d55bf..707aa264 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -23,7 +23,7 @@ namespace juce { -struct InterprocessConnection::ConnectionThread : public Thread +struct InterprocessConnection::ConnectionThread final : public Thread { ConnectionThread (InterprocessConnection& c) : Thread ("JUCE IPC"), owner (c) {} void run() override { owner.runThread(); } @@ -65,7 +65,7 @@ class SafeActionImpl bool safe = false; }; -class InterprocessConnection::SafeAction : public SafeActionImpl +class InterprocessConnection::SafeAction final : public SafeActionImpl { using SafeActionImpl::SafeActionImpl; }; @@ -246,7 +246,7 @@ void InterprocessConnection::initialiseWithPipe (std::unique_ptr newP } //============================================================================== -struct ConnectionStateMessage : public MessageManager::MessageBase +struct ConnectionStateMessage final : public MessageManager::MessageBase { ConnectionStateMessage (std::shared_ptr ipc, bool connected) noexcept : safeAction (ipc), connectionMade (connected) @@ -295,7 +295,7 @@ void InterprocessConnection::connectionLostInt() } } -struct DataDeliveryMessage : public Message +struct DataDeliveryMessage final : public Message { DataDeliveryMessage (std::shared_ptr ipc, const MemoryBlock& d) : safeAction (ipc), data (d) diff --git a/JuceLibraryCode/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp b/JuceLibraryCode/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp index add5e521..5e986316 100644 --- a/JuceLibraryCode/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp +++ b/JuceLibraryCode/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp @@ -134,8 +134,7 @@ std::vector NetworkServiceDiscovery::Available void NetworkServiceDiscovery::AvailableServiceList::handleAsyncUpdate() { - if (onChange != nullptr) - onChange(); + NullCheckedInvocation::invoke (onChange); } void NetworkServiceDiscovery::AvailableServiceList::handleMessage (const XmlElement& xml) diff --git a/JuceLibraryCode/modules/juce_events/juce_events.h b/JuceLibraryCode/modules/juce_events/juce_events.h index e11f371b..31e1680a 100644 --- a/JuceLibraryCode/modules/juce_events/juce_events.h +++ b/JuceLibraryCode/modules/juce_events/juce_events.h @@ -32,7 +32,7 @@ ID: juce_events vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE message and event handling classes description: Classes for running an application's main event loop and sending/receiving messages, timers, etc. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp index 7b0eb872..8296ddef 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -91,7 +91,7 @@ void JUCEApplicationBase::sendUnhandledException (const std::exception* const e, #endif #if JUCE_HANDLE_MULTIPLE_INSTANCES -struct JUCEApplicationBase::MultipleInstanceHandler : public ActionListener +struct JUCEApplicationBase::MultipleInstanceHandler final : public ActionListener { MultipleInstanceHandler (const String& appName) : appLock ("juceAppLock_" + appName) @@ -183,7 +183,7 @@ StringArray JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameterArray() extern void initialiseNSApplication(); #endif -#if (JUCE_LINUX || JUCE_BSD) && JUCE_MODULE_AVAILABLE_juce_gui_extra && (! defined(JUCE_WEB_BROWSER) || JUCE_WEB_BROWSER) +#if (JUCE_LINUX || JUCE_BSD) && JUCE_MODULE_AVAILABLE_juce_gui_extra && (! defined (JUCE_WEB_BROWSER) || JUCE_WEB_BROWSER) extern "C" int juce_gtkWebkitMain (int argc, const char* const* argv); #endif @@ -290,9 +290,9 @@ bool JUCEApplicationBase::initialiseApp() // a redirect or similar. FILE* ignore; - if (_fileno(stdout) < 0) freopen_s (&ignore, "CONOUT$", "w", stdout); - if (_fileno(stderr) < 0) freopen_s (&ignore, "CONOUT$", "w", stderr); - if (_fileno(stdin) < 0) freopen_s (&ignore, "CONIN$", "r", stdin); + if (_fileno (stdout) < 0) freopen_s (&ignore, "CONOUT$", "w", stdout); + if (_fileno (stderr) < 0) freopen_s (&ignore, "CONOUT$", "w", stderr); + if (_fileno (stdin) < 0) freopen_s (&ignore, "CONIN$", "r", stdin); } #endif diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 4eff17df..cae91f41 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_DeletedAtShutdown.cpp @@ -62,7 +62,7 @@ void DeletedAtShutdown::deleteAll() { JUCE_TRY { - auto* deletee = localCopy.getUnchecked(i); + auto* deletee = localCopy.getUnchecked (i); // double-check that it's not already been deleted during another object's destructor. { diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp index da949d2e..cd24761a 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.cpp @@ -87,7 +87,7 @@ namespace detail bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages); } // namespace detail -class MessageManager::QuitMessage : public MessageManager::MessageBase +class MessageManager::QuitMessage final : public MessageManager::MessageBase { public: QuitMessage() {} @@ -149,7 +149,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) #endif //============================================================================== -class AsyncFunctionCallback : public MessageManager::MessageBase +class AsyncFunctionCallback final : public MessageManager::MessageBase { public: AsyncFunctionCallback (MessageCallbackFunction* const f, void* const param) @@ -194,7 +194,7 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* func bool MessageManager::callAsync (std::function fn) { - struct AsyncCallInvoker : public MessageBase + struct AsyncCallInvoker final : public MessageBase { AsyncCallInvoker (std::function f) : callback (std::move (f)) {} void messageCallback() override { callback(); } @@ -282,7 +282,7 @@ bool MessageManager::existsAndIsCurrentThread() noexcept accessed from another thread inside a MM lock, you're screwed. (this is exactly what happens in Cocoa). */ -struct MessageManager::Lock::BlockingMessage : public MessageManager::MessageBase +struct MessageManager::Lock::BlockingMessage final : public MessageManager::MessageBase { explicit BlockingMessage (const MessageManager::Lock* parent) noexcept : owner (parent) {} @@ -292,10 +292,7 @@ struct MessageManager::Lock::BlockingMessage : public MessageManager::MessageB std::unique_lock lock { mutex }; if (owner != nullptr) - { - owner->abort(); - acquired = true; - } + owner->setAcquired (true); condvar.wait (lock, [&] { return owner == nullptr; }); } @@ -307,18 +304,11 @@ struct MessageManager::Lock::BlockingMessage : public MessageManager::MessageB owner = nullptr; } - bool wasAcquired() - { - const std::scoped_lock lock { mutex }; - return acquired; - } - private: std::mutex mutex; std::condition_variable condvar; const MessageManager::Lock* owner = nullptr; - bool acquired = false; JUCE_DECLARE_NON_COPYABLE (BlockingMessage) }; @@ -326,8 +316,23 @@ struct MessageManager::Lock::BlockingMessage : public MessageManager::MessageB //============================================================================== MessageManager::Lock::Lock() {} MessageManager::Lock::~Lock() { exit(); } -void MessageManager::Lock::enter() const noexcept { tryAcquire (true); } -bool MessageManager::Lock::tryEnter() const noexcept { return tryAcquire (false); } +void MessageManager::Lock::enter() const noexcept { exclusiveTryAcquire (true); } +bool MessageManager::Lock::tryEnter() const noexcept { return exclusiveTryAcquire (false); } + +bool MessageManager::Lock::exclusiveTryAcquire (bool lockIsMandatory) const noexcept +{ + if (lockIsMandatory) + entryMutex.enter(); + else if (! entryMutex.tryEnter()) + return false; + + const auto result = tryAcquire (lockIsMandatory); + + if (! result) + entryMutex.exit(); + + return result; +} bool MessageManager::Lock::tryAcquire (bool lockIsMandatory) const noexcept { @@ -376,7 +381,7 @@ bool MessageManager::Lock::tryAcquire (bool lockIsMandatory) const noexcept condvar.wait (lock, [&] { return std::exchange (abortWait, false); }); } - if (blockingMessage->wasAcquired()) + if (acquired) { mm->threadWithLock = Thread::getCurrentThreadId(); return true; @@ -395,14 +400,18 @@ bool MessageManager::Lock::tryAcquire (bool lockIsMandatory) const noexcept void MessageManager::Lock::exit() const noexcept { - if (blockingMessage == nullptr) - return; + const auto wasAcquired = [&] + { + const std::scoped_lock lock { mutex }; + return acquired; + }(); - const ScopeGuard scope { [&] { blockingMessage = nullptr; } }; + if (! wasAcquired) + return; - blockingMessage->stopWaiting(); + const ScopeGuard unlocker { [&] { entryMutex.exit(); } }; - if (! blockingMessage->wasAcquired()) + if (blockingMessage == nullptr) return; if (auto* mm = MessageManager::instance) @@ -410,13 +419,23 @@ void MessageManager::Lock::exit() const noexcept jassert (mm->currentThreadHasLockedMessageManager()); mm->threadWithLock = {}; } + + blockingMessage->stopWaiting(); + blockingMessage = nullptr; + acquired = false; } void MessageManager::Lock::abort() const noexcept +{ + setAcquired (false); +} + +void MessageManager::Lock::setAcquired (bool x) const noexcept { const ScopeGuard scope { [&] { condvar.notify_one(); } }; const std::scoped_lock lock { mutex }; abortWait = true; + acquired = x; } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h index 01daff8e..9c43083d 100644 --- a/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h +++ b/JuceLibraryCode/modules/juce_events/messages/juce_MessageManager.h @@ -297,11 +297,21 @@ class JUCE_API MessageManager final struct BlockingMessage; friend class ReferenceCountedObjectPtr; + bool exclusiveTryAcquire (bool) const noexcept; bool tryAcquire (bool) const noexcept; + void setAcquired (bool success) const noexcept; + //============================================================================== - mutable ReferenceCountedObjectPtr blockingMessage; + // This mutex is used to make this lock type behave like a normal mutex. + // If multiple threads call enter() simultaneously, only one will succeed in gaining + // this mutex. The mutex is released again in exit(). + mutable CriticalSection entryMutex; + + // This mutex protects the other data members of the lock from concurrent access, which + // happens when the BlockingMessage calls setAcquired to indicate that the lock was gained. mutable std::mutex mutex; + mutable ReferenceCountedObjectPtr blockingMessage; mutable std::condition_variable condvar; mutable bool abortWait = false, acquired = false; }; diff --git a/JuceLibraryCode/modules/juce_events/native/juce_EventLoop_linux.h b/JuceLibraryCode/modules/juce_events/native/juce_EventLoop_linux.h index ee0896b8..e098bcbf 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_EventLoop_linux.h +++ b/JuceLibraryCode/modules/juce_events/native/juce_EventLoop_linux.h @@ -20,11 +20,9 @@ ============================================================================== */ -namespace juce +namespace juce::LinuxEventLoop { -namespace LinuxEventLoop -{ /** Registers a callback that will be called when a file descriptor is ready for I/O. This will add the given file descriptor to the internal set of file descriptors @@ -45,6 +43,5 @@ namespace LinuxEventLoop @see registerFdCallback */ void unregisterFdCallback (int fd); -} -} // namespace juce +} // namespace juce::LinuxEventLoop diff --git a/JuceLibraryCode/modules/juce_events/native/juce_MessageManager_mac.mm b/JuceLibraryCode/modules/juce_events/native/juce_MessageManager_mac.mm index 6f9599b4..46b86baf 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_MessageManager_mac.mm +++ b/JuceLibraryCode/modules/juce_events/native/juce_MessageManager_mac.mm @@ -33,7 +33,7 @@ MenuTrackingChangedCallback menuTrackingChangedCallback = nullptr; //============================================================================== -struct AppDelegateClass : public ObjCClass +struct AppDelegateClass final : public ObjCClass { AppDelegateClass() : ObjCClass ("JUCEAppDelegate_") { @@ -110,14 +110,12 @@ addMethod (@selector (mainMenuTrackingBegan:), [] (id /*self*/, SEL, NSNotification*) { - if (menuTrackingChangedCallback != nullptr) - menuTrackingChangedCallback (true); + NullCheckedInvocation::invoke (menuTrackingChangedCallback, true); }); addMethod (@selector (mainMenuTrackingEnded:), [] (id /*self*/, SEL, NSNotification*) { - if (menuTrackingChangedCallback != nullptr) - menuTrackingChangedCallback (false); + NullCheckedInvocation::invoke (menuTrackingChangedCallback, false); }); // (used as a way of running a dummy thread) @@ -355,7 +353,7 @@ static void shutdownNSApp() } else { - struct QuitCallback : public CallbackMessage + struct QuitCallback final : public CallbackMessage { QuitCallback() {} void messageCallback() override { MessageManager::getInstance()->stopDispatchLoop(); } @@ -465,7 +463,7 @@ void initialiseNSApplication() MountedVolumeListChangeDetector& owner; id delegate; - struct ObserverClass : public ObjCClass + struct ObserverClass final : public ObjCClass { ObserverClass() : ObjCClass ("JUCEDriveObserver_") { diff --git a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_android.cpp b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_android.cpp index ac43f870..5aed46e2 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_android.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_android.cpp @@ -26,7 +26,7 @@ namespace juce //============================================================================== namespace Android { - class Runnable : public juce::AndroidInterfaceImplementer + class Runnable : public juce::AndroidInterfaceImplementer { public: virtual void run() = 0; @@ -67,7 +67,7 @@ namespace Android } //============================================================================== -struct AndroidMessageQueue : private Android::Runnable +struct AndroidMessageQueue final : private Android::Runnable { JUCE_DECLARE_SINGLETON_SINGLETHREADED (AndroidMessageQueue, true) @@ -134,7 +134,7 @@ void MessageManager::runDispatchLoop() void MessageManager::stopDispatchLoop() { - struct QuitCallback : public CallbackMessage + struct QuitCallback final : public CallbackMessage { QuitCallback() {} @@ -169,7 +169,7 @@ void MessageManager::stopDispatchLoop() } //============================================================================== -class JuceAppLifecycle : public ActivityLifecycleCallbacks +class JuceAppLifecycle final : public ActivityLifecycleCallbacks { public: JuceAppLifecycle (juce::JUCEApplicationBase* (*initSymbolAddr)()) diff --git a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_linux.cpp b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_linux.cpp index 66575775..67600aa6 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_linux.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_linux.cpp @@ -29,8 +29,8 @@ class InternalMessageQueue public: InternalMessageQueue() { - auto err = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, msgpipe); - jassertquiet (err == 0); + [[maybe_unused]] auto err = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, msgpipe); + jassert (err == 0); LinuxEventLoop::registerFdCallback (getReadHandle(), [this] (int fd) diff --git a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_windows.cpp b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_windows.cpp index 4e3e53b9..9ae2c012 100644 --- a/JuceLibraryCode/modules/juce_events/native/juce_Messaging_windows.cpp +++ b/JuceLibraryCode/modules/juce_events/native/juce_Messaging_windows.cpp @@ -164,8 +164,7 @@ class InternalMessageQueue } if (message == WM_SETTINGCHANGE) - if (settingChangeCallback != nullptr) - settingChangeCallback(); + NullCheckedInvocation::invoke (settingChangeCallback); } return DefWindowProc (h, message, wParam, lParam); @@ -200,7 +199,7 @@ class InternalMessageQueue { if (data != nullptr && data->dwData == broadcastMessageMagicNumber) { - struct BroadcastMessage : public CallbackMessage + struct BroadcastMessage final : public CallbackMessage { BroadcastMessage (CharPointer_UTF32 text, size_t length) : message (text, length) {} void messageCallback() override { MessageManager::getInstance()->deliverBroadcastMessage (message); } diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp index 8074bf8d..e546eb60 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp +++ b/JuceLibraryCode/modules/juce_events/timers/juce_MultiTimer.cpp @@ -23,7 +23,7 @@ namespace juce { -struct MultiTimerCallback : public Timer +struct MultiTimerCallback final : public Timer { MultiTimerCallback (const int tid, MultiTimer& mt) noexcept : owner (mt), timerID (tid) @@ -56,7 +56,7 @@ Timer* MultiTimer::getCallback (int timerID) const noexcept { for (int i = timers.size(); --i >= 0;) { - MultiTimerCallback* const t = static_cast (timers.getUnchecked(i)); + MultiTimerCallback* const t = static_cast (timers.getUnchecked (i)); if (t->timerID == timerID) return t; diff --git a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp index 2dde51bc..79cec025 100644 --- a/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp +++ b/JuceLibraryCode/modules/juce_events/timers/juce_Timer.cpp @@ -23,9 +23,9 @@ namespace juce { -class Timer::TimerThread : private Thread, - private DeletedAtShutdown, - private AsyncUpdater +class Timer::TimerThread final : private Thread, + private DeletedAtShutdown, + private AsyncUpdater { public: using LockType = CriticalSection; // (mysteriously, using a SpinLock here causes problems on some XP machines..) @@ -171,7 +171,7 @@ class Timer::TimerThread : private Thread, WaitableEvent callbackArrived; - struct CallTimersMessage : public MessageManager::MessageBase + struct CallTimersMessage final : public MessageManager::MessageBase { CallTimersMessage() {} @@ -371,7 +371,7 @@ void JUCE_CALLTYPE Timer::callPendingTimersSynchronously() TimerThread::instance->callTimersSynchronously(); } -struct LambdaInvoker : private Timer +struct LambdaInvoker final : private Timer { LambdaInvoker (int milliseconds, std::function f) : function (f) { diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp index 47c343ec..82a26455 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colour.cpp @@ -562,7 +562,7 @@ String Colour::toDisplayString (const bool includeAlphaValue) const //============================================================================== #if JUCE_UNIT_TESTS -class ColourTests : public UnitTest +class ColourTests final : public UnitTest { public: ColourTests() diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp index c5bf1342..72009a60 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_ColourGradient.cpp @@ -125,7 +125,7 @@ int ColourGradient::addColour (const double proportionAlongGradient, Colour colo int i; for (i = 0; i < colours.size(); ++i) - if (colours.getReference(i).position > pos) + if (colours.getReference (i).position > pos) break; colours.insert (i, { pos, colour }); @@ -177,10 +177,10 @@ Colour ColourGradient::getColourAtPosition (double position) const noexcept jassert (approximatelyEqual (colours.getReference (0).position, 0.0)); // the first colour specified has to go at position 0 if (position <= 0 || colours.size() <= 1) - return colours.getReference(0).colour; + return colours.getReference (0).colour; int i = colours.size() - 1; - while (position < colours.getReference(i).position) + while (position < colours.getReference (i).position) --i; auto& p1 = colours.getReference (i); @@ -199,7 +199,7 @@ void ColourGradient::createLookupTable (PixelARGB* const lookupTable, const int JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates? jassert (colours.size() >= 2); jassert (numEntries > 0); - jassert (approximatelyEqual (colours.getReference(0).position, 0.0)); // The first colour specified has to go at position 0 + jassert (approximatelyEqual (colours.getReference (0).position, 0.0)); // The first colour specified has to go at position 0 int index = 0; diff --git a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h index 434b2b16..0cfed34d 100644 --- a/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h +++ b/JuceLibraryCode/modules/juce_graphics/colour/juce_Colours.h @@ -23,10 +23,6 @@ ============================================================================== */ -namespace juce -{ - -//============================================================================== /** Contains a set of predefined named colours (mostly standard HTML colours) @@ -34,7 +30,7 @@ namespace juce @tags{Graphics} */ -namespace Colours +namespace juce::Colours { const Colour transparentBlack { 0 }; @@ -191,6 +187,5 @@ namespace Colours */ JUCE_API Colour findColourForName (const String& colourName, Colour defaultColour); -} // namespace Colours -} // namespace juce +} // namespace juce::Colours diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 225145fd..84291f62 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -134,10 +134,10 @@ namespace #if JUCE_DEBUG const int maxVal = 0x3fffffff; - jassertquiet ((int) x >= -maxVal && (int) x <= maxVal - && (int) y >= -maxVal && (int) y <= maxVal - && (int) w >= 0 && (int) w <= maxVal - && (int) h >= 0 && (int) h <= maxVal); + jassert ((int) x >= -maxVal && (int) x <= maxVal + && (int) y >= -maxVal && (int) y <= maxVal + && (int) w >= 0 && (int) w <= maxVal + && (int) h >= 0 && (int) h <= maxVal); #endif return { x, y, w, h }; diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h index 71cfec53..3cd2c507 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -469,7 +469,7 @@ class JUCE_API Graphics final By default a Graphics object will be set to mediumRenderingQuality. @see Graphics::drawImage, Graphics::drawImageTransformed, Graphics::drawImageWithin */ - void setImageResamplingQuality (const ResamplingQuality newQuality); + void setImageResamplingQuality (ResamplingQuality newQuality); /** Draws an image. diff --git a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 2ce23137..7c6ca2d9 100644 --- a/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/JuceLibraryCode/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -75,7 +75,7 @@ class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsC void fillRectList (const RectangleList&) override; void fillPath (const Path&, const AffineTransform&) override; void drawImage (const Image&, const AffineTransform&) override; - void drawLine (const Line &) override; + void drawLine (const Line&) override; //============================================================================== const Font& getFont() override; diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h index 75653f03..875145af 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_CustomTypeface.h @@ -157,7 +157,7 @@ class JUCE_API CustomTypeface : public Typeface OwnedArray glyphs; short lookupTable[128]; - GlyphInfo* findGlyph (const juce_wchar character, bool loadIfNeeded) noexcept; + GlyphInfo* findGlyph (juce_wchar character, bool loadIfNeeded) noexcept; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomTypeface) }; diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp index 8eb2c9d3..d510e083 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_Font.cpp @@ -46,7 +46,7 @@ float Font::getDefaultMinimumHorizontalScaleFactor() noexcept { r void Font::setDefaultMinimumHorizontalScaleFactor (float newValue) noexcept { FontValues::minimumHorizontalScale = newValue; } //============================================================================== -class TypefaceCache : private DeletedAtShutdown +class TypefaceCache final : private DeletedAtShutdown { public: TypefaceCache() @@ -89,7 +89,7 @@ class TypefaceCache : private DeletedAtShutdown for (int i = faces.size(); --i >= 0;) { - CachedFace& face = faces.getReference(i); + CachedFace& face = faces.getReference (i); if (face.typefaceName == faceName && face.typefaceStyle == faceStyle @@ -108,7 +108,7 @@ class TypefaceCache : private DeletedAtShutdown for (int i = faces.size(); --i >= 0;) { - auto lu = faces.getReference(i).lastUsageCount; + auto lu = faces.getReference (i).lastUsageCount; if (bestLastUsageCount > lu) { @@ -178,8 +178,7 @@ void Typeface::clearTypefaceCache() RenderingHelpers::SoftwareRendererSavedState::clearGlyphCache(); - if (clearOpenGLGlyphCache != nullptr) - clearOpenGLGlyphCache(); + NullCheckedInvocation::invoke (clearOpenGLGlyphCache); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index 93571e1d..9c73cbb5 100644 --- a/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/JuceLibraryCode/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -177,7 +177,7 @@ void GlyphArrangement::addCurtailedLineOfText (const Font& font, const String& t auto isWhitespace = isNonBreakingSpace (*t) || t.isWhitespace(); glyphs.add (PositionedGlyph (font, t.getAndAdvance(), - newGlyphs.getUnchecked(i), + newGlyphs.getUnchecked (i), xOffset + thisX, yOffset, nextX - thisX, isWhitespace)); } @@ -239,8 +239,8 @@ void GlyphArrangement::addJustifiedText (const Font& font, const String& text, { int i = lineStartIndex; - if (glyphs.getReference(i).getCharacter() != '\n' - && glyphs.getReference(i).getCharacter() != '\r') + if (glyphs.getReference (i).getCharacter() != '\n' + && glyphs.getReference (i).getCharacter() != '\r') ++i; auto lineMaxX = glyphs.getReference (lineStartIndex).getLeft() + maxLineWidth; @@ -256,7 +256,7 @@ void GlyphArrangement::addJustifiedText (const Font& font, const String& text, ++i; if (c == '\r' && i < glyphs.size() - && glyphs.getReference(i).getCharacter() == '\n') + && glyphs.getReference (i).getCharacter() == '\n') ++i; break; diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp index ddc55c29..c4d475e8 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -245,7 +245,7 @@ float AffineTransform::getScaleFactor() const noexcept //============================================================================== #if JUCE_UNIT_TESTS -class AffineTransformTests : public UnitTest +class AffineTransformTests final : public UnitTest { public: AffineTransformTests() diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h index 849dad2c..a85eb799 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Path.h @@ -575,9 +575,9 @@ class JUCE_API Path final */ void addBubble (Rectangle bodyArea, Rectangle maximumArea, - const Point arrowTipPosition, - const float cornerSize, - const float arrowBaseWidth); + Point arrowTipPosition, + float cornerSize, + float arrowBaseWidth); /** Adds another path to this one. diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h index 2e7bf03f..830aa7b8 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle.h @@ -324,8 +324,8 @@ class Rectangle } /** Returns a rectangle which is the same as this one moved by a given amount. */ - Rectangle translated (ValueType deltaX, - ValueType deltaY) const noexcept + [[nodiscard]] Rectangle translated (ValueType deltaX, + ValueType deltaY) const noexcept { return { pos.x + deltaX, pos.y + deltaY, w, h }; } @@ -448,8 +448,8 @@ class Rectangle Effectively, the rectangle returned is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2). @see expand, reduce, reduced */ - Rectangle expanded (ValueType deltaX, - ValueType deltaY) const noexcept + [[nodiscard]] Rectangle expanded (ValueType deltaX, + ValueType deltaY) const noexcept { auto nw = jmax (ValueType(), w + deltaX * 2); auto nh = jmax (ValueType(), h + deltaY * 2); @@ -461,7 +461,7 @@ class Rectangle Effectively, the rectangle returned is (x - delta, y - delta, w + delta * 2, h + delta * 2). @see expand, reduce, reduced */ - Rectangle expanded (ValueType delta) const noexcept + [[nodiscard]] Rectangle expanded (ValueType delta) const noexcept { return expanded (delta, delta); } @@ -482,8 +482,8 @@ class Rectangle Effectively, the rectangle returned is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2). @see reduce, expand, expanded */ - Rectangle reduced (ValueType deltaX, - ValueType deltaY) const noexcept + [[nodiscard]] Rectangle reduced (ValueType deltaX, + ValueType deltaY) const noexcept { return expanded (-deltaX, -deltaY); } @@ -493,7 +493,7 @@ class Rectangle Effectively, the rectangle returned is (x + delta, y + delta, w - delta * 2, h - delta * 2). @see reduce, expand, expanded */ - Rectangle reduced (ValueType delta) const noexcept + [[nodiscard]] Rectangle reduced (ValueType delta) const noexcept { return reduced (delta, delta); } @@ -815,7 +815,7 @@ class Rectangle This should only be used on floating point rectangles. */ - Rectangle transformedBy (const AffineTransform& transform) const noexcept + [[nodiscard]] Rectangle transformedBy (const AffineTransform& transform) const noexcept { using FloatType = TypeHelpers::SmallestFloatType; diff --git a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle_test.cpp b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle_test.cpp index 0ac97aee..3fd8f4b3 100644 --- a/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle_test.cpp +++ b/JuceLibraryCode/modules/juce_graphics/geometry/juce_Rectangle_test.cpp @@ -26,7 +26,7 @@ namespace juce { -struct RectangleUnitTest : public UnitTest +struct RectangleUnitTest final : public UnitTest { RectangleUnitTest() : UnitTest ("Rectangle", UnitTestCategories::graphics) {} diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index 00f0251d..e68d18d6 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -179,7 +179,7 @@ namespace JPEGHelpers //============================================================================== const int jpegBufferSize = 512; - struct JuceJpegDest : public jpeg_destination_mgr + struct JuceJpegDest final : public jpeg_destination_mgr { OutputStream* output; char* buffer; diff --git a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index fe40b145..8fb1b109 100644 --- a/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/JuceLibraryCode/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -355,7 +355,7 @@ namespace PNGHelpers static void JUCE_CDECL errorCallback (png_structp p, png_const_charp) { #ifdef PNG_SETJMP_SUPPORTED - setjmp(png_jmpbuf(p)); + setjmp (png_jmpbuf (p)); #else longjmp (*(jmp_buf*) p->error_ptr, 1); #endif diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp index e054ad55..38f72e44 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_Image.cpp @@ -78,7 +78,7 @@ Image ImageType::convert (const Image& source) const } //============================================================================== -class SoftwarePixelData : public ImagePixelData +class SoftwarePixelData final : public ImagePixelData { public: SoftwarePixelData (Image::PixelFormat formatToUse, int w, int h, bool clearImage) @@ -154,7 +154,7 @@ ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int widt #endif //============================================================================== -class SubsectionPixelData : public ImagePixelData +class SubsectionPixelData final : public ImagePixelData { public: SubsectionPixelData (ImagePixelData::Ptr source, Rectangle r) diff --git a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp index cdf6cc32..2fc852f1 100644 --- a/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/JuceLibraryCode/modules/juce_graphics/images/juce_ImageCache.cpp @@ -75,7 +75,7 @@ struct ImageCache::Pimpl : private Timer, for (int i = images.size(); --i >= 0;) { - auto& item = images.getReference(i); + auto& item = images.getReference (i); if (item.image.getReferenceCount() <= 1) { @@ -97,7 +97,7 @@ struct ImageCache::Pimpl : private Timer, const ScopedLock sl (lock); for (int i = images.size(); --i >= 0;) - if (images.getReference(i).image.getReferenceCount() <= 1) + if (images.getReference (i).image.getReferenceCount() <= 1) images.remove (i); } diff --git a/JuceLibraryCode/modules/juce_graphics/juce_graphics.h b/JuceLibraryCode/modules/juce_graphics/juce_graphics.h index 7f35fc74..8b50fb50 100644 --- a/JuceLibraryCode/modules/juce_graphics/juce_graphics.h +++ b/JuceLibraryCode/modules/juce_graphics/juce_graphics.h @@ -35,7 +35,7 @@ ID: juce_graphics vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE graphics classes description: Classes for 2D vector graphics, image loading/saving, font handling, etc. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm b/JuceLibraryCode/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm index d8e7f0cf..b3dce76a 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_CoreGraphicsContext_mac.mm @@ -30,7 +30,7 @@ // This class has been renamed from CoreGraphicsImage to avoid a symbol // collision in Pro Tools 2019.12 and possibly 2020 depending on the Pro Tools // release schedule. -class CoreGraphicsPixelData : public ImagePixelData +class CoreGraphicsPixelData final : public ImagePixelData { public: CoreGraphicsPixelData (const Image::PixelFormat format, int w, int h, bool clearImage) @@ -140,7 +140,7 @@ static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpa detail::ContextPtr context; detail::ImagePtr cachedImageRef; - struct ImageDataContainer : public ReferenceCountedObject + struct ImageDataContainer final : public ReferenceCountedObject { ImageDataContainer() = default; @@ -323,7 +323,7 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format) auto image = detail::ImagePtr { CoreGraphicsPixelData::createImage (singleChannelImage, greyColourSpace.get()) }; flip(); - auto t = AffineTransform::verticalFlip (sourceImage.getHeight()).followedBy (transform); + auto t = AffineTransform::verticalFlip ((float) sourceImage.getHeight()).followedBy (transform); applyTransform (t); auto r = convertToCGRect (sourceImage.getBounds()); @@ -531,7 +531,7 @@ static CGBitmapInfo getCGImageFlags (const Image::PixelFormat& format) CGContextSetAlpha (context.get(), state->fillType.getOpacity()); flip(); - applyTransform (AffineTransform::verticalFlip (ih).followedBy (transform)); + applyTransform (AffineTransform::verticalFlip ((float) ih).followedBy (transform)); auto imageRect = CGRectMake (0, 0, iw, ih); if (fillEntireClipAsTiles) @@ -813,7 +813,7 @@ static CGGradientRef createGradient (const ColourGradient& g, CGColorSpaceRef co #if USE_COREGRAPHICS_RENDERING && JUCE_USE_COREIMAGE_LOADER Image juce_loadWithCoreImage (InputStream& input) { - struct MemoryBlockHolder : public ReferenceCountedObject + struct MemoryBlockHolder final : public ReferenceCountedObject { using Ptr = ReferenceCountedObjectPtr; MemoryBlock block; @@ -912,7 +912,7 @@ Image juce_createImageFromUIImage (UIImage* img) Image retval (Image::ARGB, (int) CGImageGetWidth (image), (int) CGImageGetHeight (image), true); CGContextRef ctx = juce_getImageContext (retval); - CGContextDrawImage (ctx, CGRectMake (0.0f, 0.0f, CGImageGetWidth (image), CGImageGetHeight (image)), image); + CGContextDrawImage (ctx, CGRectMake (0.0f, 0.0f, (CGFloat) CGImageGetWidth (image), (CGFloat) CGImageGetHeight (image)), image); return retval; } diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp index a9f53db1..070cb347 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp @@ -119,7 +119,7 @@ struct Direct2DLowLevelGraphicsContext::Pimpl sink->SetFillMode (D2D1_FILL_MODE_WINDING); for (int i = clipRegion.getNumRectangles(); --i >= 0;) - rectToGeometrySink (clipRegion.getRectangle(i), sink, AffineTransform()); + rectToGeometrySink (clipRegion.getRectangle (i), sink, AffineTransform()); hr = sink->Close(); return p; @@ -449,7 +449,7 @@ struct Direct2DLowLevelGraphicsContext::SavedState const auto p1 = fillType.gradient->point1; const auto p2 = fillType.gradient->point2; - const auto r = p1.getDistanceFrom(p2); + const auto r = p1.getDistanceFrom (p2); const auto props = D2D1::RadialGradientBrushProperties ({ p1.x, p1.y }, {}, r, r); owner.pimpl->renderingTarget->CreateRadialGradientBrush (props, brushProps, gradientStops, radialGradient.resetAndGetPointerAddress()); diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeLayout_windows.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeLayout_windows.cpp index bd42ced8..ece41ec4 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeLayout_windows.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeLayout_windows.cpp @@ -29,7 +29,7 @@ namespace juce #if JUCE_USE_DIRECTWRITE namespace DirectWriteTypeLayout { - class CustomDirectWriteTextRenderer : public ComBaseClassHelper + class CustomDirectWriteTextRenderer final : public ComBaseClassHelper { public: CustomDirectWriteTextRenderer (IDWriteFontCollection& fonts, const AttributedString& as) @@ -191,7 +191,7 @@ namespace DirectWriteTypeLayout { for (int i = 0; i < attributedString.getNumAttributes(); ++i) { - auto& font = attributedString.getAttribute(i).font; + auto& font = attributedString.getAttribute (i).font; auto typeface = font.getTypefacePtr(); if (auto* wt = dynamic_cast (typeface.get())) diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp index 6e88fa67..6ff2ea93 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp @@ -53,8 +53,8 @@ namespace { jassert (family != nullptr); ComSmartPtr familyNames; - auto hr = family->GetFamilyNames (familyNames.resetAndGetPointerAddress()); - jassertquiet (SUCCEEDED (hr)); + [[maybe_unused]] auto hr = family->GetFamilyNames (familyNames.resetAndGetPointerAddress()); + jassert (SUCCEEDED (hr)); return getLocalisedName (familyNames); } @@ -62,8 +62,8 @@ namespace { jassert (font != nullptr); ComSmartPtr faceNames; - auto hr = font->GetFaceNames (faceNames.resetAndGetPointerAddress()); - jassertquiet (SUCCEEDED (hr)); + [[maybe_unused]] auto hr = font->GetFaceNames (faceNames.resetAndGetPointerAddress()); + jassert (SUCCEEDED (hr)); return getLocalisedName (faceNames); } @@ -142,7 +142,7 @@ class Direct2DFactories }; //============================================================================== -class WindowsDirectWriteTypeface : public Typeface +class WindowsDirectWriteTypeface final : public Typeface { public: WindowsDirectWriteTypeface (const Font& font, IDWriteFontCollection* fontCollection) @@ -285,7 +285,7 @@ class WindowsDirectWriteTypeface : public Typeface AffineTransform pathTransform; BOOL fontFound = false; - struct PathGeometrySink : public ComBaseClassHelper + struct PathGeometrySink final : public ComBaseClassHelper { PathGeometrySink() : ComBaseClassHelper (0) {} diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_android.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_android.cpp index ba6723d3..add9be14 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_android.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_android.cpp @@ -151,7 +151,7 @@ const float referenceFontSize = 256.0f; const float referenceFontToUnits = 1.0f / referenceFontSize; //============================================================================== -class AndroidTypeface : public Typeface +class AndroidTypeface final : public Typeface { public: AndroidTypeface (const Font& font) @@ -174,12 +174,12 @@ class AndroidTypeface : public Typeface fontFile = findFontFile (name, isBold, isItalic); if (fontFile.exists()) - typeface = GlobalRef (LocalRef(env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.createFromFile, - javaString (fontFile.getFullPathName()).get()))); + typeface = GlobalRef (LocalRef (env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.createFromFile, + javaString (fontFile.getFullPathName()).get()))); else - typeface = GlobalRef (LocalRef(env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.create, - javaString (getName()).get(), - (isBold ? 1 : 0) + (isItalic ? 2 : 0)))); + typeface = GlobalRef (LocalRef (env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.create, + javaString (getName()).get(), + (isBold ? 1 : 0) + (isItalic ? 2 : 0)))); } initialise (env); @@ -191,20 +191,20 @@ class AndroidTypeface : public Typeface auto* env = getEnv(); auto cacheFile = getCacheFileForData (data, size); - typeface = GlobalRef (LocalRef(env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.createFromFile, - javaString (cacheFile.getFullPathName()).get()))); + typeface = GlobalRef (LocalRef (env->CallStaticObjectMethod (TypefaceClass, TypefaceClass.createFromFile, + javaString (cacheFile.getFullPathName()).get()))); initialise (env); } void initialise (JNIEnv* const env) { - rect = GlobalRef (LocalRef(env->NewObject (AndroidRect, AndroidRect.constructor, 0, 0, 0, 0))); + rect = GlobalRef (LocalRef (env->NewObject (AndroidRect, AndroidRect.constructor, 0, 0, 0, 0))); paint = GlobalRef (GraphicsHelpers::createPaint (Graphics::highResamplingQuality)); const LocalRef ignored (paint.callObjectMethod (AndroidPaint.setTypeface, typeface.get())); - charArray = GlobalRef (LocalRef((jobject) env->NewCharArray (2))); + charArray = GlobalRef (LocalRef ((jobject) env->NewCharArray (2))); paint.callVoidMethod (AndroidPaint.setTextSize, referenceFontSize); @@ -474,7 +474,7 @@ class AndroidTypeface : public Typeface jassertfalse; return File(); - } (); + }(); return result; } @@ -492,20 +492,20 @@ class AndroidTypeface : public Typeface String key; { - LocalRef digest (env->CallStaticObjectMethod (JavaMessageDigest, JavaMessageDigest.getInstance, javaString("MD5").get())); - LocalRef bytes(env->NewByteArray ((int) size)); + LocalRef digest (env->CallStaticObjectMethod (JavaMessageDigest, JavaMessageDigest.getInstance, javaString ("MD5").get())); + LocalRef bytes (env->NewByteArray ((int) size)); jboolean ignore; - auto* jbytes = env->GetByteArrayElements(bytes.get(), &ignore); - memcpy(jbytes, data, size); - env->ReleaseByteArrayElements(bytes.get(), jbytes, 0); + auto* jbytes = env->GetByteArrayElements (bytes.get(), &ignore); + memcpy (jbytes, data, size); + env->ReleaseByteArrayElements (bytes.get(), jbytes, 0); - env->CallVoidMethod(digest.get(), JavaMessageDigest.update, bytes.get()); - LocalRef result((jbyteArray) env->CallObjectMethod(digest.get(), JavaMessageDigest.digest)); + env->CallVoidMethod (digest.get(), JavaMessageDigest.update, bytes.get()); + LocalRef result ((jbyteArray) env->CallObjectMethod (digest.get(), JavaMessageDigest.digest)); - auto* md5Bytes = env->GetByteArrayElements(result.get(), &ignore); - key = String::toHexString(md5Bytes, env->GetArrayLength(result.get()), 0); - env->ReleaseByteArrayElements(result.get(), md5Bytes, 0); + auto* md5Bytes = env->GetByteArrayElements (result.get(), &ignore); + key = String::toHexString (md5Bytes, env->GetArrayLength (result.get()), 0); + env->ReleaseByteArrayElements (result.get(), md5Bytes, 0); } ScopedLock lock (cs); diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_freetype.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_freetype.cpp index 89297c32..abf55e4a 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_freetype.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_freetype.cpp @@ -26,7 +26,7 @@ namespace juce { -struct FTLibWrapper : public ReferenceCountedObject +struct FTLibWrapper final : public ReferenceCountedObject { FTLibWrapper() { @@ -51,7 +51,7 @@ struct FTLibWrapper : public ReferenceCountedObject }; //============================================================================== -struct FTFaceWrapper : public ReferenceCountedObject +struct FTFaceWrapper final : public ReferenceCountedObject { FTFaceWrapper (const FTLibWrapper::Ptr& ftLib, const File& file, int faceIndex) : library (ftLib) @@ -84,7 +84,7 @@ struct FTFaceWrapper : public ReferenceCountedObject }; //============================================================================== -class FTTypefaceList : private DeletedAtShutdown +class FTTypefaceList final : private DeletedAtShutdown { public: FTTypefaceList() : library (new FTLibWrapper()) @@ -308,7 +308,7 @@ JUCE_IMPLEMENT_SINGLETON (FTTypefaceList) //============================================================================== -class FreeTypeTypeface : public CustomTypeface +class FreeTypeTypeface final : public CustomTypeface { public: FreeTypeTypeface (const Font& font) diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_mac.mm b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_mac.mm index 93c620d8..90d34d28 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_mac.mm +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_mac.mm @@ -585,7 +585,7 @@ Font result (String::fromCFString (cfsFontFamily.get()), //============================================================================== -class OSXTypeface : public Typeface +class OSXTypeface final : public Typeface { public: OSXTypeface (const Font& font) diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_windows.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_windows.cpp index ca1e6e35..83b75fed 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_windows.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_Fonts_windows.cpp @@ -313,7 +313,7 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) } //============================================================================== -class WindowsTypeface : public Typeface +class WindowsTypeface final : public Typeface { public: WindowsTypeface (const Font& font) : Typeface (font.getTypefaceName(), diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_GraphicsContext_android.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_GraphicsContext_android.cpp index 7fa14e6a..f4681e47 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_GraphicsContext_android.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_GraphicsContext_android.cpp @@ -37,12 +37,12 @@ namespace GraphicsHelpers if (quality > Graphics::lowResamplingQuality) constructorFlags |= 2; /*FILTER_BITMAP_FLAG*/ - return LocalRef(getEnv()->NewObject (AndroidPaint, AndroidPaint.constructor, constructorFlags)); + return LocalRef (getEnv()->NewObject (AndroidPaint, AndroidPaint.constructor, constructorFlags)); } static LocalRef createMatrix (JNIEnv* env, const AffineTransform& t) { - auto m = LocalRef(env->NewObject (AndroidMatrix, AndroidMatrix.constructor)); + auto m = LocalRef (env->NewObject (AndroidMatrix, AndroidMatrix.constructor)); jfloat values[9] = { t.mat00, t.mat01, t.mat02, t.mat10, t.mat11, t.mat12, diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_IconHelpers_mac.cpp b/JuceLibraryCode/modules/juce_graphics/native/juce_IconHelpers_mac.cpp index 7a6015d7..760f4a56 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_IconHelpers_mac.cpp +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_IconHelpers_mac.cpp @@ -114,12 +114,12 @@ Image JUCE_API getIconFromApplication (const String& applicationPath, const int { if (auto appBundle = CFUniquePtr (CFBundleCreate (kCFAllocatorDefault, url.get()))) { - if (CFTypeRef infoValue = CFBundleGetValueForInfoDictionaryKey (appBundle.get(), CFSTR("CFBundleIconFile"))) + if (CFTypeRef infoValue = CFBundleGetValueForInfoDictionaryKey (appBundle.get(), CFSTR ("CFBundleIconFile"))) { if (CFGetTypeID (infoValue) == CFStringGetTypeID()) { CFStringRef iconFilename = reinterpret_cast (infoValue); - CFStringRef resourceURLSuffix = CFStringHasSuffix (iconFilename, CFSTR(".icns")) ? nullptr : CFSTR("icns"); + CFStringRef resourceURLSuffix = CFStringHasSuffix (iconFilename, CFSTR (".icns")) ? nullptr : CFSTR ("icns"); if (auto iconURL = CFUniquePtr (CFBundleCopyResourceURL (appBundle.get(), iconFilename, resourceURLSuffix, nullptr))) { diff --git a/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h b/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h index d9fd8c99..1f392643 100644 --- a/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/JuceLibraryCode/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -23,14 +23,11 @@ ============================================================================== */ -namespace juce +namespace juce::RenderingHelpers { JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4127) -namespace RenderingHelpers -{ - //============================================================================== /** Holds either a simple integer translation, or an affine transform. @@ -2736,8 +2733,6 @@ class StackBasedLowLevelGraphicsContext : public LowLevelGraphicsContext RenderingHelpers::SavedStateStack stack; }; -} - JUCE_END_IGNORE_WARNINGS_MSVC -} // namespace juce +} // namespace juce::RenderingHelpers diff --git a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp index bd342bdf..5242cf51 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/application/juce_Application.cpp @@ -63,8 +63,8 @@ void JUCEApplication::getCommandInfo (const CommandID commandID, ApplicationComm { if (commandID == StandardApplicationCommandIDs::quit) { - result.setInfo (TRANS("Quit"), - TRANS("Quits the application"), + result.setInfo (TRANS ("Quit"), + TRANS ("Quits the application"), "Application", 0); result.defaultKeypresses.add (KeyPress ('q', ModifierKeys::commandModifier, 0)); diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp index 0dd5ce9f..02818c51 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -26,10 +26,10 @@ namespace juce { -struct Button::CallbackHelper : public Timer, - public ApplicationCommandManagerListener, - public Value::Listener, - public KeyListener +struct Button::CallbackHelper final : public Timer, + public ApplicationCommandManagerListener, + public Value::Listener, + public KeyListener { CallbackHelper (Button& b) : button (b) {} @@ -122,7 +122,7 @@ void Button::updateAutomaticTooltip (const ApplicationCommandInfo& info) tt << " ["; if (key.length() == 1) - tt << TRANS("shortcut") << ": '" << key << "']"; + tt << TRANS ("shortcut") << ": '" << key << "']"; else tt << key << ']'; } @@ -421,8 +421,7 @@ void Button::sendClickMessage (const ModifierKeys& modifiers) if (checker.shouldBailOut()) return; - if (onClick != nullptr) - onClick(); + NullCheckedInvocation::invoke (onClick); } void Button::sendStateMessage() @@ -439,8 +438,7 @@ void Button::sendStateMessage() if (checker.shouldBailOut()) return; - if (onStateChange != nullptr) - onStateChange(); + NullCheckedInvocation::invoke (onStateChange); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index 15c773b1..3076ce68 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -30,7 +30,7 @@ ShapeButton::ShapeButton (const String& t, Colour n, Colour o, Colour d) : Button (t), normalColour (n), overColour (o), downColour (d), normalColourOn (n), overColourOn (o), downColourOn (d), - useOnColours(false), + useOnColours (false), maintainShapeProportions (false), outlineWidth (0.0f) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index db6f1bbb..f45e32bf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -88,7 +88,7 @@ void ApplicationCommandManager::registerAllCommandsForTarget (ApplicationCommand for (int i = 0; i < commandIDs.size(); ++i) { - ApplicationCommandInfo info (commandIDs.getUnchecked(i)); + ApplicationCommandInfo info (commandIDs.getUnchecked (i)); target->getCommandInfo (info.commandID, info); registerCommand (info); @@ -122,8 +122,8 @@ void ApplicationCommandManager::commandStatusChanged() ApplicationCommandInfo* ApplicationCommandManager::getMutableCommandForID (CommandID commandID) const noexcept { for (int i = commands.size(); --i >= 0;) - if (commands.getUnchecked(i)->commandID == commandID) - return commands.getUnchecked(i); + if (commands.getUnchecked (i)->commandID == commandID) + return commands.getUnchecked (i); return nullptr; } @@ -155,7 +155,7 @@ StringArray ApplicationCommandManager::getCommandCategories() const StringArray s; for (int i = 0; i < commands.size(); ++i) - s.addIfNotAlreadyThere (commands.getUnchecked(i)->categoryName, false); + s.addIfNotAlreadyThere (commands.getUnchecked (i)->categoryName, false); return s; } @@ -165,8 +165,8 @@ Array ApplicationCommandManager::getCommandsInCategory (const String& Array results; for (int i = 0; i < commands.size(); ++i) - if (commands.getUnchecked(i)->categoryName == categoryName) - results.add (commands.getUnchecked(i)->commandID); + if (commands.getUnchecked (i)->categoryName == categoryName) + results.add (commands.getUnchecked (i)->commandID); return results; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 985951b6..041805c4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h @@ -252,7 +252,7 @@ class JUCE_API ApplicationCommandManager : private AsyncUpdater, If this is set to nullptr, then getFirstCommandTarget() will by default return the result of findDefaultComponentTarget(). - If you use this to set a target, make sure you call setFirstCommandTarget(nullptr) + If you use this to set a target, make sure you call setFirstCommandTarget (nullptr) before deleting the target object. */ void setFirstCommandTarget (ApplicationCommandTarget* newTarget) noexcept; diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp index ce51d068..fe5af8b1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp @@ -26,7 +26,7 @@ namespace juce { -class ApplicationCommandTarget::CommandMessage : public MessageManager::MessageBase +class ApplicationCommandTarget::CommandMessage final : public MessageManager::MessageBase { public: CommandMessage (ApplicationCommandTarget* const target, const InvocationInfo& inf) diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h index 0c6c2045..e174d63e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h @@ -60,7 +60,7 @@ class JUCE_API ApplicationCommandTarget struct JUCE_API InvocationInfo { //============================================================================== - InvocationInfo (const CommandID commandID); + InvocationInfo (CommandID commandID); //============================================================================== /** The UID of the command that should be performed. */ @@ -195,15 +195,15 @@ class JUCE_API ApplicationCommandTarget @see perform, ApplicationCommandManager::invoke */ bool invoke (const InvocationInfo& invocationInfo, - const bool asynchronously); + bool asynchronously); /** Invokes a given command directly on this target. This is just an easy way to call invoke() without having to fill out the InvocationInfo structure. */ - bool invokeDirectly (const CommandID commandID, - const bool asynchronously); + bool invokeDirectly (CommandID commandID, + bool asynchronously); //============================================================================== /** Searches this target and all subsequent ones for the first one that can handle @@ -212,14 +212,14 @@ class JUCE_API ApplicationCommandTarget This will use getNextCommandTarget() to determine the chain of targets to try after this one. */ - ApplicationCommandTarget* getTargetForCommand (const CommandID commandID); + ApplicationCommandTarget* getTargetForCommand (CommandID commandID); /** Checks whether this command can currently be performed by this target. This will return true only if a call to getCommandInfo() doesn't set the isDisabled flag to indicate that the command is inactive. */ - bool isCommandActive (const CommandID commandID); + bool isCommandActive (CommandID commandID); /** If this object is a Component, this method will search upwards in its current UI hierarchy for the next parent component that implements the diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp index 84e8a56a..2c321004 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp @@ -47,7 +47,7 @@ KeyPressMappingSet::~KeyPressMappingSet() Array KeyPressMappingSet::getKeyPressesAssignedToCommand (const CommandID commandID) const { for (int i = 0; i < mappings.size(); ++i) - if (mappings.getUnchecked(i)->commandID == commandID) + if (mappings.getUnchecked (i)->commandID == commandID) return mappings.getUnchecked (i)->keypresses; return {}; @@ -66,9 +66,9 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, const KeyPress& { for (int i = mappings.size(); --i >= 0;) { - if (mappings.getUnchecked(i)->commandID == commandID) + if (mappings.getUnchecked (i)->commandID == commandID) { - mappings.getUnchecked(i)->keypresses.insert (insertIndex, newKeyPress); + mappings.getUnchecked (i)->keypresses.insert (insertIndex, newKeyPress); sendChangeMessage(); return; @@ -132,7 +132,7 @@ void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID) { for (int i = mappings.size(); --i >= 0;) { - if (mappings.getUnchecked(i)->commandID == commandID) + if (mappings.getUnchecked (i)->commandID == commandID) { mappings.remove (i); sendChangeMessage(); @@ -146,7 +146,7 @@ void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress) { for (int i = mappings.size(); --i >= 0;) { - CommandMapping& cm = *mappings.getUnchecked(i); + CommandMapping& cm = *mappings.getUnchecked (i); for (int j = cm.keypresses.size(); --j >= 0;) { @@ -164,9 +164,9 @@ void KeyPressMappingSet::removeKeyPress (const CommandID commandID, const int ke { for (int i = mappings.size(); --i >= 0;) { - if (mappings.getUnchecked(i)->commandID == commandID) + if (mappings.getUnchecked (i)->commandID == commandID) { - mappings.getUnchecked(i)->keypresses.remove (keyPressIndex); + mappings.getUnchecked (i)->keypresses.remove (keyPressIndex); sendChangeMessage(); break; } @@ -177,8 +177,8 @@ void KeyPressMappingSet::removeKeyPress (const CommandID commandID, const int ke CommandID KeyPressMappingSet::findCommandForKeyPress (const KeyPress& keyPress) const noexcept { for (int i = 0; i < mappings.size(); ++i) - if (mappings.getUnchecked(i)->keypresses.contains (keyPress)) - return mappings.getUnchecked(i)->commandID; + if (mappings.getUnchecked (i)->keypresses.contains (keyPress)) + return mappings.getUnchecked (i)->commandID; return 0; } @@ -186,8 +186,8 @@ CommandID KeyPressMappingSet::findCommandForKeyPress (const KeyPress& keyPress) bool KeyPressMappingSet::containsMapping (const CommandID commandID, const KeyPress& keyPress) const noexcept { for (int i = mappings.size(); --i >= 0;) - if (mappings.getUnchecked(i)->commandID == commandID) - return mappings.getUnchecked(i)->keypresses.contains (keyPress); + if (mappings.getUnchecked (i)->commandID == commandID) + return mappings.getUnchecked (i)->keypresses.contains (keyPress); return false; } @@ -270,7 +270,7 @@ std::unique_ptr KeyPressMappingSet::createXml (const bool saveDiffer for (int i = 0; i < mappings.size(); ++i) { - auto& cm = *mappings.getUnchecked(i); + auto& cm = *mappings.getUnchecked (i); for (int j = 0; j < cm.keypresses.size(); ++j) { @@ -290,7 +290,7 @@ std::unique_ptr KeyPressMappingSet::createXml (const bool saveDiffer { for (int i = 0; i < defaultSet->mappings.size(); ++i) { - auto& cm = *defaultSet->mappings.getUnchecked(i); + auto& cm = *defaultSet->mappings.getUnchecked (i); for (int j = 0; j < cm.keypresses.size(); ++j) { @@ -316,7 +316,7 @@ bool KeyPressMappingSet::keyPressed (const KeyPress& key, Component* const origi for (int i = 0; i < mappings.size(); ++i) { - CommandMapping& cm = *mappings.getUnchecked(i); + CommandMapping& cm = *mappings.getUnchecked (i); if (cm.keypresses.contains (key)) { @@ -354,7 +354,7 @@ bool KeyPressMappingSet::keyStateChanged (const bool /*isKeyDown*/, Component* o for (int i = mappings.size(); --i >= 0;) { - CommandMapping& cm = *mappings.getUnchecked(i); + CommandMapping& cm = *mappings.getUnchecked (i); if (cm.wantsKeyUpDownCallbacks) { @@ -368,7 +368,7 @@ bool KeyPressMappingSet::keyStateChanged (const bool /*isKeyDown*/, Component* o for (int k = keysDown.size(); --k >= 0;) { - if (key == keysDown.getUnchecked(k)->key) + if (key == keysDown.getUnchecked (k)->key) { keyPressEntryIndex = k; wasDown = true; diff --git a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index c5f62b03..718f4312 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/JuceLibraryCode/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h @@ -234,8 +234,8 @@ class JUCE_API KeyPressMappingSet : public KeyListener, OwnedArray keysDown; - void invokeCommand (const CommandID, const KeyPress&, const bool isKeyDown, - const int millisecsSinceKeyPressed, Component* originator) const; + void invokeCommand (CommandID, const KeyPress&, bool isKeyDown, + int millisecsSinceKeyPressed, Component* originator) const; KeyPressMappingSet& operator= (const KeyPressMappingSet&); JUCE_LEAK_DETECTOR (KeyPressMappingSet) diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp index 9f720c79..865d6408 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.cpp @@ -496,7 +496,7 @@ bool Component::isOpaque() const noexcept } //============================================================================== -struct StandardCachedComponentImage : public CachedComponentImage +struct StandardCachedComponentImage final : public CachedComponentImage { StandardCachedComponentImage (Component& c) noexcept : owner (c) {} @@ -884,7 +884,7 @@ void Component::sendMovedResizedMessages (bool wasMoved, bool wasResized) for (int i = childComponentList.size(); --i >= 0;) { - childComponentList.getUnchecked(i)->parentSizeChanged(); + childComponentList.getUnchecked (i)->parentSizeChanged(); if (checker.shouldBailOut()) return; @@ -1910,7 +1910,7 @@ void Component::copyAllExplicitColoursTo (Component& target) const for (int i = properties.size(); --i >= 0;) { - auto name = properties.getName(i); + auto name = properties.getName (i); if (name.toString().startsWith (detail::colourPropertyPrefix)) if (target.properties.set (name, properties [name])) diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h index e5ca03d9..d2fcb8ec 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_Component.h @@ -2626,7 +2626,7 @@ class JUCE_API Component : public MouseListener void internalMouseEnter (MouseInputSource, Point, Time); void internalMouseExit (MouseInputSource, Point, Time); void internalMouseDown (MouseInputSource, const detail::PointerState&, Time); - void internalMouseUp (MouseInputSource, const detail::PointerState&, Time, const ModifierKeys oldModifiers); + void internalMouseUp (MouseInputSource, const detail::PointerState&, Time, ModifierKeys oldModifiers); void internalMouseDrag (MouseInputSource, const detail::PointerState&, Time); void internalMouseMove (MouseInputSource, Point, Time); void internalMouseWheel (MouseInputSource, Point, Time, const MouseWheelDetails&); diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_FocusTraverser.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_FocusTraverser.cpp index 34e50936..19fe0620 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_FocusTraverser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_FocusTraverser.cpp @@ -77,7 +77,7 @@ std::vector FocusTraverser::getAllComponents (Component* parentCompo //============================================================================== #if JUCE_UNIT_TESTS -struct FocusTraverserTests : public UnitTest +struct FocusTraverserTests final : public UnitTest { FocusTraverserTests() : UnitTest ("FocusTraverser", UnitTestCategories::gui) @@ -207,7 +207,7 @@ struct FocusTraverserTests : public UnitTest } private: - struct TestComponent : public Component + struct TestComponent final : public Component { TestComponent() { diff --git a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index c0855686..e8ecfec5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -26,7 +26,7 @@ namespace juce { -struct ModalComponentManager::ModalItem : public ComponentMovementWatcher +struct ModalComponentManager::ModalItem final : public ComponentMovementWatcher { ModalItem (Component* comp, bool shouldAutoDelete) : ComponentMovementWatcher (comp), diff --git a/JuceLibraryCode/modules/juce_gui_basics/desktop/juce_Desktop.cpp b/JuceLibraryCode/modules/juce_gui_basics/desktop/juce_Desktop.cpp index 9c4e7517..697f536e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/desktop/juce_Desktop.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/desktop/juce_Desktop.cpp @@ -74,7 +74,7 @@ Component* Desktop::findComponentAt (Point screenPosition) const for (int i = desktopComponents.size(); --i >= 0;) { - auto* c = desktopComponents.getUnchecked(i); + auto* c = desktopComponents.getUnchecked (i); if (c->isVisible()) { @@ -181,7 +181,7 @@ int Desktop::getNumMouseSources() const noexcept int Desktop::getNumDraggingMouseSources() const noexcept { return mouseSources->getNumDraggingMouseSources(); } MouseInputSource* Desktop::getMouseSource (int index) const noexcept { return mouseSources->getMouseSource (index); } MouseInputSource* Desktop::getDraggingMouseSource (int index) const noexcept { return mouseSources->getDraggingMouseSource (index); } -MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked(0)); } +MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked (0)); } void Desktop::beginDragAutoRepeat (int interval) { mouseSources->beginDragAutoRepeat (interval); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ComponentHelpers.h b/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ComponentHelpers.h index 41ea70a5..67d6d60a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ComponentHelpers.h +++ b/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ComponentHelpers.h @@ -189,7 +189,7 @@ struct ComponentHelpers for (int i = comp.childComponentList.size(); --i >= 0;) { - auto& child = *comp.childComponentList.getUnchecked(i); + auto& child = *comp.childComponentList.getUnchecked (i); if (child.isVisible() && ! child.isTransformed()) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ScopedContentSharerInterface.h b/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ScopedContentSharerInterface.h index f77ad896..7b3c4fc2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ScopedContentSharerInterface.h +++ b/JuceLibraryCode/modules/juce_gui_basics/detail/juce_ScopedContentSharerInterface.h @@ -150,8 +150,12 @@ std::unique_ptr ScopedContentSharerInterface::shar result.add (URL (tempFile)); } - for (const auto& url : result) - jassertquiet (url.isLocalFile() && url.getLocalFile().existsAsFile()); + jassert (std::all_of (result.begin(), + result.end(), + [] (const auto& url) + { + return url.isLocalFile() && url.getLocalFile().existsAsFile(); + })); return { std::move (result), String{} }; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp index 0c5a3cc4..29912213 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.cpp @@ -137,10 +137,10 @@ void Drawable::setBoundsToEnclose (Rectangle area) if (auto* parent = getParent()) parentOrigin = parent->originRelativeToComponent; - auto newBounds = area.getSmallestIntegerContainer() + parentOrigin; - originRelativeToComponent = parentOrigin - newBounds.getPosition(); + const auto smallestIntegerContainer = area.getSmallestIntegerContainer(); + auto newBounds = smallestIntegerContainer + parentOrigin; + originRelativeToComponent = -smallestIntegerContainer.getPosition(); setBounds (newBounds); - updateTransform(); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h index 6d3ca081..f288a9f2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_Drawable.h @@ -26,6 +26,33 @@ namespace juce { +#ifndef DOXYGEN +namespace detail +{ +class BoundsChangeListener final : private ComponentListener +{ +public: + BoundsChangeListener (Component& c, std::function cb) + : callback (std::move (cb)), + componentListenerGuard { [comp = &c, this] { comp->removeComponentListener (this); } } + { + jassert (callback != nullptr); + + c.addComponentListener (this); + } + +private: + void componentMovedOrResized (Component&, bool, bool) override + { + callback(); + } + + std::function callback; + ErasedScopeGuard componentListenerGuard; +}; +} // namespace detail +#endif + //============================================================================== /** The base class for objects which can draw themselves, e.g. polygons, images, etc. @@ -220,11 +247,16 @@ class JUCE_API Drawable : public Component AffineTransform drawableTransform; void nonConstDraw (Graphics&, float opacity, const AffineTransform&); - void updateTransform(); Drawable (const Drawable&); Drawable& operator= (const Drawable&); JUCE_LEAK_DETECTOR (Drawable) + + +private: + void updateTransform(); + + detail::BoundsChangeListener boundsChangeListener { *this, [this] { updateTransform(); } }; }; } // namespace juce diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp index 9bf865ae..2fc5117a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_DrawableText.cpp @@ -194,7 +194,7 @@ Path DrawableText::getOutlineAsPath() const pathOfAllGlyphs.addPath (gylphPath); } - pathOfAllGlyphs.applyTransform (getTextTransform (w, h).followedBy (getTransform())); + pathOfAllGlyphs.applyTransform (getTextTransform (w, h).followedBy (drawableTransform)); return pathOfAllGlyphs; } @@ -211,7 +211,7 @@ bool DrawableText::replaceColour (Colour originalColour, Colour replacementColou //============================================================================== std::unique_ptr DrawableText::createAccessibilityHandler() { - class DrawableTextAccessibilityHandler : public AccessibilityHandler + class DrawableTextAccessibilityHandler final : public AccessibilityHandler { public: DrawableTextAccessibilityHandler (DrawableText& drawableTextToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 756e2329..2a3e5e51 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -1067,12 +1067,10 @@ class SVGState if (! xml->hasTagName ("text") && ! xml->hasTagNameIgnoringNamespace ("tspan")) return nullptr; - Array xCoords, yCoords, dxCoords, dyCoords; + Array xCoords, yCoords; getCoordList (xCoords, getInheritedAttribute (xml, "x"), true, true); getCoordList (yCoords, getInheritedAttribute (xml, "y"), true, false); - getCoordList (dxCoords, getInheritedAttribute (xml, "dx"), true, true); - getCoordList (dyCoords, getInheritedAttribute (xml, "dy"), true, false); auto font = getFont (xml); auto anchorStr = getStyleAttribute (xml, "text-anchor"); @@ -1084,29 +1082,55 @@ class SVGState { if (e->isTextElement()) { - auto text = e->getText().trim(); + auto fullText = e->getText(); - auto dt = new DrawableText(); - dc->addAndMakeVisible (dt); + const auto subtextElements = [&] + { + std::vector> result; - dt->setText (text); - dt->setFont (font, true); + if (xCoords.size() == 1) + { + result.emplace_back (fullText, xCoords[0], yCoords[0]); + return result; + } - if (additonalTransform != nullptr) - dt->setDrawableTransform (transform.followedBy (*additonalTransform)); - else - dt->setDrawableTransform (transform); + if (xCoords.size() != yCoords.size() || fullText.length() != yCoords.size()) + { + jassertfalse; + result.emplace_back (fullText, xCoords[0], yCoords[0]); + return result; + } + + for (int i = 0; i < xCoords.size(); ++i) + result.emplace_back (fullText.substring (i, i + 1), xCoords[i], yCoords[i]); - dt->setColour (parseColour (xml, "fill", Colours::black) - .withMultipliedAlpha (parseSafeFloat (getStyleAttribute (xml, "fill-opacity", "1")))); + return result; + }(); - Rectangle bounds (xCoords[0], yCoords[0] - font.getAscent(), - font.getStringWidthFloat (text), font.getHeight()); + for (const auto& [text, x, y] : subtextElements) + { + auto dt = new DrawableText(); + dc->addAndMakeVisible (dt); + + dt->setText (text); + dt->setFont (font, true); + + if (additonalTransform != nullptr) + dt->setDrawableTransform (transform.followedBy (*additonalTransform)); + else + dt->setDrawableTransform (transform); - if (anchorStr == "middle") bounds.setX (bounds.getX() - bounds.getWidth() / 2.0f); - else if (anchorStr == "end") bounds.setX (bounds.getX() - bounds.getWidth()); + dt->setColour (parseColour (xml, "fill", Colours::black) + .withMultipliedAlpha (parseSafeFloat (getStyleAttribute (xml, "fill-opacity", "1")))); - dt->setBoundingBox (bounds); + Rectangle bounds (x, y - font.getAscent(), + font.getStringWidthFloat (text), font.getHeight()); + + if (anchorStr == "middle") bounds.setX (bounds.getX() - bounds.getWidth() / 2.0f); + else if (anchorStr == "end") bounds.setX (bounds.getX() - bounds.getWidth()); + + dt->setBoundingBox (bounds); + } } else if (e->hasTagNameIgnoringNamespace ("tspan")) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 75a9f1dd..e45c075c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -158,7 +158,7 @@ bool DirectoryContentsList::contains (const File& targetFile) const const ScopedLock sl (fileListLock); for (int i = files.size(); --i >= 0;) - if (root.getChildFile (files.getUnchecked(i)->filename) == targetFile) + if (root.getChildFile (files.getUnchecked (i)->filename) == targetFile) return true; return false; @@ -246,7 +246,7 @@ bool DirectoryContentsList::addFile (const File& file, const bool isDir, info->isReadOnly = isReadOnly; for (int i = files.size(); --i >= 0;) - if (files.getUnchecked(i)->filename == info->filename) + if (files.getUnchecked (i)->filename == info->filename) return false; files.add (std::move (info)); diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index d55d3db3..bde1ade8 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -323,9 +323,9 @@ void FileBrowserComponent::setFileFilter (const FileFilter* const newFileFilter) String FileBrowserComponent::getActionVerb() const { - return isSaveMode() ? ((flags & canSelectDirectories) != 0 ? TRANS("Choose") - : TRANS("Save")) - : TRANS("Open"); + return isSaveMode() ? ((flags & canSelectDirectories) != 0 ? TRANS ("Choose") + : TRANS ("Save")) + : TRANS ("Open"); } void FileBrowserComponent::setFilenameBoxLabel (const String& name) @@ -529,7 +529,7 @@ void FileBrowserComponent::getDefaultRoots (StringArray& rootNames, StringArray& for (int i = 0; i < roots.size(); ++i) { - const File& drive = roots.getReference(i); + const File& drive = roots.getReference (i); String name (drive.getFullPathName()); rootPaths.add (name); @@ -539,13 +539,13 @@ void FileBrowserComponent::getDefaultRoots (StringArray& rootNames, StringArray& String volume (drive.getVolumeLabel()); if (volume.isEmpty()) - volume = TRANS("Hard Drive"); + volume = TRANS ("Hard Drive"); name << " [" << volume << ']'; } else if (drive.isOnCDRomDrive()) { - name << " [" << TRANS("CD/DVD drive") << ']'; + name << " [" << TRANS ("CD/DVD drive") << ']'; } rootNames.add (name); @@ -555,25 +555,25 @@ void FileBrowserComponent::getDefaultRoots (StringArray& rootNames, StringArray& rootNames.add ({}); rootPaths.add (File::getSpecialLocation (File::userDocumentsDirectory).getFullPathName()); - rootNames.add (TRANS("Documents")); + rootNames.add (TRANS ("Documents")); rootPaths.add (File::getSpecialLocation (File::userMusicDirectory).getFullPathName()); - rootNames.add (TRANS("Music")); + rootNames.add (TRANS ("Music")); rootPaths.add (File::getSpecialLocation (File::userPicturesDirectory).getFullPathName()); - rootNames.add (TRANS("Pictures")); + rootNames.add (TRANS ("Pictures")); rootPaths.add (File::getSpecialLocation (File::userDesktopDirectory).getFullPathName()); - rootNames.add (TRANS("Desktop")); + rootNames.add (TRANS ("Desktop")); #elif JUCE_MAC rootPaths.add (File::getSpecialLocation (File::userHomeDirectory).getFullPathName()); - rootNames.add (TRANS("Home folder")); + rootNames.add (TRANS ("Home folder")); rootPaths.add (File::getSpecialLocation (File::userDocumentsDirectory).getFullPathName()); - rootNames.add (TRANS("Documents")); + rootNames.add (TRANS ("Documents")); rootPaths.add (File::getSpecialLocation (File::userMusicDirectory).getFullPathName()); - rootNames.add (TRANS("Music")); + rootNames.add (TRANS ("Music")); rootPaths.add (File::getSpecialLocation (File::userPicturesDirectory).getFullPathName()); - rootNames.add (TRANS("Pictures")); + rootNames.add (TRANS ("Pictures")); rootPaths.add (File::getSpecialLocation (File::userDesktopDirectory).getFullPathName()); - rootNames.add (TRANS("Desktop")); + rootNames.add (TRANS ("Desktop")); rootPaths.add ({}); rootNames.add ({}); @@ -591,9 +591,9 @@ void FileBrowserComponent::getDefaultRoots (StringArray& rootNames, StringArray& rootPaths.add ("/"); rootNames.add ("/"); rootPaths.add (File::getSpecialLocation (File::userHomeDirectory).getFullPathName()); - rootNames.add (TRANS("Home folder")); + rootNames.add (TRANS ("Home folder")); rootPaths.add (File::getSpecialLocation (File::userDesktopDirectory).getFullPathName()); - rootNames.add (TRANS("Desktop")); + rootNames.add (TRANS ("Desktop")); #endif } diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 00b111f0..c0177077 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -27,8 +27,8 @@ namespace juce { //============================================================================== -class FileChooser::NonNative : public std::enable_shared_from_this, - public FileChooser::Pimpl +class FileChooser::NonNative final : public std::enable_shared_from_this, + public FileChooser::Pimpl { public: NonNative (FileChooser& fileChooser, int flags, FilePreviewComponent* preview) diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 8ec77d0b..e0db0c3a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -26,7 +26,7 @@ namespace juce { -class FileChooserDialogBox::ContentComponent : public Component +class FileChooserDialogBox::ContentComponent final : public Component { public: ContentComponent (const String& name, const String& desc, FileBrowserComponent& chooser) @@ -186,12 +186,12 @@ void FileChooserDialogBox::okButtonPressed() { if (warnAboutOverwritingExistingFiles && content->chooserComponent.isSaveMode() - && content->chooserComponent.getSelectedFile(0).exists()) + && content->chooserComponent.getSelectedFile (0).exists()) { auto options = MessageBoxOptions::makeOptionsOkCancel (MessageBoxIconType::WarningIcon, TRANS ("File already exists"), TRANS ("There's already a file called: FLNM") - .replace ("FLNM", content->chooserComponent.getSelectedFile(0).getFullPathName()) + .replace ("FLNM", content->chooserComponent.getSelectedFile (0).getFullPathName()) + "\n\n" + TRANS ("Are you sure you want to overwrite it?"), TRANS ("Overwrite"), @@ -225,13 +225,13 @@ void FileChooserDialogBox::createNewFolder() if (parent.isDirectory()) { - auto* aw = new AlertWindow (TRANS("New Folder"), - TRANS("Please enter the name for the folder"), + auto* aw = new AlertWindow (TRANS ("New Folder"), + TRANS ("Please enter the name for the folder"), MessageBoxIconType::NoIcon, this); aw->addTextEditor ("Folder Name", String(), String(), false); - aw->addButton (TRANS("Create Folder"), 1, KeyPress (KeyPress::returnKey)); - aw->addButton (TRANS("Cancel"), 0, KeyPress (KeyPress::escapeKey)); + aw->addButton (TRANS ("Create Folder"), 1, KeyPress (KeyPress::returnKey)); + aw->addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey)); aw->enterModalState (true, ModalCallbackFunction::forComponent (createNewFolderCallback, this, diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index 853ef484..b56fd5aa 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -99,10 +99,10 @@ void FileListComponent::changeListenerCallback (ChangeBroadcaster*) } //============================================================================== -class FileListComponent::ItemComponent : public Component, - public TooltipClient, - private TimeSliceClient, - private AsyncUpdater +class FileListComponent::ItemComponent final : public Component, + public TooltipClient, + private TimeSliceClient, + private AsyncUpdater { public: ItemComponent (FileListComponent& fc, TimeSliceThread& t) diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp index 1799e738..4ad90f17 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp @@ -145,7 +145,7 @@ void FileSearchPathListComponent::deleteKeyPressed (int row) void FileSearchPathListComponent::returnKeyPressed (int row) { - chooser = std::make_unique (TRANS("Change folder..."), path.getRawString (row), "*"); + chooser = std::make_unique (TRANS ("Change folder..."), path.getRawString (row), "*"); auto chooserFlags = FileBrowserComponent::openMode | FileBrowserComponent::canSelectDirectories; chooser->launchAsync (chooserFlags, [this, row] (const FileChooser& fc) @@ -222,7 +222,7 @@ void FileSearchPathListComponent::addPath() if (start == File()) start = File::getCurrentWorkingDirectory(); - chooser = std::make_unique (TRANS("Add a folder..."), start, "*"); + chooser = std::make_unique (TRANS ("Add a folder..."), start, "*"); auto chooserFlags = FileBrowserComponent::openMode | FileBrowserComponent::canSelectDirectories; chooser->launchAsync (chooserFlags, [this] (const FileChooser& fc) diff --git a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 3ebc44c6..0d620681 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -77,9 +77,9 @@ constexpr int threeWayCompare (const std::tuple& a, const std::tuple #import #import @@ -139,6 +138,7 @@ #if JUCE_MAC || JUCE_IOS #include "native/accessibility/juce_AccessibilitySharedCode_mac.mm" + #include "native/juce_CGMetalLayerRenderer_mac.h" #if JUCE_IOS #include "native/juce_UIViewComponentPeer_ios.mm" @@ -167,6 +167,9 @@ #include "native/juce_MouseCursor_mac.mm" #elif JUCE_WINDOWS + #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client + #include + #endif #include "native/accessibility/juce_ComInterfaces_windows.h" #include "native/accessibility/juce_WindowsUIAWrapper_windows.h" #include "native/accessibility/juce_AccessibilityElement_windows.h" diff --git a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h index 161c03cd..f0759a82 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h +++ b/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h @@ -35,7 +35,7 @@ ID: juce_gui_basics vendor: juce - version: 7.0.7 + version: 7.0.8 name: JUCE GUI core classes description: Basic user-interface components and related classes. website: http://www.juce.com/juce diff --git a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index f0d5e681..092a374a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp @@ -94,7 +94,7 @@ std::vector KeyboardFocusTraverser::getAllComponents (Component* par //============================================================================== #if JUCE_UNIT_TESTS -struct KeyboardFocusTraverserTests : public UnitTest +struct KeyboardFocusTraverserTests final : public UnitTest { KeyboardFocusTraverserTests() : UnitTest ("KeyboardFocusTraverser", UnitTestCategories::gui) @@ -253,7 +253,7 @@ struct KeyboardFocusTraverserTests : public UnitTest } private: - struct TestComponent : public Component + struct TestComponent final : public Component { TestComponent() { diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index 5786d780..97d1dee9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h @@ -23,15 +23,13 @@ ============================================================================== */ -namespace juce -{ - //============================================================================== /** Contains classes for different types of physics behaviours - these classes are used as template parameters for the AnimatedPosition class. */ -namespace AnimatedPositionBehaviours +namespace juce::AnimatedPositionBehaviours { + /** A non-snapping behaviour that allows the content to be freely flicked in either direction, with momentum based on the velocity at which it was released, and variable friction to make it come to a halt. @@ -151,6 +149,5 @@ namespace AnimatedPositionBehaviours private: double targetSnapPosition = 0.0; }; -} -} // namespace juce +} // namespace juce::AnimatedPositionBehaviours diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 42732fbd..c7d87742 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -146,7 +146,7 @@ class ComponentAnimator::AnimationTask } //============================================================================== - struct ProxyComponent : public Component + struct ProxyComponent final : public Component { ProxyComponent (Component& c) { @@ -221,8 +221,8 @@ ComponentAnimator::~ComponentAnimator() {} ComponentAnimator::AnimationTask* ComponentAnimator::findTaskFor (Component* const component) const noexcept { for (int i = tasks.size(); --i >= 0;) - if (component == tasks.getUnchecked(i)->component.get()) - return tasks.getUnchecked(i); + if (component == tasks.getUnchecked (i)->component.get()) + return tasks.getUnchecked (i); return nullptr; } @@ -287,7 +287,7 @@ void ComponentAnimator::cancelAllAnimations (const bool moveComponentsToTheirFin { if (moveComponentsToTheirFinalPositions) for (int i = tasks.size(); --i >= 0;) - tasks.getUnchecked(i)->moveToFinalDestination(); + tasks.getUnchecked (i)->moveToFinalDestination(); tasks.clear(); sendChangeMessage(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index a3c002cb..e0341221 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -160,7 +160,7 @@ ComponentBuilder::TypeHandler* ComponentBuilder::getHandlerForState (const Value for (int i = 0; i < types.size(); ++i) { - TypeHandler* const t = types.getUnchecked(i); + TypeHandler* const t = types.getUnchecked (i); if (t->type == targetType) return t; @@ -279,7 +279,7 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree componentsInOrder.getLast()->toFront (false); for (int i = componentsInOrder.size() - 1; --i >= 0;) - componentsInOrder.getUnchecked(i)->toBehind (componentsInOrder.getUnchecked (i + 1)); + componentsInOrder.getUnchecked (i)->toBehind (componentsInOrder.getUnchecked (i + 1)); } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index bb1fabc3..a0b3f853 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -95,7 +95,7 @@ struct ConcertinaPanel::PanelSizes if (totalSpace <= 0) { - newSizes.get(index).size = panelHeight; + newSizes.get (index).size = panelHeight; } else { @@ -103,7 +103,7 @@ struct ConcertinaPanel::PanelSizes auto minSize = getMinimumSize (0, num); totalSpace = jmax (totalSpace, minSize); - newSizes.get(index).setSize (panelHeight); + newSizes.get (index).setSize (panelHeight); newSizes.stretchRange (0, index, totalSpace - newSizes.getTotalSize (0, num), stretchLast); newSizes.stretchRange (index, num, totalSpace - newSizes.getTotalSize (0, num), stretchLast); newSizes = newSizes.fittedInto (totalSpace); @@ -139,12 +139,12 @@ struct ConcertinaPanel::PanelSizes Array expandableItems; for (int i = start; i < end; ++i) - if (get(i).canExpand() && ! get(i).isMinimised()) - expandableItems.add (& get(i)); + if (get (i).canExpand() && ! get (i).isMinimised()) + expandableItems.add (& get (i)); for (int attempts = 4; --attempts >= 0 && spaceDiff > 0;) for (int i = expandableItems.size(); --i >= 0 && spaceDiff > 0;) - spaceDiff -= expandableItems.getUnchecked(i)->expand (spaceDiff / (i + 1)); + spaceDiff -= expandableItems.getUnchecked (i)->expand (spaceDiff / (i + 1)); growRangeLast (start, end, spaceDiff); } @@ -152,13 +152,13 @@ struct ConcertinaPanel::PanelSizes void shrinkRangeFirst (int start, int end, int spaceDiff) noexcept { for (int i = start; i < end && spaceDiff > 0; ++i) - spaceDiff -= get(i).reduce (spaceDiff); + spaceDiff -= get (i).reduce (spaceDiff); } void shrinkRangeLast (int start, int end, int spaceDiff) noexcept { for (int i = end; --i >= start && spaceDiff > 0;) - spaceDiff -= get(i).reduce (spaceDiff); + spaceDiff -= get (i).reduce (spaceDiff); } void stretchRange (int start, int end, int amountToAdd, ExpandMode expandMode) noexcept @@ -212,7 +212,7 @@ struct ConcertinaPanel::PanelSizes }; //============================================================================== -class ConcertinaPanel::PanelHolder : public Component +class ConcertinaPanel::PanelHolder final : public Component { public: PanelHolder (Component* comp, bool takeOwnership) @@ -290,7 +290,7 @@ class ConcertinaPanel::PanelHolder : public Component { ConcertinaPanel& panel = getPanel(); auto ourIndex = panel.holders.indexOf (this); - return panel.currentSizes->get(ourIndex).minSize; + return panel.currentSizes->get (ourIndex).minSize; } ConcertinaPanel& getPanel() const @@ -354,10 +354,10 @@ bool ConcertinaPanel::setPanelSize (Component* panelComponent, int height, bool auto index = indexOfComp (panelComponent); jassert (index >= 0); // The specified component doesn't seem to have been added! - height += currentSizes->get(index).minSize; - auto oldSize = currentSizes->get(index).size; + height += currentSizes->get (index).minSize; + auto oldSize = currentSizes->get (index).size; setLayout (currentSizes->withResizedPanel (index, height, getHeight()), animate); - return oldSize != currentSizes->get(index).size; + return oldSize != currentSizes->get (index).size; } bool ConcertinaPanel::expandPanelFully (Component* component, bool animate) @@ -372,7 +372,7 @@ void ConcertinaPanel::setMaximumPanelSize (Component* component, int maximumSize if (index >= 0) { - currentSizes->get(index).maxSize = currentSizes->get(index).minSize + maximumSize; + currentSizes->get (index).maxSize = currentSizes->get (index).minSize + maximumSize; resized(); } } @@ -411,7 +411,7 @@ void ConcertinaPanel::resized() int ConcertinaPanel::indexOfComp (Component* comp) const noexcept { for (int i = 0; i < holders.size(); ++i) - if (holders.getUnchecked(i)->component == comp) + if (holders.getUnchecked (i)->component == comp) return i; return -1; diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_FlexBox.cpp index ed5443b6..409be26c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -842,7 +842,7 @@ FlexItem FlexItem::withAlignSelf (AlignSelf a) const noexcept { auto fi = //============================================================================== #if JUCE_UNIT_TESTS -class FlexBoxTests : public UnitTest +class FlexBoxTests final : public UnitTest { public: FlexBoxTests() : UnitTest ("FlexBox", UnitTestCategories::gui) {} diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.cpp index 8534fde6..df9cb62a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.cpp @@ -545,31 +545,31 @@ struct Grid::Helpers if (alignContent == AlignContent::spaceBetween) { - const auto shift = ((float) (rowNumber - 1) * (calculation.remainingHeight / float(numberOfRows - 1))); + const auto shift = ((float) (rowNumber - 1) * (calculation.remainingHeight / float (numberOfRows - 1))); area.setY (area.getY() + shift); } if (justifyContent == JustifyContent::spaceBetween) { - const auto shift = ((float) (columnNumber - 1) * (calculation.remainingWidth / float(numberOfColumns - 1))); + const auto shift = ((float) (columnNumber - 1) * (calculation.remainingWidth / float (numberOfColumns - 1))); area.setX (area.getX() + shift); } if (alignContent == AlignContent::spaceEvenly) { - const auto shift = ((float) rowNumber * (calculation.remainingHeight / float(numberOfRows + 1))); + const auto shift = ((float) rowNumber * (calculation.remainingHeight / float (numberOfRows + 1))); area.setY (area.getY() + shift); } if (justifyContent == JustifyContent::spaceEvenly) { - const auto shift = ((float) columnNumber * (calculation.remainingWidth / float(numberOfColumns + 1))); + const auto shift = ((float) columnNumber * (calculation.remainingWidth / float (numberOfColumns + 1))); area.setX (area.getX() + shift); } if (alignContent == AlignContent::spaceAround) { - const auto inbetweenShift = calculation.remainingHeight / float(numberOfRows); + const auto inbetweenShift = calculation.remainingHeight / float (numberOfRows); const auto sidesShift = inbetweenShift / 2; auto shift = (float) (rowNumber - 1) * inbetweenShift + sidesShift; @@ -578,7 +578,7 @@ struct Grid::Helpers if (justifyContent == JustifyContent::spaceAround) { - const auto inbetweenShift = calculation.remainingWidth / float(numberOfColumns); + const auto inbetweenShift = calculation.remainingWidth / float (numberOfColumns); const auto sidesShift = inbetweenShift / 2; auto shift = (float) (columnNumber - 1) * inbetweenShift + sidesShift; @@ -1158,7 +1158,7 @@ void Grid::performLayout (Rectangle targetArea) //============================================================================== #if JUCE_UNIT_TESTS -struct GridTests : public UnitTest +struct GridTests final : public UnitTest { GridTests() : UnitTest ("Grid", UnitTestCategories::gui) diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.h b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.h index 437f4657..75393d30 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.h +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Grid.h @@ -43,10 +43,10 @@ class JUCE_API Grid final /** A size in pixels */ struct Px final { - explicit Px (float p) : pixels (static_cast(p)) { /*sta (p >= 0.0f);*/ } - explicit Px (int p) : pixels (static_cast(p)) { /*sta (p >= 0.0f);*/ } + explicit Px (float p) : pixels (static_cast (p)) { /*sta (p >= 0.0f);*/ } + explicit Px (int p) : pixels (static_cast (p)) { /*sta (p >= 0.0f);*/ } explicit constexpr Px (long double p) : pixels (p) {} - explicit constexpr Px (unsigned long long p) : pixels (static_cast(p)) {} + explicit constexpr Px (unsigned long long p) : pixels (static_cast (p)) {} long double pixels; }; @@ -216,8 +216,8 @@ class JUCE_API Grid final struct Helpers; }; -constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; } -constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; } -constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; } +constexpr Grid::Px operator""_px (long double px) { return Grid::Px { px }; } +constexpr Grid::Px operator""_px (unsigned long long px) { return Grid::Px { px }; } +constexpr Grid::Fr operator""_fr (unsigned long long fr) { return Grid::Fr { fr }; } } // namespace juce diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index b711858c..4d907eca 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -128,9 +128,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointercomponents.isEmpty()) { - if (callback != nullptr) - callback (true); - + NullCheckedInvocation::invoke (callback, true); return; } @@ -143,9 +141,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointercloseDocumentInternal (component); - if (callback != nullptr) - callback (closedSuccessfully); + NullCheckedInvocation::invoke (callback, closedSuccessfully); }); return; @@ -469,8 +462,7 @@ void MultiDocumentPanel::closeDocumentAsync (Component* component, jassertfalse; } - if (callback != nullptr) - callback (true); + NullCheckedInvocation::invoke (callback, true); JUCE_END_IGNORE_WARNINGS_MSVC } diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 4d5052bd..d663552f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -26,7 +26,7 @@ namespace juce { -class ScrollBar::ScrollbarButton : public Button +class ScrollBar::ScrollbarButton final : public Button { public: ScrollbarButton (int direc, ScrollBar& s) @@ -443,7 +443,7 @@ bool ScrollBar::getVisibility() const noexcept //============================================================================== std::unique_ptr ScrollBar::createAccessibilityHandler() { - class ValueInterface : public AccessibilityRangedNumericValueInterface + class ValueInterface final : public AccessibilityRangedNumericValueInterface { public: explicit ValueInterface (ScrollBar& scrollBarToWrap) : scrollBar (scrollBarToWrap) {} diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_SidePanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_SidePanel.cpp index dfd36a45..7d05bfd3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_SidePanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_SidePanel.cpp @@ -113,8 +113,7 @@ void SidePanel::showOrHide (bool show) void SidePanel::moved() { - if (onPanelMove != nullptr) - onPanelMove(); + NullCheckedInvocation::invoke (onPanelMove); } void SidePanel::resized() @@ -253,8 +252,7 @@ void SidePanel::changeListenerCallback (ChangeBroadcaster*) { if (! Desktop::getInstance().getAnimator().isAnimating (this)) { - if (onPanelShowHide != nullptr) - onPanelShowHide (isShowing); + NullCheckedInvocation::invoke (onPanelShowHide, isShowing); if (isVisible() && ! isShowing) setVisible (false); diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp index 368e2cba..5baa0b6c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp @@ -118,7 +118,7 @@ void StretchableLayoutManager::setItemPosition (const int itemIndex, { for (int i = items.size(); --i >= 0;) { - auto* layout = items.getUnchecked(i); + auto* layout = items.getUnchecked (i); if (layout->itemIndex == itemIndex) { @@ -291,7 +291,7 @@ int StretchableLayoutManager::fitComponentsIntoSpace (const int startIndex, // ..and calculate the end position for (int i = startIndex; i < endIndex; ++i) { - auto* layout = items.getUnchecked(i); + auto* layout = items.getUnchecked (i); startPos += layout->currentSize; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp index 30c65f1e..d5d9962e 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp @@ -65,7 +65,7 @@ void StretchableObjectResizer::resizeToFit (const double targetSize) for (int i = 0; i < items.size(); ++i) { - const Item& it = items.getReference(i); + const Item& it = items.getReference (i); currentSize += it.size; if (it.order <= order) @@ -91,7 +91,7 @@ void StretchableObjectResizer::resizeToFit (const double targetSize) for (int i = 0; i < items.size(); ++i) { - Item& it = items.getReference(i); + Item& it = items.getReference (i); if (it.order <= order) it.size = jlimit (it.minSize, it.maxSize, it.size + (it.maxSize - it.size) * scale); @@ -105,7 +105,7 @@ void StretchableObjectResizer::resizeToFit (const double targetSize) for (int i = 0; i < items.size(); ++i) { - Item& it = items.getReference(i); + Item& it = items.getReference (i); if (it.order <= order) it.size = jmax (it.minSize, it.minSize + (it.size - it.minSize) * scale); diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index ee0485d0..23390268 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -171,7 +171,7 @@ void TabBarButton::resized() } //============================================================================== -class TabbedButtonBar::BehindFrontTabComp : public Component +class TabbedButtonBar::BehindFrontTabComp final : public Component { public: BehindFrontTabComp (TabbedButtonBar& tb) : owner (tb) @@ -343,7 +343,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, bool shouldSendChangeMes currentTabIndex = newIndex; for (int i = 0; i < tabs.size(); ++i) - tabs.getUnchecked(i)->button->setToggleState (i == newIndex, dontSendNotification); + tabs.getUnchecked (i)->button->setToggleState (i == newIndex, dontSendNotification); resized(); @@ -365,7 +365,7 @@ TabBarButton* TabbedButtonBar::getTabButton (const int index) const int TabbedButtonBar::indexOfTabButton (const TabBarButton* button) const { for (int i = tabs.size(); --i >= 0;) - if (tabs.getUnchecked(i)->button.get() == button) + if (tabs.getUnchecked (i)->button.get() == button) return i; return -1; @@ -416,7 +416,7 @@ void TabbedButtonBar::updateTabPositions (bool animate) for (int i = 0; i < tabs.size(); ++i) { - auto* tb = tabs.getUnchecked(i)->button.get(); + auto* tb = tabs.getUnchecked (i)->button.get(); totalLength += tb->getBestTabLength (depth) - overlap; tb->overlapPixels = jmax (0, overlap / 2); @@ -459,7 +459,7 @@ void TabbedButtonBar::updateTabPositions (bool animate) for (int i = 0; i < tabs.size(); ++i) { - auto* tb = tabs.getUnchecked(i)->button.get(); + auto* tb = tabs.getUnchecked (i)->button.get(); auto newLength = totalLength + tb->getBestTabLength (depth); if (i > 0 && newLength * minimumScale > tabsButtonPos) @@ -557,7 +557,7 @@ void TabbedButtonBar::showExtraItemsMenu() for (int i = 0; i < tabs.size(); ++i) { - auto* tab = tabs.getUnchecked(i); + auto* tab = tabs.getUnchecked (i); if (! tab->button->isVisible()) m.addItem (PopupMenu::Item (tab->name) diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index b19bc3d3..d4caa60f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -53,7 +53,7 @@ namespace TabbedComponentHelpers } //============================================================================== -struct TabbedComponent::ButtonBar : public TabbedButtonBar +struct TabbedComponent::ButtonBar final : public TabbedButtonBar { ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o) : TabbedButtonBar (o), owner (tabComp) diff --git a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp index 0abbc4f1..f18da221 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -28,8 +28,8 @@ namespace juce using ViewportDragPosition = AnimatedPosition; -struct Viewport::DragToScrollListener : private MouseListener, - private ViewportDragPosition::Listener +struct Viewport::DragToScrollListener final : private MouseListener, + private ViewportDragPosition::Listener { DragToScrollListener (Viewport& v) : viewport (v) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index af5af212..476856c4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -58,7 +58,7 @@ LookAndFeel::~LookAndFeel() - there's a WeakReference to it somewhere else in your code Generally the fix for this will be to make sure you call - Component::setLookandFeel (nullptr) on any components that were still using + Component::setLookAndFeel (nullptr) on any components that were still using it before you delete it, or call LookAndFeel::setDefaultLookAndFeel (nullptr) if you had set it up to be the default one. This assertion can also be avoided by declaring your LookAndFeel object before any of the Components that use it as diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h index 08de34e0..b312341f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h @@ -80,7 +80,7 @@ class JUCE_API LookAndFeel_V1 : public LookAndFeel_V2 //============================================================================== void drawLinearSlider (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; int getSliderThumbRadius (Slider&) override; Button* createSliderButton (Slider&, bool isIncrement) override; diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 9cf2b16b..c44236fb 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -1591,7 +1591,7 @@ Button* LookAndFeel_V2::createSliderButton (Slider&, const bool isIncrement) return new TextButton (isIncrement ? "+" : "-", String()); } -class LookAndFeel_V2::SliderLabelComp : public Label +class LookAndFeel_V2::SliderLabelComp final : public Label { public: SliderLabelComp() : Label ({}, {}) {} @@ -1745,7 +1745,7 @@ void LookAndFeel_V2::drawTooltip (Graphics& g, const String& text, int width, in //============================================================================== Button* LookAndFeel_V2::createFilenameComponentBrowseButton (const String& text) { - return new TextButton (text, TRANS("click to browse for a different file")); + return new TextButton (text, TRANS ("click to browse for a different file")); } void LookAndFeel_V2::layoutFilenameComponent (FilenameComponent& filenameComp, @@ -1912,7 +1912,7 @@ void LookAndFeel_V2::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic } //============================================================================== -class LookAndFeel_V2::GlassWindowButton : public Button +class LookAndFeel_V2::GlassWindowButton final : public Button { public: GlassWindowButton (const String& name, Colour col, @@ -2062,7 +2062,7 @@ std::unique_ptr LookAndFeel_V2::createDropShadowerForComponent (Co std::unique_ptr LookAndFeel_V2::createFocusOutlineForComponent (Component&) { - struct WindowProperties : public FocusOutline::OutlineWindowProperties + struct WindowProperties final : public FocusOutline::OutlineWindowProperties { Rectangle getOutlineBounds (Component& c) override { diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h index 68174244..feb6aea4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h @@ -243,19 +243,19 @@ class JUCE_API LookAndFeel_V2 : public LookAndFeel //============================================================================== void drawLinearSlider (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawLinearSliderOutline (Graphics&, int x, int y, int width, int height, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawLinearSliderThumb (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawRotarySlider (Graphics&, int x, int y, int width, int height, float sliderPosProportional, float rotaryStartAngle, float rotaryEndAngle, diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index 8ad233b0..75375f47 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp @@ -521,7 +521,7 @@ void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height, p.addRectangle (50.0f - thickness, 50.0f + thickness, thickness * 2.0f, 50.0f - indent - thickness); p.setUsingNonZeroWinding (false); - g.setColour (textColour.darker(0.1f).withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f))); + g.setColour (textColour.darker (0.1f).withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f))); g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, (float) width - 4.0f, (float) height - 4.0f, true)); } @@ -533,7 +533,7 @@ void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height, } -class LookAndFeel_V3_DocumentWindowButton : public Button +class LookAndFeel_V3_DocumentWindowButton final : public Button { public: LookAndFeel_V3_DocumentWindowButton (const String& name, Colour c, const Path& normal, const Path& toggled) diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h index 88e896c7..d346405b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h @@ -76,11 +76,11 @@ class JUCE_API LookAndFeel_V3 : public LookAndFeel_V2 void drawLinearSlider (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawConcertinaPanelHeader (Graphics&, const Rectangle& area, bool isMouseOver, bool isMouseDown, ConcertinaPanel&, Component&) override; diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index f6accad9..d005ca6a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -106,7 +106,7 @@ LookAndFeel_V4::ColourScheme LookAndFeel_V4::getLightColourScheme() } //============================================================================== -class LookAndFeel_V4_DocumentWindowButton : public Button +class LookAndFeel_V4_DocumentWindowButton final : public Button { public: LookAndFeel_V4_DocumentWindowButton (const String& name, Colour c, const Path& normal, const Path& toggled) diff --git a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h index cbf1c61d..d3c88c52 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h +++ b/JuceLibraryCode/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h @@ -201,7 +201,7 @@ class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3 void drawLinearSlider (Graphics&, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, - const Slider::SliderStyle, Slider&) override; + Slider::SliderStyle, Slider&) override; void drawRotarySlider (Graphics&, int x, int y, int width, int height, float sliderPosProportional, float rotaryStartAngle, diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp index dc9f961a..d83ee014 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_BurgerMenuComponent.cpp @@ -27,7 +27,7 @@ namespace juce { //============================================================================== -struct CustomMenuBarItemHolder : public Component +struct CustomMenuBarItemHolder final : public Component { CustomMenuBarItemHolder (const ReferenceCountedObjectPtr& customComponent) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp index 328b46f7..b462bbaa 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp @@ -26,7 +26,7 @@ namespace juce { -class MenuBarComponent::AccessibleItemComponent : public Component +class MenuBarComponent::AccessibleItemComponent final : public Component { public: AccessibleItemComponent (MenuBarComponent& comp, const String& menuItemName) @@ -41,7 +41,7 @@ class MenuBarComponent::AccessibleItemComponent : public Component private: std::unique_ptr createAccessibilityHandler() override { - class ComponentHandler : public AccessibilityHandler + class ComponentHandler final : public AccessibilityHandler { public: explicit ComponentHandler (AccessibleItemComponent& item) @@ -447,7 +447,7 @@ void MenuBarComponent::timerCallback() //============================================================================== std::unique_ptr MenuBarComponent::createAccessibilityHandler() { - struct MenuBarComponentAccessibilityHandler : public AccessibilityHandler + struct MenuBarComponentAccessibilityHandler final : public AccessibilityHandler { explicit MenuBarComponentAccessibilityHandler (MenuBarComponent& menuBarComponent) : AccessibilityHandler (menuBarComponent, AccessibilityRole::menuBar) diff --git a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 952608e7..c38ee126 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -57,7 +57,7 @@ static bool hasActiveSubMenu (const PopupMenu::Item& item) noexcept } //============================================================================== -struct HeaderItemComponent : public PopupMenu::CustomComponent +struct HeaderItemComponent final : public PopupMenu::CustomComponent { HeaderItemComponent (const String& name, const Options& opts) : CustomComponent (false), options (opts) @@ -96,7 +96,7 @@ struct HeaderItemComponent : public PopupMenu::CustomComponent }; //============================================================================== -struct ItemComponent : public Component +struct ItemComponent final : public Component { ItemComponent (const PopupMenu::Item& i, const PopupMenu::Options& o, MenuWindow& parent) : item (i), parentWindow (parent), options (o), customComp (i.customComponent) @@ -188,7 +188,7 @@ struct ItemComponent : public Component private: //============================================================================== - class ItemAccessibilityHandler : public AccessibilityHandler + class ItemAccessibilityHandler final : public AccessibilityHandler { public: explicit ItemAccessibilityHandler (ItemComponent& itemComponentToWrap) @@ -322,7 +322,7 @@ struct ItemComponent : public Component }; //============================================================================== -struct MenuWindow : public Component +struct MenuWindow final : public Component { MenuWindow (const PopupMenu& menu, MenuWindow* parentWindow, @@ -1331,7 +1331,7 @@ struct MenuWindow : public Component }; //============================================================================== -class MouseSourceState : public Timer +class MouseSourceState final : public Timer { public: MouseSourceState (MenuWindow& w, MouseInputSource s) @@ -1574,7 +1574,7 @@ class MouseSourceState : public Timer }; //============================================================================== -struct NormalComponentWrapper : public PopupMenu::CustomComponent +struct NormalComponentWrapper final : public PopupMenu::CustomComponent { NormalComponentWrapper (Component& comp, int w, int h, bool triggerMenuItemAutomaticallyWhenClicked) : PopupMenu::CustomComponent (triggerMenuItemAutomaticallyWhenClicked), @@ -2068,7 +2068,7 @@ Component* PopupMenu::createWindow (const Options& options, //============================================================================== // This invokes any command manager commands and deletes the menu window when it is dismissed -struct PopupMenuCompletionCallback : public ModalComponentManager::Callback +struct PopupMenuCompletionCallback final : public ModalComponentManager::Callback { PopupMenuCompletionCallback() = default; diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp index d431a033..8e3de83b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -26,7 +26,7 @@ namespace juce { -class DropShadower::ShadowWindow : public Component +class DropShadower::ShadowWindow final : public Component { public: ShadowWindow (Component* comp, const DropShadow& ds) @@ -170,7 +170,7 @@ class DropShadower::VirtualDesktopWatcher final : public ComponentListener, JUCE_DECLARE_WEAK_REFERENCEABLE (VirtualDesktopWatcher) }; -class DropShadower::ParentVisibilityChangedListener : public ComponentListener +class DropShadower::ParentVisibilityChangedListener final : public ComponentListener { public: ParentVisibilityChangedListener (Component& r, ComponentListener& l) diff --git a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_FocusOutline.cpp b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_FocusOutline.cpp index ad30f265..a410a766 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/misc/juce_FocusOutline.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/misc/juce_FocusOutline.cpp @@ -27,7 +27,7 @@ namespace juce { //============================================================================== -struct OutlineWindowComponent : public Component +struct OutlineWindowComponent final : public Component { OutlineWindowComponent (Component* c, FocusOutline::OutlineWindowProperties& p) : target (c), props (p) diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index e4911ac1..45fbe2ac 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -31,8 +31,8 @@ bool juce_performDragDropText (const String&, bool& shouldStop); //============================================================================== -class DragAndDropContainer::DragImageComponent : public Component, - private Timer +class DragAndDropContainer::DragImageComponent final : public Component, + private Timer { public: DragImageComponent (const ScaledImage& im, diff --git a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index f670992b..7de6aff7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/JuceLibraryCode/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -104,9 +104,9 @@ class SelectedItemSet : public ChangeBroadcaster { for (int i = selectedItems.size(); --i >= 0;) { - if (selectedItems.getUnchecked(i) != item) + if (selectedItems.getUnchecked (i) != item) { - deselect (selectedItems.getUnchecked(i)); + deselect (selectedItems.getUnchecked (i)); i = jmin (i, selectedItems.size()); } } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp index c6594f95..4b439f88 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp @@ -27,7 +27,11 @@ namespace juce { #if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED - class AccessibilityHandler::AccessibilityNativeImpl { public: AccessibilityNativeImpl (AccessibilityHandler&) {} }; + class AccessibilityHandler::AccessibilityNativeImpl + { + public: + AccessibilityNativeImpl (AccessibilityHandler&) {} + }; #endif } // namespace juce diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityElement_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityElement_windows.cpp index 404d5b15..fe4221c1 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityElement_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityElement_windows.cpp @@ -31,8 +31,8 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") int AccessibilityNativeHandle::idCounter = 0; //============================================================================== -class UIAScrollProvider : public UIAProviderBase, - public ComBaseClassHelper +class UIAScrollProvider final : public UIAProviderBase, + public ComBaseClassHelper { public: using UIAProviderBase::UIAProviderBase; @@ -50,8 +50,8 @@ class UIAScrollProvider : public UIAProviderBase, JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAScrollProvider) }; -class UIAScrollItemProvider : public UIAProviderBase, - public ComBaseClassHelper +class UIAScrollItemProvider final : public UIAProviderBase, + public ComBaseClassHelper { public: using UIAProviderBase::UIAProviderBase; diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilitySharedCode_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilitySharedCode_mac.mm index be798fcd..95c09786 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilitySharedCode_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilitySharedCode_mac.mm @@ -40,7 +40,7 @@ void operator() (ElementType* element) const }; template -class AccessibleObjCClass : public ObjCClass +class AccessibleObjCClass : public ObjCClass { public: using Holder = std::unique_ptr; diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp index 1b527f10..82d806d3 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp @@ -26,7 +26,7 @@ namespace juce { -struct AccessibilityTextHelpersTest : public UnitTest +struct AccessibilityTextHelpersTest final : public UnitTest { AccessibilityTextHelpersTest() : UnitTest ("AccessibilityTextHelpers", UnitTestCategories::gui) {} @@ -125,7 +125,7 @@ struct AccessibilityTextHelpersTest : public UnitTest enum class CursorPosition { begin, end }; - class MockAccessibilityTextInterface : public AccessibilityTextInterface + class MockAccessibilityTextInterface final : public AccessibilityTextInterface { public: MockAccessibilityTextInterface (String stringIn, Range selectionIn, CursorPosition insertIn) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_ios.mm b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_ios.mm index acd73907..130f435a 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_ios.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_ios.mm @@ -39,45 +39,45 @@ static void juceFreeAccessibilityPlatformSpecificData (UIAccessibilityElement* e #define JUCE_NATIVE_ACCESSIBILITY_INCLUDED 1 -template struct Signature; +template struct Signature {}; template struct Signature {}; // @selector isn't constexpr, so the 'sel' members are functions rather than static constexpr data members -struct SignatureHasText : Signature { static auto sel() { return @selector (hasText); } }; -struct SignatureSetSelectedTextRange : Signature { static auto sel() { return @selector (setSelectedTextRange:); } }; -struct SignatureSelectedTextRange : Signature { static auto sel() { return @selector (selectedTextRange); } }; -struct SignatureMarkedTextRange : Signature { static auto sel() { return @selector (markedTextRange); } }; -struct SignatureSetMarkedTextSelectedRange : Signature { static auto sel() { return @selector (setMarkedText:selectedRange:); } }; -struct SignatureUnmarkText : Signature { static auto sel() { return @selector (unmarkText); } }; -struct SignatureMarkedTextStyle : Signature*()> { static auto sel() { return @selector (markedTextStyle); } }; -struct SignatureSetMarkedTextStyle : Signature*)> { static auto sel() { return @selector (setMarkedTextStyle:); } }; -struct SignatureBeginningOfDocument : Signature { static auto sel() { return @selector (beginningOfDocument); } }; -struct SignatureEndOfDocument : Signature { static auto sel() { return @selector (endOfDocument); } }; -struct SignatureTokenizer : Signature()> { static auto sel() { return @selector (tokenizer); } }; -struct SignatureBaseWritingDirection : Signature { static auto sel() { return @selector (baseWritingDirectionForPosition:inDirection:); } }; -struct SignatureCaretRectForPosition : Signature { static auto sel() { return @selector (caretRectForPosition:); } }; -struct SignatureCharacterRangeByExtending : Signature { static auto sel() { return @selector (characterRangeByExtendingPosition:inDirection:); } }; -struct SignatureCharacterRangeAtPoint : Signature { static auto sel() { return @selector (characterRangeAtPoint:); } }; -struct SignatureClosestPositionToPoint : Signature { static auto sel() { return @selector (closestPositionToPoint:); } }; -struct SignatureClosestPositionToPointInRange : Signature { static auto sel() { return @selector (closestPositionToPoint:withinRange:); } }; -struct SignatureComparePositionToPosition : Signature { static auto sel() { return @selector (comparePosition:toPosition:); } }; -struct SignatureOffsetFromPositionToPosition : Signature { static auto sel() { return @selector (offsetFromPosition:toPosition:); } }; -struct SignaturePositionFromPositionInDirection : Signature { static auto sel() { return @selector (positionFromPosition:inDirection:offset:); } }; -struct SignaturePositionFromPositionOffset : Signature { static auto sel() { return @selector (positionFromPosition:offset:); } }; -struct SignatureFirstRectForRange : Signature { static auto sel() { return @selector (firstRectForRange:); } }; -struct SignatureSelectionRectsForRange : Signature* (UITextRange*)> { static auto sel() { return @selector (selectionRectsForRange:); } }; -struct SignaturePositionWithinRange : Signature { static auto sel() { return @selector (positionWithinRange:farthestInDirection:); } }; -struct SignatureReplaceRangeWithText : Signature { static auto sel() { return @selector (replaceRange:withText:); } }; -struct SignatureSetBaseWritingDirection : Signature { static auto sel() { return @selector (setBaseWritingDirection:forRange:); } }; -struct SignatureTextInRange : Signature { static auto sel() { return @selector (textInRange:); } }; -struct SignatureTextRangeFromPosition : Signature { static auto sel() { return @selector (textRangeFromPosition:toPosition:); } }; -struct SignatureSetInputDelegate : Signature { static auto sel() { return @selector (setInputDelegate:); } }; -struct SignatureInputDelegate : Signature { static auto sel() { return @selector (inputDelegate); } }; -struct SignatureKeyboardType : Signature { static auto sel() { return @selector (keyboardType); } }; -struct SignatureAutocapitalizationType : Signature { static auto sel() { return @selector (autocapitalizationType); } }; -struct SignatureAutocorrectionType : Signature { static auto sel() { return @selector (autocorrectionType); } }; +struct SignatureHasText final : public Signature { static auto sel() { return @selector (hasText); } }; +struct SignatureSetSelectedTextRange final : public Signature { static auto sel() { return @selector (setSelectedTextRange:); } }; +struct SignatureSelectedTextRange final : public Signature { static auto sel() { return @selector (selectedTextRange); } }; +struct SignatureMarkedTextRange final : public Signature { static auto sel() { return @selector (markedTextRange); } }; +struct SignatureSetMarkedTextSelectedRange final : public Signature { static auto sel() { return @selector (setMarkedText:selectedRange:); } }; +struct SignatureUnmarkText final : public Signature { static auto sel() { return @selector (unmarkText); } }; +struct SignatureMarkedTextStyle final : public Signature*()> { static auto sel() { return @selector (markedTextStyle); } }; +struct SignatureSetMarkedTextStyle final : public Signature*)> { static auto sel() { return @selector (setMarkedTextStyle:); } }; +struct SignatureBeginningOfDocument final : public Signature { static auto sel() { return @selector (beginningOfDocument); } }; +struct SignatureEndOfDocument final : public Signature { static auto sel() { return @selector (endOfDocument); } }; +struct SignatureTokenizer final : public Signature()> { static auto sel() { return @selector (tokenizer); } }; +struct SignatureBaseWritingDirection final : public Signature { static auto sel() { return @selector (baseWritingDirectionForPosition:inDirection:); } }; +struct SignatureCaretRectForPosition final : public Signature { static auto sel() { return @selector (caretRectForPosition:); } }; +struct SignatureCharacterRangeByExtending final : public Signature { static auto sel() { return @selector (characterRangeByExtendingPosition:inDirection:); } }; +struct SignatureCharacterRangeAtPoint final : public Signature { static auto sel() { return @selector (characterRangeAtPoint:); } }; +struct SignatureClosestPositionToPoint final : public Signature { static auto sel() { return @selector (closestPositionToPoint:); } }; +struct SignatureClosestPositionToPointInRange final : public Signature { static auto sel() { return @selector (closestPositionToPoint:withinRange:); } }; +struct SignatureComparePositionToPosition final : public Signature { static auto sel() { return @selector (comparePosition:toPosition:); } }; +struct SignatureOffsetFromPositionToPosition final : public Signature { static auto sel() { return @selector (offsetFromPosition:toPosition:); } }; +struct SignaturePositionFromPositionInDirection final : public Signature { static auto sel() { return @selector (positionFromPosition:inDirection:offset:); } }; +struct SignaturePositionFromPositionOffset final : public Signature { static auto sel() { return @selector (positionFromPosition:offset:); } }; +struct SignatureFirstRectForRange final : public Signature { static auto sel() { return @selector (firstRectForRange:); } }; +struct SignatureSelectionRectsForRange final : public Signature* (UITextRange*)> { static auto sel() { return @selector (selectionRectsForRange:); } }; +struct SignaturePositionWithinRange final : public Signature { static auto sel() { return @selector (positionWithinRange:farthestInDirection:); } }; +struct SignatureReplaceRangeWithText final : public Signature { static auto sel() { return @selector (replaceRange:withText:); } }; +struct SignatureSetBaseWritingDirection final : public Signature { static auto sel() { return @selector (setBaseWritingDirection:forRange:); } }; +struct SignatureTextInRange final : public Signature { static auto sel() { return @selector (textInRange:); } }; +struct SignatureTextRangeFromPosition final : public Signature { static auto sel() { return @selector (textRangeFromPosition:toPosition:); } }; +struct SignatureSetInputDelegate final : public Signature { static auto sel() { return @selector (setInputDelegate:); } }; +struct SignatureInputDelegate final : public Signature { static auto sel() { return @selector (inputDelegate); } }; +struct SignatureKeyboardType final : public Signature { static auto sel() { return @selector (keyboardType); } }; +struct SignatureAutocapitalizationType final : public Signature { static auto sel() { return @selector (autocapitalizationType); } }; +struct SignatureAutocorrectionType final : public Signature { static auto sel() { return @selector (autocorrectionType); } }; //============================================================================== class AccessibilityHandler::AccessibilityNativeImpl @@ -95,7 +95,7 @@ explicit AccessibilityNativeImpl (AccessibilityHandler& handler) private: //============================================================================== - class AccessibilityContainer : public AccessibleObjCClass + class AccessibilityContainer final : public AccessibleObjCClass { public: AccessibilityContainer() @@ -212,7 +212,7 @@ explicit AccessibilityNativeImpl (AccessibilityHandler& handler) }; //============================================================================== - class AccessibilityElement : public AccessibleObjCClass + class AccessibilityElement final : public AccessibleObjCClass { template static constexpr void forEach (Func&& func, Items&&... items) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm index 8ae9b652..1c2c1936 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm @@ -49,7 +49,7 @@ explicit AccessibilityNativeImpl (AccessibilityHandler& handler) private: //============================================================================== - class API_AVAILABLE (macos (10.10)) AccessibilityElement : public AccessibleObjCClass> + class API_AVAILABLE (macos (10.10)) AccessibilityElement final : public AccessibleObjCClass> { public: static Holder create (AccessibilityHandler& handler) @@ -269,10 +269,18 @@ static Holder create (AccessibilityHandler& handler) { if (auto* handler = getHandler (self)) { - if (handler->getCurrentState().isCheckable()) - return juceStringToNS (handler->getCurrentState().isChecked() ? TRANS ("On") : TRANS ("Off")); + if (! handler->getCurrentState().isCheckable()) + return getAccessibilityValueFromInterfaces (*handler); - return getAccessibilityValueFromInterfaces (*handler); + const auto checked = handler->getCurrentState().isChecked(); + + if ( handler->getRole() == AccessibilityRole::toggleButton + || handler->getRole() == AccessibilityRole::radioButton) + { + return checked ? @YES : @NO; + } + + return juceStringToNS (checked ? TRANS ("On") : TRANS ("Off")); } return nil; diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_windows.cpp index 18293685..a47cb519 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_Accessibility_windows.cpp @@ -242,13 +242,13 @@ void AccessibilityHandler::notifyAccessibilityEvent (AccessibilityEvent eventTyp sendAccessibilityAutomationEvent (*this, event); } -struct SpVoiceWrapper : public DeletedAtShutdown +struct SpVoiceWrapper final : public DeletedAtShutdown { SpVoiceWrapper() { - auto hr = voice.CoCreateInstance (ComTypes::CLSID_SpVoice); + [[maybe_unused]] auto hr = voice.CoCreateInstance (ComTypes::CLSID_SpVoice); - jassertquiet (SUCCEEDED (hr)); + jassert (SUCCEEDED (hr)); } ~SpVoiceWrapper() override diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_ComInterfaces_windows.h b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_ComInterfaces_windows.h index 8071c69f..be2400b0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_ComInterfaces_windows.h +++ b/JuceLibraryCode/modules/juce_gui_basics/native/accessibility/juce_ComInterfaces_windows.h @@ -23,9 +23,7 @@ ============================================================================== */ -namespace juce -{ -namespace ComTypes +namespace juce::ComTypes { /* @@ -474,8 +472,7 @@ JUCE_COMCLASS (IScrollItemProvider, "2360c714-4bf1-4b26-ba65-9b21316127eb") : p constexpr CLSID CLSID_SpVoice { 0x96749377, 0x3391, 0x11D2, { 0x9E, 0xE3, 0x00, 0xC0, 0x4F, 0x79, 0x73, 0x96 } }; -} // namespace ComTypes -} // namespace juce +} // namespace juce::ComTypes #ifdef __CRT_UUID_DECL __CRT_UUID_DECL (juce::ComTypes::IRawElementProviderFragmentRoot, 0x620ce2a5, 0xab8f, 0x40a9, 0x86, 0xcb, 0xde, 0x3c, 0x75, 0x59, 0x9b, 0x58) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_CGMetalLayerRenderer_mac.h b/JuceLibraryCode/modules/juce_gui_basics/native/juce_CGMetalLayerRenderer_mac.h index a26dfe65..6b27c366 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_CGMetalLayerRenderer_mac.h +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_CGMetalLayerRenderer_mac.h @@ -310,7 +310,7 @@ class CoreGraphicsMetalLayerRenderer if (alignedSize > size) { - size = std::max (alignedSize, alignTo ((size_t) (size * growthFactor), pagesize)); + size = std::max (alignedSize, alignTo ((size_t) ((float) size * growthFactor), pagesize)); allocation = std::make_unique (pagesize, size); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp index 50f8c329..cabf5643 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp @@ -688,7 +688,7 @@ DECLARE_JNI_CLASS (AndroidReceiver, "com/rmsl/juce/Receiver") #undef JNI_CLASS_MEMBERS //============================================================================== -class AndroidContentSharerPrepareFilesTask : private AsyncUpdater +class AndroidContentSharerPrepareFilesTask final : private AsyncUpdater { public: AndroidContentSharerPrepareFilesTask (const Array& fileUrls, @@ -875,7 +875,7 @@ class AndroidContentSharerPrepareFilesTask : private AsyncUpdater auto detail::ScopedContentSharerInterface::shareFiles (const Array& urls, Component*) -> std::unique_ptr { - class NativeScopedContentSharerInterface : public detail::ScopedContentSharerInterface + class NativeScopedContentSharerInterface final : public detail::ScopedContentSharerInterface { public: explicit NativeScopedContentSharerInterface (Array f) @@ -914,7 +914,7 @@ auto detail::ScopedContentSharerInterface::shareFiles (const Array& urls, C auto detail::ScopedContentSharerInterface::shareText (const String& text, Component*) -> std::unique_ptr { - class NativeScopedContentSharerInterface : public detail::ScopedContentSharerInterface + class NativeScopedContentSharerInterface final : public detail::ScopedContentSharerInterface { public: explicit NativeScopedContentSharerInterface (String t) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_ios.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_ios.cpp index 5285f934..b3912cda 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_ios.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_ContentSharer_ios.cpp @@ -26,8 +26,8 @@ namespace juce { -class NativeScopedContentSharerInterface : public detail::ScopedContentSharerInterface, - public detail::NativeModalWrapperComponent +class NativeScopedContentSharerInterface final : public detail::ScopedContentSharerInterface, + public detail::NativeModalWrapperComponent { public: NativeScopedContentSharerInterface (Component* parentIn, NSUniquePtr itemsIn) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp index 52a6273a..9848ed8c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp @@ -340,8 +340,7 @@ class X11DragState X11Symbols::getInstance()->xUngrabPointer (getDisplay(), CurrentTime); } - if (completionCallback != nullptr) - completionCallback(); + NullCheckedInvocation::invoke (completionCallback); dragging = false; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_windows.cpp index e1f9e3b6..701bf262 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_DragAndDrop_windows.cpp @@ -29,7 +29,7 @@ namespace juce namespace DragAndDropHelpers { //============================================================================== - struct JuceDropSource : public ComBaseClassHelper + struct JuceDropSource final : public ComBaseClassHelper { JuceDropSource() {} @@ -51,7 +51,7 @@ namespace DragAndDropHelpers }; //============================================================================== - struct JuceEnumFormatEtc : public ComBaseClassHelper + struct JuceEnumFormatEtc final : public ComBaseClassHelper { JuceEnumFormatEtc (const FORMATETC* f) : format (f) {} @@ -123,7 +123,7 @@ namespace DragAndDropHelpers }; //============================================================================== - class JuceDataObject : public ComBaseClassHelper + class JuceDataObject final : public ComBaseClassHelper { public: JuceDataObject (const FORMATETC* f, const STGMEDIUM* m) @@ -251,7 +251,7 @@ namespace DragAndDropHelpers return static_cast (hDrop.release()); } - struct DragAndDropJob : public ThreadPoolJob + struct DragAndDropJob final : public ThreadPoolJob { DragAndDropJob (FORMATETC f, STGMEDIUM m, DWORD d, std::function&& cb) : ThreadPoolJob ("DragAndDrop"), @@ -288,7 +288,7 @@ namespace DragAndDropHelpers std::function completionCallback; }; - class ThreadPoolHolder : private DeletedAtShutdown + class ThreadPoolHolder final : private DeletedAtShutdown { public: ThreadPoolHolder() = default; diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_android.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_android.cpp index 14327e03..40535613 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_android.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_android.cpp @@ -39,7 +39,7 @@ DECLARE_JNI_CLASS (ClipData, "android/content/ClipData") DECLARE_JNI_CLASS (ClipDataItem, "android/content/ClipData$Item") #undef JNI_CLASS_MEMBERS -class FileChooser::Native : public FileChooser::Pimpl +class FileChooser::Native final : public FileChooser::Pimpl { public: //============================================================================== @@ -128,7 +128,7 @@ class FileChooser::Native : public FileChooser::Pimpl auto allMimeTypesHaveSameGroup = true; LocalRef jMimeTypes (env->NewObjectArray (mimeTypes.size(), JavaString, - javaString("").get())); + javaString ("").get())); for (int i = 0; i < mimeTypes.size(); ++i) { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_ios.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_ios.mm index 152e2969..14099e07 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_ios.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_ios.mm @@ -40,10 +40,10 @@ - (id) initWithOwner: (FileChooser::Native*) owner; #endif //============================================================================== -class FileChooser::Native : public FileChooser::Pimpl, - public detail::NativeModalWrapperComponent, - public AsyncUpdater, - public std::enable_shared_from_this +class FileChooser::Native final : public FileChooser::Pimpl, + public detail::NativeModalWrapperComponent, + public AsyncUpdater, + public std::enable_shared_from_this { public: static std::shared_ptr make (FileChooser& fileChooser, int flags) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_linux.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_linux.cpp index 46a4f7a8..56d59207 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_linux.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_linux.cpp @@ -44,8 +44,8 @@ static bool isSet (int flags, int toCheck) return (flags & toCheck) != 0; } -class FileChooser::Native : public FileChooser::Pimpl, - private Timer +class FileChooser::Native final : public FileChooser::Pimpl, + private Timer { public: Native (FileChooser& fileChooser, int flags) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_mac.mm index 6b58a0e3..4aa57242 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_mac.mm @@ -52,8 +52,8 @@ } //============================================================================== -class FileChooser::Native : public Component, - public FileChooser::Pimpl +class FileChooser::Native final : public Component, + public FileChooser::Pimpl { public: Native (FileChooser& fileChooser, int flags, FilePreviewComponent* previewComponent) @@ -371,7 +371,7 @@ explicit SafeModalPanel (const char* name) : ObjCClass (name) }; //============================================================================== - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCEFileChooser_") { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp index e51f20be..a1c4ea75 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp @@ -32,7 +32,7 @@ namespace detail bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages); } // namespace detail -class Win32NativeFileChooser : private Thread +class Win32NativeFileChooser final : private Thread { public: enum { charsAvailableForResult = 32768 }; @@ -124,7 +124,7 @@ class Win32NativeFileChooser : private Thread private: //============================================================================== - class CustomComponentHolder : public Component + class CustomComponentHolder final : public Component { public: CustomComponentHolder (Component* const customComp) @@ -142,7 +142,7 @@ class Win32NativeFileChooser : private Thread void resized() override { - if (Component* const c = getChildComponent(0)) + if (Component* const c = getChildComponent (0)) c->setBounds (getLocalBounds()); } @@ -239,7 +239,7 @@ class Win32NativeFileChooser : private Thread if (! selectsDirectories && FAILED (dialog.SetFileTypes (numElementsInArray (spec), spec))) return false; - struct Events : public ComBaseClassHelper + struct Events final : public ComBaseClassHelper { explicit Events (Win32NativeFileChooser& o) : owner (o) {} @@ -811,9 +811,9 @@ class Win32NativeFileChooser : private Thread JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Win32NativeFileChooser) }; -class FileChooser::Native : public std::enable_shared_from_this, - public Component, - public FileChooser::Pimpl +class FileChooser::Native final : public std::enable_shared_from_this, + public Component, + public FileChooser::Pimpl { public: Native (FileChooser& fileChooser, int flagsIn, FilePreviewComponent* previewComp) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_MainMenu_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_MainMenu_mac.mm index 01bb64bd..e70458af 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_MainMenu_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_MainMenu_mac.mm @@ -31,7 +31,7 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE //============================================================================== -struct JuceMainMenuBarHolder : private DeletedAtShutdown +struct JuceMainMenuBarHolder final : private DeletedAtShutdown { JuceMainMenuBarHolder() : mainMenuBar ([[NSMenu alloc] initWithTitle: nsStringLiteral ("MainMenu")]) @@ -68,8 +68,8 @@ JUCE_IMPLEMENT_SINGLETON (JuceMainMenuBarHolder) //============================================================================== -class JuceMainMenuHandler : private MenuBarModel::Listener, - private DeletedAtShutdown +class JuceMainMenuHandler final : private MenuBarModel::Listener, + private DeletedAtShutdown { public: JuceMainMenuHandler() @@ -449,7 +449,7 @@ static void flashMenuBar (NSMenu* menu) // When the f35Event is invoked, the item's enablement is checked and a // NSBeep is triggered if the item appears to be disabled. // This ValidatorClass exists solely to return YES from validateMenuItem. - struct ValidatorClass : public ObjCClass + struct ValidatorClass final : public ObjCClass { ValidatorClass() : ObjCClass ("JUCEMenuValidator_") { @@ -462,9 +462,9 @@ static void flashMenuBar (NSMenu* menu) }; static ValidatorClass validatorClass; - static auto* instance = validatorClass.createInstance(); + static auto* vcInstance = validatorClass.createInstance(); - [item setTarget: instance]; + [item setTarget: vcInstance]; [menu insertItem: item atIndex: [menu numberOfItems]]; [item release]; @@ -537,7 +537,7 @@ static void removeItemRecursive (NSMenu* menu) } //============================================================================== - struct JuceMenuCallbackClass : public ObjCClass + struct JuceMenuCallbackClass final : public ObjCClass { JuceMenuCallbackClass() : ObjCClass ("JUCEMainMenu_") { @@ -664,7 +664,7 @@ static bool checkModalEvent (FilePreviewComponent* preview, const Component* tar // This override is also important because it stops the base class // calling ModalComponentManager::bringToFront, which can get // recursive when file dialogs are involved - struct SilentDummyModalComp : public Component + struct SilentDummyModalComp final : public Component { explicit SilentDummyModalComp (FilePreviewComponent* p) : preview (p) {} @@ -720,16 +720,16 @@ static void createStandardAppMenu (NSMenu* menu, const String& appName, const Po [NSApp setServicesMenu: servicesMenu]; [menu addItem: [NSMenuItem separatorItem]]; - createMenuItem (menu, TRANS("Hide") + String (" ") + appName, @selector (hide:), nsStringLiteral ("h")); + createMenuItem (menu, TRANS ("Hide") + String (" ") + appName, @selector (hide:), nsStringLiteral ("h")); - [createMenuItem (menu, TRANS("Hide Others"), @selector (hideOtherApplications:), nsStringLiteral ("h")) + [createMenuItem (menu, TRANS ("Hide Others"), @selector (hideOtherApplications:), nsStringLiteral ("h")) setKeyEquivalentModifierMask: NSEventModifierFlagCommand | NSEventModifierFlagOption]; - createMenuItem (menu, TRANS("Show All"), @selector (unhideAllApplications:), nsEmptyString()); + createMenuItem (menu, TRANS ("Show All"), @selector (unhideAllApplications:), nsEmptyString()); [menu addItem: [NSMenuItem separatorItem]]; - createMenuItem (menu, TRANS("Quit") + String (" ") + appName, @selector (terminate:), nsStringLiteral ("q")); + createMenuItem (menu, TRANS ("Quit") + String (" ") + appName, @selector (terminate:), nsStringLiteral ("q")); } // Since our app has no NIB, this initialises a standard app menu... diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm index 8e4e0dba..0f3bd8cc 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm @@ -23,8 +23,6 @@ ============================================================================== */ -#include "juce_CGMetalLayerRenderer_mac.h" - @interface NSEvent (DeviceDelta) - (float)deviceDeltaX; - (float)deviceDeltaY; @@ -122,7 +120,7 @@ static constexpr int translateVirtualToAsciiKeyCode (int keyCode) noexcept constexpr int extendedKeyModifier = 0x30000; //============================================================================== -class JuceCALayerDelegate : public ObjCClass> +class JuceCALayerDelegate final : public ObjCClass> { public: struct Callback @@ -168,8 +166,8 @@ static void setOwner (id self, Callback* newOwner) }; //============================================================================== -class NSViewComponentPeer : public ComponentPeer, - private JuceCALayerDelegate::Callback +class NSViewComponentPeer final : public ComponentPeer, + private JuceCALayerDelegate::Callback { public: NSViewComponentPeer (Component& comp, const int windowStyleFlags, NSView* viewToAttachTo) @@ -1039,8 +1037,8 @@ void renderRect (CGContextRef cg, NSRect r, float displayScale) if (! clip.isEmpty()) { Image temp (component.isOpaque() ? Image::RGB : Image::ARGB, - roundToInt (clipW * displayScale), - roundToInt (clipH * displayScale), + roundToInt ((float) clipW * displayScale), + roundToInt ((float) clipH * displayScale), ! component.isOpaque()); { @@ -1759,7 +1757,7 @@ auto tie() const // avoid unnecessarily duplicating display-link threads. SharedResourcePointer sharedDisplayLinks; - class AsyncRepainter : private AsyncUpdater + class AsyncRepainter final : private AsyncUpdater { public: explicit AsyncRepainter (NSViewComponentPeer& o) : owner (o) {} @@ -1896,7 +1894,7 @@ static bool checkEventBlockedByModalComps (NSEvent* e) case NSEventTypeRightMouseUp: case NSEventTypeOtherMouseUp: case NSEventTypeOtherMouseDragged: - if (Desktop::getInstance().getDraggingMouseSource(0) != nullptr) + if (Desktop::getInstance().getDraggingMouseSource (0) != nullptr) return false; break; @@ -2009,7 +2007,7 @@ void displayLayer ([[maybe_unused]] CALayer* layer) override //============================================================================== template -struct NSViewComponentPeerWrapper : public Base +struct NSViewComponentPeerWrapper : public Base { explicit NSViewComponentPeerWrapper (const char* baseName) : Base (baseName) @@ -2033,7 +2031,7 @@ static id getAccessibleChild (id self) }; //============================================================================== -struct JuceNSViewClass : public NSViewComponentPeerWrapper> +struct JuceNSViewClass final : public NSViewComponentPeerWrapper> { JuceNSViewClass() : NSViewComponentPeerWrapper ("JUCEView_") { @@ -2104,6 +2102,10 @@ static id getAccessibleChild (id self) addMethod (@selector (draggingEnded:), draggingExited); addMethod (@selector (draggingExited:), draggingExited); + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector") + addMethod (@selector (clipsToBounds), [] (id, SEL) { return YES; }); + JUCE_END_IGNORE_WARNINGS_GCC_LIKE + addMethod (@selector (acceptsFirstMouse:), [] (id, SEL, NSEvent*) { return YES; }); #if JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS @@ -2600,7 +2602,7 @@ static NSDragOperation draggingUpdated (id self, SEL, id sender) }; //============================================================================== -struct JuceNSWindowClass : public NSViewComponentPeerWrapper> +struct JuceNSWindowClass final : public NSViewComponentPeerWrapper> { JuceNSWindowClass() : NSViewComponentPeerWrapper ("JUCEWindow_") { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_android.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_android.cpp index 41529419..8eabb2a9 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_android.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_android.cpp @@ -28,7 +28,7 @@ namespace juce::detail std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) { - class AndroidMessageBox : public ScopedMessageBoxInterface + class AndroidMessageBox final : public ScopedMessageBoxInterface { public: explicit AndroidMessageBox (const MessageBoxOptions& o) : opts (o) {} diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_ios.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_ios.mm index 4b6a663d..52b82cff 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_ios.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_ios.mm @@ -28,7 +28,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) { - class MessageBox : public ScopedMessageBoxInterface + class MessageBox final : public ScopedMessageBoxInterface { public: explicit MessageBox (const MessageBoxOptions& opts) : options (opts) {} diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_linux.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_linux.cpp index e0d19a47..dcb0eb02 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_linux.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_linux.cpp @@ -31,7 +31,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (co // On Linux, we re-use the AlertWindow rather than using a platform-specific dialog. // For consistency with the NativeMessageBox on other platforms, the result code must // match the button index, hence this adapter. - class MessageBox : public ScopedMessageBoxInterface + class MessageBox final : public ScopedMessageBoxInterface { public: explicit MessageBox (const MessageBoxOptions& options) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_mac.mm index 0da09108..eaaffadf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_mac.mm @@ -28,7 +28,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) { - class OSXMessageBox : public ScopedMessageBoxInterface + class OSXMessageBox final : public ScopedMessageBoxInterface { public: explicit OSXMessageBox (const MessageBoxOptions& opts) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp index 36d34a9e..7c8afc89 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp @@ -40,7 +40,7 @@ namespace juce::detail std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) { - class WindowsMessageBoxBase : public ScopedMessageBoxInterface + class WindowsMessageBoxBase : public ScopedMessageBoxInterface { public: explicit WindowsMessageBoxBase (Component* comp) @@ -106,7 +106,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (co JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowsMessageBoxBase) }; - class PreVistaMessageBox : public WindowsMessageBoxBase + class PreVistaMessageBox final : public WindowsMessageBoxBase { public: PreVistaMessageBox (const MessageBoxOptions& opts, UINT extraFlags) @@ -199,7 +199,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (co JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreVistaMessageBox) }; - class WindowsTaskDialog : public WindowsMessageBoxBase + class WindowsTaskDialog final : public WindowsMessageBoxBase { static auto getTaskDialogFunc() { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeModalWrapperComponent_ios.h b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeModalWrapperComponent_ios.h index a0127ba4..c46a2d9d 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeModalWrapperComponent_ios.h +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_NativeModalWrapperComponent_ios.h @@ -49,7 +49,7 @@ class NativeModalWrapperComponent : public Component if (auto* popoverController = getViewController().popoverPresentationController) { popoverController.sourceView = peer->view; - popoverController.sourceRect = CGRectMake (0.f, getHeight() - 10.f, getWidth(), 10.f); + popoverController.sourceRect = CGRectMake (0.0f, (float) getHeight() - 10.0f, (float) getWidth(), 10.0f); popoverController.canOverlapSourceViewRect = YES; popoverController.delegate = popoverDelegate.get(); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_PerScreenDisplayLinks_mac.h b/JuceLibraryCode/modules/juce_gui_basics/native/juce_PerScreenDisplayLinks_mac.h index b4a508c7..a193efca 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_PerScreenDisplayLinks_mac.h +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_PerScreenDisplayLinks_mac.h @@ -107,9 +107,9 @@ class ScopedDisplayLink link ([display = displayId] { CVDisplayLinkRef ptr = nullptr; - const auto result = CVDisplayLinkCreateWithCGDisplay (display, &ptr); - jassertquiet (result == kCVReturnSuccess); - jassertquiet (ptr != nullptr); + [[maybe_unused]] const auto result = CVDisplayLinkCreateWithCGDisplay (display, &ptr); + jassert (result == kCVReturnSuccess); + jassert (ptr != nullptr); return ptr; }()), onCallback (std::move (onCallbackIn)) @@ -125,11 +125,11 @@ class ScopedDisplayLink return kCVReturnSuccess; }; - const auto callbackResult = CVDisplayLinkSetOutputCallback (link.get(), callback, this); - jassertquiet (callbackResult == kCVReturnSuccess); + [[maybe_unused]] const auto callbackResult = CVDisplayLinkSetOutputCallback (link.get(), callback, this); + jassert (callbackResult == kCVReturnSuccess); - const auto startResult = CVDisplayLinkStart (link.get()); - jassertquiet (startResult == kCVReturnSuccess); + [[maybe_unused]] const auto startResult = CVDisplayLinkStart (link.get()); + jassert (startResult == kCVReturnSuccess); } ~ScopedDisplayLink() noexcept @@ -274,9 +274,9 @@ class PerScreenDisplayLinks // This is the callback that will actually fire in response to this screen's display // link callback. - result.emplace_back (screen, [callbacks = std::move (callbacks)] + result.emplace_back (screen, [cbs = std::move (callbacks)] { - for (const auto& callback : callbacks) + for (const auto& callback : cbs) callback(); }); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm index e5781e45..c69b07f2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm @@ -23,8 +23,6 @@ ============================================================================== */ -#include "juce_CGMetalLayerRenderer_mac.h" - #if TARGET_OS_SIMULATOR && JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS #warning JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS uses parts of the Metal API that are currently unsupported in the simulator - falling back to JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS=0 #undef JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS @@ -389,8 +387,8 @@ - (void) becomeKeyWindow; }; //============================================================================== -class UIViewComponentPeer : public ComponentPeer, - public UIViewPeerControllerReceiver +class UIViewComponentPeer final : public ComponentPeer, + public UIViewPeerControllerReceiver { public: UIViewComponentPeer (Component&, int windowStyleFlags, UIView* viewToAttachTo); @@ -545,7 +543,7 @@ void appStyleChanged() override } //============================================================================== - class AsyncRepaintMessage : public CallbackMessage + class AsyncRepaintMessage final : public CallbackMessage { public: UIViewComponentPeer* const peer; @@ -984,7 +982,7 @@ static bool attemptToConsumeKeys (JuceUIView* view, NSSet* presses) return used; } -- (void) pressesBegan:(NSSet*) presses withEvent:(UIPressesEvent*) event +- (void) pressesBegan: (NSSet*) presses withEvent: (UIPressesEvent*) event { const auto handledEvent = [&] { @@ -1033,13 +1031,13 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr return false; } -- (void) pressesEnded:(NSSet*) presses withEvent:(UIPressesEvent*) event +- (void) pressesEnded: (NSSet*) presses withEvent: (UIPressesEvent*) event { if (! doKeysUp (owner, presses, event)) [super pressesEnded: presses withEvent: event]; } -- (void) pressesCancelled:(NSSet*) presses withEvent:(UIPressesEvent*) event +- (void) pressesCancelled: (NSSet*) presses withEvent: (UIPressesEvent*) event { if (! doKeysUp (owner, presses, event)) [super pressesCancelled: presses withEvent: event]; @@ -1929,11 +1927,11 @@ - (UITextRange*) rangeEnclosingPosition: (JuceUITextPosition*) position { // this will re-centre the window, but leave its size unchanged - auto centreRelX = oldArea.getCentreX() / (float) oldDesktop.getWidth(); - auto centreRelY = oldArea.getCentreY() / (float) oldDesktop.getHeight(); + auto centreRelX = (float) oldArea.getCentreX() / (float) oldDesktop.getWidth(); + auto centreRelY = (float) oldArea.getCentreY() / (float) oldDesktop.getHeight(); - auto x = ((int) (newDesktop.getWidth() * centreRelX)) - (oldArea.getWidth() / 2); - auto y = ((int) (newDesktop.getHeight() * centreRelY)) - (oldArea.getHeight() / 2); + auto x = ((int) ((float) newDesktop.getWidth() * centreRelX)) - (oldArea.getWidth() / 2); + auto y = ((int) ((float) newDesktop.getHeight() * centreRelY)) - (oldArea.getHeight() / 2); component.setBounds (oldArea.withPosition (x, y)); } @@ -2232,7 +2230,7 @@ static float getTouchForce (UITouch* touch) noexcept CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, 0, getComponent().getHeight())); - CoreGraphicsContext g (cg, getComponent().getHeight()); + CoreGraphicsContext g (cg, (float) getComponent().getHeight()); insideDrawRect = true; handlePaint (g); diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_android.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_android.cpp index 3d52620e..e13394e5 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_android.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_android.cpp @@ -904,7 +904,7 @@ const uint8 javaComponentPeerView[] void juce_firebaseDeviceNotificationsTokenRefreshed (void*); void juce_firebaseRemoteNotificationReceived (void*); void juce_firebaseRemoteMessagesDeleted(); - void juce_firebaseRemoteMessageSent(void*); + void juce_firebaseRemoteMessageSent (void*); void juce_firebaseRemoteMessageSendError (void*, void*); #endif @@ -1223,8 +1223,8 @@ static constexpr int translateAndroidKeyboardFlags (int javaFlags) noexcept } //============================================================================== -class AndroidComponentPeer : public ComponentPeer, - private Timer +class AndroidComponentPeer final : public ComponentPeer, + private Timer { public: AndroidComponentPeer (Component& comp, int windowStyleFlags, void* nativeViewHandle) @@ -1915,7 +1915,7 @@ class AndroidComponentPeer : public ComponentPeer, static int64 touchesDown; //============================================================================== - struct StartupActivityCallbackListener : public ActivityLifecycleCallbacks + struct StartupActivityCallbackListener final : public ActivityLifecycleCallbacks { void onActivityStarted (jobject /*activity*/) override { @@ -2074,7 +2074,7 @@ class AndroidComponentPeer : public ComponentPeer, } //============================================================================== - class ViewWindowInsetsListener : public juce::AndroidInterfaceImplementer + class ViewWindowInsetsListener final : public juce::AndroidInterfaceImplementer { public: jobject onApplyWindowInsets (LocalRef, LocalRef insets) @@ -2115,7 +2115,7 @@ class AndroidComponentPeer : public ComponentPeer, }; //============================================================================== - struct PreallocatedImage : public ImagePixelData + struct PreallocatedImage final : public ImagePixelData { PreallocatedImage (int width_, int height_, jint* data_, bool hasAlpha_) : ImagePixelData (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_) @@ -2458,7 +2458,7 @@ DECLARE_JNI_CLASS (AndroidDialogOnClickListener, "android/content/DialogInterfac #undef JNI_CLASS_MEMBERS //============================================================================== -class DialogListener : public juce::AndroidInterfaceImplementer +class DialogListener final : public juce::AndroidInterfaceImplementer { public: explicit DialogListener (std::function cb) : callback (std::move (cb)) {} @@ -2568,7 +2568,7 @@ DECLARE_JNI_CLASS (AndroidDisplayMetrics, "android/util/DisplayMetrics") #undef JNI_CLASS_MEMBERS //============================================================================== -class LayoutChangeListener : public juce::AndroidInterfaceImplementer +class LayoutChangeListener : public juce::AndroidInterfaceImplementer { public: virtual void onLayoutChange (LocalRef view, int left, int top, int right, int bottom, @@ -2607,7 +2607,7 @@ class LayoutChangeListener : public juce::AndroidInterfaceImplementer }; //============================================================================== -struct MainActivityWindowLayoutListener : public LayoutChangeListener +struct MainActivityWindowLayoutListener final : public LayoutChangeListener { MainActivityWindowLayoutListener (std::function&& updateDisplaysCb) : forceDisplayUpdate (std::move (updateDisplaysCb)) @@ -2776,7 +2776,7 @@ void SystemClipboard::copyTextToClipboard (const String& text) auto* env = getEnv(); LocalRef clipboardManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService, javaString ("clipboard").get())); - env->CallVoidMethod (clipboardManager.get(), AndroidClipboardManager.setText, javaString(text).get()); + env->CallVoidMethod (clipboardManager.get(), AndroidClipboardManager.setText, javaString (text).get()); } String SystemClipboard::getTextFromClipboard() @@ -2789,7 +2789,7 @@ String SystemClipboard::getTextFromClipboard() if (charSequence == nullptr) return {}; - return juceString(LocalRef ((jstring) env->CallObjectMethod(charSequence.get(), JavaCharSequence.toString))); + return juceString (LocalRef ((jstring) env->CallObjectMethod (charSequence.get(), JavaCharSequence.toString))); } //============================================================================== diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_ios.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_ios.mm index 9cb1266f..619e244f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_ios.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_ios.mm @@ -189,7 +189,7 @@ - (void) applicationWillResignActive: (UIApplication*) application isIOSAppActive = false; for (int i = appBecomingInactiveCallbacks.size(); --i >= 0;) - appBecomingInactiveCallbacks.getReference(i)->appBecomingInactive(); + appBecomingInactiveCallbacks.getReference (i)->appBecomingInactive(); } - (void) application: (UIApplication*) application handleEventsForBackgroundURLSession: (NSString*)identifier @@ -556,7 +556,7 @@ int juce_iOSMain (int argc, const char* argv[], void* customDelegatePtr) } private: - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCEDelegate_") { @@ -674,7 +674,7 @@ int juce_iOSMain (int argc, const char* argv[], void* customDelegatePtr) auto getInsets() const { return insets; } private: - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCEOnScreenKeyboardObserver_") { diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_linux.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_linux.cpp index fa47e747..d6cd835b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_linux.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_linux.cpp @@ -27,8 +27,8 @@ namespace juce { //============================================================================== -class LinuxComponentPeer : public ComponentPeer, - private XWindowSystemUtilities::XSettings::Listener +class LinuxComponentPeer final : public ComponentPeer, + private XWindowSystemUtilities::XSettings::Listener { public: LinuxComponentPeer (Component& comp, int windowStyleFlags, ::Window parentToAddTo) @@ -509,7 +509,7 @@ class LinuxComponentPeer : public ComponentPeer, JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager) }; - class LinuxVBlankManager : public Timer + class LinuxVBlankManager final : public Timer { public: explicit LinuxVBlankManager (std::function cb) : callback (std::move (cb)) diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_mac.mm b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_mac.mm index fe6e6999..daa26c2f 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_mac.mm +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_mac.mm @@ -53,7 +53,7 @@ static NSRect getDragRect (NSView* view, NSEvent* event) return nil; } -class NSDraggingSourceHelper : public ObjCClass> +class NSDraggingSourceHelper final : public ObjCClass> { public: static void setText (id self, const String& text) @@ -312,7 +312,7 @@ static void setDragOperation (id self, NSDragOperation op) } private: - struct DelegateClass : public ObjCClass + struct DelegateClass final : public ObjCClass { DelegateClass() : ObjCClass ("JUCEDelegate_") { @@ -333,7 +333,7 @@ static void setDragOperation (id self, NSDragOperation op) } //============================================================================== -class ScreenSaverDefeater : public Timer +class ScreenSaverDefeater final : public Timer { public: ScreenSaverDefeater() @@ -394,7 +394,7 @@ void timerCallback() override } //============================================================================== -struct DisplaySettingsChangeCallback : private DeletedAtShutdown +struct DisplaySettingsChangeCallback final : private DeletedAtShutdown { DisplaySettingsChangeCallback() { @@ -410,8 +410,7 @@ void timerCallback() override static void displayReconfigurationCallback (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void* userInfo) { if (auto* thisPtr = static_cast (userInfo)) - if (thisPtr->forceDisplayUpdate != nullptr) - thisPtr->forceDisplayUpdate(); + NullCheckedInvocation::invoke (thisPtr->forceDisplayUpdate); } std::function forceDisplayUpdate; diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 785744fc..8e2921a7 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -23,10 +23,6 @@ ============================================================================== */ -#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client - #include -#endif - namespace juce { @@ -423,8 +419,7 @@ static void setDPIAwareness() && SUCCEEDED (setProcessDPIAwareness (DPI_Awareness::DPI_Awareness_System_Aware))) return; - if (setProcessDPIAware != nullptr) - setProcessDPIAware(); + NullCheckedInvocation::invoke (setProcessDPIAware); } static bool isPerMonitorDPIAwareProcess() @@ -974,7 +969,7 @@ const int KeyPress::rewindKey = 0x30003; //============================================================================== -class WindowsBitmapImage : public ImagePixelData +class WindowsBitmapImage final : public ImagePixelData { public: WindowsBitmapImage (const Image::PixelFormat format, @@ -1164,7 +1159,7 @@ namespace IconConverters if (icon == nullptr) return {}; - struct ScopedICONINFO : public ICONINFO + struct ScopedICONINFO final : public ICONINFO { ScopedICONINFO() { @@ -1430,8 +1425,8 @@ static HMONITOR getMonitorFromOutput (ComSmartPtr output) using VBlankListener = ComponentPeer::VBlankListener; //============================================================================== -class VSyncThread : private Thread, - private AsyncUpdater +class VSyncThread final : private Thread, + private AsyncUpdater { public: VSyncThread (ComSmartPtr out, @@ -1519,7 +1514,7 @@ class VSyncThread : private Thread, }; //============================================================================== -class VBlankDispatcher : public DeletedAtShutdown +class VBlankDispatcher final : public DeletedAtShutdown { public: void updateDisplay (VBlankListener& listener, HMONITOR monitor) @@ -1659,7 +1654,7 @@ class VBlankDispatcher : public DeletedAtShutdown JUCE_IMPLEMENT_SINGLETON (VBlankDispatcher) //============================================================================== -class SimpleTimer : private Timer +class SimpleTimer final : private Timer { public: SimpleTimer (int intervalMs, std::function callbackIn) @@ -1684,12 +1679,12 @@ class SimpleTimer : private Timer }; //============================================================================== -class HWNDComponentPeer : public ComponentPeer, - private VBlankListener, - private Timer - #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client - , public ModifierKeyReceiver - #endif +class HWNDComponentPeer final : public ComponentPeer, + private VBlankListener, + private Timer + #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client + , public ModifierKeyReceiver + #endif { public: enum RenderingEngineType @@ -2197,7 +2192,7 @@ class HWNDComponentPeer : public ComponentPeer, static ModifierKeys modifiersAtLastCallback; //============================================================================== - struct FileDropTarget : public ComBaseClassHelper + struct FileDropTarget final : public ComBaseClassHelper { FileDropTarget (HWNDComponentPeer& p) : peer (p) {} @@ -2334,48 +2329,68 @@ class HWNDComponentPeer : public ComponentPeer, JUCE_DECLARE_NON_COPYABLE (FileDropTarget) }; - static bool offerKeyMessageToJUCEWindow (MSG& m) + static bool offerKeyMessageToJUCEWindow (const MSG& msg) { - auto* peer = getOwnerOfWindow (m.hwnd); + // If this isn't a keyboard message, let the host deal with it. - if (peer == nullptr) + constexpr UINT messages[] { WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP, WM_CHAR, WM_SYSCHAR }; + + if (std::find (std::begin (messages), std::end (messages), msg.message) == std::end (messages)) return false; + auto* peer = getOwnerOfWindow (msg.hwnd); auto* focused = Component::getCurrentlyFocusedComponent(); - if (focused == nullptr || focused->getPeer() != peer) + if (focused == nullptr || peer == nullptr || focused->getPeer() != peer) return false; - constexpr UINT keyMessages[] { WM_KEYDOWN, - WM_KEYUP, - WM_SYSKEYDOWN, - WM_SYSKEYUP, - WM_CHAR }; - - const auto messageTypeMatches = [&] (UINT msg) { return m.message == msg; }; + auto* hwnd = static_cast (peer->getNativeHandle()); - if (std::none_of (std::begin (keyMessages), std::end (keyMessages), messageTypeMatches)) + if (hwnd == nullptr) return false; - ScopedThreadDPIAwarenessSetter threadDpiAwarenessSetter { m.hwnd }; + ScopedThreadDPIAwarenessSetter threadDpiAwarenessSetter { hwnd }; - if (m.message == WM_CHAR) - return peer->doKeyChar ((int) m.wParam, m.lParam); + // If we've been sent a text character, process it as text. - TranslateMessage (&m); + if (msg.message == WM_CHAR || msg.message == WM_SYSCHAR) + return peer->doKeyChar ((int) msg.wParam, msg.lParam); - switch (m.message) + // The event was a keypress, rather than a text character + + if (peer->findCurrentTextInputTarget() != nullptr) { - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - return peer->doKeyDown (m.wParam); + // If there's a focused text input target, we want to attempt "real" text input with an + // IME, and we want to prevent the host from eating keystrokes (spaces etc.). - case WM_KEYUP: - case WM_SYSKEYUP: - return peer->doKeyUp (m.wParam); + TranslateMessage (&msg); + + // TranslateMessage may post WM_CHAR back to the window, so we remove those messages + // from the queue before the host gets to see them. + // This will dispatch pending WM_CHAR messages, so we may end up reentering + // offerKeyMessageToJUCEWindow and hitting the WM_CHAR case above. + // We always return true if WM_CHAR is posted so that the keypress is not forwarded + // to the host. Otherwise, the host may call TranslateMessage again on this message, + // resulting in duplicate WM_CHAR messages being posted. + + MSG peeked{}; + if (PeekMessage (&peeked, hwnd, WM_CHAR, WM_DEADCHAR, PM_REMOVE) + || PeekMessage (&peeked, hwnd, WM_SYSCHAR, WM_SYSDEADCHAR, PM_REMOVE)) + { + return true; + } + + // If TranslateMessage didn't add a WM_CHAR to the queue, fall back to processing the + // event as a plain keypress } - return false; + // There's no text input target, or the key event wasn't translated, so we'll just see if we + // can use the plain keystroke event + + if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) + return peer->doKeyDown (msg.wParam); + + return peer->doKeyUp (msg.wParam); } double getPlatformScaleFactor() const noexcept override @@ -2429,7 +2444,7 @@ class HWNDComponentPeer : public ComponentPeer, static MultiTouchMapper currentTouches; //============================================================================== - struct TemporaryImage : private Timer + struct TemporaryImage final : private Timer { TemporaryImage() {} @@ -2459,7 +2474,7 @@ class HWNDComponentPeer : public ComponentPeer, TemporaryImage offscreenImageGenerator; //============================================================================== - class WindowClassHolder : private DeletedAtShutdown + class WindowClassHolder final : private DeletedAtShutdown { public: WindowClassHolder() @@ -2549,7 +2564,7 @@ class HWNDComponentPeer : public ComponentPeer, case WM_POINTERHWHEEL: case WM_POINTERUP: case WM_POINTERACTIVATE: - return isHWNDBlockedByModalComponents(m.hwnd); + return isHWNDBlockedByModalComponents (m.hwnd); case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDBLCLK: case WM_NCRBUTTONDOWN: @@ -3065,8 +3080,8 @@ class HWNDComponentPeer : public ComponentPeer, // This avoids a rare stuck-button problem when focus is lost unexpectedly, but must // not be called as part of a move, in case it's actually a mouse-drag from another // app which ends up here when we get focus before the mouse is released.. - if (isMouseDownEvent && getNativeRealtimeModifiers != nullptr) - getNativeRealtimeModifiers(); + if (isMouseDownEvent) + NullCheckedInvocation::invoke (getNativeRealtimeModifiers); updateKeyModifiers(); @@ -3955,8 +3970,8 @@ class HWNDComponentPeer : public ComponentPeer, { // Ensure that non-client areas are scaled for per-monitor DPI awareness v1 - can't // do this in peerWindowProc as we have no window at this point - if (message == WM_NCCREATE && enableNonClientDPIScaling != nullptr) - enableNonClientDPIScaling (h); + if (message == WM_NCCREATE) + NullCheckedInvocation::invoke (enableNonClientDPIScaling, h); if (auto* peer = getOwnerOfWindow (h)) { @@ -4354,10 +4369,10 @@ class HWNDComponentPeer : public ComponentPeer, case WM_IME_SETCONTEXT: imeHandler.handleSetContext (h, wParam == TRUE); lParam &= ~(LPARAM) ISC_SHOWUICOMPOSITIONWINDOW; - break; + return ImmIsUIMessage (h, message, wParam, lParam); case WM_IME_STARTCOMPOSITION: imeHandler.handleStartComposition (*this); return 0; - case WM_IME_ENDCOMPOSITION: imeHandler.handleEndComposition (*this, h); break; + case WM_IME_ENDCOMPOSITION: imeHandler.handleEndComposition (*this, h); return 0; case WM_IME_COMPOSITION: imeHandler.handleComposition (*this, h, lParam); return 0; case WM_GETDLGCODE: @@ -4855,7 +4870,7 @@ void MouseInputSource::setRawMousePosition (Point newPosition) } //============================================================================== -class ScreenSaverDefeater : public Timer +class ScreenSaverDefeater final : public Timer { public: ScreenSaverDefeater() @@ -5271,7 +5286,7 @@ class MouseCursor::PlatformSpecificHandle case NoCursor: return std::make_unique (nullptr); case WaitCursor: cursorName = IDC_WAIT; break; case IBeamCursor: cursorName = IDC_IBEAM; break; - case PointingHandCursor: cursorName = MAKEINTRESOURCE(32649); break; + case PointingHandCursor: cursorName = MAKEINTRESOURCE (32649); break; case CrosshairCursor: cursorName = IDC_CROSS; break; case LeftRightResizeCursor: diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_WindowsHooks_windows.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_WindowsHooks_windows.cpp index 5e21bef9..3d2ba76c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_WindowsHooks_windows.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_WindowsHooks_windows.cpp @@ -50,7 +50,7 @@ class WindowsHooks::Hooks if (nCode >= 0 && wParam == WM_MOUSEWHEEL) { // using a local copy of this struct to support old mingw libraries - struct MOUSEHOOKSTRUCTEX_ : public MOUSEHOOKSTRUCT { DWORD mouseData; }; + struct MOUSEHOOKSTRUCTEX_ final : public MOUSEHOOKSTRUCT { DWORD mouseData; }; auto& hs = *(MOUSEHOOKSTRUCTEX_*) lParam; @@ -65,12 +65,11 @@ class WindowsHooks::Hooks static LRESULT CALLBACK keyboardHookCallback (int nCode, WPARAM wParam, LPARAM lParam) { - MSG& msg = *(MSG*) lParam; + auto& msg = *reinterpret_cast (lParam); - if (nCode == HC_ACTION && wParam == PM_REMOVE - && HWNDComponentPeer::offerKeyMessageToJUCEWindow (msg)) + if (nCode == HC_ACTION && wParam == PM_REMOVE && HWNDComponentPeer::offerKeyMessageToJUCEWindow (msg)) { - zerostruct (msg); + msg = {}; msg.message = WM_USER; return 0; } diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp index 1812c0c6..98d10835 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp @@ -844,7 +844,7 @@ namespace Visuals } //================================= X11 - Bitmap =============================== -class XBitmapImage : public ImagePixelData +class XBitmapImage final : public ImagePixelData { public: explicit XBitmapImage (XImage* image) @@ -2261,8 +2261,7 @@ void XWindowSystem::setScreenSaverEnabled (bool enabled) const XWindowSystemUtilities::ScopedXLock xLock; - if (xScreenSaverSuspend != nullptr) - xScreenSaverSuspend (display, ! enabled); + NullCheckedInvocation::invoke (xScreenSaverSuspend, display, ! enabled); } Point XWindowSystem::getCurrentMousePosition() const diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index 0cfee9f6..29cd2679 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_MarkerList.cpp @@ -59,7 +59,7 @@ bool MarkerList::operator== (const MarkerList& other) const noexcept for (int i = markers.size(); --i >= 0;) { - const Marker* const m1 = markers.getUnchecked(i); + const Marker* const m1 = markers.getUnchecked (i); jassert (m1 != nullptr); const Marker* const m2 = other.getMarker (m1->name); @@ -96,7 +96,7 @@ MarkerList::Marker* MarkerList::getMarkerByName (const String& name) const noexc { for (int i = 0; i < markers.size(); ++i) { - Marker* const m = markers.getUnchecked(i); + Marker* const m = markers.getUnchecked (i); if (m->name == name) return m; @@ -135,7 +135,7 @@ void MarkerList::removeMarker (const String& name) { for (int i = 0; i < markers.size(); ++i) { - const Marker* const m = markers.getUnchecked(i); + const Marker* const m = markers.getUnchecked (i); if (m->name == name) { @@ -278,7 +278,7 @@ void MarkerList::ValueTreeWrapper::readFrom (const MarkerList& markerList, UndoM state.removeAllChildren (undoManager); for (int i = 0; i < markerList.getNumMarkers(); ++i) - setMarker (*markerList.getMarker(i), undoManager); + setMarker (*markerList.getMarker (i), undoManager); } } // namespace juce diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index be1322b2..6c802a38 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -26,7 +26,7 @@ namespace juce { -struct MarkerListScope : public Expression::Scope +struct MarkerListScope final : public Expression::Scope { MarkerListScope (Component& comp) : component (comp) {} @@ -156,7 +156,7 @@ Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponen } //============================================================================== -class RelativeCoordinatePositionerBase::DependencyFinderScope : public ComponentScope +class RelativeCoordinatePositionerBase::DependencyFinderScope final : public ComponentScope { public: DependencyFinderScope (Component& comp, RelativeCoordinatePositionerBase& p, bool& result) @@ -323,10 +323,10 @@ void RelativeCoordinatePositionerBase::registerMarkerListListener (MarkerList* c void RelativeCoordinatePositionerBase::unregisterListeners() { for (int i = sourceComponents.size(); --i >= 0;) - sourceComponents.getUnchecked(i)->removeComponentListener (this); + sourceComponents.getUnchecked (i)->removeComponentListener (this); for (int i = sourceMarkerLists.size(); --i >= 0;) - sourceMarkerLists.getUnchecked(i)->removeListener (this); + sourceMarkerLists.getUnchecked (i)->removeListener (this); sourceComponents.clear(); sourceMarkerLists.clear(); diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 04748c84..8c98d92b 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp @@ -37,7 +37,7 @@ RelativePointPath::RelativePointPath (const RelativePointPath& other) containsDynamicPoints (false) { for (int i = 0; i < other.elements.size(); ++i) - elements.add (other.elements.getUnchecked(i)->clone()); + elements.add (other.elements.getUnchecked (i)->clone()); } RelativePointPath::RelativePointPath (const Path& path) @@ -71,8 +71,8 @@ bool RelativePointPath::operator== (const RelativePointPath& other) const noexce for (int i = 0; i < elements.size(); ++i) { - ElementBase* const e1 = elements.getUnchecked(i); - ElementBase* const e2 = other.elements.getUnchecked(i); + ElementBase* const e1 = elements.getUnchecked (i); + ElementBase* const e2 = other.elements.getUnchecked (i); if (e1->type != e2->type) return false; @@ -106,7 +106,7 @@ void RelativePointPath::swapWith (RelativePointPath& other) noexcept void RelativePointPath::createPath (Path& path, Expression::Scope* scope) const { for (int i = 0; i < elements.size(); ++i) - elements.getUnchecked(i)->addToPath (path, scope); + elements.getUnchecked (i)->addToPath (path, scope); } bool RelativePointPath::containsAnyDynamicPoints() const diff --git a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp index a8ce138a..dae3cda4 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp @@ -64,7 +64,7 @@ namespace RelativeRectangleHelpers else { for (int i = e.getNumInputs(); --i >= 0;) - if (dependsOnSymbolsOtherThanThis (e.getInput(i))) + if (dependsOnSymbolsOtherThanThis (e.getInput (i))) return true; } @@ -116,7 +116,7 @@ bool RelativeRectangle::operator!= (const RelativeRectangle& other) const noexce //============================================================================== // An expression context that can evaluate expressions using "this" -class RelativeRectangleLocalScope : public Expression::Scope +class RelativeRectangleLocalScope final : public Expression::Scope { public: RelativeRectangleLocalScope (const RelativeRectangle& rect_) : rect (rect_) {} @@ -197,7 +197,7 @@ void RelativeRectangle::renameSymbol (const Expression::Symbol& oldSymbol, const } //============================================================================== -class RelativeRectangleComponentPositioner : public RelativeCoordinatePositionerBase +class RelativeRectangleComponentPositioner final : public RelativeCoordinatePositionerBase { public: RelativeRectangleComponentPositioner (Component& comp, const RelativeRectangle& r) diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index eaa5baed..64688c34 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp @@ -27,8 +27,8 @@ namespace juce { //============================================================================== -class ChoiceRemapperValueSource : public Value::ValueSource, - private Value::Listener +class ChoiceRemapperValueSource final : public Value::ValueSource, + private Value::Listener { public: ChoiceRemapperValueSource (const Value& source, const Array& map) @@ -68,8 +68,8 @@ class ChoiceRemapperValueSource : public Value::ValueSource, }; //============================================================================== -class ChoiceRemapperValueSourceWithDefault : public Value::ValueSource, - private Value::Listener +class ChoiceRemapperValueSourceWithDefault final : public Value::ValueSource, + private Value::Listener { public: ChoiceRemapperValueSourceWithDefault (const ValueTreePropertyWithDefault& v, const Array& map) @@ -136,13 +136,13 @@ ChoicePropertyComponent::ChoicePropertyComponent (const String& name) ChoicePropertyComponent::ChoicePropertyComponent (const String& name, const StringArray& choiceList, - const Array& correspondingValues) + [[maybe_unused]] const Array& correspondingValues) : PropertyComponent (name), choices (choiceList) { // The array of corresponding values must contain one value for each of the items in // the choices array! - jassertquiet (correspondingValues.size() == choices.size()); + jassert (correspondingValues.size() == choices.size()); } ChoicePropertyComponent::ChoicePropertyComponent (const Value& valueToControl, diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp index 77e51fa5..8503b3c0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp @@ -49,8 +49,8 @@ static void updateButtonTickColour (ToggleButton* button, bool usingDefault) } //============================================================================== -class MultiChoicePropertyComponent::MultiChoiceRemapperSource : public Value::ValueSource, - private Value::Listener +class MultiChoicePropertyComponent::MultiChoiceRemapperSource final : public Value::ValueSource, + private Value::Listener { public: MultiChoiceRemapperSource (const Value& source, var v, int c) @@ -107,8 +107,8 @@ class MultiChoicePropertyComponent::MultiChoiceRemapperSource : public Value: }; //============================================================================== -class MultiChoicePropertyComponent::MultiChoiceRemapperSourceWithDefault : public Value::ValueSource, - private Value::Listener +class MultiChoicePropertyComponent::MultiChoiceRemapperSourceWithDefault final : public Value::ValueSource, + private Value::Listener { public: MultiChoiceRemapperSourceWithDefault (const ValueTreePropertyWithDefault& val, @@ -209,12 +209,12 @@ int MultiChoicePropertyComponent::getTotalButtonsHeight (int numButtons) MultiChoicePropertyComponent::MultiChoicePropertyComponent (const String& propertyName, const StringArray& choices, - const Array& correspondingValues) + [[maybe_unused]] const Array& correspondingValues) : PropertyComponent (propertyName, jmin (getTotalButtonsHeight (choices.size()), collapsedHeight)) { // The array of corresponding values must contain one value for each of the items in // the choices array! - jassertquiet (choices.size() == correspondingValues.size()); + jassert (choices.size() == correspondingValues.size()); for (auto choice : choices) addAndMakeVisible (choiceButtons.add (new ToggleButton (choice))); @@ -334,8 +334,7 @@ void MultiChoicePropertyComponent::setExpanded (bool shouldBeExpanded) noexcept if (auto* propertyPanel = findParentComponentOfClass()) propertyPanel->resized(); - if (onHeightChange != nullptr) - onHeightChange(); + NullCheckedInvocation::invoke (onHeightChange); expandButton.setTransform (AffineTransform::rotation (expanded ? MathConstants::pi : MathConstants::twoPi, (float) expandButton.getBounds().getCentreX(), diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 6fc0eb3f..dc190ee0 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -44,7 +44,7 @@ void PropertyComponent::paint (Graphics& g) void PropertyComponent::resized() { - if (auto c = getChildComponent(0)) + if (auto c = getChildComponent (0)) c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this)); } diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index 65741ad9..6528581c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -26,7 +26,7 @@ namespace juce { -struct PropertyPanel::SectionComponent : public Component +struct PropertyPanel::SectionComponent final : public Component { SectionComponent (const String& sectionTitle, const Array& newProperties, @@ -136,7 +136,7 @@ struct PropertyPanel::SectionComponent : public Component }; //============================================================================== -struct PropertyPanel::PropertyHolderComponent : public Component +struct PropertyPanel::PropertyHolderComponent final : public Component { PropertyHolderComponent() {} @@ -200,7 +200,7 @@ PropertyPanel::PropertyPanel (const String& name) : Component (name) void PropertyPanel::init() { - messageWhenEmpty = TRANS("(nothing selected)"); + messageWhenEmpty = TRANS ("(nothing selected)"); addAndMakeVisible (viewport); viewport.setViewedComponent (propertyHolderComponent = new PropertyHolderComponent()); diff --git a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 27663aa1..797262bf 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -27,8 +27,8 @@ namespace juce { //============================================================================== -class TextPropertyComponent::LabelComp : public Label, - public FileDragAndDropTarget +class TextPropertyComponent::LabelComp final : public Label, + public FileDragAndDropTarget { public: LabelComp (TextPropertyComponent& tpc, int charLimit, bool multiline, bool editable) @@ -120,7 +120,7 @@ class TextPropertyComponent::LabelComp : public Label, }; //============================================================================== -class TextRemapperValueSourceWithDefault : public Value::ValueSource +class TextRemapperValueSourceWithDefault final : public Value::ValueSource { public: TextRemapperValueSourceWithDefault (const ValueTreePropertyWithDefault& v) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 21d64a4e..bcedfe3c 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -28,7 +28,7 @@ namespace juce ComboBox::ComboBox (const String& name) : Component (name), - noChoicesMessage (TRANS("(no choices)")) + noChoicesMessage (TRANS ("(no choices)")) { setRepaintsOnMouseActivity (true); lookAndFeelChanged(); @@ -625,8 +625,7 @@ void ComboBox::handleAsyncUpdate() if (checker.shouldBailOut()) return; - if (onChange != nullptr) - onChange(); + NullCheckedInvocation::invoke (onChange); if (checker.shouldBailOut()) return; @@ -651,7 +650,7 @@ void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange) void ComboBox::setText (const String& newText, const bool dontSendChange) { setText (newText, dontSendChange ? dontSendNotification : sendNotification); } //============================================================================== -class ComboBoxAccessibilityHandler : public AccessibilityHandler +class ComboBoxAccessibilityHandler final : public AccessibilityHandler { public: explicit ComboBoxAccessibilityHandler (ComboBox& comboBoxToWrap) @@ -674,7 +673,7 @@ class ComboBoxAccessibilityHandler : public AccessibilityHandler String getHelp() const override { return comboBox.getTooltip(); } private: - class ComboBoxValueInterface : public AccessibilityTextValueInterface + class ComboBoxValueInterface final : public AccessibilityTextValueInterface { public: explicit ComboBoxValueInterface (ComboBox& comboBoxToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp index 56d56d10..43861dfe 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp @@ -83,7 +83,7 @@ void ImageComponent::paint (Graphics& g) //============================================================================== std::unique_ptr ImageComponent::createAccessibilityHandler() { - class ImageComponentAccessibilityHandler : public AccessibilityHandler + class ImageComponentAccessibilityHandler final : public AccessibilityHandler { public: explicit ImageComponentAccessibilityHandler (ImageComponent& imageComponentToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp index 438c8d23..31dad478 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -202,8 +202,7 @@ void Label::editorShown (TextEditor* textEditor) if (checker.shouldBailOut()) return; - if (onEditorShow != nullptr) - onEditorShow(); + NullCheckedInvocation::invoke (onEditorShow); } void Label::editorAboutToBeHidden (TextEditor* textEditor) @@ -214,8 +213,7 @@ void Label::editorAboutToBeHidden (TextEditor* textEditor) if (checker.shouldBailOut()) return; - if (onEditorHide != nullptr) - onEditorHide(); + NullCheckedInvocation::invoke (onEditorHide); } void Label::showEditor() @@ -399,7 +397,7 @@ void Label::setMinimumHorizontalScale (const float newScale) //============================================================================== // We'll use a custom focus traverser here to make sure focus goes from the // text editor to another component rather than back to the label itself. -class LabelKeyboardFocusTraverser : public KeyboardFocusTraverser +class LabelKeyboardFocusTraverser final : public KeyboardFocusTraverser { public: explicit LabelKeyboardFocusTraverser (Label& l) : owner (l) {} @@ -463,8 +461,7 @@ void Label::callChangeListeners() if (checker.shouldBailOut()) return; - if (onTextChange != nullptr) - onTextChange(); + NullCheckedInvocation::invoke (onTextChange); } //============================================================================== @@ -504,11 +501,11 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed) } } -void Label::textEditorEscapeKeyPressed (TextEditor& ed) +void Label::textEditorEscapeKeyPressed ([[maybe_unused]] TextEditor& ed) { if (editor != nullptr) { - jassertquiet (&ed == editor.get()); + jassert (&ed == editor.get()); editor->setText (textValue.toString(), false); hideEditor (true); @@ -521,7 +518,7 @@ void Label::textEditorFocusLost (TextEditor& ed) } //============================================================================== -class LabelAccessibilityHandler : public AccessibilityHandler +class LabelAccessibilityHandler final : public AccessibilityHandler { public: explicit LabelAccessibilityHandler (Label& labelToWrap) @@ -545,7 +542,7 @@ class LabelAccessibilityHandler : public AccessibilityHandler } private: - class LabelValueInterface : public AccessibilityTextValueInterface + class LabelValueInterface final : public AccessibilityTextValueInterface { public: explicit LabelValueInterface (Label& labelToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 10adefa2..bb9fca48 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -151,8 +151,8 @@ class ComponentWithListRowMouseBehaviours : public Component }; //============================================================================== -class ListBox::RowComponent : public TooltipClient, - public ComponentWithListRowMouseBehaviours +class ListBox::RowComponent final : public TooltipClient, + public ComponentWithListRowMouseBehaviours { public: explicit RowComponent (ListBox& lb) : owner (lb) {} @@ -227,7 +227,7 @@ class ListBox::RowComponent : public TooltipClient, private: //============================================================================== - class RowAccessibilityHandler : public AccessibilityHandler + class RowAccessibilityHandler final : public AccessibilityHandler { public: explicit RowAccessibilityHandler (RowComponent& rowComponentToWrap) @@ -269,7 +269,7 @@ class ListBox::RowComponent : public TooltipClient, } private: - class RowCellInterface : public AccessibilityCellInterface + class RowCellInterface final : public AccessibilityCellInterface { public: explicit RowCellInterface (RowAccessibilityHandler& h) : handler (h) {} @@ -297,15 +297,15 @@ class ListBox::RowComponent : public TooltipClient, //============================================================================== -class ListBox::ListViewport : public Viewport, - private Timer +class ListBox::ListViewport final : public Viewport, + private Timer { public: ListViewport (ListBox& lb) : owner (lb) { setWantsKeyboardFocus (false); - struct IgnoredComponent : Component + struct IgnoredComponent final : public Component { std::unique_ptr createAccessibilityHandler() override { @@ -512,7 +512,7 @@ class ListBox::ListViewport : public Viewport, }; //============================================================================== -struct ListBoxMouseMoveSelector : public MouseListener +struct ListBoxMouseMoveSelector final : public MouseListener { ListBoxMouseMoveSelector (ListBox& lb) : owner (lb) { @@ -1159,7 +1159,7 @@ void ListBox::startDragAndDrop (const MouseEvent& e, const SparseSet& rowsT std::unique_ptr ListBox::createAccessibilityHandler() { - class TableInterface : public AccessibilityTableInterface + class TableInterface final : public AccessibilityTableInterface { public: explicit TableInterface (ListBox& listBoxToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index 5ca85b79..91964f80 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp @@ -133,7 +133,7 @@ void ProgressBar::timerCallback() //============================================================================== std::unique_ptr ProgressBar::createAccessibilityHandler() { - class ProgressBarAccessibilityHandler : public AccessibilityHandler + class ProgressBarAccessibilityHandler final : public AccessibilityHandler { public: explicit ProgressBarAccessibilityHandler (ProgressBar& progressBarToWrap) @@ -148,7 +148,7 @@ std::unique_ptr ProgressBar::createAccessibilityHandler() String getHelp() const override { return progressBar.getTooltip(); } private: - class ValueInterface : public AccessibilityRangedNumericValueInterface + class ValueInterface final : public AccessibilityRangedNumericValueInterface { public: explicit ValueInterface (ProgressBar& progressBarToWrap) diff --git a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp index efe8ec5b..03f945fb 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -359,8 +359,7 @@ class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwis if (checker.shouldBailOut()) return; - if (owner.onValueChange != nullptr) - owner.onValueChange(); + NullCheckedInvocation::invoke (owner.onValueChange); if (checker.shouldBailOut()) return; @@ -379,8 +378,7 @@ class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwis if (checker.shouldBailOut()) return; - if (owner.onDragStart != nullptr) - owner.onDragStart(); + NullCheckedInvocation::invoke (owner.onDragStart); } void sendDragEnd() @@ -394,8 +392,7 @@ class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwis if (checker.shouldBailOut()) return; - if (owner.onDragEnd != nullptr) - owner.onDragEnd(); + NullCheckedInvocation::invoke (owner.onDragEnd); } void incrementOrDecrement (double delta) @@ -1350,8 +1347,8 @@ class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwis std::unique_ptr