Removed dependency to stdbool.h in implementation file for Android.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 10 Dec 2014 21:20:41 +0100
changeset 92718f71cb5dc099
parent 9270 4b93f61e564d
child 9272 5c894fec85b9
Removed dependency to stdbool.h in implementation file for Android.

This reduced mixing of different types in the file (bool, jboolean, SDL_bool).
src/core/android/SDL_android.c
     1.1 --- a/src/core/android/SDL_android.c	Wed Dec 10 21:13:43 2014 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Wed Dec 10 21:20:41 2014 +0100
     1.3 @@ -44,8 +44,8 @@
     1.4  #define LOG_TAG "SDL_android"
     1.5  /* #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */
     1.6  /* #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */
     1.7 -#define LOGI(...) do {} while (false)
     1.8 -#define LOGE(...) do {} while (false)
     1.9 +#define LOGI(...) do {} while (0)
    1.10 +#define LOGE(...) do {} while (0)
    1.11  
    1.12  /* Uncomment this to log messages entering and exiting methods in this file */
    1.13  /* #define DEBUG_JNI */
    1.14 @@ -57,7 +57,6 @@
    1.15  *******************************************************************************/
    1.16  #include <jni.h>
    1.17  #include <android/log.h>
    1.18 -#include <stdbool.h>
    1.19  
    1.20  
    1.21  /*******************************************************************************
    1.22 @@ -80,7 +79,7 @@
    1.23  
    1.24  /* Accelerometer data storage */
    1.25  static float fLastAccelerometer[3];
    1.26 -static bool bHasNewData;
    1.27 +static SDL_bool bHasNewData;
    1.28  
    1.29  /*******************************************************************************
    1.30                   Functions called by JNI
    1.31 @@ -132,7 +131,7 @@
    1.32      midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.33                                  "pollInputDevices", "()V");
    1.34  
    1.35 -    bHasNewData = false;
    1.36 +    bHasNewData = SDL_FALSE;
    1.37  
    1.38      if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
    1.39         !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
    1.40 @@ -302,7 +301,7 @@
    1.41      fLastAccelerometer[0] = x;
    1.42      fLastAccelerometer[1] = y;
    1.43      fLastAccelerometer[2] = z;
    1.44 -    bHasNewData = true;
    1.45 +    bHasNewData = SDL_TRUE;
    1.46  }
    1.47  
    1.48  /* Low memory */
    1.49 @@ -487,7 +486,7 @@
    1.50          for (i = 0; i < 3; ++i) {
    1.51              values[i] = fLastAccelerometer[i];
    1.52          }
    1.53 -        bHasNewData = false;
    1.54 +        bHasNewData = SDL_FALSE;
    1.55          retval = SDL_TRUE;
    1.56      }
    1.57  
    1.58 @@ -647,7 +646,7 @@
    1.59  
    1.60  /* Test for an exception and call SDL_SetError with its detail if one occurs */
    1.61  /* If the parameter silent is truthy then SDL_SetError() will not be called. */
    1.62 -static bool Android_JNI_ExceptionOccurred(bool silent)
    1.63 +static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
    1.64  {
    1.65      SDL_assert(LocalReferenceHolder_IsActive());
    1.66      JNIEnv *mEnv = Android_JNI_GetEnv();
    1.67 @@ -681,10 +680,10 @@
    1.68              (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8);
    1.69          }
    1.70  
    1.71 -        return true;
    1.72 +        return SDL_TRUE;
    1.73      }
    1.74  
    1.75 -    return false;
    1.76 +    return SDL_FALSE;
    1.77  }
    1.78  
    1.79  static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
    1.80 @@ -728,19 +727,19 @@
    1.81      */
    1.82      mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
    1.83      inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString);
    1.84 -    if (Android_JNI_ExceptionOccurred(true)) {
    1.85 +    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
    1.86          goto fallback;
    1.87      }
    1.88  
    1.89      mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
    1.90      ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.91 -    if (Android_JNI_ExceptionOccurred(true)) {
    1.92 +    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
    1.93          goto fallback;
    1.94      }
    1.95  
    1.96      mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
    1.97      ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.98 -    if (Android_JNI_ExceptionOccurred(true)) {
    1.99 +    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
   1.100          goto fallback;
   1.101      }
   1.102  
   1.103 @@ -754,7 +753,7 @@
   1.104      /* Seek to the correct offset in the file. */
   1.105      lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
   1.106  
   1.107 -    if (false) {
   1.108 +    if (0) {
   1.109  fallback:
   1.110          /* Disabled log message because of spam on the Nexus 7 */
   1.111          /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */
   1.112 @@ -766,13 +765,13 @@
   1.113          mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager),
   1.114                  "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
   1.115          inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
   1.116 -        if (Android_JNI_ExceptionOccurred(false)) {
   1.117 +        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.118              // Try fallback to APK Extension files
   1.119              mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
   1.120                  "openAPKExtensionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
   1.121              inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
   1.122  
   1.123 -            if (Android_JNI_ExceptionOccurred(false)) {
   1.124 +            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.125                  goto failure;
   1.126              }
   1.127          }
   1.128 @@ -790,7 +789,7 @@
   1.129          mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
   1.130                  "available", "()I");
   1.131          ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid);
   1.132 -        if (Android_JNI_ExceptionOccurred(false)) {
   1.133 +        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.134              goto failure;
   1.135          }
   1.136  
   1.137 @@ -801,7 +800,7 @@
   1.138                  "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
   1.139          readableByteChannel = (*mEnv)->CallStaticObjectMethod(
   1.140                  mEnv, channels, mid, inputStream);
   1.141 -        if (Android_JNI_ExceptionOccurred(false)) {
   1.142 +        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.143              goto failure;
   1.144          }
   1.145  
   1.146 @@ -814,7 +813,7 @@
   1.147          ctx->hidden.androidio.readMethod = mid;
   1.148      }
   1.149  
   1.150 -    if (false) {
   1.151 +    if (0) {
   1.152  failure:
   1.153          result = -1;
   1.154  
   1.155 @@ -907,7 +906,7 @@
   1.156              /* result = readableByteChannel.read(...); */
   1.157              int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer);
   1.158  
   1.159 -            if (Android_JNI_ExceptionOccurred(false)) {
   1.160 +            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.161                  LocalReferenceHolder_Cleanup(&refs);            
   1.162                  return 0;
   1.163              }
   1.164 @@ -932,7 +931,7 @@
   1.165      return 0;
   1.166  }
   1.167  
   1.168 -static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release)
   1.169 +static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release)
   1.170  {
   1.171      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
   1.172  
   1.173 @@ -955,7 +954,7 @@
   1.174                      "close", "()V");
   1.175              (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
   1.176              (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
   1.177 -            if (Android_JNI_ExceptionOccurred(false)) {
   1.178 +            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.179                  result = -1;
   1.180              }
   1.181          }
   1.182 @@ -968,7 +967,7 @@
   1.183              (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
   1.184              (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
   1.185              (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
   1.186 -            if (Android_JNI_ExceptionOccurred(false)) {
   1.187 +            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.188                  result = -1;
   1.189              }
   1.190          }
   1.191 @@ -1059,7 +1058,7 @@
   1.192          } else if (movement < 0) {
   1.193              /* We can't seek backwards so we have to reopen the file and seek */
   1.194              /* forwards which obviously isn't very efficient */
   1.195 -            Internal_Android_JNI_FileClose(ctx, false);
   1.196 +            Internal_Android_JNI_FileClose(ctx, SDL_FALSE);
   1.197              Internal_Android_JNI_FileOpen(ctx);
   1.198              Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET);
   1.199          }
   1.200 @@ -1071,7 +1070,7 @@
   1.201  
   1.202  int Android_JNI_FileClose(SDL_RWops* ctx)
   1.203  {
   1.204 -    return Internal_Android_JNI_FileClose(ctx, true);
   1.205 +    return Internal_Android_JNI_FileClose(ctx, SDL_TRUE);
   1.206  }
   1.207  
   1.208  /* returns a new global reference which needs to be released later */