Browse Source

winrt: Remove SDL_WinRTGetFSPathUNICODE, rename SDL_WinRTGetFSPathUTF8.

Fixes #9470.
Ryan C. Gordon 1 year ago
parent
commit
98e9f361a8

+ 5 - 0
build-scripts/SDL_migration.cocci

@@ -3129,3 +3129,8 @@ typedef SDL_Colour, SDL_Color;
 @@
 @@
 - SDL_Colour
 - SDL_Colour
 + SDL_Color
 + SDL_Color
+@@
+@@
+- SDL_WinRTGetFSPathUTF8
++ SDL_WinRTGetFSPath
+  (...)

+ 4 - 0
docs/README-migration.md

@@ -1491,6 +1491,10 @@ The following functions have been removed:
 * SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property
 * SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property
 * SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property
 * SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property
 * SDL_RenderGetD3D9Device() - replaced with the "SDL.renderer.d3d9.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.
+
+The following functions have been renamed:
+* SDL_WinRTGetFSPathUTF8() => SDL_WinRTGetFSPath()
 
 
 ## SDL_syswm.h
 ## SDL_syswm.h
 
 

+ 1 - 2
docs/README-winrt.md

@@ -129,8 +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).
    (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
 Apps that wish to get their Roaming folder's path can do so either by using
-SDL_WinRTGetFSPathUTF8(), SDL_WinRTGetFSPathUNICODE() (which returns a
-UCS-2/wide-char string), or directly through the WinRT class,
+SDL_WinRTGetFSPath(), or directly through the WinRT class,
 Windows.Storage.ApplicationData.
 Windows.Storage.ApplicationData.
 
 
 
 

+ 6 - 0
include/SDL3/SDL_oldnames.h

@@ -511,6 +511,9 @@
 #define SDL_UpperBlit SDL_BlitSurface
 #define SDL_UpperBlit SDL_BlitSurface
 #define SDL_UpperBlitScaled SDL_BlitSurfaceScaled
 #define SDL_UpperBlitScaled SDL_BlitSurfaceScaled
 
 
+/* ##SDL_system.h */
+#define SDL_WinRTGetFSPathUTF8 SDL_WinRTGetFSPath
+
 /* ##SDL_thread.h */
 /* ##SDL_thread.h */
 #define SDL_TLSCleanup SDL_CleanupTLS
 #define SDL_TLSCleanup SDL_CleanupTLS
 #define SDL_TLSCreate SDL_CreateTLS
 #define SDL_TLSCreate SDL_CreateTLS
@@ -1012,6 +1015,9 @@
 #define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface
 #define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface
 #define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled
 #define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled
 
 
+/* ##SDL_system.h */
+#define SDL_WinRTGetFSPathUTF8 SDL_WinRTGetFSPathUTF8_renamed_SDL_WinRTGetFSPath
+
 /* ##SDL_thread.h */
 /* ##SDL_thread.h */
 #define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS
 #define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS
 #define SDL_TLSCreate SDL_TLSCreate_renamed_SDL_CreateTLS
 #define SDL_TLSCreate SDL_TLSCreate_renamed_SDL_CreateTLS

+ 1 - 26
include/SDL3/SDL_system.h

@@ -527,29 +527,6 @@ typedef enum SDL_WinRT_DeviceFamily
 } SDL_WinRT_DeviceFamily;
 } SDL_WinRT_DeviceFamily;
 
 
 
 
-/**
- * Retrieve a WinRT defined path on the local file system.
- *
- * Not all paths are available on all versions of Windows. This is especially
- * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path
- * for more information on which path types are supported where.
- *
- * Documentation on most app-specific path types on WinRT can be found on
- * MSDN, at the URL:
- *
- * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
- *
- * \param pathType the type of path to retrieve, one of SDL_WinRT_Path
- * \returns a UCS-2 string (16-bit, wide-char) containing the path, or NULL if
- *          the path is not available for any reason; call SDL_GetError() for
- *          more information.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_WinRTGetFSPathUTF8
- */
-extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
-
 /**
 /**
  * Retrieve a WinRT defined path on the local file system.
  * Retrieve a WinRT defined path on the local file system.
  *
  *
@@ -568,10 +545,8 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
  *          more information.
  *          more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_WinRTGetFSPathUNICODE
  */
  */
-extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
+extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPath(SDL_WinRT_Path pathType);
 
 
 /**
 /**
  * Detects the device family of WinRT platform at runtime.
  * Detects the device family of WinRT platform at runtime.

+ 2 - 10
src/core/SDL_core_unsupported.c

@@ -102,16 +102,8 @@ int SDL_WinRTGetDeviceFamily()
     return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */
     return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */
 }
 }
 
 
-DECLSPEC const wchar_t *SDLCALL SDL_WinRTGetFSPathUNICODE(int pathType); /* SDL_WinRT_Path pathType */
-const wchar_t *SDL_WinRTGetFSPathUNICODE(int pathType)
-{
-    (void)pathType;
-    SDL_Unsupported();
-    return NULL;
-}
-
-DECLSPEC const char *SDLCALL SDL_WinRTGetFSPathUTF8(int pathType); /* SDL_WinRT_Path pathType */
-const char *SDL_WinRTGetFSPathUTF8(int pathType)
+DECLSPEC const char *SDLCALL SDL_WinRTGetFSPath(int pathType); /* SDL_WinRT_Path pathType */
+const char *SDL_WinRTGetFSPath(int pathType)
 {
 {
     (void)pathType;
     (void)pathType;
     SDL_Unsupported();
     SDL_Unsupported();

+ 1 - 2
src/dynapi/SDL_dynapi.sym

@@ -838,8 +838,7 @@ SDL3_0.0.0 {
     SDL_WarpMouseInWindow;
     SDL_WarpMouseInWindow;
     SDL_WasInit;
     SDL_WasInit;
     SDL_WinRTGetDeviceFamily;
     SDL_WinRTGetDeviceFamily;
-    SDL_WinRTGetFSPathUNICODE;
-    SDL_WinRTGetFSPathUTF8;
+    SDL_WinRTGetFSPath;
     SDL_WindowHasSurface;
     SDL_WindowHasSurface;
     SDL_WriteIO;
     SDL_WriteIO;
     SDL_WriteS16BE;
     SDL_WriteS16BE;

+ 1 - 2
src/dynapi/SDL_dynapi_overrides.h

@@ -862,8 +862,7 @@
 #define SDL_WarpMouseInWindow SDL_WarpMouseInWindow_REAL
 #define SDL_WarpMouseInWindow SDL_WarpMouseInWindow_REAL
 #define SDL_WasInit SDL_WasInit_REAL
 #define SDL_WasInit SDL_WasInit_REAL
 #define SDL_WinRTGetDeviceFamily    SDL_WinRTGetDeviceFamily_REAL
 #define SDL_WinRTGetDeviceFamily    SDL_WinRTGetDeviceFamily_REAL
-#define SDL_WinRTGetFSPathUNICODE   SDL_WinRTGetFSPathUNICODE_REAL
-#define SDL_WinRTGetFSPathUTF8  SDL_WinRTGetFSPathUTF8_REAL
+#define SDL_WinRTGetFSPath  SDL_WinRTGetFSPath_REAL
 #define SDL_WindowHasSurface SDL_WindowHasSurface_REAL
 #define SDL_WindowHasSurface SDL_WindowHasSurface_REAL
 #define SDL_WriteIO SDL_WriteIO_REAL
 #define SDL_WriteIO SDL_WriteIO_REAL
 #define SDL_WriteS16BE SDL_WriteS16BE_REAL
 #define SDL_WriteS16BE SDL_WriteS16BE_REAL

+ 1 - 2
src/dynapi/SDL_dynapi_procs.h

@@ -882,8 +882,7 @@ SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(float a, float b),(a,b),return)
 SDL_DYNAPI_PROC(void,SDL_WarpMouseInWindow,(SDL_Window *a, float b, float c),(a,b,c),)
 SDL_DYNAPI_PROC(void,SDL_WarpMouseInWindow,(SDL_Window *a, float b, float c),(a,b,c),)
 SDL_DYNAPI_PROC(Uint32,SDL_WasInit,(Uint32 a),(a),return)
 SDL_DYNAPI_PROC(Uint32,SDL_WasInit,(Uint32 a),(a),return)
 SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_WinRTGetDeviceFamily,(void),(),return)
 SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_WinRTGetDeviceFamily,(void),(),return)
-SDL_DYNAPI_PROC(const wchar_t*,SDL_WinRTGetFSPathUNICODE,(SDL_WinRT_Path a),(a),return)
-SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPathUTF8,(SDL_WinRT_Path a),(a),return)
+SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPath,(SDL_WinRT_Path a),(a),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_WindowHasSurface,(SDL_Window *a),(a),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_WindowHasSurface,(SDL_Window *a),(a),return)
 SDL_DYNAPI_PROC(size_t,SDL_WriteIO,(SDL_IOStream *a, const void *b, size_t c),(a,b,c),return)
 SDL_DYNAPI_PROC(size_t,SDL_WriteIO,(SDL_IOStream *a, const void *b, size_t c),(a,b,c),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS16BE,(SDL_IOStream *a, Sint16 b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_WriteS16BE,(SDL_IOStream *a, Sint16 b),(a,b),return)

+ 5 - 9
src/filesystem/winrt/SDL_sysfilesystem.cpp

@@ -35,8 +35,7 @@ extern "C" {
 using namespace std;
 using namespace std;
 using namespace Windows::Storage;
 using namespace Windows::Storage;
 
 
-extern "C" const wchar_t *
-SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
+static const wchar_t *SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
 {
 {
     switch (pathType) {
     switch (pathType) {
     case SDL_WINRT_PATH_INSTALLED_LOCATION:
     case SDL_WINRT_PATH_INSTALLED_LOCATION:
@@ -94,8 +93,7 @@ SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
     return NULL;
     return NULL;
 }
 }
 
 
-extern "C" const char *
-SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
+extern "C" const char *SDL_WinRTGetFSPath(SDL_WinRT_Path pathType)
 {
 {
     typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
     typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
     static UTF8PathMap utf8Paths;
     static UTF8PathMap utf8Paths;
@@ -116,10 +114,9 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
     return utf8Paths[pathType].c_str();
     return utf8Paths[pathType].c_str();
 }
 }
 
 
-extern "C" char *
-SDL_GetBasePath(void)
+extern "C" char *SDL_GetBasePath(void)
 {
 {
-    const char *srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
+    const char *srcPath = SDL_WinRTGetFSPath(SDL_WINRT_PATH_INSTALLED_LOCATION);
     size_t destPathLen;
     size_t destPathLen;
     char *destPath = NULL;
     char *destPath = NULL;
 
 
@@ -138,8 +135,7 @@ SDL_GetBasePath(void)
     return destPath;
     return destPath;
 }
 }
 
 
-extern "C" char *
-SDL_GetPrefPath(const char *org, const char *app)
+extern "C" char *SDL_GetPrefPath(const char *org, const char *app)
 {
 {
     /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and
     /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and
      * earlier is not available on WinRT or Windows Phone.  WinRT provides
      * earlier is not available on WinRT or Windows Phone.  WinRT provides