Enable SDL_LoadObject on iOS 8+ and tvOS.
authorAlex Szpakowski <slime73@gmail.com>
Sun, 25 Sep 2016 15:02:06 -0300
changeset 1037219b0437c4099
parent 10371 155d4f094f62
child 10373 b0f90ab3a5f6
Enable SDL_LoadObject on iOS 8+ and tvOS.
include/SDL_config_iphoneos.h
premake/Xcode-iOS/SDL_config_premake.h
premake/projects/SDL2.lua
src/loadso/dlopen/SDL_sysloadso.c
src/video/uikit/SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.m
     1.1 --- a/include/SDL_config_iphoneos.h	Sun Sep 25 11:46:25 2016 -0300
     1.2 +++ b/include/SDL_config_iphoneos.h	Sun Sep 25 15:02:06 2016 -0300
     1.3 @@ -119,11 +119,7 @@
     1.4  #define SDL_JOYSTICK_MFI 1
     1.5  
     1.6  /* Enable Unix style SO loading */
     1.7 -/* Technically this works, but violates the iOS dev agreement prior to iOS 8 */
     1.8 -/* #define SDL_LOADSO_DLOPEN 1 */
     1.9 -
    1.10 -/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
    1.11 -#define SDL_LOADSO_DISABLED 1
    1.12 +#define SDL_LOADSO_DLOPEN 1
    1.13  
    1.14  /* Enable various threading systems */
    1.15  #define SDL_THREAD_PTHREAD  1
     2.1 --- a/premake/Xcode-iOS/SDL_config_premake.h	Sun Sep 25 11:46:25 2016 -0300
     2.2 +++ b/premake/Xcode-iOS/SDL_config_premake.h	Sun Sep 25 15:02:06 2016 -0300
     2.3 @@ -150,8 +150,8 @@
     2.4  #ifndef SDL_VIDEO_RENDER_OGL_ES2
     2.5  #define SDL_VIDEO_RENDER_OGL_ES2 1
     2.6  #endif
     2.7 -#ifndef SDL_LOADSO_DISABLED
     2.8 -#define SDL_LOADSO_DISABLED 1
     2.9 +#ifndef SDL_LOADSO_DLOPEN
    2.10 +#define SDL_LOADSO_DLOPEN 1
    2.11  #endif
    2.12  #ifndef SDL_HAPTIC_DISABLED
    2.13  #define SDL_HAPTIC_DISABLED 1
     3.1 --- a/premake/projects/SDL2.lua	Sun Sep 25 11:46:25 2016 -0300
     3.2 +++ b/premake/projects/SDL2.lua	Sun Sep 25 15:02:06 2016 -0300
     3.3 @@ -369,7 +369,7 @@
     3.4  			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
     3.5  			["SDL_JOYSTICK_MFI"] = 1,
     3.6  			["SDL_HAPTIC_DISABLED"] = 1,
     3.7 -			["SDL_LOADSO_DISABLED"] = 1,
     3.8 +			["SDL_LOADSO_DLOPEN"] = 1,
     3.9  			["SDL_THREAD_PTHREAD"] = 1,
    3.10  			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
    3.11  			["SDL_TIMER_UNIX"] = 1,
     4.1 --- a/src/loadso/dlopen/SDL_sysloadso.c	Sun Sep 25 11:46:25 2016 -0300
     4.2 +++ b/src/loadso/dlopen/SDL_sysloadso.c	Sun Sep 25 15:02:06 2016 -0300
     4.3 @@ -30,11 +30,25 @@
     4.4  
     4.5  #include "SDL_loadso.h"
     4.6  
     4.7 +#if SDL_VIDEO_DRIVER_UIKIT
     4.8 +#include "../../video/uikit/SDL_uikitvideo.h"
     4.9 +#endif
    4.10 +
    4.11  void *
    4.12  SDL_LoadObject(const char *sofile)
    4.13  {
    4.14 -    void *handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
    4.15 -    const char *loaderror = (char *) dlerror();
    4.16 +    void *handle;
    4.17 +    const char *loaderror;
    4.18 +
    4.19 +#if SDL_VIDEO_DRIVER_UIKIT
    4.20 +    if (!UIKit_IsSystemVersionAtLeast(8.0)) {
    4.21 +        SDL_SetError("SDL_LoadObject requires iOS 8+");
    4.22 +        return NULL;
    4.23 +    }
    4.24 +#endif
    4.25 +
    4.26 +    handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
    4.27 +    loaderror = (char *) dlerror();
    4.28      if (handle == NULL) {
    4.29          SDL_SetError("Failed loading %s: %s", sofile, loaderror);
    4.30      }
     5.1 --- a/src/video/uikit/SDL_uikitvideo.h	Sun Sep 25 11:46:25 2016 -0300
     5.2 +++ b/src/video/uikit/SDL_uikitvideo.h	Sun Sep 25 15:02:06 2016 -0300
     5.3 @@ -21,20 +21,25 @@
     5.4  #ifndef _SDL_uikitvideo_h
     5.5  #define _SDL_uikitvideo_h
     5.6  
     5.7 +#include "../SDL_sysvideo.h"
     5.8 +
     5.9 +#ifdef __OBJC__
    5.10 +
    5.11  #include <UIKit/UIKit.h>
    5.12  
    5.13 -#include "../SDL_sysvideo.h"
    5.14 -
    5.15  @interface SDL_VideoData : NSObject
    5.16  
    5.17  @property (nonatomic) id pasteboardObserver;
    5.18  
    5.19  @end
    5.20  
    5.21 +CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
    5.22 +
    5.23 +#endif /* __OBJC__ */
    5.24 +
    5.25  void UIKit_SuspendScreenSaver(_THIS);
    5.26  
    5.27 -BOOL UIKit_IsSystemVersionAtLeast(double version);
    5.28 -CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
    5.29 +SDL_bool UIKit_IsSystemVersionAtLeast(double version);
    5.30  
    5.31  #endif /* _SDL_uikitvideo_h */
    5.32  
     6.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sun Sep 25 11:46:25 2016 -0300
     6.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sun Sep 25 15:02:06 2016 -0300
     6.3 @@ -167,7 +167,7 @@
     6.4      }
     6.5  }
     6.6  
     6.7 -BOOL
     6.8 +SDL_bool
     6.9  UIKit_IsSystemVersionAtLeast(double version)
    6.10  {
    6.11      return [[UIDevice currentDevice].systemVersion doubleValue] >= version;