From ef21e31a9a020b56f58a280a30b1d69d2232ccdf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 22 Jul 2024 10:33:25 -0700 Subject: [PATCH] SDL_GUIDFromString() renamed SDL_StringToGUID() --- build-scripts/SDL_migration.cocci | 5 +++++ docs/README-migration.md | 5 ++++- include/SDL3/SDL_guid.h | 4 ++-- include/SDL3/SDL_oldnames.h | 8 +++++++- src/SDL_guid.c | 2 +- src/dynapi/SDL_dynapi.sym | 2 +- src/dynapi/SDL_dynapi_overrides.h | 2 +- src/dynapi/SDL_dynapi_procs.h | 2 +- src/joystick/SDL_gamepad.c | 2 +- test/testautomation_guid.c | 14 +++++++------- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index af4b1bc94..3c8525a5e 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -3581,3 +3581,8 @@ typedef SDL_JoystickGUID, SDL_GUID; @@ - SDL_JoystickGUID + SDL_GUID +@@ +@@ +- SDL_GUIDFromString ++ SDL_StringToGUID + (...) diff --git a/docs/README-migration.md b/docs/README-migration.md index 0d3083069..d43fc2309 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -698,6 +698,9 @@ functionality to your app and aid migration. That is located in the SDL_GUIDToString() returns a const pointer to the string representation of a GUID. +The following functions have been renamed: +* SDL_GUIDFromString() => SDL_StringToGUID() + ## SDL_haptic.h Gamepads with simple rumble capability no longer show up in the SDL haptics interface, instead you should use SDL_RumbleGamepad(). @@ -872,7 +875,7 @@ The following functions have been renamed: * SDL_JoystickGetButton() => SDL_GetJoystickButton() * SDL_JoystickGetFirmwareVersion() => SDL_GetJoystickFirmwareVersion() * SDL_JoystickGetGUID() => SDL_GetJoystickGUID() -* SDL_JoystickGetGUIDFromString() => SDL_GUIDFromString() +* SDL_JoystickGetGUIDFromString() => SDL_StringToGUID() * SDL_JoystickGetHat() => SDL_GetJoystickHat() * SDL_JoystickGetPlayerIndex() => SDL_GetJoystickPlayerIndex() * SDL_JoystickGetProduct() => SDL_GetJoystickProduct() diff --git a/include/SDL3/SDL_guid.h b/include/SDL3/SDL_guid.h index 0bac68f46..e0d519b9f 100644 --- a/include/SDL3/SDL_guid.h +++ b/include/SDL3/SDL_guid.h @@ -75,7 +75,7 @@ typedef struct SDL_GUID { * * \since This function is available since SDL 3.0.0. * - * \sa SDL_GUIDFromString + * \sa SDL_StringToGUID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GUIDToString(SDL_GUID guid); @@ -93,7 +93,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GUIDToString(SDL_GUID guid); * * \sa SDL_GUIDToString */ -extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID); +extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_StringToGUID(const char *pchGUID); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index a34080528..88642d056 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -266,6 +266,9 @@ #define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMEPAD #define SDL_IsGameController SDL_IsGamepad +/* ##SDL_guid.h */ +#define SDL_GUIDFromString SDL_StringToGUID + /* ##SDL_haptic.h */ #define SDL_HapticClose SDL_CloseHaptic #define SDL_HapticDestroyEffect SDL_DestroyHapticEffect @@ -317,7 +320,7 @@ #define SDL_JoystickGetButton SDL_GetJoystickButton #define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion #define SDL_JoystickGetGUID SDL_GetJoystickGUID -#define SDL_JoystickGetGUIDFromString SDL_GUIDFromString +#define SDL_JoystickGetGUIDFromString SDL_StringToGUID #define SDL_JoystickGetHat SDL_GetJoystickHat #define SDL_JoystickGetPlayerIndex SDL_GetJoystickPlayerIndex #define SDL_JoystickGetProduct SDL_GetJoystickProduct @@ -882,6 +885,9 @@ #define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMECONTROLLER_renamed_SDL_INIT_GAMEPAD #define SDL_IsGameController SDL_IsGameController_renamed_SDL_IsGamepad +/* ##SDL_guid.h */ +#define SDL_GUIDFromString SDL_GUIDFromString_renamed_SDL_StringToGUID + /* ##SDL_haptic.h */ #define SDL_HapticClose SDL_HapticClose_renamed_SDL_CloseHaptic #define SDL_HapticDestroyEffect SDL_HapticDestroyEffect_renamed_SDL_DestroyHapticEffect diff --git a/src/SDL_guid.c b/src/SDL_guid.c index 3e68961ea..d3a3c0b04 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -63,7 +63,7 @@ static unsigned char nibble(unsigned char c) } /* convert the string version of a guid to the struct */ -SDL_GUID SDL_GUIDFromString(const char *pchGUID) +SDL_GUID SDL_StringToGUID(const char *pchGUID) { SDL_GUID guid; int maxoutputbytes = sizeof(guid); diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index e1ec1e895..5b9b1722e 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -146,7 +146,6 @@ SDL3_0.0.0 { SDL_GL_SetSwapInterval; SDL_GL_SwapWindow; SDL_GL_UnloadLibrary; - SDL_GUIDFromString; SDL_GUIDToString; SDL_GamepadConnected; SDL_GamepadEventsEnabled; @@ -816,6 +815,7 @@ SDL3_0.0.0 { SDL_StopHapticRumble; SDL_StopTextInput; SDL_StorageReady; + SDL_StringToGUID; SDL_SurfaceHasColorKey; SDL_SurfaceHasRLE; SDL_SyncWindow; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 953c847a3..278310dc1 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -171,7 +171,6 @@ #define SDL_GL_SetSwapInterval SDL_GL_SetSwapInterval_REAL #define SDL_GL_SwapWindow SDL_GL_SwapWindow_REAL #define SDL_GL_UnloadLibrary SDL_GL_UnloadLibrary_REAL -#define SDL_GUIDFromString SDL_GUIDFromString_REAL #define SDL_GUIDToString SDL_GUIDToString_REAL #define SDL_GamepadConnected SDL_GamepadConnected_REAL #define SDL_GamepadEventsEnabled SDL_GamepadEventsEnabled_REAL @@ -841,6 +840,7 @@ #define SDL_StopHapticRumble SDL_StopHapticRumble_REAL #define SDL_StopTextInput SDL_StopTextInput_REAL #define SDL_StorageReady SDL_StorageReady_REAL +#define SDL_StringToGUID SDL_StringToGUID_REAL #define SDL_SurfaceHasColorKey SDL_SurfaceHasColorKey_REAL #define SDL_SurfaceHasRLE SDL_SurfaceHasRLE_REAL #define SDL_SyncWindow SDL_SyncWindow_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 2561743ea..375a0d845 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -191,7 +191,6 @@ SDL_DYNAPI_PROC(int,SDL_GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GL_SetSwapInterval,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GL_SwapWindow,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),) -SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(const char *,SDL_GUIDToString,(SDL_GUID a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadConnected,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadEventsEnabled,(void),(),return) @@ -851,6 +850,7 @@ SDL_DYNAPI_PROC(int,SDL_StopHapticEffects,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_StopHapticRumble,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_StopTextInput,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_StorageReady,(SDL_Storage *a),(a),return) +SDL_DYNAPI_PROC(SDL_GUID,SDL_StringToGUID,(const char *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasColorKey,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasRLE,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return) diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index b2576dc26..435f3b3b3 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -2028,7 +2028,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa } else if (!SDL_strcasecmp(pchGUID, "xinput")) { is_xinput_mapping = SDL_TRUE; } - jGUID = SDL_GUIDFromString(pchGUID); + jGUID = SDL_StringToGUID(pchGUID); SDL_free(pchGUID); pGamepadMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); diff --git a/test/testautomation_guid.c b/test/testautomation_guid.c index 03bc495b8..b2fe4d8a4 100644 --- a/test/testautomation_guid.c +++ b/test/testautomation_guid.c @@ -72,14 +72,14 @@ upper_lower_to_bytestring(Uint8 *out, Uint64 upper, Uint64 lower) /** * Check String-to-GUID conversion * - * \sa SDL_GUIDFromString + * \sa SDL_StringToGUID */ static int -TestGuidFromString(void *arg) +TestStringToGUID(void *arg) { int i; - SDLTest_AssertPass("Call to SDL_GUIDFromString"); + SDLTest_AssertPass("Call to SDL_StringToGUID"); for (i = 0; i < NUM_TEST_GUIDS; ++i) { Uint8 expected[16]; SDL_GUID guid; @@ -87,7 +87,7 @@ TestGuidFromString(void *arg) upper_lower_to_bytestring(expected, test_guids[i].upper, test_guids[i].lower); - guid = SDL_GUIDFromString(test_guids[i].str); + guid = SDL_StringToGUID(test_guids[i].str); SDLTest_AssertCheck(SDL_memcmp(expected, guid.data, 16) == 0, "GUID from string, GUID was: '%s'", test_guids[i].str); } @@ -100,7 +100,7 @@ TestGuidFromString(void *arg) * \sa SDL_GUIDToString */ static int -TestGuidToString(void *arg) +TestGUIDToString(void *arg) { int i; @@ -123,11 +123,11 @@ TestGuidToString(void *arg) /* GUID routine test cases */ static const SDLTest_TestCaseReference guidTest1 = { - (SDLTest_TestCaseFp)TestGuidFromString, "TestGuidFromString", "Call to SDL_GUIDFromString", TEST_ENABLED + (SDLTest_TestCaseFp)TestStringToGUID, "TestStringToGUID", "Call to SDL_StringToGUID", TEST_ENABLED }; static const SDLTest_TestCaseReference guidTest2 = { - (SDLTest_TestCaseFp)TestGuidToString, "TestGuidToString", "Call to SDL_GUIDToString", TEST_ENABLED + (SDLTest_TestCaseFp)TestGUIDToString, "TestGUIDToString", "Call to SDL_GUIDToString", TEST_ENABLED }; /* Sequence of GUID routine test cases */