mirror of
https://github.com/Noratrieb/minmax.git
synced 2026-01-14 23:35:04 +01:00
jni
This commit is contained in:
parent
193c89c25c
commit
5bfabd3cec
7 changed files with 568 additions and 3 deletions
35
rs-wrapper/src/lib.rs
Normal file
35
rs-wrapper/src/lib.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// This is the interface to the JVM that we'll call the majority of our
|
||||
// methods on.
|
||||
use jni::JNIEnv;
|
||||
|
||||
// These objects are what you should use as arguments to your native
|
||||
// function. They carry extra lifetime information to prevent them escaping
|
||||
// this context and getting used after being GC'd.
|
||||
use jni::objects::{JClass, JObject};
|
||||
|
||||
// This is just a pointer. We'll be returning it from our function. We
|
||||
// can't return one of the objects with lifetime information because the
|
||||
// lifetime checker won't let us.
|
||||
use jni::sys::{jbyte, jint};
|
||||
use minmax::{connect4::board::Connect4, GamePlayer};
|
||||
|
||||
// 0 -> X
|
||||
// 1 -> O
|
||||
pub fn wrap_player<P: GamePlayer<Connect4>>(current_player: i8, board: ()) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
// This keeps Rust from "mangling" the name and making it unique for this
|
||||
// crate.
|
||||
#[no_mangle]
|
||||
pub extern "system" fn Java_ch_bbw_m411_connect4_RustPlayer_rustPlay(
|
||||
env: JNIEnv<'_>,
|
||||
// This is the class that owns our static method. It's not going to be used,
|
||||
// but still must be present to match the expected signature of a static
|
||||
// native method.
|
||||
class: JClass<'_>,
|
||||
player: jbyte,
|
||||
board: JObject<'_>,
|
||||
) -> jint {
|
||||
0
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue