Cleanup: use 'override' specifier for GHOST: X11, SDL & None with CLANG

Clang would warn about failure to use 'override' when a single
method was added that used 'override' when none of the other methods
did.

This meant a single correct use of override caused noisy compiler
warnings (for CLANG but not GCC).
Avoid this by using 'override' where appropriate.
This commit is contained in:
Campbell Barton
2023-03-28 12:14:18 +11:00
parent 47e065f165
commit 2ec4ce18ae
9 changed files with 120 additions and 120 deletions

View File

@@ -43,52 +43,52 @@ class GHOST_ContextEGL : public GHOST_Context {
/**
* Destructor.
*/
~GHOST_ContextEGL();
~GHOST_ContextEGL() override;
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
GHOST_TSuccess swapBuffers();
GHOST_TSuccess swapBuffers() override;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
GHOST_TSuccess activateDrawingContext();
GHOST_TSuccess activateDrawingContext() override;
/**
* Release the drawing context of the calling thread.
* \return A boolean success indicator.
*/
GHOST_TSuccess releaseDrawingContext();
GHOST_TSuccess releaseDrawingContext() override;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \return Indication as to whether initialization has succeeded.
*/
GHOST_TSuccess initializeDrawingContext();
GHOST_TSuccess initializeDrawingContext() override;
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
GHOST_TSuccess releaseNativeHandles();
GHOST_TSuccess releaseNativeHandles() override;
/**
* Sets the swap interval for #swapBuffers.
* \param interval: The swap interval to use.
* \return A boolean success indicator.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Gets the current swap interval for #swapBuffers.
* \param intervalOut: Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
GHOST_TSuccess getSwapInterval(int &intervalOut) override;
EGLDisplay getDisplay() const;

View File

@@ -41,52 +41,52 @@ class GHOST_ContextGLX : public GHOST_Context {
/**
* Destructor.
*/
~GHOST_ContextGLX();
~GHOST_ContextGLX() override;
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
GHOST_TSuccess swapBuffers();
GHOST_TSuccess swapBuffers() override;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
GHOST_TSuccess activateDrawingContext();
GHOST_TSuccess activateDrawingContext() override;
/**
* Release the drawing context of the calling thread.
* \return A boolean success indicator.
*/
GHOST_TSuccess releaseDrawingContext();
GHOST_TSuccess releaseDrawingContext() override;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \return Indication as to whether initialization has succeeded.
*/
GHOST_TSuccess initializeDrawingContext();
GHOST_TSuccess initializeDrawingContext() override;
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
GHOST_TSuccess releaseNativeHandles();
GHOST_TSuccess releaseNativeHandles() override;
/**
* Sets the swap interval for #swapBuffers.
* \param interval: The swap interval to use.
* \return A boolean success indicator.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Gets the current swap interval for #swapBuffers.
* \param intervalOut: Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
GHOST_TSuccess getSwapInterval(int &intervalOut) override;
private:
Display *m_display;

View File

@@ -21,50 +21,50 @@ class GHOST_ContextNone : public GHOST_Context {
* Dummy function
* \return Always succeeds
*/
GHOST_TSuccess swapBuffers();
GHOST_TSuccess swapBuffers() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess activateDrawingContext();
GHOST_TSuccess activateDrawingContext() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess releaseDrawingContext();
GHOST_TSuccess releaseDrawingContext() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess updateDrawingContext();
GHOST_TSuccess updateDrawingContext() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess initializeDrawingContext();
GHOST_TSuccess initializeDrawingContext() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess releaseNativeHandles();
GHOST_TSuccess releaseNativeHandles() override;
/**
* Dummy function
* \return Always succeeds.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Dummy function
* \param intervalOut: Gets whatever was set by #setSwapInterval.
* \return Always succeeds.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
GHOST_TSuccess getSwapInterval(int &intervalOut) override;
private:
int m_swapInterval;

View File

@@ -41,52 +41,52 @@ class GHOST_ContextSDL : public GHOST_Context {
/**
* Destructor.
*/
~GHOST_ContextSDL();
~GHOST_ContextSDL() override;
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
GHOST_TSuccess swapBuffers();
GHOST_TSuccess swapBuffers() override;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
GHOST_TSuccess activateDrawingContext();
GHOST_TSuccess activateDrawingContext() override;
/**
* Release the drawing context of the calling thread.
* \return A boolean success indicator.
*/
GHOST_TSuccess releaseDrawingContext();
GHOST_TSuccess releaseDrawingContext() override;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \return Indication as to whether initialization has succeeded.
*/
GHOST_TSuccess initializeDrawingContext();
GHOST_TSuccess initializeDrawingContext() override;
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
GHOST_TSuccess releaseNativeHandles();
GHOST_TSuccess releaseNativeHandles() override;
/**
* Sets the swap interval for #swapBuffers.
* \param interval: The swap interval to use.
* \return A boolean success indicator.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Gets the current swap interval for #swapBuffers.
* \param intervalOut: Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
GHOST_TSuccess getSwapInterval(int &intervalOut) override;
private:
SDL_Window *m_window;

View File

@@ -770,7 +770,7 @@ void GHOST_SystemSDL::putClipboard(const char *buffer, bool /*selection*/) const
SDL_SetClipboardText(buffer);
}
uint64_t GHOST_SystemSDL::getMilliSeconds()
uint64_t GHOST_SystemSDL::getMilliSeconds() const
{
return uint64_t(SDL_GetTicks()); /* NOTE: 32 -> 64bits. */
}

View File

@@ -31,41 +31,41 @@ class GHOST_SystemSDL : public GHOST_System {
GHOST_SystemSDL();
~GHOST_SystemSDL();
bool processEvents(bool waitForEvent);
bool processEvents(bool waitForEvent) override;
bool setConsoleWindowState(GHOST_TConsoleWindowState /*action*/)
bool setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) override
{
return false;
}
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const;
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override;
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const;
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
GHOST_TCapabilityFlag getCapabilities() const;
GHOST_TCapabilityFlag getCapabilities() const override;
char *getClipboard(bool selection) const;
char *getClipboard(bool selection) const override;
void putClipboard(const char *buffer, bool selection) const;
void putClipboard(const char *buffer, bool selection) const override;
uint64_t getMilliSeconds();
uint64_t getMilliSeconds() const override;
uint8_t getNumDisplays() const;
uint8_t getNumDisplays() const override;
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const;
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override;
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y);
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override;
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const;
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const;
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings);
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) override;
GHOST_TSuccess disposeContext(GHOST_IContext *context);
GHOST_TSuccess disposeContext(GHOST_IContext *context) override;
private:
GHOST_TSuccess init();
GHOST_TSuccess init() override;
GHOST_IWindow *createWindow(const char *title,
int32_t left,
@@ -76,7 +76,7 @@ class GHOST_SystemSDL : public GHOST_System {
GHOST_GLSettings glSettings,
const bool exclusive = false,
const bool is_dialog = false,
const GHOST_IWindow *parentWindow = NULL);
const GHOST_IWindow *parentWindow = nullptr) override;
/* SDL specific */
GHOST_WindowSDL *findGhostWindow(SDL_Window *sdl_win);

View File

@@ -69,9 +69,9 @@ class GHOST_SystemX11 : public GHOST_System {
/**
* Destructor.
*/
~GHOST_SystemX11();
~GHOST_SystemX11() override;
GHOST_TSuccess init();
GHOST_TSuccess init() override;
/**
* \section Interface Inherited from GHOST_ISystem
@@ -82,25 +82,25 @@ class GHOST_SystemX11 : public GHOST_System {
* Returns the number of milliseconds since the start of the system process.
* \return The number of milliseconds.
*/
uint64_t getMilliSeconds() const;
uint64_t getMilliSeconds() const override;
/**
* Returns the number of displays on this system.
* \return The number of displays.
*/
uint8_t getNumDisplays() const;
uint8_t getNumDisplays() const override;
/**
* Returns the dimensions of the main display on this system.
* \return The dimension of the main display.
*/
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const;
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
/**
* Returns the dimensions of all displays on this system.
* \return The dimension of the main display.
*/
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const;
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
/**
* Create a new window.
@@ -127,48 +127,48 @@ class GHOST_SystemX11 : public GHOST_System {
GHOST_GLSettings glSettings,
const bool exclusive = false,
const bool is_dialog = false,
const GHOST_IWindow *parentWindow = 0);
const GHOST_IWindow *parentWindow = nullptr) override;
/**
* Create a new off-screen context.
* Never explicitly delete the context, use #disposeContext() instead.
* \return The new context (or 0 if creation failed).
*/
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings);
GHOST_IContext *createOffscreenContext(GHOST_GLSettings glSettings) override;
/**
* Dispose of a context.
* \param context: Pointer to the context to be disposed.
* \return Indication of success.
*/
GHOST_TSuccess disposeContext(GHOST_IContext *context);
GHOST_TSuccess disposeContext(GHOST_IContext *context) override;
/**
* Retrieves events from the system and stores them in the queue.
* \param waitForEvent: Flag to wait for an event (or return immediately).
* \return Indication of the presence of events.
*/
bool processEvents(bool waitForEvent);
bool processEvents(bool waitForEvent) override;
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const;
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override;
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y);
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override;
/**
* Returns the state of all modifier keys.
* \param keys: The state of all modifier keys (true == pressed).
* \return Indication of success.
*/
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const;
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override;
/**
* Returns the state of the mouse buttons (outside the message queue).
* \param buttons: The state of the buttons.
* \return Indication of success.
*/
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const;
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
GHOST_TCapabilityFlag getCapabilities() const;
GHOST_TCapabilityFlag getCapabilities() const override;
/**
* Flag a window as dirty. This will
@@ -206,14 +206,14 @@ class GHOST_SystemX11 : public GHOST_System {
* \param selection: Get selection, X11 only feature.
* \return Returns the Clipboard indicated by Flag.
*/
char *getClipboard(bool selection) const;
char *getClipboard(bool selection) const override;
/**
* Puts buffer to system clipboard
* \param buffer: The buffer to copy to the clipboard.
* \param selection: Set the selection into the clipboard, X11 only feature.
*/
void putClipboard(const char *buffer, bool selection) const;
void putClipboard(const char *buffer, bool selection) const override;
/**
* Show a system message box
@@ -229,7 +229,7 @@ class GHOST_SystemX11 : public GHOST_System {
const char *help_label,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options) const;
GHOST_DialogOptions dialog_options) const override;
#ifdef WITH_XDND
/**
* Creates a drag'n'drop event and pushes it immediately onto the event queue.
@@ -253,7 +253,7 @@ class GHOST_SystemX11 : public GHOST_System {
/**
* \see GHOST_ISystem
*/
bool setConsoleWindowState(GHOST_TConsoleWindowState /*action*/)
bool setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) override
{
return 0;
}

View File

@@ -42,7 +42,7 @@ class GHOST_WindowSDL : public GHOST_Window {
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const bool exclusive = false,
const GHOST_IWindow *parentWindow = NULL);
const GHOST_IWindow *parentWindow = nullptr);
~GHOST_WindowSDL();
@@ -52,7 +52,7 @@ class GHOST_WindowSDL : public GHOST_Window {
return m_sdl_win;
}
GHOST_TSuccess invalidate(void);
GHOST_TSuccess invalidate(void) override;
/**
* called by the X11 system implementation when expose events
@@ -64,22 +64,22 @@ class GHOST_WindowSDL : public GHOST_Window {
m_invalid_window = false;
}
bool getValid() const;
bool getValid() const override;
void getWindowBounds(GHOST_Rect &bounds) const;
void getClientBounds(GHOST_Rect &bounds) const;
void getWindowBounds(GHOST_Rect &bounds) const override;
void getClientBounds(GHOST_Rect &bounds) const override;
protected:
/**
* \param type: The type of rendering context create.
* \return Indication of success.
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type) override;
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override;
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override;
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape) override;
GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap,
uint8_t *mask,
@@ -87,44 +87,44 @@ class GHOST_WindowSDL : public GHOST_Window {
int sizey,
int hotX,
int hotY,
bool canInvertColor);
bool canInvertColor) override;
GHOST_TSuccess setWindowCursorVisibility(bool visible);
GHOST_TSuccess setWindowCursorVisibility(bool visible) override;
void setTitle(const char *title);
void setTitle(const char *title) override;
std::string getTitle() const;
std::string getTitle() const override;
GHOST_TSuccess setClientWidth(uint32_t width);
GHOST_TSuccess setClientWidth(uint32_t width) override;
GHOST_TSuccess setClientHeight(uint32_t height);
GHOST_TSuccess setClientHeight(uint32_t height) override;
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height);
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override;
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
GHOST_TSuccess setState(GHOST_TWindowState state);
GHOST_TSuccess setState(GHOST_TWindowState state) override;
GHOST_TWindowState getState() const;
GHOST_TWindowState getState() const override;
GHOST_TSuccess setOrder(GHOST_TWindowOrder /*order*/)
GHOST_TSuccess setOrder(GHOST_TWindowOrder /*order*/) override
{
// TODO
return GHOST_kSuccess;
}
// TODO
GHOST_TSuccess beginFullScreen() const
GHOST_TSuccess beginFullScreen() const override
{
return GHOST_kFailure;
}
GHOST_TSuccess endFullScreen() const
GHOST_TSuccess endFullScreen() const override
{
return GHOST_kFailure;
}
uint16_t getDPIHint();
uint16_t getDPIHint() override;
};

View File

@@ -63,44 +63,44 @@ class GHOST_WindowX11 : public GHOST_Window {
const bool exclusive = false,
const bool is_debug = false);
bool getValid() const;
bool getValid() const override;
void setTitle(const char *title);
void setTitle(const char *title) override;
std::string getTitle() const;
std::string getTitle() const override;
void getWindowBounds(GHOST_Rect &bounds) const;
void getWindowBounds(GHOST_Rect &bounds) const override;
void getClientBounds(GHOST_Rect &bounds) const;
void getClientBounds(GHOST_Rect &bounds) const override;
bool isDialog() const;
bool isDialog() const override;
GHOST_TSuccess setClientWidth(uint32_t width);
GHOST_TSuccess setClientWidth(uint32_t width) override;
GHOST_TSuccess setClientHeight(uint32_t height);
GHOST_TSuccess setClientHeight(uint32_t height) override;
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height);
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override;
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
GHOST_TWindowState getState() const;
GHOST_TWindowState getState() const override;
GHOST_TSuccess setState(GHOST_TWindowState state);
GHOST_TSuccess setState(GHOST_TWindowState state) override;
GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override;
GHOST_TSuccess invalidate();
GHOST_TSuccess invalidate() override;
GHOST_TSuccess setProgressBar(float progress);
GHOST_TSuccess endProgressBar();
GHOST_TSuccess setProgressBar(float progress) override;
GHOST_TSuccess endProgressBar() override;
/**
* Destructor.
* Closes the window and disposes resources allocated.
*/
~GHOST_WindowX11();
~GHOST_WindowX11() override;
/**
* \section x11specific X11 system specific calls
@@ -152,32 +152,32 @@ class GHOST_WindowX11 : public GHOST_Window {
bool m_post_init;
GHOST_TWindowState m_post_state;
GHOST_TSuccess beginFullScreen() const;
GHOST_TSuccess beginFullScreen() const override;
GHOST_TSuccess endFullScreen() const;
GHOST_TSuccess endFullScreen() const override;
GHOST_TSuccess setDialogHints(GHOST_WindowX11 *parentWindow);
uint16_t getDPIHint();
uint16_t getDPIHint() override;
protected:
/**
* \param type: The type of rendering context create.
* \return Indication of success.
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type) override;
/**
* Sets the cursor visibility on the window using
* native window system calls.
*/
GHOST_TSuccess setWindowCursorVisibility(bool visible);
GHOST_TSuccess setWindowCursorVisibility(bool visible) override;
/**
* Sets the cursor grab on the window using
* native window system calls.
*/
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override;
GHOST_TGrabCursorMode getWindowCursorGrab() const;
@@ -185,8 +185,8 @@ class GHOST_WindowX11 : public GHOST_Window {
* Sets the cursor shape on the window using
* native window system calls.
*/
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override;
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape) override;
/**
* Sets the cursor shape on the window using
@@ -198,7 +198,7 @@ class GHOST_WindowX11 : public GHOST_Window {
int sizey,
int hotX,
int hotY,
bool canInvertColor);
bool canInvertColor) override;
private:
/* Force use of public constructor. */