From f626ea0f7ea1ef09a5fa912825dcc1a16eb751df Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 17 May 2021 22:06:30 +0100 Subject: [PATCH] Define DISTRHO_DEPRECATED_BY and use it in a few places Signed-off-by: falkTX --- dgl/Base.hpp | 6 +++--- dgl/Geometry.hpp | 20 ++++++++++---------- dgl/Image.hpp | 2 +- dgl/OpenGL.hpp | 11 ++++++----- dgl/TopLevelWidget.hpp | 4 +++- dgl/Widget.hpp | 4 +++- dgl/Window.hpp | 8 ++++++-- distrho/src/DistrhoDefines.h | 9 +++++++++ 8 files changed, 41 insertions(+), 23 deletions(-) diff --git a/dgl/Base.hpp b/dgl/Base.hpp index e64a28cf..d726c6fc 100644 --- a/dgl/Base.hpp +++ b/dgl/Base.hpp @@ -67,9 +67,9 @@ enum Key { kKeyDelete = 0x7F, // Backwards compatibility with old DPF - kCharBackspace = kKeyBackspace, - kCharEscape = kKeyEscape, - kCharDelete = kKeyDelete, + kCharBackspace DISTRHO_DEPRECATED_BY("kKeyBackspace") = kKeyBackspace, + kCharEscape DISTRHO_DEPRECATED_BY("kKeyEscape") = kKeyEscape, + kCharDelete DISTRHO_DEPRECATED_BY("kKeyDelete") = kKeyDelete, // Unicode Private Use Area kKeyF1 = 0xE000, diff --git a/dgl/Geometry.hpp b/dgl/Geometry.hpp index cc48904c..078b9c35 100644 --- a/dgl/Geometry.hpp +++ b/dgl/Geometry.hpp @@ -374,7 +374,7 @@ public: Draw this line using the current OpenGL state. DEPRECATED please use draw(const GraphicsContext&) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)") void draw(); #endif @@ -492,14 +492,14 @@ public: Draw this circle using the current OpenGL state. DEPRECATED please use draw(const GraphicsContext&) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)") void draw(); /** Draw lines (outline of this circle) using the current OpenGL state. - DEPRECATED please use draw(const GraphicsContext&) instead. + DEPRECATED please use draw(const GraphicsContext&,T) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)") void drawOutline(); #endif @@ -585,14 +585,14 @@ public: Draw this triangle using the current OpenGL state. DEPRECATED please use draw(const GraphicsContext&) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)") void draw(); /** Draw lines (outline of this triangle) using the current OpenGL state. - DEPRECATED please use draw(const GraphicsContext&) instead. + DEPRECATED please use draw(const GraphicsContext&,T) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)") void drawOutline(); #endif @@ -804,14 +804,14 @@ public: Draw this rectangle using the current OpenGL state. DEPRECATED please use draw(const GraphicsContext&) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)") void draw(); /** DEPRECATED Draw lines (outline of this rectangle) using the current OpenGL state. - DEPRECATED please use drawOutline(const GraphicsContext&) instead. + DEPRECATED please use drawOutline(const GraphicsContext&,T) instead. */ - // TODO mark deprecated + DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)") void drawOutline(); private: diff --git a/dgl/Image.hpp b/dgl/Image.hpp index 138a9147..0a3a5db9 100644 --- a/dgl/Image.hpp +++ b/dgl/Image.hpp @@ -22,7 +22,7 @@ START_NAMESPACE_DGL -// TODO mark as deprecated +DISTRHO_DEPRECATED_BY("OpenGLImage") typedef OpenGLImage Image; END_NAMESPACE_DGL diff --git a/dgl/OpenGL.hpp b/dgl/OpenGL.hpp index 8dff7f74..8c0d87d0 100644 --- a/dgl/OpenGL.hpp +++ b/dgl/OpenGL.hpp @@ -180,19 +180,19 @@ public: /** Draw this image at (0, 0) point using the current OpenGL context. */ - // TODO mark as deprecated + DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)") void draw(); /** Draw this image at (x, y) point using the current OpenGL context. */ - // TODO mark as deprecated + DISTRHO_DEPRECATED_BY("drawAt(const GraphicsContext&,int,int)") void drawAt(const int x, const int y); /** Draw this image at position @a pos using the current OpenGL context. */ - // TODO mark as deprecated + DISTRHO_DEPRECATED_BY("drawAt(const GraphicsContext&,const Point&)") void drawAt(const Point& pos); // FIXME this should not be needed @@ -203,8 +203,9 @@ public: /** Get the image type. + DEPRECATED Type is always assumed to be GL_UNSIGNED_BYTE. */ - // TODO mark as deprecated + DISTRHO_DEPRECATED GLenum getType() const noexcept { return GL_UNSIGNED_BYTE; } private: @@ -216,7 +217,7 @@ private: typedef ImageBaseAboutWindow OpenGLImageAboutWindow; -// TODO deprecated +DISTRHO_DEPRECATED_BY("OpenGLImageAboutWindow") typedef OpenGLImageAboutWindow ImageAboutWindow; // ----------------------------------------------------------------------- diff --git a/dgl/TopLevelWidget.hpp b/dgl/TopLevelWidget.hpp index e7ac44d3..165f41bd 100644 --- a/dgl/TopLevelWidget.hpp +++ b/dgl/TopLevelWidget.hpp @@ -77,8 +77,10 @@ public: bool keepAspectRatio = false, bool automaticallyScale = false); - // TODO deprecated + DISTRHO_DEPRECATED_BY("getApp()") Application& getParentApp() const noexcept { return getApp(); } + + DISTRHO_DEPRECATED_BY("getWindow()") Window& getParentWindow() const noexcept { return getWindow(); } private: diff --git a/dgl/Widget.hpp b/dgl/Widget.hpp index 0db175b1..fe01ed1e 100644 --- a/dgl/Widget.hpp +++ b/dgl/Widget.hpp @@ -172,8 +172,10 @@ public: */ virtual void repaint() noexcept; - // TODO deprecated + DISTRHO_DEPRECATED_BY("getApp()") Application& getParentApp() const noexcept { return getApp(); } + + DISTRHO_DEPRECATED_BY("getWindow()") Window& getParentWindow() const noexcept { return getWindow(); } protected: diff --git a/dgl/Window.hpp b/dgl/Window.hpp index f363820a..d4d109bb 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -276,9 +276,13 @@ public: void setTransientWinId(uintptr_t winId); */ - // TODO deprecated + DISTRHO_DEPRECATED_BY("isIgnoringKeyRepeat()") inline bool getIgnoringKeyRepeat() const noexcept { return isIgnoringKeyRepeat(); } - inline double getScaling() const noexcept { return getScaling(); } + + DISTRHO_DEPRECATED_BY("getScaleFactor()") + inline double getScaling() const noexcept { return getScaleFactor(); } + + DISTRHO_DEPRECATED_BY("runAsModal(bool)") inline void exec(bool blockWait = false) { runAsModal(blockWait); } protected: diff --git a/distrho/src/DistrhoDefines.h b/distrho/src/DistrhoDefines.h index a2e5522c..a30bc296 100644 --- a/distrho/src/DistrhoDefines.h +++ b/distrho/src/DistrhoDefines.h @@ -75,6 +75,15 @@ # define DISTRHO_DEPRECATED #endif +/* Define DISTRHO_DEPRECATED_BY */ +#if defined(__clang__) +# define DISTRHO_DEPRECATED_BY(other) __attribute__((deprecated("", other))) +#elif defined(__GNUC__) +# define DISTRHO_DEPRECATED_BY(other) __attribute__((deprecated("Use " other))) +#else +# define DISTRHO_DEPRECATED_BY(other) DISTRHO_DEPRECATED +#endif + /* Define DISTRHO_SAFE_ASSERT* */ #define DISTRHO_SAFE_ASSERT(cond) if (! (cond)) d_safe_assert(#cond, __FILE__, __LINE__); #define DISTRHO_SAFE_ASSERT_BREAK(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); break; }