From e6e96de0fdae0ca6c8f89f9a915ca6cbc388b11f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 21 May 2021 14:13:13 -0400 Subject: [PATCH] Replace most inclusions of MemoryX.h with ... ... Most often it was needed for a custom definition of std::make_unique, but we build C++14 now. --- src/AudacityApp.h | 2 +- src/AudioIOBase.cpp | 1 + src/DeviceChange.h | 2 +- src/FileFormats.cpp | 1 + src/FileFormats.h | 2 +- src/FileIO.h | 2 +- src/FileNames.cpp | 2 +- src/FileNames.h | 2 +- src/HitTestResult.h | 2 +- src/ImageManipulation.h | 3 +- src/MemoryX.h | 58 --------------------------- src/ModuleManager.cpp | 1 + src/ModuleManager.h | 2 +- src/Prefs.cpp | 1 + src/Registrar.h | 2 +- src/SelectionState.h | 2 +- src/Theme.cpp | 1 + src/TrackPanelCell.h | 2 +- src/TrackPanelDrawingContext.h | 2 +- src/TrackPanelMouseEvent.h | 2 +- src/UIHandle.h | 4 +- src/ViewInfo.h | 2 +- src/commands/AppCommandEvent.h | 2 +- src/commands/CommandBuilder.h | 3 +- src/commands/CommandHandler.h | 2 +- src/commands/CommandTargets.h | 3 +- src/commands/LoadCommands.h | 2 +- src/commands/ScriptCommandRelay.h | 2 +- src/effects/EBUR128.h | 2 +- src/effects/Equalization48x.h | 2 +- src/effects/LoadEffects.h | 2 +- src/effects/RealtimeEffectManager.cpp | 2 +- src/effects/TimeWarper.h | 2 +- src/effects/VST/VSTControlOSX.mm | 2 +- src/effects/lv2/LoadLV2.h | 2 +- src/export/ExportMP3.h | 2 +- src/import/ImportForwards.h | 2 +- src/import/ImportRaw.h | 2 +- src/toolbars/ToolDock.h | 1 + src/tracks/ui/PlayIndicatorOverlay.h | 2 +- src/tracks/ui/SliderHandle.h | 1 + src/widgets/Grid.cpp | 1 + src/widgets/NumericTextCtrl.h | 2 +- src/widgets/OverlayPanel.cpp | 1 + src/widgets/PopupMenuTable.h | 2 +- src/widgets/valnum.h | 2 +- src/widgets/wxPanelWrapper.h | 2 +- 47 files changed, 49 insertions(+), 97 deletions(-) diff --git a/src/AudacityApp.h b/src/AudacityApp.h index 768202d08..a5c0eaaed 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -22,7 +22,7 @@ #include // to inherit #include // member variable -#include "MemoryX.h" +#include class wxSingleInstanceChecker; class wxSocketEvent; diff --git a/src/AudioIOBase.cpp b/src/AudioIOBase.cpp index 2425e7fff..75736086a 100644 --- a/src/AudioIOBase.cpp +++ b/src/AudioIOBase.cpp @@ -17,6 +17,7 @@ Paul Licameli split from AudioIO.cpp #include #include +#include "MemoryX.h" #include "Prefs.h" #include "widgets/MeterPanelBase.h" diff --git a/src/DeviceChange.h b/src/DeviceChange.h index e9eb475db..bc373f77e 100644 --- a/src/DeviceChange.h +++ b/src/DeviceChange.h @@ -17,7 +17,7 @@ #if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER) -#include "MemoryX.h" +#include #if defined(__WXMSW__) || defined(__WXMAC__) || defined(HAVE_LIBUDEV_H) #define HAVE_DEVICE_CHANGE diff --git a/src/FileFormats.cpp b/src/FileFormats.cpp index 457dae154..7cc054581 100644 --- a/src/FileFormats.cpp +++ b/src/FileFormats.cpp @@ -22,6 +22,7 @@ information. #include #include "sndfile.h" #include "Internat.h" +#include "MemoryX.h" #include "widgets/AudacityMessageBox.h" #include "Prefs.h" diff --git a/src/FileFormats.h b/src/FileFormats.h index efc8b69e8..03619f180 100644 --- a/src/FileFormats.h +++ b/src/FileFormats.h @@ -17,7 +17,7 @@ #include "Identifier.h" //#include -#include "MemoryX.h" +#include #include "sndfile.h" diff --git a/src/FileIO.h b/src/FileIO.h index e970946e6..c188b8403 100644 --- a/src/FileIO.h +++ b/src/FileIO.h @@ -11,7 +11,7 @@ #ifndef __AUDACITY_FILEIO__ #define __AUDACITY_FILEIO__ -#include "MemoryX.h" +#include class wxInputStream; class wxOutputStream; diff --git a/src/FileNames.cpp b/src/FileNames.cpp index 2e238b856..2e5b861c4 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -25,7 +25,7 @@ used throughout Audacity into this one place. -#include "MemoryX.h" +#include #include #include diff --git a/src/FileNames.h b/src/FileNames.h index 71074c82a..92be64df3 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -17,7 +17,7 @@ #include // function return value #include "Identifier.h" #include "Prefs.h" -#include "MemoryX.h" +#include // Please try to support unlimited path length instead of using PLATFORM_MAX_PATH! // Define one constant for maximum path value, so we don't have to do diff --git a/src/HitTestResult.h b/src/HitTestResult.h index 737d13173..7b888ccb9 100644 --- a/src/HitTestResult.h +++ b/src/HitTestResult.h @@ -11,7 +11,7 @@ Paul Licameli #ifndef __AUDACITY_HIT_TEST_RESULT__ #define __AUDACITY_HIT_TEST_RESULT__ -#include "MemoryX.h" +#include #include "Internat.h" // for TranslatableString class wxCursor; diff --git a/src/ImageManipulation.h b/src/ImageManipulation.h index 164059a99..a65e2bb41 100644 --- a/src/ImageManipulation.h +++ b/src/ImageManipulation.h @@ -8,11 +8,12 @@ **********************************************************************/ -#include "MemoryX.h" +#include #include class wxColour; class wxImage; +class wxRect; // This looks at the first pixel in the image, and shifts // the entire image by the vector difference between that diff --git a/src/MemoryX.h b/src/MemoryX.h index cb8f36458..213d4db26 100644 --- a/src/MemoryX.h +++ b/src/MemoryX.h @@ -10,64 +10,6 @@ #include -#if !(_MSC_VER >= 1800 || __cplusplus >= 201402L) -/* replicate the very useful C++14 make_unique for those build environments -that don't implement it yet. -typical usage: -auto p = std::make_unique(ctorArg1, ctorArg2, ... ctorArgN); -p->DoSomething(); -auto q = std::make_unique(count); -q[0].DoSomethingElse(); - -The first hides naked NEW and DELETE from the source code. -The second hides NEW[] and DELETE[]. Both of course ensure destruction if -you don't use something like std::move(p) or q.release(). Both expressions require -that you identify the type only once, which is brief and less error prone. - -(Whereas this omission of [] might invite a runtime error: -std::unique_ptr q { safenew Myclass[count] }; ) - -Some C++11 tricks needed here are (1) variadic argument lists and -(2) making the compile-time dispatch work correctly. You can't have -a partially specialized template function, but you get the effect of that -by other metaprogramming means. -*/ - -namespace std { - // For overloading resolution - template struct __make_unique_result { - using scalar_case = unique_ptr; - }; - - // Partial specialization of the struct for array case - template struct __make_unique_result { - using array_case = unique_ptr; - using element = X; - }; - - // Now the scalar version of unique_ptr - template inline - typename __make_unique_result::scalar_case - make_unique(Args&&... args) - { - return typename __make_unique_result::scalar_case - { safenew X(forward(args)...) }; - } - - // Now the array version of unique_ptr - // The compile-time dispatch trick is that the non-existence - // of the scalar_case type makes the above overload - // unavailable when the template parameter is explicit - template inline - typename __make_unique_result::array_case - make_unique(size_t count) - { - return typename __make_unique_result::array_case - { safenew typename __make_unique_result::element[count] }; - } -} -#endif - /* * ArrayOf * Not to be confused with std::array (which takes a fixed size) or std::vector diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index ff0c67205..a5d8b8804 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -30,6 +30,7 @@ i.e. an alternative to the usual interface, for Audacity. #include #include "FileNames.h" +#include "MemoryX.h" #include "PluginManager.h" #include "audacity/PluginInterface.h" diff --git a/src/ModuleManager.h b/src/ModuleManager.h index 21efc330e..3954ff700 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -12,7 +12,7 @@ #ifndef __AUDACITY_MODULEMANAGER_H__ #define __AUDACITY_MODULEMANAGER_H__ -#include "MemoryX.h" +#include #include #include diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 3978762ff..6dab73e7e 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -61,6 +61,7 @@ #include "Internat.h" #include "MemoryX.h" +#include std::unique_ptr ugPrefs {}; diff --git a/src/Registrar.h b/src/Registrar.h index a499884ad..938d29705 100644 --- a/src/Registrar.h +++ b/src/Registrar.h @@ -22,7 +22,7 @@ responsible for calling the appropriate callback functions. -#include "MemoryX.h" +#include class AudacityCommand; class LoadableModule; diff --git a/src/SelectionState.h b/src/SelectionState.h index 053d583e3..6ccbeb4ad 100644 --- a/src/SelectionState.h +++ b/src/SelectionState.h @@ -14,7 +14,7 @@ class Track; class TrackList; class ViewInfo; #include "ClientData.h" -#include "MemoryX.h" +#include #include // State relating to the set of selected tracks diff --git a/src/Theme.cpp b/src/Theme.cpp index 146137f07..ef8a694cf 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -77,6 +77,7 @@ can't be. #include "Prefs.h" #include "ImageManipulation.h" #include "Internat.h" +#include "MemoryX.h" #include "widgets/AudacityMessageBox.h" // JKC: First get the MAC specific images. diff --git a/src/TrackPanelCell.h b/src/TrackPanelCell.h index eee46533a..508e1e9d0 100644 --- a/src/TrackPanelCell.h +++ b/src/TrackPanelCell.h @@ -13,7 +13,7 @@ Paul Licameli -#include "MemoryX.h" +#include #include "TrackPanelDrawable.h" // to inherit class AudacityProject; diff --git a/src/TrackPanelDrawingContext.h b/src/TrackPanelDrawingContext.h index b743fc465..7adb195db 100644 --- a/src/TrackPanelDrawingContext.h +++ b/src/TrackPanelDrawingContext.h @@ -11,7 +11,7 @@ #ifndef __AUDACITY_TRACK_PANEL_DRAWING_CONTEXT__ #define __AUDACITY_TRACK_PANEL_DRAWING_CONTEXT__ -#include "MemoryX.h" +#include class UIHandle; using UIHandlePtr = std::shared_ptr; diff --git a/src/TrackPanelMouseEvent.h b/src/TrackPanelMouseEvent.h index 6be261be9..868587156 100644 --- a/src/TrackPanelMouseEvent.h +++ b/src/TrackPanelMouseEvent.h @@ -16,7 +16,7 @@ class wxMouseState; class wxRect; class wxSize; class TrackPanelCell; -#include "MemoryX.h" +#include // This is a hack so that the code that fakes a MOUSE_LEFT_BTN_UP on // capture lost doesn't get in the way of handling MOUSE_RIGHT_BTN_UP. diff --git a/src/UIHandle.h b/src/UIHandle.h index 099aa0654..fd5791b8d 100644 --- a/src/UIHandle.h +++ b/src/UIHandle.h @@ -12,7 +12,7 @@ Paul Licameli #define __AUDACITY_UI_HANDLE__ #include -#include "MemoryX.h" +#include #include "TrackPanelDrawable.h" // to inherit class wxDC; @@ -26,8 +26,6 @@ class TrackPanelCell; struct TrackPanelMouseEvent; struct TrackPanelMouseState; -#include "MemoryX.h" - /// \brief Short-lived drawing and event-handling object associated with a TrackPanelCell // A TrackPanelCell reports a handle object of some subclass, in response to a // hit test at a mouse position; then this handle processes certain events, diff --git a/src/ViewInfo.h b/src/ViewInfo.h index 46a09769a..10f2a2d46 100644 --- a/src/ViewInfo.h +++ b/src/ViewInfo.h @@ -16,7 +16,7 @@ #include // inherit wxEvtHandler #include // member variable #include "SelectedRegion.h" -#include "MemoryX.h" +#include #include "ZoomInfo.h" // to inherit diff --git a/src/commands/AppCommandEvent.h b/src/commands/AppCommandEvent.h index e8cfd9dac..462523826 100644 --- a/src/commands/AppCommandEvent.h +++ b/src/commands/AppCommandEvent.h @@ -19,7 +19,7 @@ #include // to declare custom event types -#include "../MemoryX.h" +#include DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED, -1); diff --git a/src/commands/CommandBuilder.h b/src/commands/CommandBuilder.h index 48949209c..036d3acab 100644 --- a/src/commands/CommandBuilder.h +++ b/src/commands/CommandBuilder.h @@ -16,7 +16,8 @@ #ifndef __COMMANDBUILDER__ #define __COMMANDBUILDER__ -#include "../MemoryX.h" +#include +#include class AudacityProject; class ResponseTarget; diff --git a/src/commands/CommandHandler.h b/src/commands/CommandHandler.h index 07b10e0ad..6a71923a7 100644 --- a/src/commands/CommandHandler.h +++ b/src/commands/CommandHandler.h @@ -16,7 +16,7 @@ #ifndef __COMMANDHANDLER__ #define __COMMANDHANDLER__ -#include "../MemoryX.h" +#include class AudacityApp; class AudacityProject; class AppCommandEvent; diff --git a/src/commands/CommandTargets.h b/src/commands/CommandTargets.h index e9e021210..e836419e9 100644 --- a/src/commands/CommandTargets.h +++ b/src/commands/CommandTargets.h @@ -55,8 +55,9 @@ and sends it to that message target. #ifndef __COMMANDTARGETS__ #define __COMMANDTARGETS__ -#include "../MemoryX.h" +#include #include +#include #include class wxStatusBar; diff --git a/src/commands/LoadCommands.h b/src/commands/LoadCommands.h index f8b1dfbc2..9aacbdfc9 100644 --- a/src/commands/LoadCommands.h +++ b/src/commands/LoadCommands.h @@ -17,7 +17,7 @@ #include #include #include -#include "../MemoryX.h" +#include class AudacityCommand; diff --git a/src/commands/ScriptCommandRelay.h b/src/commands/ScriptCommandRelay.h index da8361a38..d2350d0f0 100644 --- a/src/commands/ScriptCommandRelay.h +++ b/src/commands/ScriptCommandRelay.h @@ -18,7 +18,7 @@ -#include "../MemoryX.h" +#include class wxString; diff --git a/src/effects/EBUR128.h b/src/effects/EBUR128.h index 4148f4c35..e12b76263 100644 --- a/src/effects/EBUR128.h +++ b/src/effects/EBUR128.h @@ -12,7 +12,7 @@ Max Maisel #define __EBUR128_H__ #include "Biquad.h" -#include "MemoryX.h" +#include #include "SampleFormat.h" /// \brief Implements EBU-R128 loudness measurement. diff --git a/src/effects/Equalization48x.h b/src/effects/Equalization48x.h index cf8883a94..1335ceea0 100644 --- a/src/effects/Equalization48x.h +++ b/src/effects/Equalization48x.h @@ -13,7 +13,7 @@ Intrinsics (SSE/AVX) and Threaded Equalization #ifdef EXPERIMENTAL_EQ_SSE_THREADED -#include "../MemoryX.h" +#include #include // to inherit #include diff --git a/src/effects/LoadEffects.h b/src/effects/LoadEffects.h index 245cbad07..29fdc613a 100644 --- a/src/effects/LoadEffects.h +++ b/src/effects/LoadEffects.h @@ -16,7 +16,7 @@ #include #include #include -#include "../MemoryX.h" +#include class Effect; diff --git a/src/effects/RealtimeEffectManager.cpp b/src/effects/RealtimeEffectManager.cpp index 8fccb4764..b20a6a17f 100644 --- a/src/effects/RealtimeEffectManager.cpp +++ b/src/effects/RealtimeEffectManager.cpp @@ -12,7 +12,7 @@ #include "RealtimeEffectManager.h" #include "audacity/EffectInterface.h" -#include "MemoryX.h" +#include #include #include diff --git a/src/effects/TimeWarper.h b/src/effects/TimeWarper.h index 223e48d03..7d42f5cde 100644 --- a/src/effects/TimeWarper.h +++ b/src/effects/TimeWarper.h @@ -56,7 +56,7 @@ of the warped region. #ifndef __TIMEWARPER__ #define __TIMEWARPER__ -#include "../MemoryX.h" +#include class AUDACITY_DLL_API TimeWarper /* not final */ { diff --git a/src/effects/VST/VSTControlOSX.mm b/src/effects/VST/VSTControlOSX.mm index cb8aafa30..f27be106a 100644 --- a/src/effects/VST/VSTControlOSX.mm +++ b/src/effects/VST/VSTControlOSX.mm @@ -24,7 +24,7 @@ #include "VSTControlOSX.h" -#include "../../MemoryX.h" +#include @interface VSTView : NSView { diff --git a/src/effects/lv2/LoadLV2.h b/src/effects/lv2/LoadLV2.h index e5046561b..35430aa26 100755 --- a/src/effects/lv2/LoadLV2.h +++ b/src/effects/lv2/LoadLV2.h @@ -12,7 +12,7 @@ #ifndef LV2EFFECTSMODULE_H #define LV2EFFECTSMODULE_H -#include "../../MemoryX.h" +#include #include "lilv/lilv.h" diff --git a/src/export/ExportMP3.h b/src/export/ExportMP3.h index 11528fe83..b90cd5c0b 100644 --- a/src/export/ExportMP3.h +++ b/src/export/ExportMP3.h @@ -13,7 +13,7 @@ /* --------------------------------------------------------------------------*/ -#include "../MemoryX.h" +#include enum MP3RateMode : unsigned { MODE_SET = 0, diff --git a/src/import/ImportForwards.h b/src/import/ImportForwards.h index ee957abc3..4c180d63a 100644 --- a/src/import/ImportForwards.h +++ b/src/import/ImportForwards.h @@ -10,7 +10,7 @@ #define __AUDACITY_IMPORT_FORWARDS__ #include -#include "../MemoryX.h" +#include class ImportPlugin; class UnusableImportPlugin; diff --git a/src/import/ImportRaw.h b/src/import/ImportRaw.h index fcd5d670b..cd54b90ec 100644 --- a/src/import/ImportRaw.h +++ b/src/import/ImportRaw.h @@ -11,7 +11,7 @@ #ifndef __AUDACITY_IMPORT_RAW__ #define __AUDACITY_IMPORT_RAW__ -#include "../MemoryX.h" +#include class AudacityProject; class WaveTrackFactory; diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index c7099e836..758dd4e10 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -17,6 +17,7 @@ #include #include "ToolBar.h" +#include "../MemoryX.h" class wxCommandEvent; class wxEraseEvent; diff --git a/src/tracks/ui/PlayIndicatorOverlay.h b/src/tracks/ui/PlayIndicatorOverlay.h index 459344b33..0a680d8bb 100644 --- a/src/tracks/ui/PlayIndicatorOverlay.h +++ b/src/tracks/ui/PlayIndicatorOverlay.h @@ -12,7 +12,7 @@ Paul Licameli split from TrackPanel.cpp #define __AUDACITY_PLAY_INDICATOR_OVERLAY__ #include // to inherit -#include "../../MemoryX.h" +#include #include "../../ClientData.h" #include "../../widgets/Overlay.h" // to inherit diff --git a/src/tracks/ui/SliderHandle.h b/src/tracks/ui/SliderHandle.h index 13bfb9943..259ccd16b 100644 --- a/src/tracks/ui/SliderHandle.h +++ b/src/tracks/ui/SliderHandle.h @@ -14,6 +14,7 @@ Paul Licameli #include "../../UIHandle.h" class wxMouseEvent; +class wxMouseState; class LWSlider; class Track; class TranslatableString; diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index ffbdf6182..c4b9e5fca 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -27,6 +27,7 @@ #include #include +#include "../MemoryX.h" #include "../SelectedRegion.h" #if wxUSE_ACCESSIBILITY diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index 805061719..f32a83f48 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -17,7 +17,7 @@ -#include "../MemoryX.h" +#include #include "../../include/audacity/ComponentInterface.h" #include #include // for wxUSE_* macros diff --git a/src/widgets/OverlayPanel.cpp b/src/widgets/OverlayPanel.cpp index 5224098f2..49156b146 100644 --- a/src/widgets/OverlayPanel.cpp +++ b/src/widgets/OverlayPanel.cpp @@ -10,6 +10,7 @@ #include "OverlayPanel.h" #include "Overlay.h" +#include "../MemoryX.h" #include #include diff --git a/src/widgets/PopupMenuTable.h b/src/widgets/PopupMenuTable.h index 32d9bbe01..7cec9b61a 100644 --- a/src/widgets/PopupMenuTable.h +++ b/src/widgets/PopupMenuTable.h @@ -23,7 +23,7 @@ class wxCommandEvent; #include #include #include // to inherit wxMenu -#include "../MemoryX.h" +#include #include "Internat.h" #include "../commands/CommandManager.h" diff --git a/src/widgets/valnum.h b/src/widgets/valnum.h index 792c5a0b5..72b049f96 100644 --- a/src/widgets/valnum.h +++ b/src/widgets/valnum.h @@ -11,7 +11,7 @@ #ifndef _WIDGETS_VALNUM_H_ #define _WIDGETS_VALNUM_H_ -#include "../MemoryX.h" +#include #include // for wxUSE_* macros #include diff --git a/src/widgets/wxPanelWrapper.h b/src/widgets/wxPanelWrapper.h index 3163a6f88..6fb428a73 100644 --- a/src/widgets/wxPanelWrapper.h +++ b/src/widgets/wxPanelWrapper.h @@ -9,7 +9,7 @@ #ifndef __AUDACITY_WXPANEL_WRAPPER__ #define __AUDACITY_WXPANEL_WRAPPER__ -#include "../MemoryX.h" +#include #include // to inherit #include // to inherit