11use autocorrect:: { LineResult , LintResult } ;
2+ use jni:: JNIEnv ;
23use jni:: objects:: { JClass , JString } ;
34use jni:: sys:: { jboolean, jintArray, jlong, jsize, jstring} ;
4- use jni:: JNIEnv ;
55
6- #[ no_mangle]
76pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_format (
87 env : JNIEnv ,
98 _class : JClass ,
@@ -16,7 +15,6 @@ pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_format(
1615 output. into_raw ( )
1716}
1817
19- #[ no_mangle]
2018pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_formatFor (
2119 env : JNIEnv ,
2220 _class : JClass ,
@@ -31,7 +29,6 @@ pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_formatFor(
3129 output. into_raw ( )
3230}
3331
34- #[ no_mangle]
3532pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintFor (
3633 env : JNIEnv ,
3734 _class : JClass ,
@@ -45,15 +42,14 @@ pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintFor(
4542 Box :: into_raw ( Box :: new ( result) ) as jlong
4643}
4744
48- #[ no_mangle]
4945/// # Safety
5046pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintResultString (
5147 env : JNIEnv ,
5248 _class : JClass ,
5349 lint_result : jlong ,
5450 field : JString ,
5551) -> jstring {
56- let result = & * ( lint_result as * const LintResult ) ;
52+ let result = unsafe { & * ( lint_result as * const LintResult ) } ;
5753 let field: String = env. get_string ( field) . unwrap ( ) . into ( ) ;
5854
5955 let val = match field. as_str ( ) {
@@ -66,14 +62,13 @@ pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintResu
6662 output. into_raw ( )
6763}
6864
69- #[ no_mangle]
7065/// # Safety
7166pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintResultLines (
7267 env : JNIEnv ,
7368 _class : JClass ,
7469 lint_result : jlong ,
7570) -> jintArray {
76- let result = & * ( lint_result as * const LintResult ) ;
71+ let result = unsafe { & * ( lint_result as * const LintResult ) } ;
7772
7873 let mut line_ptrs: Vec < jlong > = vec ! [ ] ;
7974 for line in result. lines . clone ( ) {
@@ -86,15 +81,14 @@ pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLintResu
8681 lines
8782}
8883
89- #[ no_mangle]
9084/// # Safety
9185pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLineResultString (
9286 env : JNIEnv ,
9387 _class : JClass ,
9488 line_result : jlong ,
9589 field : JString ,
9690) -> jstring {
97- let result = & * ( line_result as * const LineResult ) ;
91+ let result = unsafe { & * ( line_result as * const LineResult ) } ;
9892 let field: String = env. get_string ( field) . unwrap ( ) . into ( ) ;
9993 let val = match field. as_str ( ) {
10094 "new" => result. new . clone ( ) ,
@@ -106,15 +100,14 @@ pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLineResu
106100 output. into_raw ( )
107101}
108102
109- #[ no_mangle]
110103/// # Safety
111104pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLineResultLong (
112105 env : JNIEnv ,
113106 _class : JClass ,
114107 line_result : jlong ,
115108 field : JString ,
116109) -> jlong {
117- let result = & * ( line_result as * const LineResult ) ;
110+ let result = unsafe { & * ( line_result as * const LineResult ) } ;
118111 let field: String = env. get_string ( field) . unwrap ( ) . into ( ) ;
119112
120113 let val = match field. as_str ( ) {
@@ -127,7 +120,6 @@ pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeLineResu
127120 val as jlong
128121}
129122
130- #[ no_mangle]
131123#[ allow( unused) ]
132124pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_loadConfig (
133125 env : JNIEnv ,
@@ -142,7 +134,6 @@ pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_loadConfig(
142134 } ;
143135}
144136
145- #[ no_mangle]
146137pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeNewIgnorer (
147138 env : JNIEnv ,
148139 _class : JClass ,
@@ -155,15 +146,14 @@ pub extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeNewIgnorer(
155146 Box :: into_raw ( Box :: new ( ignorer) ) as jlong
156147}
157148
158- #[ no_mangle]
159149/// # Safety
160150pub unsafe extern "system" fn Java_io_github_huacnlee_AutoCorrect_nativeIgnorerIsIgnored (
161151 env : JNIEnv ,
162152 _class : JClass ,
163153 ignorer : jlong ,
164154 filepath : JString ,
165155) -> jboolean {
166- let ignorer = & * ( ignorer as * const autocorrect:: ignorer:: Ignorer ) ;
156+ let ignorer = unsafe { & * ( ignorer as * const autocorrect:: ignorer:: Ignorer ) } ;
167157 let filepath: String = env. get_string ( filepath) . unwrap ( ) . into ( ) ;
168158
169159 ignorer. is_ignored ( & filepath) as jboolean
0 commit comments