https://github.com/ewpratten/jni-mangle
Mangle Rust functions for use with JNI
https://github.com/ewpratten/jni-mangle
jni jni-rust rust rust-proc-macro
Last synced: over 1 year ago
JSON representation
Mangle Rust functions for use with JNI
- Host: GitHub
- URL: https://github.com/ewpratten/jni-mangle
- Owner: ewpratten
- License: gpl-3.0
- Created: 2023-09-06T14:31:29.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T17:22:42.000Z (almost 3 years ago)
- Last Synced: 2025-03-16T14:48:39.453Z (over 1 year ago)
- Topics: jni, jni-rust, rust, rust-proc-macro
- Language: Rust
- Homepage: https://crates.io/crates/jni-mangle
- Size: 29.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust function mangler for JNI
[](https://crates.io/crates/jni-mangle)
[](https://docs.rs/jni-mangle)
[](https://github.com/Ewpratten/jni-mangle/actions/workflows/build.yml)
[](https://github.com/Ewpratten/jni-mangle/actions/workflows/clippy.yml)
The `jni-mangle` crate provides proc macros for working with Rust functions that are called from Java through JNI.
The main purpose of this crate is to turn rust functions that might look like this:
```rust
#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_com_example_Example_addTwoNumbers(a: i32, b: i32) -> i32 {
a + b
}
```
Into something a little more readable:
```rust
use jni_mangle::mangle;
#[mangle(package="com.example", class="Example", method="addTwoNumbers")]
pub fn add_two_numbers(a: i32, b: i32) -> i32 {
a + b
}
```