Removed dependency to stdbool.h in implementation file for Android. This reduced mixing of different types in the file (bool, jboolean, SDL_bool).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 51a1269..e09b06d 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -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 @@ static void Android_JNI_ThreadDestroyed(void*);
*******************************************************************************/
#include <jni.h>
#include <android/log.h>
-#include <stdbool.h>
/*******************************************************************************
@@ -80,7 +79,7 @@ static jmethodID midPollInputDevices;
/* Accelerometer data storage */
static float fLastAccelerometer[3];
-static bool bHasNewData;
+static SDL_bool bHasNewData;
/*******************************************************************************
Functions called by JNI
@@ -132,7 +131,7 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
"pollInputDevices", "()V");
- bHasNewData = false;
+ bHasNewData = SDL_FALSE;
if(!midGetNativeSurface || !midFlipBuffers || !midAudioInit ||
!midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit || !midPollInputDevices) {
@@ -302,7 +301,7 @@ JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeAccel(
fLastAccelerometer[0] = x;
fLastAccelerometer[1] = y;
fLastAccelerometer[2] = z;
- bHasNewData = true;
+ bHasNewData = SDL_TRUE;
}
/* Low memory */
@@ -487,7 +486,7 @@ SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
for (i = 0; i < 3; ++i) {
values[i] = fLastAccelerometer[i];
}
- bHasNewData = false;
+ bHasNewData = SDL_FALSE;
retval = SDL_TRUE;
}
@@ -647,7 +646,7 @@ void Android_JNI_CloseAudioDevice()
/* 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 @@ static bool Android_JNI_ExceptionOccurred(bool silent)
(*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 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
*/
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 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
/* 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 @@ fallback:
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 @@ fallback:
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 @@ fallback:
"(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 @@ fallback:
ctx->hidden.androidio.readMethod = mid;
}
- if (false) {
+ if (0) {
failure:
result = -1;
@@ -907,7 +906,7 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
/* 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 @@ size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer,
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 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release)
"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 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, bool release)
(*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 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
} 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 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
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 */