mirror of
https://github.com/Noratrieb/minmax.git
synced 2026-01-14 15:25:08 +01:00
jni
This commit is contained in:
parent
193c89c25c
commit
5bfabd3cec
7 changed files with 568 additions and 3 deletions
13
rs-wrapper/Cargo.toml
Normal file
13
rs-wrapper/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "rs-wrapper"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
jni = "0.20.0"
|
||||
minmax = { path = "../minmax-rs" }
|
||||
21
rs-wrapper/ch_bbw_m411_connect4_RustPlayer.h
Normal file
21
rs-wrapper/ch_bbw_m411_connect4_RustPlayer.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class ch_bbw_m411_connect4_RustPlayer */
|
||||
|
||||
#ifndef _Included_ch_bbw_m411_connect4_RustPlayer
|
||||
#define _Included_ch_bbw_m411_connect4_RustPlayer
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: ch_bbw_m411_connect4_RustPlayer
|
||||
* Method: rustPlay
|
||||
* Signature: (B[Lch/bbw/m411/connect4/Connect4ArenaMain/Stone;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ch_bbw_m411_connect4_RustPlayer_rustPlay
|
||||
(JNIEnv *, jobject, jbyte, jobjectArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
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