0.1.0-0-pre.8
This commit is contained in:
@@ -1,19 +1,37 @@
|
||||
// file: Android/common/src/main/java/com/sasedev/games/common/NativeBridge.java
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
package com.sasedev.games.common;
|
||||
|
||||
/** Stable Java side of the future Java/JNI platform bridge. */
|
||||
/** Stable Java/JNI platform bridge contract shared by Android game applications. */
|
||||
public final class NativeBridge {
|
||||
private static final int CONTRACT_VERSION = 1;
|
||||
|
||||
private NativeBridge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bridge contract version.
|
||||
* Returns the Java-side bridge contract version.
|
||||
*
|
||||
* @return bridge contract version
|
||||
*/
|
||||
public static int contractVersion() {
|
||||
return 1;
|
||||
return CONTRACT_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Rust-side bridge contract version.
|
||||
*
|
||||
* @return native bridge contract version
|
||||
*/
|
||||
public static native int nativeContractVersion();
|
||||
|
||||
/** Verifies that the loaded native bridge matches the Java contract. */
|
||||
public static void requireCompatibleContract() {
|
||||
final int nativeVersion = nativeContractVersion();
|
||||
if (nativeVersion != CONTRACT_VERSION) {
|
||||
throw new IllegalStateException(
|
||||
"Native bridge contract mismatch: java=" + CONTRACT_VERSION + ", native=" + nativeVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// file: Android/common/src/main/java/com/sasedev/games/common/SaseGameActivity.java
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
package com.sasedev.games.common;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* Common Android activity boundary for games.sasedev applications.
|
||||
*
|
||||
@@ -10,6 +12,13 @@ package com.sasedev.games.common;
|
||||
*/
|
||||
public abstract class SaseGameActivity extends org.libsdl.app.SDLActivity {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
NativeBridge.requireCompatibleContract();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final String[] getLibraries() {
|
||||
|
||||
Reference in New Issue
Block a user