Added version checking to SDLActivity.java
Make sure the SDL java and C code match when updating SDL in a game. Right now we're assuming that we only have to make sure release versions match. We can extend the version string with an interface version if we need more fine grained sanity checking. Fixes https://github.com/libsdl-org/SDL/issues/1540
This commit is contained in:
parent
3607f8316f
commit
5291e5cb76
4 changed files with 46 additions and 2 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "SDL_hints.h"
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
|
@ -63,6 +64,9 @@
|
|||
#define ENCODING_PCM_FLOAT 4
|
||||
|
||||
/* Java class SDLActivity */
|
||||
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(
|
||||
JNIEnv *env, jclass cls);
|
||||
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
|
||||
JNIEnv *env, jclass cls);
|
||||
|
||||
|
@ -167,6 +171,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)(
|
|||
jint requestCode, jboolean result);
|
||||
|
||||
static JNINativeMethod SDLActivity_tab[] = {
|
||||
{ "nativeGetVersion", "()Ljava/lang/String;", SDL_JAVA_INTERFACE(nativeGetVersion) },
|
||||
{ "nativeSetupJNI", "()I", SDL_JAVA_INTERFACE(nativeSetupJNI) },
|
||||
{ "nativeRunMain", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I", SDL_JAVA_INTERFACE(nativeRunMain) },
|
||||
{ "onNativeDropFile", "(Ljava/lang/String;)V", SDL_JAVA_INTERFACE(onNativeDropFile) },
|
||||
|
@ -536,6 +541,16 @@ void checkJNIReady(void)
|
|||
SDL_SetMainReady();
|
||||
}
|
||||
|
||||
/* Get SDL version -- called before SDL_main() to verify JNI bindings */
|
||||
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetVersion)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
char version[128];
|
||||
|
||||
SDL_snprintf(version, sizeof(version), "%d.%d.%d", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
||||
|
||||
return (*env)->NewStringUTF(env, version);
|
||||
}
|
||||
|
||||
/* Activity initialization -- called before SDL_main() to initialize JNI bindings */
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue