xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/android/demo.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan #[no_mangle]
android_link_hack()2*d4726bddSHONG Yifan pub extern "C" fn android_link_hack() {}
3*d4726bddSHONG Yifan 
4*d4726bddSHONG Yifan #[no_mangle]
print_something_from_rust()5*d4726bddSHONG Yifan pub extern fn print_something_from_rust() {
6*d4726bddSHONG Yifan     println!("Ferris says hello!");
7*d4726bddSHONG Yifan }
8*d4726bddSHONG Yifan 
9*d4726bddSHONG Yifan #[no_mangle]
get_a_value_from_rust() -> i3210*d4726bddSHONG Yifan pub extern fn get_a_value_from_rust() -> i32 {
11*d4726bddSHONG Yifan     42
12*d4726bddSHONG Yifan }
13*d4726bddSHONG Yifan 
14*d4726bddSHONG Yifan #[no_mangle]
Java_com_example_androidapp_JniShim_getValue() -> i3215*d4726bddSHONG Yifan pub extern "system" fn Java_com_example_androidapp_JniShim_getValue() -> i32 {
16*d4726bddSHONG Yifan     get_a_value_from_rust()
17*d4726bddSHONG Yifan }
18