Commit 1e5dad61 authored by Pascal Menuet's avatar Pascal Menuet

Cleaner fix for VS2015

parent fe2fd053
...@@ -16,8 +16,18 @@ ...@@ -16,8 +16,18 @@
#pragma once #pragma once
#ifdef _MSC_VER // weak attribute not supported by MSVC #ifdef _MSC_VER
#define DJINNI_WEAK_DEFINITION #define DJINNI_WEAK_DEFINITION // weak attribute not supported by MSVC
#define DJINNI_NORETURN_DEFINITION __declspec(noreturn)
#if _MSC_VER < 1900 // snprintf not implemented prior to VS2015
#define DJINNI_SNPRINTF snprintf
#define noexcept _NOEXCEPT // work-around for missing noexcept VS2015
#define constexpr // work-around for missing constexpr VS2015
#else
#define DJINNI_SNPRINTF _snprintf
#endif
#else #else
#define DJINNI_WEAK_DEFINITION __attribute__((weak)) #define DJINNI_WEAK_DEFINITION __attribute__((weak))
#define DJINNI_NORETURN_DEFINITION __attribute__((noreturn))
#define DJINNI_SNPRINTF snprintf
#endif #endif
...@@ -113,7 +113,8 @@ void jniExceptionCheck(JNIEnv * env) { ...@@ -113,7 +113,8 @@ void jniExceptionCheck(JNIEnv * env) {
} }
} }
DJINNI_WEAK_DEFINITION __attribute__((noreturn)) DJINNI_WEAK_DEFINITION
DJINNI_NORETURN_DEFINITION
void jniThrowCppFromJavaException(JNIEnv * env, jthrowable java_exception) { void jniThrowCppFromJavaException(JNIEnv * env, jthrowable java_exception) {
throw jni_exception { env, java_exception }; throw jni_exception { env, java_exception };
} }
...@@ -154,12 +155,7 @@ void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const cha ...@@ -154,12 +155,7 @@ void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const cha
const char * file_basename = slash ? slash + 1 : file; const char * file_basename = slash ? slash + 1 : file;
char buf[256]; char buf[256];
#if (defined _MSC_VER) && (_MSC_VER < 1900) DJINNI_SNPRINTF(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check);
// snprintf not implemented on MSVC prior to 2015
_snprintf(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check);
#else
snprintf(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check);
#endif
const jclass cassert = env->FindClass("java/lang/Error"); const jclass cassert = env->FindClass("java/lang/Error");
assert(cassert); assert(cassert);
......
...@@ -24,14 +24,9 @@ ...@@ -24,14 +24,9 @@
#include <unordered_map> #include <unordered_map>
#include "../proxy_cache_interface.hpp" #include "../proxy_cache_interface.hpp"
#include "../djinni_common.hpp"
#include <jni.h> #include <jni.h>
// work-around for missing noexcept and constexpr support in MSVC prior to 2015
#if (defined _MSC_VER) && (_MSC_VER < 1900)
# define noexcept _NOEXCEPT
# define constexpr
#endif
/* /*
* Djinni support library * Djinni support library
*/ */
...@@ -150,17 +145,13 @@ void jniExceptionCheck(JNIEnv * env); ...@@ -150,17 +145,13 @@ void jniExceptionCheck(JNIEnv * env);
* can replace it by defining your own version. The default implementation * can replace it by defining your own version. The default implementation
* will throw a jni_exception containing the given jthrowable. * will throw a jni_exception containing the given jthrowable.
*/ */
__attribute__((noreturn)) DJINNI_NORETURN_DEFINITION
void jniThrowCppFromJavaException(JNIEnv * env, jthrowable java_exception); void jniThrowCppFromJavaException(JNIEnv * env, jthrowable java_exception);
/* /*
* Set an AssertionError in env with message message, and then throw via jniExceptionCheck. * Set an AssertionError in env with message message, and then throw via jniExceptionCheck.
*/ */
#ifdef _MSC_VER DJINNI_NORETURN_DEFINITION
__declspec(noreturn)
#else
__attribute__((noreturn))
#endif
void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const char * check); void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const char * check);
#define DJINNI_ASSERT_MSG(check, env, message) \ #define DJINNI_ASSERT_MSG(check, env, message) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment