Skip to content

Commit

Permalink
Rename functions in SDL_system.h to match SDL 3.0 naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 15, 2024
1 parent 9406a9d commit 50a2136
Show file tree
Hide file tree
Showing 32 changed files with 252 additions and 158 deletions.
61 changes: 58 additions & 3 deletions build-scripts/SDL_migration.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -3134,17 +3134,17 @@ typedef SDL_Colour, SDL_Color;
@@
@@
- SDL_WinRTGetFSPathUTF8
+ SDL_WinRTGetFSPath
+ SDL_GetWinRTFSPath
(...)
@@
@@
- SDL_iPhoneSetAnimationCallback
+ SDL_iOSSetAnimationCallback
+ SDL_SetiOSAnimationCallback
(...)
@@
@@
- SDL_iPhoneSetEventPump
+ SDL_iOSSetEventPump
+ SDL_SetiOSEventPump
(...)
@@
@@
Expand Down Expand Up @@ -3501,3 +3501,58 @@ typedef SDL_Colour, SDL_Color;
- SDL_GL_DeleteContext
+ SDL_GL_DestroyContext
(...)
@@
@@
- SDL_AndroidGetActivity
+ SDL_GetAndroidActivity
(...)
@@
@@
- SDL_AndroidGetExternalStoragePath
+ SDL_GetAndroidExternalStoragePath
(...)
@@
@@
- SDL_AndroidGetExternalStorageState
+ SDL_GetAndroidExternalStorageState
(...)
@@
@@
- SDL_AndroidGetInternalStoragePath
+ SDL_GetAndroidInternalStoragePath
(...)
@@
@@
- SDL_AndroidGetJNIEnv
+ SDL_GetAndroidJNIEnv
(...)
@@
@@
- SDL_Direct3D9GetAdapterIndex
+ SDL_GetDirect3D9AdapterIndex
(...)
@@
@@
- SDL_GDKGetDefaultUser
+ SDL_GetGDKDefaultUser
(...)
@@
@@
- SDL_GDKGetTaskQueue
+ SDL_GetGDKTaskQueue
(...)
@@
@@
- SDL_WinRTGetDeviceFamily
+ SDL_GetWinRTDeviceFamily
(...)
@@
@@
- SDL_LinuxSetThreadPriority
+ SDL_SetLinuxThreadPriority
(...)
@@
@@
- SDL_LinuxSetThreadPriorityAndPolicy
+ SDL_SetLinuxThreadPriorityAndPolicy
(...)
8 changes: 4 additions & 4 deletions docs/README-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ them using the standard functions in SDL_iostream.h.

There are also a few Android specific functions that allow you to get other
useful paths for saving and loading data:
* SDL_AndroidGetInternalStoragePath()
* SDL_AndroidGetExternalStorageState()
* SDL_AndroidGetExternalStoragePath()
* SDL_AndroidGetCachePath()
* SDL_GetAndroidInternalStoragePath()
* SDL_GetAndroidExternalStorageState()
* SDL_GetAndroidExternalStoragePath()
* SDL_GetAndroidCachePath()

See SDL_system.h for more details on these functions.

Expand Down
4 changes: 2 additions & 2 deletions docs/README-gdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ The Windows GDK port supports the full set of Win32 APIs, renderers, controllers

* An implementation on `WinMain` that performs the above GDK setup that you can use by #include'ing SDL_main.h in the source file that includes your standard main() function. If you are unable to do this, you can instead manually call `SDL_RunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. To use `SDL_RunApp`, `#define SDL_MAIN_HANDLED` before `#include <SDL3/SDL_main.h>`.
* Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
* You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak).
* You can get the handle of the global task queue through `SDL_GetGDKTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak).

* Single-player games have some additional features available:
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
* Call `SDL_GetGDKDefaultUser` to get the default XUserHandle pointer.
* `SDL_GetPrefPath` still works, but only for single-player titles.

These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
Expand Down
6 changes: 3 additions & 3 deletions docs/README-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Game Center

Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:

int SDL_iOSSetAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
int SDL_SetiOSAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);

This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.

Expand All @@ -247,7 +247,7 @@ e.g.

// Set up the game to run in the window animation callback on iOS
// so that Game Center and so forth works correctly.
SDL_iOSSetAnimationCallback(window, 1, ShowFrame, NULL);
SDL_SetiOSAnimationCallback(window, 1, ShowFrame, NULL);
#else
while ( running ) {
ShowFrame(0);
Expand All @@ -258,7 +258,7 @@ e.g.
}


Note that if you are using main callbacks instead of a standard C main() function, your SDL_AppIterate() callback is already doing this and you don't need to use SDL_iOSSetAnimationCallback.
Note that if you are using main callbacks instead of a standard C main() function, your SDL_AppIterate() callback is already doing this and you don't need to use SDL_SetiOSAnimationCallback.


Deploying to older versions of iOS
Expand Down
25 changes: 19 additions & 6 deletions docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1748,23 +1748,36 @@ The following symbols have been renamed:

SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.

SDL_AndroidGetExternalStorageState() takes the state as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
SDL_GetAndroidExternalStorageState() takes the state as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.

SDL_AndroidRequestPermission is no longer a blocking call; the caller now provides a callback function that fires when a response is available.

SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() have been renamed to SDL_iOSSetAnimationCallback() and SDL_iOSSetEventPump(), respectively. SDL2 has had macros to provide this new name with the old symbol since the introduction of the iPad, but now the correctly-named symbol is the only option.
SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() have been renamed to SDL_SetiOSAnimationCallback() and SDL_SetiOSEventPump(), respectively. SDL2 has had macros to provide this new name with the old symbol since the introduction of the iPad, but now the correctly-named symbol is the only option.


The following functions have been removed:
* SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property
* SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property
* SDL_RenderGetD3D9Device() - replaced with the "SDL.renderer.d3d9.device" property
* SDL_WinRTGetFSPathUNICODE() - Use SDL_WinRTGetFSPath() and SDL_iconv_string to convert from UTF-8 to UTF-16.
* SDL_GetWinRTFSPathUNICODE() - Use SDL_GetWinRTFSPath() and SDL_iconv_string to convert from UTF-8 to UTF-16.

The following functions have been renamed:
* SDL_WinRTGetFSPathUTF8() => SDL_WinRTGetFSPath()
* SDL_iPhoneSetAnimationCallback() => SDL_iOSSetAnimationCallback()
* SDL_iPhoneSetEventPump() => SDL_iOSSetEventPump()
* SDL_AndroidGetActivity() => SDL_GetAndroidActivity()
* SDL_AndroidGetExternalStoragePath() => SDL_GetAndroidExternalStoragePath()
* SDL_AndroidGetExternalStorageState() => SDL_GetAndroidExternalStorageState()
* SDL_AndroidGetInternalStoragePath() => SDL_GetAndroidInternalStoragePath()
* SDL_AndroidGetJNIEnv() => SDL_GetAndroidJNIEnv()
* SDL_Direct3D9GetAdapterIndex() => SDL_GetDirect3D9AdapterIndex()
* SDL_GDKGetDefaultUser() => SDL_GetGDKDefaultUser()
* SDL_GDKGetTaskQueue() => SDL_GetGDKTaskQueue()
* SDL_LinuxSetThreadPriority() => SDL_SetLinuxThreadPriority()
* SDL_LinuxSetThreadPriorityAndPolicy() => SDL_SetLinuxThreadPriorityAndPolicy()
* SDL_WinRTGetDeviceFamily() => SDL_GetWinRTDeviceFamily()
* SDL_GetWinRTFSPathUTF8() => SDL_GetWinRTFSPath()
* SDL_iOSSetAnimationCallback() => SDL_SetiOSAnimationCallback()
* SDL_iOSSetEventPump() => SDL_SetiOSEventPump()
* SDL_iPhoneSetAnimationCallback() => SDL_SetiOSAnimationCallback()
* SDL_iPhoneSetEventPump() => SDL_SetiOSEventPump()

## SDL_syswm.h

Expand Down
2 changes: 1 addition & 1 deletion docs/README-winrt.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ SDL_GetPrefPath(), starting with SDL 2.0.4, addresses these by:
(and which require less work to use safely, in terms of data integrity).

Apps that wish to get their Roaming folder's path can do so either by using
SDL_WinRTGetFSPath(), or directly through the WinRT class,
SDL_GetWinRTFSPath(), or directly through the WinRT class,
Windows.Storage.ApplicationData.


Expand Down
34 changes: 30 additions & 4 deletions include/SDL3/SDL_oldnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,22 @@
#define SDL_UpperBlitScaled SDL_BlitSurfaceScaled

/* ##SDL_system.h */
#define SDL_WinRTGetFSPathUTF8 SDL_WinRTGetFSPath
#define SDL_iPhoneSetAnimationCallback SDL_iOSSetAnimationCallback
#define SDL_iPhoneSetEventPump SDL_iOSSetEventPump
#define SDL_AndroidGetActivity SDL_GetAndroidActivity
#define SDL_AndroidGetExternalStoragePath SDL_GetAndroidExternalStoragePath
#define SDL_AndroidGetExternalStorageState SDL_GetAndroidExternalStorageState
#define SDL_AndroidGetInternalStoragePath SDL_GetAndroidInternalStoragePath
#define SDL_AndroidGetJNIEnv SDL_GetAndroidJNIEnv
#define SDL_Direct3D9GetAdapterIndex SDL_GetDirect3D9AdapterIndex
#define SDL_GDKGetDefaultUser SDL_GetGDKDefaultUser
#define SDL_GDKGetTaskQueue SDL_GetGDKTaskQueue
#define SDL_LinuxSetThreadPriority SDL_SetLinuxThreadPriority
#define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy
#define SDL_WinRTGetDeviceFamily SDL_GetWinRTDeviceFamily
#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPath
#define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback
#define SDL_iOSSetEventPump SDL_SetiOSEventPump
#define SDL_iPhoneSetAnimationCallback SDL_SetiOSAnimationCallback
#define SDL_iPhoneSetEventPump SDL_SetiOSEventPump

/* ##SDL_thread.h */
#define SDL_TLSCleanup SDL_CleanupTLS
Expand Down Expand Up @@ -1197,7 +1210,20 @@
#define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled

/* ##SDL_system.h */
#define SDL_WinRTGetFSPathUTF8 SDL_WinRTGetFSPathUTF8_renamed_SDL_WinRTGetFSPath
#define SDL_AndroidGetActivity SDL_AndroidGetActivity_renamed_SDL_GetAndroidActivity
#define SDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath_renamed_SDL_GetAndroidExternalStoragePath
#define SDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState_renamed_SDL_GetAndroidExternalStorageState
#define SDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath_renamed_SDL_GetAndroidInternalStoragePath
#define SDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv_renamed_SDL_GetAndroidJNIEnv
#define SDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex_renamed_SDL_GetDirect3D9AdapterIndex
#define SDL_GDKGetDefaultUser SDL_GDKGetDefaultUser_renamed_SDL_GetGDKDefaultUser
#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_renamed_SDL_GetGDKTaskQueue
#define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_renamed_SDL_SetLinuxThreadPriority
#define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy
#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_renamed_SDL_GetWinRTDeviceFamily
#define SDL_GetWinRTFSPathUTF8 SDL_GetWinRTFSPathUTF8_renamed_SDL_GetWinRTFSPath
#define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback
#define SDL_iOSSetEventPump SDL_iOSSetEventPump_renamed_SDL_SetiOSEventPump
#define SDL_iPhoneSetAnimationCallback SDL_iPhoneSetAnimationCallback_renamed_SDL_iOSSetAnimationCallback
#define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump

Expand Down
Loading

0 comments on commit 50a2136

Please sign in to comment.