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 9271 8f71cb5dc099
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
--- a/src/core/android/SDL_android.c	Wed Dec 10 21:13:43 2014 +0100
+++ b/src/core/android/SDL_android.c	Wed Dec 10 21:20:41 2014 +0100
@@ -44,8 +44,8 @@
 #define LOG_TAG "SDL_android"
 /* #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */
 /* #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */
-#define LOGI(...) do {} while (false)
-#define LOGE(...) do {} while (false)
+#define LOGI(...) do {} while (0)
+#define LOGE(...) do {} while (0)
 
 /* Uncomment this to log messages entering and exiting methods in this file */
 /* #define DEBUG_JNI */
@@ -57,7 +57,6 @@
 *******************************************************************************/
 #include <jni.h>
 #include <android/log.h>
-#include <stdbool.h>
 
 
 /*******************************************************************************
@@ -80,7 +79,7 @@
 
 /* Accelerometer data storage */
 static float fLastAccelerometer[3];
-static bool bHasNewData;
+static SDL_bool bHasNewData;
 
 /*******************************************************************************
                  Functions called by JNI
@@ -132,7 +131,7 @@
     midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
                                 "pollInputDevices", "()V");
 
-    bHasNewData = false;
+    bHasNewData = SDL_FALSE;
 
     if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
        !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
@@ -302,7 +301,7 @@
     fLastAccelerometer[0] = x;
     fLastAccelerometer[1] = y;
     fLastAccelerometer[2] = z;
-    bHasNewData = true;
+    bHasNewData = SDL_TRUE;
 }
 
 /* Low memory */
@@ -487,7 +486,7 @@
         for (i = 0; i < 3; ++i) {
             values[i] = fLastAccelerometer[i];
         }
-        bHasNewData = false;
+        bHasNewData = SDL_FALSE;
         retval = SDL_TRUE;
     }
 
@@ -647,7 +646,7 @@
 
 /* Test for an exception and call SDL_SetError with its detail if one occurs */
 /* If the parameter silent is truthy then SDL_SetError() will not be called. */
-static bool Android_JNI_ExceptionOccurred(bool silent)
+static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
 {
     SDL_assert(LocalReferenceHolder_IsActive());
     JNIEnv *mEnv = Android_JNI_GetEnv();
@@ -681,10 +680,10 @@
             (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8);
         }
 
-        return true;
+        return SDL_TRUE;
     }
 
-    return false;
+    return SDL_FALSE;
 }
 
 static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
@@ -728,19 +727,19 @@
     */
     mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
     inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString);
-    if (Android_JNI_ExceptionOccurred(true)) {
+    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
     mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
     ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
-    if (Android_JNI_ExceptionOccurred(true)) {
+    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
     mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
     ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
-    if (Android_JNI_ExceptionOccurred(true)) {
+    if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
         goto fallback;
     }
 
@@ -754,7 +753,7 @@
     /* Seek to the correct offset in the file. */
     lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
 
-    if (false) {
+    if (0) {
 fallback:
         /* Disabled log message because of spam on the Nexus 7 */
         /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */
@@ -766,13 +765,13 @@
         mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager),
                 "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
         inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
-        if (Android_JNI_ExceptionOccurred(false)) {
+        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             // Try fallback to APK Extension files
             mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
                 "openAPKExtensionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
             inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);
 
-            if (Android_JNI_ExceptionOccurred(false)) {
+            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 goto failure;
             }
         }
@@ -790,7 +789,7 @@
         mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
                 "available", "()I");
         ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid);
-        if (Android_JNI_ExceptionOccurred(false)) {
+        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             goto failure;
         }
 
@@ -801,7 +800,7 @@
                 "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
         readableByteChannel = (*mEnv)->CallStaticObjectMethod(
                 mEnv, channels, mid, inputStream);
-        if (Android_JNI_ExceptionOccurred(false)) {
+        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
             goto failure;
         }
 
@@ -814,7 +813,7 @@
         ctx->hidden.androidio.readMethod = mid;
     }
 
-    if (false) {
+    if (0) {
 failure:
         result = -1;
 
@@ -907,7 +906,7 @@
             /* result = readableByteChannel.read(...); */
             int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer);
 
-            if (Android_JNI_ExceptionOccurred(false)) {
+            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 LocalReferenceHolder_Cleanup(&refs);            
                 return 0;
             }
@@ -932,7 +931,7 @@
     return 0;
 }
 
-static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release)
+static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release)
 {
     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
 
@@ -955,7 +954,7 @@
                     "close", "()V");
             (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
             (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
-            if (Android_JNI_ExceptionOccurred(false)) {
+            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 result = -1;
             }
         }
@@ -968,7 +967,7 @@
             (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
             (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
             (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
-            if (Android_JNI_ExceptionOccurred(false)) {
+            if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
                 result = -1;
             }
         }
@@ -1059,7 +1058,7 @@
         } else if (movement < 0) {
             /* We can't seek backwards so we have to reopen the file and seek */
             /* forwards which obviously isn't very efficient */
-            Internal_Android_JNI_FileClose(ctx, false);
+            Internal_Android_JNI_FileClose(ctx, SDL_FALSE);
             Internal_Android_JNI_FileOpen(ctx);
             Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET);
         }
@@ -1071,7 +1070,7 @@
 
 int Android_JNI_FileClose(SDL_RWops* ctx)
 {
-    return Internal_Android_JNI_FileClose(ctx, true);
+    return Internal_Android_JNI_FileClose(ctx, SDL_TRUE);
 }
 
 /* returns a new global reference which needs to be released later */