Add #error case to all platform #if/else chains

This is a bit more robust: if we typo one of the platform defines, we'll
know about it rather than silently missing bits of code.
bzip2
Graham 5 years ago
parent a902d6655e
commit adffb1ecac
  1. 30
      gl-natives/src/main/c/jaggl.c

@ -78,6 +78,8 @@
#define JAGGL_UNLOCK(env) #define JAGGL_UNLOCK(env)
#define JAGGL_PROC_ADDR(name) wglGetProcAddress(name) #define JAGGL_PROC_ADDR(name) wglGetProcAddress(name)
#else
#error Unsupported platform
#endif #endif
#if defined(__unix__) #if defined(__unix__)
@ -91,6 +93,8 @@ static bool jaggl_double_buffered;
static HWND jaggl_window; static HWND jaggl_window;
static HDC jaggl_device; static HDC jaggl_device;
static HGLRC jaggl_context; static HGLRC jaggl_context;
#else
#error Unsupported platform
#endif #endif
static int jaggl_alpha_bits; static int jaggl_alpha_bits;
@ -144,6 +148,8 @@ static PFNGLXSWAPINTERVALSGIPROC jaggl_glXSwapIntervalSGI;
#elif defined(_WIN32) #elif defined(_WIN32)
static PFNWGLGETEXTENSIONSSTRINGEXTPROC jaggl_wglGetExtensionsStringEXT; static PFNWGLGETEXTENSIONSSTRINGEXTPROC jaggl_wglGetExtensionsStringEXT;
static PFNWGLSWAPINTERVALEXTPROC jaggl_wglSwapIntervalEXT; static PFNWGLSWAPINTERVALEXTPROC jaggl_wglSwapIntervalEXT;
#else
#error Unsupported platform
#endif #endif
static void jaggl_init_proc_table(void) { static void jaggl_init_proc_table(void) {
@ -197,6 +203,8 @@ static void jaggl_init_proc_table(void) {
#elif defined(_WIN32) #elif defined(_WIN32)
jaggl_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) JAGGL_PROC_ADDR("wglGetExtensionsStringEXT"); jaggl_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) JAGGL_PROC_ADDR("wglGetExtensionsStringEXT");
jaggl_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) JAGGL_PROC_ADDR("wglSwapIntervalEXT"); jaggl_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) JAGGL_PROC_ADDR("wglSwapIntervalEXT");
#else
#error Unsupported platform
#endif #endif
} }
@ -227,6 +235,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_createContext(JNIEnv *env, jclass
} }
jaggl_context = wglCreateContext(jaggl_device); jaggl_context = wglCreateContext(jaggl_device);
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -248,6 +258,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_releaseContext(JNIEnv *env, jclass
if (current) { if (current) {
result = (jboolean) wglMakeCurrent(jaggl_device, NULL); result = (jboolean) wglMakeCurrent(jaggl_device, NULL);
} }
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -291,6 +303,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_destroy(JNIEnv *env, jclass cls) {
} }
jaggl_window = NULL; jaggl_window = NULL;
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -310,6 +324,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_swapBuffers(JNIEnv *env, jclass cl
} }
#elif defined(_WIN32) #elif defined(_WIN32)
result = (jboolean) SwapBuffers(jaggl_device); result = (jboolean) SwapBuffers(jaggl_device);
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -317,10 +333,12 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_swapBuffers(JNIEnv *env, jclass cl
} }
JNIEXPORT jint JNICALL Java_jaggl_context_getLastError(JNIEnv *env, jclass cls) { JNIEXPORT jint JNICALL Java_jaggl_context_getLastError(JNIEnv *env, jclass cls) {
#if defined(_WIN32) #if defined(__unix__)
return 0;
#elif defined(_WIN32)
return (jint) GetLastError(); return (jint) GetLastError();
#else #else
return 0; #error Unsupported platform
#endif #endif
} }
@ -335,6 +353,8 @@ JNIEXPORT void JNICALL Java_jaggl_context_setSwapInterval(JNIEnv *env, jclass cl
if (jaggl_wglSwapIntervalEXT) { if (jaggl_wglSwapIntervalEXT) {
jaggl_wglSwapIntervalEXT((int) interval); jaggl_wglSwapIntervalEXT((int) interval);
} }
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -355,6 +375,8 @@ JNIEXPORT jstring JNICALL Java_jaggl_context_getExtensionsString(JNIEnv *env, jc
} else { } else {
extensions = NULL; extensions = NULL;
} }
#else
#error Unsupported platform
#endif #endif
JAGGL_UNLOCK(env); JAGGL_UNLOCK(env);
@ -499,6 +521,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_choosePixelFormat1(JNIEnv *env, jc
goto dsi_free; goto dsi_free;
} }
} }
#else
#error Unsupported platform
#endif #endif
dsi_free: dsi_free:
@ -545,6 +569,8 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_makeCurrent1(JNIEnv *env, jclass c
if (!wglMakeCurrent(jaggl_device, jaggl_context)) { if (!wglMakeCurrent(jaggl_device, jaggl_context)) {
goto done; goto done;
} }
#else
#error Unsupported platform
#endif #endif
jaggl_init_proc_table(); jaggl_init_proc_table();

Loading…
Cancel
Save