modelassetlib_native/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
extern crate jni;

use jni::JNIEnv;
use jni::objects::{JByteArray, JClass, JObject, JString};
use jni::sys::{jboolean, jbyteArray, jint, jstring};

pub mod jniimpl;
pub mod util;
pub mod constants;

// Class: top.srcres.mods.modelassetlib.jni.NativeLibrary
// File: top/srcres/mods/modelassetlib/jni/NativeLibrary.kt

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_jni_NativeLibrary_initNative0<'local>(
    _: JNIEnv<'local>,
    _: JObject<'local>
) -> jboolean {
    println!("Native library initialized.");
    util::jni::bool_to_jboolean(true)
}

// Class: top.srcres.mods.modelassetlib.gltf.Gltf
// File: top/srcres/mods/modelassetlib/gltf/Gltf.kt

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_gltf_Gltf_nativeInit<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) {
    jniimpl::gltf::handle_native_init(&mut env, &this);
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_gltf_Gltf_nativeDestroy<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) {
    jniimpl::gltf::handle_native_destroy(&mut env, &this);
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_gltf_Gltf_getImageDataByURI<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>,
    uri: JString
) -> jbyteArray {
    jniimpl::gltf::handle_get_image_data_by_uri(&mut env, &this, &uri)
}

// Class: top.srcres.mods.modelassetlib.image.ImageKt
// File: top/srcres/mods/modelassetlib/image/Image.kt

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_ImageKt_nativeIsErrorOccurred0<'local>(
    mut env: JNIEnv<'local>,
    class: JClass<'local>
) -> jboolean {
    util::jni::bool_to_jboolean(jniimpl::image::handle_is_error_occurred(&mut env, &class))
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_ImageKt_nativeGetErrorMessage0<'local>(
    mut env: JNIEnv<'local>,
    class: JClass<'local>
) -> jstring {
    jniimpl::image::handle_get_error_message(&mut env, &class)
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_ImageKt_nativeClearError0<'local>(
    mut env: JNIEnv<'local>,
    class: JClass<'local>
) {
    jniimpl::image::handle_clear_error(&mut env, &class)
}

// Class: top.srcres.mods.modelassetlib.image.Image
// File: top/srcres/mods/modelassetlib/image/Image.kt

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_nativeInit<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>,
    raw_data: JByteArray
) -> jboolean {
    match jniimpl::image::handle_native_init(&mut env, &this, &raw_data) {
        Ok(_) => {
            util::jni::bool_to_jboolean(true)
        }
        Err(err) => {
            jniimpl::image::record_error(&format!(
                "jniimpl::image::handle_native_init failed: {}", err));
            util::jni::bool_to_jboolean(false)
        }
    }
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_nativeInitWithFormat<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>,
    raw_data: JByteArray,
    format_id: jint
) -> jboolean {
    match jniimpl::image::handle_native_init_with_format(&mut env, &this, &raw_data, format_id) {
        Ok(_) => {
            util::jni::bool_to_jboolean(true)
        }
        Err(err) => {
            jniimpl::image::record_error(&format!(
                "jniimpl::image::handle_native_init_with_format failed: {}", err));
            util::jni::bool_to_jboolean(false)
        }
    }
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_nativeDestroy<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) {
    jniimpl::image::handle_native_destroy(&mut env, &this).unwrap()
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_getWidth0<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) -> jint {
    jniimpl::image::handle_get_width(&mut env, &this).unwrap_or_else(|err| {
        jniimpl::image::record_error(&format!(
            "jniimpl::image::handle_get_width failed: {}", err));
        -1
    })
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_getHeight0<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) -> jint {
    jniimpl::image::handle_get_height(&mut env, &this).unwrap_or_else(|err| {
        jniimpl::image::record_error(&format!(
            "jniimpl::image::handle_get_height failed: {}", err));
        -1
    })
}

#[no_mangle]
pub extern "system" fn Java_top_srcres_mods_modelassetlib_image_Image_getRgbaData0<'local>(
    mut env: JNIEnv<'local>,
    this: JObject<'local>
) -> jbyteArray {
    jniimpl::image::handle_get_rgba_data(&mut env, &this).unwrap_or_else(|err| {
        jniimpl::image::record_error(&format!(
            "jniimpl::image::handle_get_rgba_data failed: {}", err));
        util::jni::new_empty_byte_array(&mut env)
    })
}