sdl2-compat: Fixed bug #30 - add SDL_RunApp() (thanks @DanielGibson)

From e8431199233d65c9a042c32fafd7e3e1d6f31374 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Wed, 1 Feb 2023 13:12:31 +0100
Subject: [PATCH] Fixed bug #30 - add SDL_RunApp() (thanks @DanielGibson)

---
 src/sdl2_compat.c          | 21 +++++++++++++++++++++
 src/sdl3_include_wrapper.h |  1 +
 src/sdl3_syms.h            |  6 +-----
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index fbcc961..b0b7bbc 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -4352,6 +4352,27 @@ DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window *window, int *w, int
     SDL_GetWindowSizeInPixels(window, w, h);
 }
 
+#ifdef __WINRT__
+DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void *reserved)
+{
+    return SDL3_RunApp(0, NULL, mainFunction, reserved);
+}
+#endif
+
+#if defined(__GDK__)
+DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
+{
+    return SDL3_RunApp(0, NULL, mainFunction, reserved);
+}
+#endif
+
+#ifdef __IOS__
+DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction)
+{
+    return SDL3_RunApp(argc, argv, mainFunction, NULL);
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index d838825..6f8e654 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -873,6 +873,7 @@
 #define SDL_DISABLE_OLD_NAMES 1
 #define __BUILDING_SDL2_COMPAT__ 1
 #include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
 
 #if !SDL_VERSION_ATLEAST(3,0,0)
 #error You need to compile against SDL >= 3.0.0 headers.
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 964b463..0394603 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -550,7 +550,6 @@ SDL3_SYM_PASSTHROUGH(SDL_bool,DXGIGetOutputInfo,(int a,int *b, int *c),(a,b,c),r
 #endif
 SDL3_SYM_RENAMED(SDL_bool,RenderIsClipEnabled,RenderClipEnabled,(SDL_Renderer *a),(a),return)
 #ifdef __WINRT__
-SDL3_SYM_PASSTHROUGH(int,WinRTRunApp,(int a, char **b, void *c),(a,b,c),return)
 SDL3_SYM_PASSTHROUGH(const wchar_t*,WinRTGetFSPathUNICODE,(SDL_WinRT_Path a),(a),return)
 SDL3_SYM_PASSTHROUGH(const char*,WinRTGetFSPathUTF8,(SDL_WinRT_Path a),(a),return)
 #endif
@@ -689,9 +688,6 @@ SDL3_SYM_RENAMED(int,RenderFillRectsF,RenderFillRects,(SDL_Renderer *a, const SD
 SDL3_SYM_RENAMED(int,RenderCopyF,RenderTexture,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d),(a,b,c,d),return)
 SDL3_SYM_RENAMED(int,RenderCopyExF,RenderTextureRotated,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_RendererFlip g),(a,b,c,d,e,f,g),return)
 SDL3_SYM_PASSTHROUGH(SDL_TouchDeviceType,GetTouchDeviceType,(SDL_TouchID a),(a),return)
-#ifdef __IOS__
-SDL3_SYM_PASSTHROUGH(int,UIKitRunApp,(int a, char *b, SDL_main_func c),(a,b,c),return)
-#endif
 SDL3_SYM_PASSTHROUGH(size_t,SIMDGetAlignment,(void),(),return)
 SDL3_SYM(void*,aligned_alloc,(size_t a, size_t b),(a,b),return)
 SDL3_SYM(void,aligned_free,(void *a),(a),)
@@ -866,7 +862,6 @@ SDL3_SYM_PASSTHROUGH(size_t,utf8strnlen,(const char *a, size_t b),(a,b),return)
 
 #if defined(__GDK__)
 SDL3_SYM_PASSTHROUGH(int,GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,GDKRunApp,(SDL_main_func a, void *b),(a,b),return)
 #endif
 SDL3_SYM_PASSTHROUGH(void,GetOriginalMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
 SDL3_SYM_PASSTHROUGH(void,ResetKeyboard,(void),(),)
@@ -919,6 +914,7 @@ SDL3_SYM(SDL_DisplayID,GetDisplayForWindow,(SDL_Window *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetDisplayForPoint,(const SDL_Point *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetDisplayForRect,(const SDL_Rect *a),(a),return)
 SDL3_SYM(SDL_DisplayID,GetPrimaryDisplay,(),(),return)
+SDL3_SYM(int,RunApp,(int a, char *b, SDL_main_func c, void *d),(a,b,c,d),return)
 
 #undef SDL3_SYM
 #undef SDL3_SYM_PASSTHROUGH