GameActivity PATCH: rename symbols to export via Rust

This commit is contained in:
Robert Bragg
2022-05-08 22:27:46 +01:00
parent 9267b60938
commit 32843ac726
3 changed files with 13 additions and 6 deletions
@@ -1295,9 +1295,13 @@ extern "C" int GameActivity_register(JNIEnv *env) {
NELEM(g_methods));
}
// XXX: This symbol is renamed with a _C suffix and then re-exported from
// Rust because Rust/Cargo don't give us a way to directly export symbols
// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
//
// Register this method so that GameActiviy_register does not need to be called
// manually.
extern "C" jlong Java_com_google_androidgamesdk_GameActivity_loadNativeCode(
extern "C" jlong Java_com_google_androidgamesdk_GameActivity_loadNativeCode_C(
JNIEnv *env, jobject javaGameActivity, jstring path, jstring funcName,
jstring internalDataDir, jstring obbDir, jstring externalDataDir,
jobject jAssetMgr, jbyteArray savedState) {
@@ -205,7 +205,7 @@ static void* android_app_entry(void* param) {
pthread_cond_broadcast(&android_app->cond);
pthread_mutex_unlock(&android_app->mutex);
android_main(android_app);
_rust_glue_entry(android_app);
android_app_destroy(android_app);
return NULL;
@@ -542,7 +542,7 @@ static void onWindowInsetsChanged(GameActivity* activity) {
}
JNIEXPORT
void GameActivity_onCreate(GameActivity* activity, void* savedState,
void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
size_t savedStateSize) {
LOGV("Creating: %p", activity);
activity->callbacks->onDestroy = onDestroy;
@@ -452,10 +452,10 @@ void android_app_clear_motion_events(struct android_input_buffer* inputBuffer);
void android_app_clear_key_events(struct android_input_buffer* inputBuffer);
/**
* This is the function that application code must implement, representing
* the main entry to the app.
* This is a springboard into the Rust glue layer that wraps calling the
* main entry for the app itself.
*/
extern void android_main(struct android_app* app);
extern void _rust_glue_entry(struct android_app* app);
/**
* Set the filter to use when processing key events.
@@ -479,6 +479,9 @@ void android_app_set_key_event_filter(struct android_app* app,
void android_app_set_motion_event_filter(struct android_app* app,
android_motion_event_filter filter);
void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
size_t savedStateSize);
#ifdef __cplusplus
}
#endif