SDL_migration.cocci / rename_api.py: handle migration of enum/structure

and fix previous one in SDL_migration.cocci.
This commit is contained in:
Sylvain 2023-01-11 23:26:53 +01:00 committed by Sylvain Becker
parent 30516fd3a6
commit 84cd7214bd
2 changed files with 36 additions and 14 deletions

View File

@ -540,30 +540,30 @@ SDL_CreateRenderer(e1,
- SDL_CONTROLLERTOUCHPADUP
+ SDL_GAMEPADTOUCHPADUP
@@
typedef SDL_ControllerAxisEvent, SDL_GamepadAxisEvent;
@@
- SDL_ControllerAxisEvent
+ SDL_GamepadAxisEvent
(...)
@@
typedef SDL_ControllerButtonEvent, SDL_GamepadButtonEvent;
@@
- SDL_ControllerButtonEvent
+ SDL_GamepadButtonEvent
(...)
@@
typedef SDL_ControllerDeviceEvent, SDL_GamepadDeviceEvent;
@@
- SDL_ControllerDeviceEvent
+ SDL_GamepadDeviceEvent
(...)
@@
typedef SDL_ControllerSensorEvent, SDL_GamepadSensorEvent;
@@
- SDL_ControllerSensorEvent
+ SDL_GamepadSensorEvent
(...)
@@
typedef SDL_ControllerTouchpadEvent, SDL_GamepadTouchpadEvent;
@@
- SDL_ControllerTouchpadEvent
+ SDL_GamepadTouchpadEvent
(...)
@@
@@
- SDL_CONTROLLER_AXIS_INVALID
@ -761,10 +761,10 @@ SDL_CreateRenderer(e1,
- SDL_CONTROLLER_TYPE_XBOXONE
+ SDL_GAMEPAD_TYPE_XBOXONE
@@
typedef SDL_GameController, SDL_Gamepad;
@@
- SDL_GameController
+ SDL_Gamepad
(...)
@@
@@
- SDL_GameControllerAddMapping
@ -781,25 +781,25 @@ SDL_CreateRenderer(e1,
+ SDL_AddGamepadMappingsFromRW
(...)
@@
typedef SDL_GameControllerAxis, SDL_GamepadAxis;
@@
- SDL_GameControllerAxis
+ SDL_GamepadAxis
(...)
@@
typedef SDL_GameControllerBindType, SDL_GamepadBindingType;
@@
- SDL_GameControllerBindType
+ SDL_GamepadBindingType
(...)
@@
typedef SDL_GameControllerButton, SDL_GamepadButton;
@@
- SDL_GameControllerButton
+ SDL_GamepadButton
(...)
@@
typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
@@
- SDL_GameControllerButtonBind
+ SDL_GamepadBinding
(...)
@@
@@
- SDL_GameControllerClose

View File

@ -88,12 +88,34 @@ def add_content(lines, i, content, add_trailing_line):
def add_symbol_to_coccinelle(symbol_type, oldname, newname):
file = open(SDL_BUILD_SCRIPTS / "SDL_migration.cocci", "a")
# Append-adds at last
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
if symbol_type == "function":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
file.write(" (...)\n")
if symbol_type == "symbol":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
# double check ?
if symbol_type == "hint":
file.write("@@\n")
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
if symbol_type == "enum" or symbol_type == "structure":
file.write("@@\n")
file.write("typedef %s, %s;\n" % (oldname, newname))
file.write("@@\n")
file.write("- %s\n" % oldname)
file.write("+ %s\n" % newname)
file.close()