# HG changeset patch # User Xeli # Date 1308859051 -7200 # Node ID cd9b7b170fbf3effafdded92fee3582b1e6bb701 # Parent c239cb473a3f21f633a972298df044167d543157 more packing name changes diff -r c239cb473a3f -r cd9b7b170fbf project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp Thu Jun 23 21:57:31 2011 +0200 @@ -0,0 +1,47 @@ + +/* Include the SDL main definition header */ +#include "SDL_main.h" + +/******************************************************************************* + Functions called by JNI +*******************************************************************************/ +#include + +// Called before SDL_main() to initialize JNI bindings in SDL library +extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls); + +// Library init +extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) +{ + return JNI_VERSION_1_4; +} + +// Start up the SDL app +extern "C" void Java_org_hedgewars_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobjectArray strArray) +{ + /* This interface could expand with ABI negotiation, calbacks, etc. */ + SDL_Android_Init(env, cls); + + //Get the String array from java + int argc = env->GetArrayLength(strArray); + char* argv[argc]; + jstring jstringArgv[argc]; + for(int i = 0; i < argc; i++){ + jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i); //get the element + strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location + env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]); //release mem + } + + /* Run the application code! */ + int status; + status = SDL_main(argc, argv); + + //Clean up argv + for(int i = 0; i < argc; i++){ + } + + /* We exit here for consistency with other platforms. */ + exit(status); +} + +/* vi: set ts=4 sw=4 expandtab: */