Skip to content

Commit b4fca81

Browse files
committed
methods now are generated
1 parent f7ec2ed commit b4fca81

File tree

16 files changed

+258
-130
lines changed

16 files changed

+258
-130
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ mc-mappings/output.txt
88
crates/gen_src.rs
99
crates/map-gen/test.ron
1010
crates/mc-mappings/mappings
11-
/mappings
11+
/mappings
12+
crates/mc-mappings/gen_src.rs
13+
crates/map-gen/lookup.ron

Cargo.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ DYLD_INSERT_LIBRARIES=/Users/****/dev/mci/target/debug/libmci.dylib ./polymc
2424
- [x] set static fields
2525
- [x] call methods
2626
- [x] call static methods
27-
- [ ] general QOL
27+
- [x] general QOL
2828
- [x] jclass not operable with jobject (prevents you from shooting yourself)
29-
- [ ] easier setting & getting via traits/macros (?)
29+
- [x] easier setting & getting via traits/macros (?)
3030
- [ ] types
3131
- [x] jclass
3232
- [x] jobject
@@ -51,10 +51,10 @@ DYLD_INSERT_LIBRARIES=/Users/****/dev/mci/target/debug/libmci.dylib ./polymc
5151
- [x] call static methods
5252
- [x] set fields
5353
- [x] set static fields
54-
- [ ] compilable
54+
- [x] compilable
5555
- [ ] auto static detection (i)
5656
#### information
57-
1. im currently working on a tool to get static fields and method names from a jar file.
57+
i. i'll eventually work on a tool to get static fields and method names from a jar file.
5858
### MCI (root)
5959
im not even working on it until mappings work lol
6060

crates/jdk-sys/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::{path::PathBuf, env, fs};
22

33
fn main() {
44

5-
println!("cargo:rerun-if-env-changed=JAVA_HOME");
65
let mut jdk_location = PathBuf::from(std::env::var("JAVA_HOME").expect("JAVA_HOME not set"));
76

7+
println!("cargo:rerun-if-changed={}",std::env::var("JAVA_HOME").unwrap());
8+
89
if jdk_location.display().to_string().contains("homebrew") && !jdk_location.display().to_string().contains("Contents"){
910
jdk_location = jdk_location.join("libexec/openjdk.jdk/Contents/Home");
1011
println!("cargo:rustc-link-search={}",jdk_location.join("lib/server").display());

crates/jni/src/jarray.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{ops::{Index, Deref, DerefMut}, default, marker::PhantomData};
22

33
use crate::{unchecked_jnic, object::JObject, jvalue::JValue};
4+
use crate::object::JClassInstance;
45
use super::env::Jenv;
56
pub struct JArray<'a,T> {
67
pub ptr : JObject<'a>,
@@ -34,4 +35,10 @@ impl<'a> JArray<'a,i32> {
3435
Vec::from_raw_parts(unchecked_jnic!(self.ptr.env.ptr,GetIntArrayElements, self.ptr.ptr, std::ptr::null_mut()), self.length, self.length)
3536
}
3637
}
38+
}
39+
40+
impl<T> JClassInstance for JArray<'_,T> {
41+
fn get_jobject(&self) -> JObject {
42+
self.ptr.clone()
43+
}
3744
}

crates/jni/src/jvalue.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ impl<'a> From<JObject<'a>> for JValue<'a> {
9696
Self::JObject(obj)
9797
}
9898
}
99+
impl<'a> From<&JObject<'a>> for JValue<'a> {
100+
fn from(obj: &JObject<'a>) -> Self {
101+
Self::JObject(obj.clone())
102+
}
103+
}
99104

100105
impl From<bool> for JValue<'_> {
101106
fn from(x: bool) -> Self {

crates/jni/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pub mod prelude {
1515
pub use crate::jarray::JArray;
1616
pub use crate::jstring::JString;
1717
pub use crate::class::JClass;
18+
pub use crate::object::JClassInstance;
1819
}

crates/jni/src/object.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,12 @@ impl<'a,T> From<JArray<'a,T>> for JObject<'a> {
296296
fn from(x: JArray<'a,T>) -> Self {
297297
Self::from(&x.ptr)
298298
}
299+
}
300+
pub trait JClassInstance {
301+
fn get_jobject(&self) -> JObject;
302+
}
303+
impl<'a> JClassInstance for JObject<'a> {
304+
fn get_jobject(&self) -> JObject<'a> {
305+
self.clone()
306+
}
299307
}

crates/map-gen/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ parking_lot = "0.12.1"
1111
walkdir = "2"
1212
proc-macro2 = "1.0.43"
1313
quote = "1.0.21"
14-
codegen = "0.2.0"
14+
codegen = "0.2.0"
15+
rand = "0.8.5"

0 commit comments

Comments
 (0)