Change return type from void to int, for functions that set an error

(SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(), SDL_InvalidParam())

Update prototype to forward errors to generic layer, for the functions:
MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes.

Check invalid parameter in SDL_SetTextInputRect() generic layer.
This commit is contained in:
Sylvain
2023-02-06 20:24:12 +01:00
committed by Sam Lantinga
parent 6c37d5b57f
commit c5c94a6be6
100 changed files with 472 additions and 389 deletions

View File

@@ -851,10 +851,12 @@ extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
* \param len the length of the audio buffer in bytes
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
extern DECLSPEC int SDLCALL SDL_MixAudioFormat(Uint8 * dst,
const Uint8 * src,
SDL_AudioFormat format,
Uint32 len, int volume);

View File

@@ -377,10 +377,12 @@ extern DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsi
* Close a HID device.
*
* \param dev A device handle returned from SDL_hid_open().
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_hid_close(SDL_hid_device *dev);
extern DECLSPEC int SDLCALL SDL_hid_close(SDL_hid_device *dev);
/**
* Get The Manufacturer String from a HID device.

View File

@@ -493,10 +493,12 @@ extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
* \param player_index Player index to assign to this joystick, or -1 to clear
* the player index and turn off player LEDs.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
/**
* Get the implementation-dependent GUID for the joystick.
@@ -966,12 +968,14 @@ extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const
* Close a joystick previously opened with SDL_OpenJoystick().
*
* \param joystick The joystick device to close
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_OpenJoystick
*/
extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
extern DECLSPEC int SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
/**
* Get the battery level of a joystick as SDL_JoystickPowerLevel.

View File

@@ -310,12 +310,14 @@ extern DECLSPEC SDL_bool SDLCALL SDL_TextInputShown(void);
*
* \param rect the SDL_Rect structure representing the rectangle to receive
* text (ignored if NULL)
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_StartTextInput
*/
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_SetTextInputRect(const SDL_Rect *rect);
/**
* Check whether the platform has screen keyboard support.

View File

@@ -364,13 +364,15 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
* this is desired for any reason.
*
* \param cursor a cursor to make active
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateCursor
* \sa SDL_GetCursor
*/
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
extern DECLSPEC int SDLCALL SDL_SetCursor(SDL_Cursor * cursor);
/**
* Get the active cursor.

View File

@@ -416,12 +416,14 @@ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_CreatePixelFormat(Uint32 pixel_for
* Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().
*
* \param format the SDL_PixelFormat structure to free
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreatePixelFormat
*/
extern DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
extern DECLSPEC int SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
/**
* Create a palette structure with the specified number of color entries.
@@ -478,12 +480,14 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
* Free a palette created with SDL_CreatePalette().
*
* \param palette the SDL_Palette structure to be freed
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreatePalette
*/
extern DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
extern DECLSPEC int SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
/**
* Map an RGB triple to an opaque pixel value for a given pixel format.

View File

@@ -172,10 +172,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect * A,
* \param B an SDL_Rect structure representing the second rectangle
* \param result an SDL_Rect structure filled in with the union of rectangles
* `A` and `B`
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
extern DECLSPEC int SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
const SDL_Rect * B,
SDL_Rect * result);
@@ -311,10 +313,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect *
* \param B an SDL_FRect structure representing the second rectangle
* \param result an SDL_FRect structure filled in with the union of rectangles
* `A` and `B`
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
extern DECLSPEC int SDLCALL SDL_GetRectUnionFloat(const SDL_FRect * A,
const SDL_FRect * B,
SDL_FRect * result);

View File

@@ -783,11 +783,14 @@ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
*
* \param texture a texture locked by SDL_LockTexture()
*
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_LockTexture
*/
extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
extern DECLSPEC int SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
/**
* Set a texture as the current rendering target.
@@ -1408,6 +1411,8 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer,
* pixel.
*
* \param renderer the rendering context
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \threadsafety You may only call this function on the main thread.
*
@@ -1425,7 +1430,7 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer,
* \sa SDL_SetRenderDrawBlendMode
* \sa SDL_SetRenderDrawColor
*/
extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
extern DECLSPEC int SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
/**
* Destroy the specified texture.
@@ -1434,13 +1439,15 @@ extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
* to "Invalid texture".
*
* \param texture the texture to destroy
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateTexture
* \sa SDL_CreateTextureFromSurface
*/
extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
extern DECLSPEC int SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
/**
* Destroy the rendering context for a window and free associated textures.
@@ -1449,12 +1456,14 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
* the SDL error message to "Invalid renderer". See SDL_GetError().
*
* \param renderer the rendering context
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateRenderer
*/
extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
extern DECLSPEC int SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
/**
* Force the rendering context to flush any pending commands to the underlying

View File

@@ -821,12 +821,14 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *
* `SDL_WINDOWPOS_UNDEFINED`
* \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
* `SDL_WINDOWPOS_UNDEFINED`
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowPosition
*/
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
/**
* Get the position of a window, in screen coordinates.
@@ -837,12 +839,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, in
* \param window the window to query
* \param x a pointer filled in with the x position of the window, may be NULL
* \param y a pointer filled in with the y position of the window, may be NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowPosition
*/
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
/**
* Set the size of a window's client area, in screen coordinates.
@@ -880,6 +884,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
* \param window the window to query the width and height from
* \param w a pointer filled in with the width of the window, may be NULL
* \param h a pointer filled in with the height of the window, may be NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
@@ -887,7 +893,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
* \sa SDL_GetWindowSizeInPixels
* \sa SDL_SetWindowSize
*/
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
extern DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
/**
* Get the size of a window's borders (decorations) around the client area, in
@@ -934,13 +940,15 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *to
* \param w a pointer to variable for storing the width in pixels, may be NULL
* \param h a pointer to variable for storing the height in pixels, may be
* NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateWindow
* \sa SDL_GetWindowSize
*/
extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
/**
* Set the minimum size of a window's client area, in screen coordinates.
@@ -966,13 +974,15 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min
* NULL
* \param h a pointer filled in with the minimum height of the window, may be
* NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowMaximumSize
* \sa SDL_SetWindowMinimumSize
*/
extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
/**
* Set the maximum size of a window's client area, in screen coordinates.
@@ -998,13 +1008,15 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max
* NULL
* \param h a pointer filled in with the maximum height of the window, may be
* NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowMinimumSize
* \sa SDL_SetWindowMaximumSize
*/
extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
extern DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
/**
* Set the border state of a window.
@@ -1017,12 +1029,14 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w
*
* \param window the window of which to change the border state
* \param bordered SDL_FALSE to remove border, SDL_TRUE to add border
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowFlags
*/
extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
extern DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
/**
* Set the user-resizable state of a window.
@@ -1035,12 +1049,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool
*
* \param window the window of which to change the resizable state
* \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowFlags
*/
extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
extern DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
/**
* Set the window to always be above the others.
@@ -1051,80 +1067,94 @@ extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool
* \param window The window of which to change the always on top state
* \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
* disable
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowFlags
*/
extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
extern DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
/**
* Show a window.
*
* \param window the window to show
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HideWindow
* \sa SDL_RaiseWindow
*/
extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
/**
* Hide a window.
*
* \param window the window to hide
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_ShowWindow
*/
extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
/**
* Raise a window above other windows and set the input focus.
*
* \param window the window to raise
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
/**
* Make a window as large as possible.
*
* \param window the window to maximize
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_MinimizeWindow
* \sa SDL_RestoreWindow
*/
extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
/**
* Minimize a window to an iconic representation.
*
* \param window the window to minimize
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_MaximizeWindow
* \sa SDL_RestoreWindow
*/
extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
/**
* Restore the size and position of a minimized or maximized window.
*
* \param window the window to restore
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_MaximizeWindow
* \sa SDL_MinimizeWindow
*/
extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
/**
* Set a window's fullscreen state.
@@ -1222,13 +1252,15 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, con
*
* \param window the window for which the input grab mode should be set
* \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetGrabbedWindow
* \sa SDL_GetWindowGrab
*/
extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
extern DECLSPEC int SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
/**
* Set a window's keyboard grab mode.
@@ -1251,6 +1283,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grab
*
* \param window The window for which the keyboard grab mode should be set.
* \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
@@ -1258,7 +1292,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grab
* \sa SDL_SetWindowMouseGrab
* \sa SDL_SetWindowGrab
*/
extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
extern DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
/**
* Set a window's mouse grab mode.
@@ -1267,6 +1301,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_b
*
* \param window The window for which the mouse grab mode should be set.
* \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
@@ -1274,7 +1310,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_b
* \sa SDL_SetWindowKeyboardGrab
* \sa SDL_SetWindowGrab
*/
extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
extern DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
/**
* Get a window's input grab mode.
@@ -1521,13 +1557,15 @@ extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperati
* the SDL error message to "Invalid window". See SDL_GetError().
*
* \param window the window to destroy
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateWindow
* \sa SDL_CreateWindowFrom
*/
extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
extern DECLSPEC int SDLCALL SDL_DestroyWindow(SDL_Window *window);
/**
@@ -1933,12 +1971,14 @@ extern DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
* Delete an OpenGL context.
*
* \param context the OpenGL context to be deleted
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GL_CreateContext
*/
extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
extern DECLSPEC int SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
/* @} *//* OpenGL support functions */